| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "chrome/browser/extensions/install_observer.h" | 15 #include "chrome/browser/extensions/install_observer.h" |
| 15 #include "chrome/browser/ui/app_list/app_list_model_builder.h" | 16 #include "chrome/browser/ui/app_list/app_list_model_builder.h" |
| 17 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h" |
| 16 #include "components/prefs/pref_change_registrar.h" | 18 #include "components/prefs/pref_change_registrar.h" |
| 17 #include "extensions/browser/extension_registry_observer.h" | |
| 18 #include "ui/base/models/list_model_observer.h" | 19 #include "ui/base/models/list_model_observer.h" |
| 19 | 20 |
| 20 class AppListControllerDelegate; | 21 class AppListControllerDelegate; |
| 22 class LauncherExtensionAppUpdater; |
| 21 class ExtensionAppItem; | 23 class ExtensionAppItem; |
| 22 | 24 |
| 23 namespace extensions { | 25 namespace extensions { |
| 24 class Extension; | 26 class Extension; |
| 25 class ExtensionRegistry; | 27 class ExtensionRegistry; |
| 26 class ExtensionSet; | 28 class ExtensionSet; |
| 27 class InstallTracker; | 29 class InstallTracker; |
| 28 } | 30 } |
| 29 | 31 |
| 30 namespace gfx { | 32 namespace gfx { |
| 31 class ImageSkia; | 33 class ImageSkia; |
| 32 } | 34 } |
| 33 | 35 |
| 34 // This class populates and maintains the given |model| for extension items | 36 // This class populates and maintains the given |model| for extension items |
| 35 // with information from |profile|. | 37 // with information from |profile|. |
| 36 class ExtensionAppModelBuilder : public AppListModelBuilder, | 38 class ExtensionAppModelBuilder : public AppListModelBuilder, |
| 37 public extensions::InstallObserver, | 39 public extensions::InstallObserver, |
| 38 public extensions::ExtensionRegistryObserver { | 40 public LauncherAppUpdater::Delegate { |
| 39 public: | 41 public: |
| 40 explicit ExtensionAppModelBuilder(AppListControllerDelegate* controller); | 42 explicit ExtensionAppModelBuilder(AppListControllerDelegate* controller); |
| 41 ~ExtensionAppModelBuilder() override; | 43 ~ExtensionAppModelBuilder() override; |
| 42 | 44 |
| 43 private: | 45 private: |
| 44 typedef std::vector<ExtensionAppItem*> ExtensionAppList; | 46 typedef std::vector<ExtensionAppItem*> ExtensionAppList; |
| 45 | 47 |
| 46 // AppListModelBuilder | 48 // AppListModelBuilder |
| 47 void BuildModel() override; | 49 void BuildModel() override; |
| 48 | 50 |
| 49 // extensions::InstallObserver. | 51 // extensions::InstallObserver. |
| 50 void OnBeginExtensionInstall(const ExtensionInstallParams& params) override; | 52 void OnBeginExtensionInstall(const ExtensionInstallParams& params) override; |
| 51 void OnDownloadProgress(const std::string& extension_id, | 53 void OnDownloadProgress(const std::string& extension_id, |
| 52 int percent_downloaded) override; | 54 int percent_downloaded) override; |
| 53 void OnInstallFailure(const std::string& extension_id) override; | 55 void OnInstallFailure(const std::string& extension_id) override; |
| 54 void OnDisabledExtensionUpdated( | 56 void OnDisabledExtensionUpdated( |
| 55 const extensions::Extension* extension) override; | 57 const extensions::Extension* extension) override; |
| 56 void OnShutdown() override; | 58 void OnShutdown() override; |
| 57 | 59 |
| 58 // extensions::ExtensionRegistryObserver. | 60 // LauncherAppUpdater::Delegate: |
| 59 void OnExtensionLoaded(content::BrowserContext* browser_context, | 61 void OnAppInstalled(content::BrowserContext* browser_context, |
| 60 const extensions::Extension* extension) override; | 62 const std::string& app_id) override; |
| 61 void OnExtensionUnloaded( | 63 void OnAppUpdated(content::BrowserContext* browser_context, |
| 62 content::BrowserContext* browser_context, | 64 const std::string& app_id) override; |
| 63 const extensions::Extension* extension, | 65 void OnAppUninstalled(content::BrowserContext* browser_context, |
| 64 extensions::UnloadedExtensionInfo::Reason reason) override; | 66 const std::string& app_id) override; |
| 65 void OnExtensionUninstalled(content::BrowserContext* browser_context, | |
| 66 const extensions::Extension* extension, | |
| 67 extensions::UninstallReason reason) override; | |
| 68 void OnShutdown(extensions::ExtensionRegistry* registry) override; | |
| 69 | 67 |
| 70 // AppListItemListObserver. | 68 // AppListItemListObserver. |
| 71 void OnListItemMoved(size_t from_index, | 69 void OnListItemMoved(size_t from_index, |
| 72 size_t to_index, | 70 size_t to_index, |
| 73 app_list::AppListItem* item) override; | 71 app_list::AppListItem* item) override; |
| 74 | 72 |
| 75 std::unique_ptr<ExtensionAppItem> CreateAppItem( | 73 std::unique_ptr<ExtensionAppItem> CreateAppItem( |
| 76 const std::string& extension_id, | 74 const std::string& extension_id, |
| 77 const std::string& extension_name, | 75 const std::string& extension_name, |
| 78 const gfx::ImageSkia& installing_icon, | 76 const gfx::ImageSkia& installing_icon, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 98 | 96 |
| 99 // Registrar used to monitor the profile prefs. | 97 // Registrar used to monitor the profile prefs. |
| 100 PrefChangeRegistrar profile_pref_change_registrar_; | 98 PrefChangeRegistrar profile_pref_change_registrar_; |
| 101 | 99 |
| 102 // Registrar used to monitor the extension prefs. | 100 // Registrar used to monitor the extension prefs. |
| 103 PrefChangeRegistrar extension_pref_change_registrar_; | 101 PrefChangeRegistrar extension_pref_change_registrar_; |
| 104 | 102 |
| 105 // We listen to this to show app installing progress. | 103 // We listen to this to show app installing progress. |
| 106 extensions::InstallTracker* tracker_ = nullptr; | 104 extensions::InstallTracker* tracker_ = nullptr; |
| 107 | 105 |
| 108 // Listen extension's load, unload, uninstalled. | 106 // Dispatches extension lifecycle events. |
| 109 extensions::ExtensionRegistry* extension_registry_ = nullptr; | 107 std::unique_ptr<LauncherExtensionAppUpdater> app_updater_; |
| 110 | 108 |
| 111 DISALLOW_COPY_AND_ASSIGN(ExtensionAppModelBuilder); | 109 DISALLOW_COPY_AND_ASSIGN(ExtensionAppModelBuilder); |
| 112 }; | 110 }; |
| 113 | 111 |
| 114 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_MODEL_BUILDER_H_ | 112 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_MODEL_BUILDER_H_ |
| OLD | NEW |