| 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_EXTENSION_APP_MODEL_BUILDER_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_MODEL_BUILDER_H_ |
| 6 #define CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_MODEL_BUILDER_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_MODEL_BUILDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 class ImageSkia; | 35 class ImageSkia; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // This class populates and maintains the given |model| with information from | 38 // This class populates and maintains the given |model| with information from |
| 39 // |profile|. | 39 // |profile|. |
| 40 class ExtensionAppModelBuilder : public extensions::InstallObserver, | 40 class ExtensionAppModelBuilder : public extensions::InstallObserver, |
| 41 public extensions::ExtensionRegistryObserver, | 41 public extensions::ExtensionRegistryObserver, |
| 42 public app_list::AppListItemListObserver { | 42 public app_list::AppListItemListObserver { |
| 43 public: | 43 public: |
| 44 explicit ExtensionAppModelBuilder(AppListControllerDelegate* controller); | 44 explicit ExtensionAppModelBuilder(AppListControllerDelegate* controller); |
| 45 virtual ~ExtensionAppModelBuilder(); | 45 ~ExtensionAppModelBuilder() override; |
| 46 | 46 |
| 47 // Initialize to use app-list sync and sets |service_| to |service|. | 47 // Initialize to use app-list sync and sets |service_| to |service|. |
| 48 void InitializeWithService(app_list::AppListSyncableService* service); | 48 void InitializeWithService(app_list::AppListSyncableService* service); |
| 49 | 49 |
| 50 // Initialize to use extension sync and sets |service_| to NULL. Used in | 50 // Initialize to use extension sync and sets |service_| to NULL. Used in |
| 51 // tests and when AppList sync is not enabled. | 51 // tests and when AppList sync is not enabled. |
| 52 void InitializeWithProfile(Profile* profile, app_list::AppListModel* model); | 52 void InitializeWithProfile(Profile* profile, app_list::AppListModel* model); |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 typedef std::vector<ExtensionAppItem*> ExtensionAppList; | 55 typedef std::vector<ExtensionAppItem*> ExtensionAppList; |
| 56 | 56 |
| 57 // Builds the model with the current profile. | 57 // Builds the model with the current profile. |
| 58 void BuildModel(); | 58 void BuildModel(); |
| 59 | 59 |
| 60 // extensions::InstallObserver. | 60 // extensions::InstallObserver. |
| 61 virtual void OnBeginExtensionInstall( | 61 void OnBeginExtensionInstall(const ExtensionInstallParams& params) override; |
| 62 const ExtensionInstallParams& params) override; | 62 void OnDownloadProgress(const std::string& extension_id, |
| 63 virtual void OnDownloadProgress(const std::string& extension_id, | 63 int percent_downloaded) override; |
| 64 int percent_downloaded) override; | 64 void OnInstallFailure(const std::string& extension_id) override; |
| 65 virtual void OnInstallFailure(const std::string& extension_id) override; | 65 void OnDisabledExtensionUpdated( |
| 66 virtual void OnDisabledExtensionUpdated( | |
| 67 const extensions::Extension* extension) override; | 66 const extensions::Extension* extension) override; |
| 68 virtual void OnShutdown() override; | 67 void OnShutdown() override; |
| 69 | 68 |
| 70 // extensions::ExtensionRegistryObserver. | 69 // extensions::ExtensionRegistryObserver. |
| 71 virtual void OnExtensionLoaded( | 70 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 72 content::BrowserContext* browser_context, | 71 const extensions::Extension* extension) override; |
| 73 const extensions::Extension* extension) override; | 72 void OnExtensionUnloaded( |
| 74 virtual void OnExtensionUnloaded( | |
| 75 content::BrowserContext* browser_context, | 73 content::BrowserContext* browser_context, |
| 76 const extensions::Extension* extension, | 74 const extensions::Extension* extension, |
| 77 extensions::UnloadedExtensionInfo::Reason reason) override; | 75 extensions::UnloadedExtensionInfo::Reason reason) override; |
| 78 virtual void OnExtensionUninstalled( | 76 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 79 content::BrowserContext* browser_context, | 77 const extensions::Extension* extension, |
| 80 const extensions::Extension* extension, | 78 extensions::UninstallReason reason) override; |
| 81 extensions::UninstallReason reason) override; | 79 void OnShutdown(extensions::ExtensionRegistry* registry) override; |
| 82 virtual void OnShutdown(extensions::ExtensionRegistry* registry) override; | |
| 83 | 80 |
| 84 // AppListItemListObserver. | 81 // AppListItemListObserver. |
| 85 virtual void OnListItemMoved(size_t from_index, | 82 void OnListItemMoved(size_t from_index, |
| 86 size_t to_index, | 83 size_t to_index, |
| 87 app_list::AppListItem* item) override; | 84 app_list::AppListItem* item) override; |
| 88 | 85 |
| 89 scoped_ptr<ExtensionAppItem> CreateAppItem( | 86 scoped_ptr<ExtensionAppItem> CreateAppItem( |
| 90 const std::string& extension_id, | 87 const std::string& extension_id, |
| 91 const std::string& extension_name, | 88 const std::string& extension_name, |
| 92 const gfx::ImageSkia& installing_icon, | 89 const gfx::ImageSkia& installing_icon, |
| 93 bool is_platform_app); | 90 bool is_platform_app); |
| 94 | 91 |
| 95 // Populates the model with apps. | 92 // Populates the model with apps. |
| 96 void PopulateApps(); | 93 void PopulateApps(); |
| 97 | 94 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // We listen to this to show app installing progress. | 129 // We listen to this to show app installing progress. |
| 133 extensions::InstallTracker* tracker_; | 130 extensions::InstallTracker* tracker_; |
| 134 | 131 |
| 135 // Listen extension's load, unload, uninstalled. | 132 // Listen extension's load, unload, uninstalled. |
| 136 extensions::ExtensionRegistry* extension_registry_; | 133 extensions::ExtensionRegistry* extension_registry_; |
| 137 | 134 |
| 138 DISALLOW_COPY_AND_ASSIGN(ExtensionAppModelBuilder); | 135 DISALLOW_COPY_AND_ASSIGN(ExtensionAppModelBuilder); |
| 139 }; | 136 }; |
| 140 | 137 |
| 141 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_MODEL_BUILDER_H_ | 138 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_MODEL_BUILDER_H_ |
| OLD | NEW |