OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/app_list/app_list_item_model.h" | 5 #include "ui/app_list/app_list_item_model.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/app_list/app_list_item_model_observer.h" | 8 #include "ui/app_list/app_list_item_model_observer.h" |
9 | 9 |
10 namespace app_list { | 10 namespace app_list { |
11 | 11 |
12 AppListItemModel::AppListItemModel() : highlighted_(false) { | 12 AppListItemModel::AppListItemModel() |
| 13 : highlighted_(false), |
| 14 is_installing_(false), |
| 15 percent_downloaded_(-1) { |
13 } | 16 } |
14 | 17 |
15 AppListItemModel::~AppListItemModel() { | 18 AppListItemModel::~AppListItemModel() { |
16 } | 19 } |
17 | 20 |
18 void AppListItemModel::SetIcon(const gfx::ImageSkia& icon) { | 21 void AppListItemModel::SetIcon(const gfx::ImageSkia& icon) { |
19 icon_ = icon; | 22 icon_ = icon; |
20 FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemIconChanged()); | 23 FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemIconChanged()); |
21 } | 24 } |
22 | 25 |
23 void AppListItemModel::SetTitle(const std::string& title) { | 26 void AppListItemModel::SetTitle(const std::string& title) { |
24 if (title_ == title) | 27 if (title_ == title) |
25 return; | 28 return; |
26 | 29 |
27 title_ = title; | 30 title_ = title; |
28 FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemTitleChanged()); | 31 FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemTitleChanged()); |
29 } | 32 } |
30 | 33 |
31 void AppListItemModel::SetHighlighted(bool highlighted) { | 34 void AppListItemModel::SetHighlighted(bool highlighted) { |
32 if (highlighted_ == highlighted) | 35 if (highlighted_ == highlighted) |
33 return; | 36 return; |
34 | 37 |
35 highlighted_ = highlighted; | 38 highlighted_ = highlighted; |
36 FOR_EACH_OBSERVER(AppListItemModelObserver, | 39 FOR_EACH_OBSERVER(AppListItemModelObserver, |
37 observers_, | 40 observers_, |
38 ItemHighlightedChanged()); | 41 ItemHighlightedChanged()); |
39 } | 42 } |
40 | 43 |
| 44 void AppListItemModel::SetIsInstalling(bool is_installing) { |
| 45 if (is_installing_ == is_installing) |
| 46 return; |
| 47 |
| 48 is_installing_ = is_installing; |
| 49 FOR_EACH_OBSERVER(AppListItemModelObserver, |
| 50 observers_, |
| 51 ItemIsInstallingChanged()); |
| 52 } |
| 53 |
| 54 void AppListItemModel::SetPercentDownloaded(int percent_downloaded) { |
| 55 if (percent_downloaded_ == percent_downloaded) |
| 56 return; |
| 57 |
| 58 percent_downloaded_ = percent_downloaded; |
| 59 FOR_EACH_OBSERVER(AppListItemModelObserver, |
| 60 observers_, |
| 61 ItemPercentDownloadedChanged()); |
| 62 } |
| 63 |
41 void AppListItemModel::AddObserver(AppListItemModelObserver* observer) { | 64 void AppListItemModel::AddObserver(AppListItemModelObserver* observer) { |
42 observers_.AddObserver(observer); | 65 observers_.AddObserver(observer); |
43 } | 66 } |
44 | 67 |
45 void AppListItemModel::RemoveObserver(AppListItemModelObserver* observer) { | 68 void AppListItemModel::RemoveObserver(AppListItemModelObserver* observer) { |
46 observers_.RemoveObserver(observer); | 69 observers_.RemoveObserver(observer); |
47 } | 70 } |
48 | 71 |
49 ui::MenuModel* AppListItemModel::GetContextMenuModel() { | 72 ui::MenuModel* AppListItemModel::GetContextMenuModel() { |
50 return NULL; | 73 return NULL; |
51 } | 74 } |
52 | 75 |
53 } // namespace app_list | 76 } // namespace app_list |
OLD | NEW |