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 #ifndef CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/prefs/public/pref_change_registrar.h" | 11 #include "base/prefs/public/pref_change_registrar.h" |
| 12 #include "base/prefs/public/pref_observer.h" |
12 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
14 #include "ui/app_list/app_list_model.h" | 15 #include "ui/app_list/app_list_model.h" |
15 #include "ui/base/models/list_model_observer.h" | 16 #include "ui/base/models/list_model_observer.h" |
16 | 17 |
17 class AppListControllerDelegate; | 18 class AppListControllerDelegate; |
18 class ExtensionAppItem; | 19 class ExtensionAppItem; |
19 class Profile; | 20 class Profile; |
20 | 21 |
21 class AppsModelBuilder : public content::NotificationObserver, | 22 class AppsModelBuilder : public content::NotificationObserver, |
| 23 public PrefObserver, |
22 public ui::ListModelObserver { | 24 public ui::ListModelObserver { |
23 public: | 25 public: |
24 AppsModelBuilder(Profile* profile, | 26 AppsModelBuilder(Profile* profile, |
25 app_list::AppListModel::Apps* model, | 27 app_list::AppListModel::Apps* model, |
26 AppListControllerDelegate* controller); | 28 AppListControllerDelegate* controller); |
27 virtual ~AppsModelBuilder(); | 29 virtual ~AppsModelBuilder(); |
28 | 30 |
29 // Populates the model. | 31 // Populates the model. |
30 void Build(); | 32 void Build(); |
31 | 33 |
(...skipping 17 matching lines...) Expand all Loading... |
49 void HighlightApp(); | 51 void HighlightApp(); |
50 | 52 |
51 // Returns app instance at given |index|. | 53 // Returns app instance at given |index|. |
52 ExtensionAppItem* GetAppAt(size_t index); | 54 ExtensionAppItem* GetAppAt(size_t index); |
53 | 55 |
54 // content::NotificationObserver | 56 // content::NotificationObserver |
55 virtual void Observe(int type, | 57 virtual void Observe(int type, |
56 const content::NotificationSource& source, | 58 const content::NotificationSource& source, |
57 const content::NotificationDetails& details) OVERRIDE; | 59 const content::NotificationDetails& details) OVERRIDE; |
58 | 60 |
| 61 // PrefObserver |
| 62 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 63 const std::string& pref_name) OVERRIDE; |
| 64 |
59 // ui::ListModelObserver overrides: | 65 // ui::ListModelObserver overrides: |
60 virtual void ListItemsAdded(size_t start, size_t count) OVERRIDE; | 66 virtual void ListItemsAdded(size_t start, size_t count) OVERRIDE; |
61 virtual void ListItemsRemoved(size_t start, size_t count) OVERRIDE; | 67 virtual void ListItemsRemoved(size_t start, size_t count) OVERRIDE; |
62 virtual void ListItemMoved(size_t index, size_t target_index) OVERRIDE; | 68 virtual void ListItemMoved(size_t index, size_t target_index) OVERRIDE; |
63 virtual void ListItemsChanged(size_t start, size_t count) OVERRIDE; | 69 virtual void ListItemsChanged(size_t start, size_t count) OVERRIDE; |
64 | 70 |
65 Profile* profile_; | 71 Profile* profile_; |
66 AppListControllerDelegate* controller_; | 72 AppListControllerDelegate* controller_; |
67 | 73 |
68 // Sub apps model of AppListModel that represents apps grid view. | 74 // Sub apps model of AppListModel that represents apps grid view. |
69 app_list::AppListModel::Apps* model_; | 75 app_list::AppListModel::Apps* model_; |
70 | 76 |
71 std::string highlight_app_id_; | 77 std::string highlight_app_id_; |
72 | 78 |
73 // True to ignore |model_| changes. | 79 // True to ignore |model_| changes. |
74 bool ignore_changes_; | 80 bool ignore_changes_; |
75 | 81 |
76 content::NotificationRegistrar registrar_; | 82 content::NotificationRegistrar registrar_; |
77 PrefChangeRegistrar pref_change_registrar_; | 83 PrefChangeRegistrar pref_change_registrar_; |
78 | 84 |
79 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder); | 85 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder); |
80 }; | 86 }; |
81 | 87 |
82 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ | 88 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ |
OLD | NEW |