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 11 matching lines...) Expand all Loading... |
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 | 30 // This class populates and maintains the given |model| with information from |
31 // |profile|. | 31 // |profile|. |
32 class ExtensionAppModelBuilder : public extensions::InstallObserver { | 32 class ExtensionAppModelBuilder : public extensions::InstallObserver, |
| 33 public ui::ListModelObserver { |
33 public: | 34 public: |
34 ExtensionAppModelBuilder(Profile* profile, | 35 ExtensionAppModelBuilder(Profile* profile, |
35 app_list::AppListModel* model, | 36 app_list::AppListModel* model, |
36 AppListControllerDelegate* controller); | 37 AppListControllerDelegate* controller); |
37 virtual ~ExtensionAppModelBuilder(); | 38 virtual ~ExtensionAppModelBuilder(); |
38 | 39 |
39 // Rebuilds the model with the given profile. | 40 // Rebuilds the model with the given profile. |
40 void SwitchProfile(Profile* profile); | 41 void SwitchProfile(Profile* profile); |
41 | 42 |
42 private: | 43 private: |
43 typedef std::vector<ExtensionAppItem*> ExtensionAppList; | 44 typedef std::vector<ExtensionAppItem*> ExtensionAppList; |
44 | 45 |
45 // Overridden from extensions::InstallObserver: | 46 // extensions::InstallObserver |
46 virtual void OnBeginExtensionInstall(const std::string& extension_id, | 47 virtual void OnBeginExtensionInstall(const std::string& extension_id, |
47 const std::string& extension_name, | 48 const std::string& extension_name, |
48 const gfx::ImageSkia& installing_icon, | 49 const gfx::ImageSkia& installing_icon, |
49 bool is_app, | 50 bool is_app, |
50 bool is_platform_app) OVERRIDE; | 51 bool is_platform_app) OVERRIDE; |
51 | |
52 virtual void OnDownloadProgress(const std::string& extension_id, | 52 virtual void OnDownloadProgress(const std::string& extension_id, |
53 int percent_downloaded) OVERRIDE; | 53 int percent_downloaded) OVERRIDE; |
54 | |
55 virtual void OnInstallFailure(const std::string& extension_id) OVERRIDE; | 54 virtual void OnInstallFailure(const std::string& extension_id) OVERRIDE; |
56 virtual void OnExtensionInstalled( | 55 virtual void OnExtensionInstalled( |
57 const extensions::Extension* extension) OVERRIDE {} | 56 const extensions::Extension* extension) OVERRIDE {} |
58 virtual void OnExtensionLoaded( | 57 virtual void OnExtensionLoaded( |
59 const extensions::Extension* extension) OVERRIDE; | 58 const extensions::Extension* extension) OVERRIDE; |
60 virtual void OnExtensionUnloaded( | 59 virtual void OnExtensionUnloaded( |
61 const extensions::Extension* extension) OVERRIDE; | 60 const extensions::Extension* extension) OVERRIDE; |
62 virtual void OnExtensionUninstalled( | 61 virtual void OnExtensionUninstalled( |
63 const extensions::Extension* extension) OVERRIDE; | 62 const extensions::Extension* extension) OVERRIDE; |
64 virtual void OnAppsReordered() OVERRIDE; | 63 virtual void OnAppsReordered() OVERRIDE; |
65 virtual void OnAppInstalledToAppList( | 64 virtual void OnAppInstalledToAppList( |
66 const std::string& extension_id) OVERRIDE; | 65 const std::string& extension_id) OVERRIDE; |
67 virtual void OnShutdown() OVERRIDE; | 66 virtual void OnShutdown() OVERRIDE; |
68 | 67 |
| 68 // ui::ListModelObserver |
| 69 virtual void ListItemsAdded(size_t start, size_t count) OVERRIDE; |
| 70 virtual void ListItemsRemoved(size_t start, size_t count) OVERRIDE; |
| 71 virtual void ListItemMoved(size_t index, size_t target_index) OVERRIDE; |
| 72 virtual void ListItemsChanged(size_t start, size_t count) OVERRIDE; |
| 73 |
69 // Adds apps in |extensions| to |apps|. | 74 // Adds apps in |extensions| to |apps|. |
70 void AddApps(const ExtensionSet* extensions, ExtensionAppList* apps); | 75 void AddApps(const ExtensionSet* extensions, ExtensionAppList* apps); |
71 | 76 |
72 // Populates the model with apps. | 77 // Populates the model with apps. |
73 void PopulateApps(); | 78 void PopulateApps(); |
74 | 79 |
75 // Re-sort apps in case app ordinal prefs are changed. | 80 // Re-sort apps in case app ordinal prefs are changed. |
76 void ResortApps(); | 81 void ResortApps(); |
77 | 82 |
78 // Inserts an app based on app ordinal prefs. | 83 // Inserts an app based on app ordinal prefs. |
(...skipping 26 matching lines...) Expand all Loading... |
105 // if we try to highlight an app that doesn't exist in the list yet. | 110 // if we try to highlight an app that doesn't exist in the list yet. |
106 bool highlighted_app_pending_; | 111 bool highlighted_app_pending_; |
107 | 112 |
108 // We listen to this to show app installing progress. | 113 // We listen to this to show app installing progress. |
109 extensions::InstallTracker* tracker_; | 114 extensions::InstallTracker* tracker_; |
110 | 115 |
111 DISALLOW_COPY_AND_ASSIGN(ExtensionAppModelBuilder); | 116 DISALLOW_COPY_AND_ASSIGN(ExtensionAppModelBuilder); |
112 }; | 117 }; |
113 | 118 |
114 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_MODEL_BUILDER_H_ | 119 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_MODEL_BUILDER_H_ |
OLD | NEW |