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

Unified Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 7799008: Fix crash on NTP related to multi-profile extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix sources for incognito Created 9 years, 4 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/webui/ntp/app_launcher_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index 0355ee7e2ad6279726f037212487ea77ff267862..9be4b23bbe3604c12885a9f07deade217267d2f9 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -259,6 +259,10 @@ void AppLauncherHandler::Observe(int type,
switch (type) {
case chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED: {
+ Profile* profile = Source<Profile>(source).ptr();
+ if (!Profile::FromWebUI(web_ui_)->IsSameProfile(profile))
+ return;
+
const std::string& id = *Details<const std::string>(details).ptr();
const AppNotification* notification =
extension_service_->app_notification_manager()->GetLast(id);
@@ -441,7 +445,8 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
// b) Conceptually, it doesn't really make sense to count a
// prefchange-triggered refresh as a promo 'view'.
AppsPromo* apps_promo = extension_service_->apps_promo();
- PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs();
+ Profile* profile = Profile::FromWebUI(web_ui_);
+ PrefService* prefs = profile->GetPrefs();
bool apps_promo_just_expired = false;
if (apps_promo->ShouldShowPromo(extension_service_->GetAppIds(),
&apps_promo_just_expired)) {
@@ -472,15 +477,15 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
registrar_.Add(this, chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED,
NotificationService::AllSources());
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
- NotificationService::AllSources());
+ Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
- NotificationService::AllSources());
+ Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED,
- NotificationService::AllSources());
+ Source<ExtensionPrefs>(extension_service_->extension_prefs()));
registrar_.Add(this, chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED,
- NotificationService::AllSources());
+ Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
- NotificationService::AllSources());
+ Source<Profile>(profile));
}
if (pref_change_registrar_.IsEmpty()) {
pref_change_registrar_.Init(

Powered by Google App Engine
This is Rietveld 408576698