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

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

Issue 12298015: Change NotifyAppList*() functions into observers on a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 7 years, 9 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 "base/prefs/public/pref_change_registrar.h" 12 #include "base/prefs/public/pref_change_registrar.h"
13 #include "chrome/browser/extensions/install_observer.h"
13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
15 #include "ui/app_list/app_list_model.h" 16 #include "ui/app_list/app_list_model.h"
16 #include "ui/base/models/list_model_observer.h" 17 #include "ui/base/models/list_model_observer.h"
17 18
18 class AppListControllerDelegate; 19 class AppListControllerDelegate;
19 class ExtensionAppItem; 20 class ExtensionAppItem;
20 class ExtensionSet; 21 class ExtensionSet;
21 class Profile; 22 class Profile;
22 23
23 namespace gfx { 24 namespace gfx {
24 class ImageSkia; 25 class ImageSkia;
25 } 26 }
26 27
27 class AppsModelBuilder : public content::NotificationObserver, 28 class AppsModelBuilder : public content::NotificationObserver,
28 public ui::ListModelObserver { 29 public ui::ListModelObserver,
30 public extensions::InstallObserver {
29 public: 31 public:
30 AppsModelBuilder(Profile* profile, 32 AppsModelBuilder(Profile* profile,
31 app_list::AppListModel::Apps* model, 33 app_list::AppListModel::Apps* model,
32 AppListControllerDelegate* controller); 34 AppListControllerDelegate* controller);
33 virtual ~AppsModelBuilder(); 35 virtual ~AppsModelBuilder();
34 36
35 // Populates the model. 37 // Populates the model.
36 void Build(); 38 void Build();
37 39
38 // Called when an extension starts installing.
39 void OnBeginExtensionInstall(const std::string& extension_id,
40 const std::string& extension_name,
41 const gfx::ImageSkia& installing_icon);
42
43 // Called when progress is made on an extension's download.
44 void OnDownloadProgress(const std::string& extension_id,
45 int percent_downloaded);
46
47 // Called when an extension fails to install.
48 void OnInstallFailure(const std::string& extension_id);
49
50 private: 40 private:
51 typedef std::vector<ExtensionAppItem*> Apps; 41 typedef std::vector<ExtensionAppItem*> Apps;
52 42
43 // InstallObserver overrides.
tfarina 2013/02/25 23:43:02 extensions::InstallObserver overrides: Although m
koz (OOO until 15th September) 2013/02/26 00:10:51 Done.
44 virtual void OnBeginExtensionInstall(const std::string& extension_id,
45 const std::string& extension_name,
46 const gfx::ImageSkia& installing_icon,
47 bool is_app) OVERRIDE;
48
49 virtual void OnDownloadProgress(const std::string& extension_id,
50 int percent_downloaded) OVERRIDE;
51
52 virtual void OnInstallFailure(const std::string& extension_id) OVERRIDE;
53
53 // Adds apps in |extensions| to |apps|. 54 // Adds apps in |extensions| to |apps|.
54 void AddApps(const ExtensionSet* extensions, Apps* apps); 55 void AddApps(const ExtensionSet* extensions, Apps* apps);
55 56
56 // Populates the model with apps. 57 // Populates the model with apps.
57 void PopulateApps(); 58 void PopulateApps();
58 59
59 // Re-sort apps in case app ordinal prefs are changed. 60 // Re-sort apps in case app ordinal prefs are changed.
60 void ResortApps(); 61 void ResortApps();
61 62
62 // Inserts an app based on app ordinal prefs. 63 // Inserts an app based on app ordinal prefs.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // True to ignore |model_| changes. 97 // True to ignore |model_| changes.
97 bool ignore_changes_; 98 bool ignore_changes_;
98 99
99 content::NotificationRegistrar registrar_; 100 content::NotificationRegistrar registrar_;
100 PrefChangeRegistrar pref_change_registrar_; 101 PrefChangeRegistrar pref_change_registrar_;
101 102
102 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder); 103 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder);
103 }; 104 };
104 105
105 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ 106 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698