Chromium Code Reviews| Index: chrome/browser/ui/webui/options/extension_settings_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/extension_settings_handler.cc b/chrome/browser/ui/webui/options/extension_settings_handler.cc |
| index 9943a750c34b902e90e2476a8faca5c05732a802..987c6d1ccbdce8f1ecded015f1d2ce5c005a0060 100644 |
| --- a/chrome/browser/ui/webui/options/extension_settings_handler.cc |
| +++ b/chrome/browser/ui/webui/options/extension_settings_handler.cc |
| @@ -26,6 +26,7 @@ |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| #include "chrome/common/chrome_view_types.h" |
| +#include "content/browser/browsing_instance.h" |
| #include "content/browser/renderer_host/render_process_host.h" |
| #include "content/browser/renderer_host/render_view_host.h" |
| #include "content/browser/tab_contents/tab_contents.h" |
| @@ -194,34 +195,37 @@ void ExtensionSettingsHandler::MaybeRegisterForNotifications() { |
| return; |
| registered_for_notifications_ = true; |
| + Profile* profile = Profile::FromWebUI(web_ui_); |
| // Register for notifications that we need to reload the page. |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| - NotificationService::AllSources()); |
| + Source<Profile>(profile)); |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED, |
| - NotificationService::AllSources()); |
| + Source<Profile>(profile)); |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| - NotificationService::AllSources()); |
| + Source<Profile>(profile)); |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| - NotificationService::AllSources()); |
| - registrar_.Add(this, |
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| - NotificationService::AllSources()); |
| + Source<Profile>(profile)); |
| registrar_.Add(this, |
| - content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, |
| - NotificationService::AllSources()); |
| + content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| + NotificationService::AllBrowserContextsAndSources()); |
| registrar_.Add(this, |
| - content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, |
| - NotificationService::AllSources()); |
| + content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, |
| + NotificationService::AllBrowserContextsAndSources()); |
| registrar_.Add(this, |
| - chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, |
| - NotificationService::AllSources()); |
| + content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, |
| + NotificationService::AllBrowserContextsAndSources()); |
| registrar_.Add(this, |
| - chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, |
| - NotificationService::AllSources()); |
| + chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, |
| + NotificationService::AllBrowserContextsAndSources()); |
| registrar_.Add(this, |
| + chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, |
| + NotificationService::AllBrowserContextsAndSources()); |
| + registrar_.Add( |
| + this, |
| chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
| - NotificationService::AllSources()); |
| + Source<ExtensionPrefs>(profile->GetExtensionService()-> |
| + extension_prefs())); |
| } |
| ExtensionUninstallDialog* |
| @@ -573,6 +577,7 @@ WebUIMessageHandler* ExtensionSettingsHandler::Attach(WebUI* web_ui) { |
| void ExtensionSettingsHandler::Observe(int type, |
| const NotificationSource& source, |
| const NotificationDetails& details) { |
| + Profile* this_profile = Profile::FromWebUI(web_ui_); |
| switch (type) { |
| // We listen for notifications that will result in the page being |
| // repopulated with data twice for the same event in certain cases. |
| @@ -588,21 +593,62 @@ void ExtensionSettingsHandler::Observe(int type, |
| // |
| // Doing it this way gets everything but causes the page to be rendered |
| // more than we need. It doesn't seem to result in any noticeable flicker. |
| + case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: |
| + { |
| + Profile* profile = Profile::FromBrowserContext( |
| + Source<RenderViewHost>(source)->site_instance()-> |
| + browsing_instance()->browser_context()); |
| + if (!this_profile->IsSameProfile(profile)) |
| + return; |
| + MaybeUpdateAfterNotification(); |
| + break; |
| + } |
| case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: |
| - deleting_rvh_ = Source<RenderViewHost>(source).ptr(); |
| - MaybeUpdateAfterNotification(); |
| - break; |
| + { |
| + Profile* profile = Profile::FromBrowserContext( |
| + Source<RenderViewHost>(source)->site_instance()-> |
| + browsing_instance()->browser_context()); |
| + if (!this_profile->IsSameProfile(profile)) |
| + return; |
| + deleting_rvh_ = Source<RenderViewHost>(source).ptr(); |
| + MaybeUpdateAfterNotification(); |
| + break; |
| + } |
| case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: |
| - deleting_rvh_ = Details<BackgroundContents>(details)->render_view_host(); |
| - MaybeUpdateAfterNotification(); |
| - break; |
| + { |
| + Profile* profile = Profile::FromBrowserContext( |
| + Details<BackgroundContents>(details)->render_view_host()-> |
| + site_instance()->browsing_instance()->browser_context()); |
| + if (!this_profile->IsSameProfile(profile)) |
| + return; |
| + deleting_rvh_ = |
| + Details<BackgroundContents>(details)->render_view_host(); |
| + MaybeUpdateAfterNotification(); |
| + break; |
| + } |
| + case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: |
| + { |
| + Profile* profile = Profile::FromBrowserContext( |
| + Details<BackgroundContents>(details)->render_view_host()-> |
| + site_instance()->browsing_instance()->browser_context()); |
| + if (!this_profile->IsSameProfile(profile)) |
| + return; |
| + MaybeUpdateAfterNotification(); |
| + break; |
| + } |
| + case content::NOTIFICATION_NAV_ENTRY_COMMITTED: |
| + { |
| + Profile* profile = Profile::FromBrowserContext( |
| + Source<NavigationController>(source).ptr()->browser_context()); |
| + if (!this_profile->IsSameProfile(profile)) |
| + return; |
| + MaybeUpdateAfterNotification(); |
| + break; |
| + } |
|
Finnur
2011/10/10 10:34:53
There's a lot of duplicate code here... I'm wonder
|
| case chrome::NOTIFICATION_EXTENSION_LOADED: |
| case chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED: |
| case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
| - case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: |
| - case content::NOTIFICATION_NAV_ENTRY_COMMITTED: |
| - case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: |
| case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: |
| MaybeUpdateAfterNotification(); |
| break; |