Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: chrome/browser/ui/app_list/apps_model_builder.h

Issue 25859005: Elim ActivateAppListItem, ChromeAppListItem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix static cast in AppModelBuilder, add AppType Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 app_list {
22 class AppListItemModel;
23 }
24
21 namespace extensions { 25 namespace extensions {
22 class Extension; 26 class Extension;
23 class InstallTracker; 27 class InstallTracker;
24 } 28 }
25 29
26 namespace gfx { 30 namespace gfx {
27 class ImageSkia; 31 class ImageSkia;
28 } 32 }
29 33
30 // This class populates and maintains the given |model| with information from 34 // This class populates and maintains the given |model| with information from
31 // |profile|. 35 // |profile|.
32 class AppsModelBuilder : public ui::ListModelObserver, 36 class AppsModelBuilder : public ui::ListModelObserver,
33 public extensions::InstallObserver { 37 public extensions::InstallObserver {
34 public: 38 public:
35 AppsModelBuilder(Profile* profile, 39 AppsModelBuilder(Profile* profile,
36 app_list::AppListModel::Apps* model, 40 app_list::AppListModel::Apps* model,
37 AppListControllerDelegate* controller); 41 AppListControllerDelegate* controller);
38 virtual ~AppsModelBuilder(); 42 virtual ~AppsModelBuilder();
39 43
40 // Returns app instance with id |extension_id|. 44 // Returns app instance with id |extension_id|.
41 ExtensionAppItem* GetApp(const std::string& extension_id); 45 app_list::AppListItemModel* GetApp(const std::string& extension_id);
42 46
43 // Rebuilds the model with the given profile. 47 // Rebuilds the model with the given profile.
44 void SwitchProfile(Profile* profile); 48 void SwitchProfile(Profile* profile);
45 49
46 private: 50 private:
47 typedef std::vector<ExtensionAppItem*> Apps; 51 typedef std::vector<ExtensionAppItem*> ExtensionApps;
48 52
49 // Overridden from extensions::InstallObserver: 53 // Overridden from extensions::InstallObserver:
50 virtual void OnBeginExtensionInstall(const std::string& extension_id, 54 virtual void OnBeginExtensionInstall(const std::string& extension_id,
51 const std::string& extension_name, 55 const std::string& extension_name,
52 const gfx::ImageSkia& installing_icon, 56 const gfx::ImageSkia& installing_icon,
53 bool is_app, 57 bool is_app,
54 bool is_platform_app) OVERRIDE; 58 bool is_platform_app) OVERRIDE;
55 59
56 virtual void OnDownloadProgress(const std::string& extension_id, 60 virtual void OnDownloadProgress(const std::string& extension_id,
57 int percent_downloaded) OVERRIDE; 61 int percent_downloaded) OVERRIDE;
58 62
59 virtual void OnInstallFailure(const std::string& extension_id) OVERRIDE; 63 virtual void OnInstallFailure(const std::string& extension_id) OVERRIDE;
60 virtual void OnExtensionInstalled( 64 virtual void OnExtensionInstalled(
61 const extensions::Extension* extension) OVERRIDE {} 65 const extensions::Extension* extension) OVERRIDE {}
62 virtual void OnExtensionLoaded( 66 virtual void OnExtensionLoaded(
63 const extensions::Extension* extension) OVERRIDE; 67 const extensions::Extension* extension) OVERRIDE;
64 virtual void OnExtensionUnloaded( 68 virtual void OnExtensionUnloaded(
65 const extensions::Extension* extension) OVERRIDE; 69 const extensions::Extension* extension) OVERRIDE;
66 virtual void OnExtensionUninstalled( 70 virtual void OnExtensionUninstalled(
67 const extensions::Extension* extension) OVERRIDE; 71 const extensions::Extension* extension) OVERRIDE;
68 virtual void OnAppsReordered() OVERRIDE; 72 virtual void OnAppsReordered() OVERRIDE;
69 virtual void OnAppInstalledToAppList( 73 virtual void OnAppInstalledToAppList(
70 const std::string& extension_id) OVERRIDE; 74 const std::string& extension_id) OVERRIDE;
71 virtual void OnShutdown() OVERRIDE; 75 virtual void OnShutdown() OVERRIDE;
72 76
73 // Adds apps in |extensions| to |apps|. 77 // Adds apps in |extensions| to |apps|.
74 void AddApps(const ExtensionSet* extensions, Apps* apps); 78 void AddApps(const ExtensionSet* extensions, ExtensionApps* apps);
jennyz 2013/10/03 20:40:27 Should this be renamed as AddExtensionApps?
75 79
76 // Populates the model with apps. 80 // Populates the model with apps.
77 void PopulateApps(); 81 void PopulateApps();
78 82
79 // Re-sort apps in case app ordinal prefs are changed. 83 // Re-sort apps in case app ordinal prefs are changed.
80 void ResortApps(); 84 void ResortApps();
81 85
82 // Inserts an app based on app ordinal prefs. 86 // Inserts an app based on app ordinal prefs.
83 void InsertApp(ExtensionAppItem* app); 87 void InsertApp(ExtensionAppItem* app);
84 88
85 // Returns the index of the application app with |app_id| in |model_|. If 89 // Returns the index of the application app with |app_id| in |model_|. If
86 // no match is found, returns -1. 90 // no match is found, returns -1.
87 int FindApp(const std::string& app_id); 91 int FindApp(const std::string& app_id);
88 92
89 // Sets which app is intended to be highlighted. Will remove the highlight 93 // Sets which app is intended to be highlighted. Will remove the highlight
90 // from a currently highlighted app. 94 // from a currently highlighted app.
91 void SetHighlightedApp(const std::string& extension_id); 95 void SetHighlightedApp(const std::string& extension_id);
92 96
93 // Sets the application app with |highlight_app_id_| in |model_| as 97 // Sets the application app with |highlight_app_id_| in |model_| as
94 // highlighted if |highlighted_app_pending_| is true. If such an app is found, 98 // highlighted if |highlighted_app_pending_| is true. If such an app is found,
95 // reset |highlighted_app_pending_| so that won't be highlighted again until 99 // reset |highlighted_app_pending_| so that won't be highlighted again until
96 // another call to SetHighlightedApp() is made. 100 // another call to SetHighlightedApp() is made.
97 void UpdateHighlight(); 101 void UpdateHighlight();
98 102
99 // Returns app instance at given |index|. 103 // Returns app instance at given |index|.
100 ExtensionAppItem* GetAppAt(size_t index); 104 app_list::AppListItemModel* GetAppAt(size_t index);
105
106 // Returns the ExtensionAppItem at |index| or NULL if the item is not an
107 // exension app.
108 ExtensionAppItem* GetExtensionAppAt(size_t index);
101 109
102 // ui::ListModelObserver overrides: 110 // ui::ListModelObserver overrides:
103 virtual void ListItemsAdded(size_t start, size_t count) OVERRIDE; 111 virtual void ListItemsAdded(size_t start, size_t count) OVERRIDE;
104 virtual void ListItemsRemoved(size_t start, size_t count) OVERRIDE; 112 virtual void ListItemsRemoved(size_t start, size_t count) OVERRIDE;
105 virtual void ListItemMoved(size_t index, size_t target_index) OVERRIDE; 113 virtual void ListItemMoved(size_t index, size_t target_index) OVERRIDE;
106 virtual void ListItemsChanged(size_t start, size_t count) OVERRIDE; 114 virtual void ListItemsChanged(size_t start, size_t count) OVERRIDE;
107 115
108 Profile* profile_; 116 Profile* profile_;
109 AppListControllerDelegate* controller_; 117 AppListControllerDelegate* controller_;
110 118
111 // Sub apps model of AppListModel that represents apps grid view. 119 // Sub apps model of AppListModel that represents apps grid view.
112 app_list::AppListModel::Apps* model_; 120 app_list::AppListModel::Apps* model_;
113 121
114 std::string highlight_app_id_; 122 std::string highlight_app_id_;
115 123
116 // True if we haven't set |highlight_app_id_| to be highlighted. This happens 124 // True if we haven't set |highlight_app_id_| to be highlighted. This happens
117 // if we try to highlight an app that doesn't exist in the list yet. 125 // if we try to highlight an app that doesn't exist in the list yet.
118 bool highlighted_app_pending_; 126 bool highlighted_app_pending_;
119 127
120 // True to ignore |model_| changes. 128 // True to ignore |model_| changes.
121 bool ignore_changes_; 129 bool ignore_changes_;
122 130
123 // We listen to this to show app installing progress. 131 // We listen to this to show app installing progress.
124 extensions::InstallTracker* tracker_; 132 extensions::InstallTracker* tracker_;
125 133
126 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder); 134 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder);
127 }; 135 };
128 136
129 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ 137 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698