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

Unified Diff: chrome/browser/extensions/extension_process_manager.cc

Issue 7830046: Allow window.close() in background pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/DCHECK/CHECK/ Created 9 years, 3 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/extensions/extension_process_manager.cc
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 806968623b580adb85e0ca85fda6e49460839f9b..b5290f7be01a0ff59aa4e19885483396f0a977f3 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -100,6 +100,8 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
Source<Profile>(original_profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
Source<Profile>(profile));
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
+ Source<Profile>(profile));
// We can listen to everything for SITE_INSTANCE_DELETED because we check the
// |site_instance_id| in UnregisterExtensionSiteInstance.
registrar_.Add(this, content::NOTIFICATION_SITE_INSTANCE_DELETED,
@@ -336,6 +338,16 @@ void ExtensionProcessManager::Observe(int type,
break;
}
+ case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: {
+ ExtensionHost* host = Details<ExtensionHost>(details).ptr();
+ if (host->extension_host_type() == ViewType::EXTENSION_BACKGROUND_PAGE) {
+ delete host;
+ // |host| should deregister itself from our structures.
+ CHECK(background_hosts_.find(host) == background_hosts_.end());
+ }
+ break;
+ }
+
case content::NOTIFICATION_APP_TERMINATING: {
// Close background hosts when the last browser is closed so that they
// have time to shutdown various objects on different threads. Our

Powered by Google App Engine
This is Rietveld 408576698