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

Unified Diff: chrome/browser/ui/app_list/apps_model_builder.cc

Issue 12298015: Change NotifyAppList*() functions into observers on a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/apps_model_builder.cc
diff --git a/chrome/browser/ui/app_list/apps_model_builder.cc b/chrome/browser/ui/app_list/apps_model_builder.cc
index 4bacc0a56eb637382f3489a835243896899052a5..b10f70de18aa37bf30a93e67c79418b3fd7e5394 100644
--- a/chrome/browser/ui/app_list/apps_model_builder.cc
+++ b/chrome/browser/ui/app_list/apps_model_builder.cc
@@ -19,6 +19,7 @@
#include "ui/gfx/image/image_skia.h"
using extensions::Extension;
+using extensions::ExtensionInstallingDetails;
namespace {
@@ -53,6 +54,12 @@ AppsModelBuilder::AppsModelBuilder(Profile* profile,
content::Source<Profile>(profile_));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED,
content::Source<ExtensionSorting>(extension_prefs->extension_sorting()));
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_BEGIN,
+ content::Source<Profile>(profile_));
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_PROGRESS,
+ content::Source<Profile>(profile_));
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_FAIL,
+ content::Source<Profile>(profile_));
registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST,
content::Source<Profile>(profile_));
@@ -75,34 +82,6 @@ void AppsModelBuilder::Build() {
HighlightApp();
}
-void AppsModelBuilder::OnBeginExtensionInstall(
- const std::string& extension_id,
- const std::string& extension_name,
- const gfx::ImageSkia& installing_icon) {
- InsertApp(new ExtensionAppItem(profile_,
- extension_id,
- controller_,
- extension_name,
- installing_icon));
- highlight_app_id_ = extension_id;
- HighlightApp();
-}
-
-void AppsModelBuilder::OnDownloadProgress(const std::string& extension_id,
- int percent_downloaded) {
- int i = FindApp(extension_id);
- if (i == -1)
- return;
- GetAppAt(i)->SetPercentDownloaded(percent_downloaded);
-}
-
-void AppsModelBuilder::OnInstallFailure(const std::string& extension_id) {
- int i = FindApp(extension_id);
- if (i == -1)
- return;
- model_->DeleteAt(i);
-}
-
void AppsModelBuilder::AddApps(const ExtensionSet* extensions, Apps* apps) {
for (ExtensionSet::const_iterator app = extensions->begin();
app != extensions->end(); ++app) {
@@ -252,6 +231,36 @@ void AppsModelBuilder::Observe(int type,
ResortApps();
break;
}
+ case chrome::NOTIFICATION_EXTENSION_INSTALL_BEGIN: {
+ ExtensionInstallingDetails* d =
+ content::Details<ExtensionInstallingDetails>(details).ptr();
+
+ InsertApp(new ExtensionAppItem(profile_,
+ d->extension_id,
+ controller_,
+ d->extension_name,
+ d->icon));
+ highlight_app_id_ = d->extension_id;
+ HighlightApp();
+ }
+ case chrome::NOTIFICATION_EXTENSION_INSTALL_PROGRESS: {
+ std::pair<std::string, int>* complete_details =
+ content::Details<std::pair<std::string, int> >(details).ptr();
+ std::string& extension_id = complete_details->first;
+ int percent_downloaded = complete_details->second;
+ int i = FindApp(extension_id);
+ if (i == -1)
+ return;
+ GetAppAt(i)->SetPercentDownloaded(percent_downloaded);
+ }
+ case chrome::NOTIFICATION_EXTENSION_INSTALL_FAIL: {
+ const std::string& extension_id =
+ *content::Details<std::string>(details).ptr();
+ int i = FindApp(extension_id);
+ if (i == -1)
+ return;
+ model_->DeleteAt(i);
+ }
case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: {
highlight_app_id_ = *content::Details<const std::string>(details).ptr();
HighlightApp();

Powered by Google App Engine
This is Rietveld 408576698