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 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "chrome/browser/extensions/install_observer.h" | 12 #include "chrome/browser/extensions/install_observer.h" |
13 #include "ui/app_list/app_list_model.h" | 13 #include "ui/app_list/app_list_model.h" |
14 #include "ui/base/models/list_model_observer.h" | 14 #include "ui/base/models/list_model_observer.h" |
15 | 15 |
16 class AppListControllerDelegate; | 16 class AppListControllerDelegate; |
17 class ExtensionAppItem; | 17 class ExtensionAppItem; |
18 class ExtensionSet; | 18 class ExtensionSet; |
19 class Profile; | 19 class Profile; |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 class Extension; | 22 class Extension; |
23 class InstallTracker; | 23 class InstallTracker; |
24 } | 24 } |
25 | 25 |
26 namespace gfx { | 26 namespace gfx { |
27 class ImageSkia; | 27 class ImageSkia; |
28 } | 28 } |
29 | 29 |
| 30 // This class populates and maintains the given |model| with information from |
| 31 // |profile|. |
30 class AppsModelBuilder : public ui::ListModelObserver, | 32 class AppsModelBuilder : public ui::ListModelObserver, |
31 public extensions::InstallObserver { | 33 public extensions::InstallObserver { |
32 public: | 34 public: |
33 AppsModelBuilder(Profile* profile, | 35 AppsModelBuilder(Profile* profile, |
34 app_list::AppListModel::Apps* model, | 36 app_list::AppListModel::Apps* model, |
35 AppListControllerDelegate* controller); | 37 AppListControllerDelegate* controller); |
36 virtual ~AppsModelBuilder(); | 38 virtual ~AppsModelBuilder(); |
37 | 39 |
38 // Populates the model. | |
39 void Build(); | |
40 | |
41 // Returns app instance with id |extension_id|. | 40 // Returns app instance with id |extension_id|. |
42 ExtensionAppItem* GetApp(const std::string& extension_id); | 41 ExtensionAppItem* GetApp(const std::string& extension_id); |
43 | 42 |
| 43 // Rebuilds the model with the given profile. |
| 44 void SwitchProfile(Profile* profile); |
| 45 |
44 private: | 46 private: |
45 typedef std::vector<ExtensionAppItem*> Apps; | 47 typedef std::vector<ExtensionAppItem*> Apps; |
46 | 48 |
47 // Overridden from extensions::InstallObserver: | 49 // Overridden from extensions::InstallObserver: |
48 virtual void OnBeginExtensionInstall(const std::string& extension_id, | 50 virtual void OnBeginExtensionInstall(const std::string& extension_id, |
49 const std::string& extension_name, | 51 const std::string& extension_name, |
50 const gfx::ImageSkia& installing_icon, | 52 const gfx::ImageSkia& installing_icon, |
51 bool is_app, | 53 bool is_app, |
52 bool is_platform_app) OVERRIDE; | 54 bool is_platform_app) OVERRIDE; |
53 | 55 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // True to ignore |model_| changes. | 120 // True to ignore |model_| changes. |
119 bool ignore_changes_; | 121 bool ignore_changes_; |
120 | 122 |
121 // We listen to this to show app installing progress. | 123 // We listen to this to show app installing progress. |
122 extensions::InstallTracker* tracker_; | 124 extensions::InstallTracker* tracker_; |
123 | 125 |
124 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder); | 126 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder); |
125 }; | 127 }; |
126 | 128 |
127 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ | 129 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ |
OLD | NEW |