summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 23:03:15 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 23:03:15 +0000
commitba93a0a13327c878692f388f5e39f64b1f36e564 (patch)
tree208fb5d10c5b9edeff94cf1317b211d66827d42a /chrome/browser
parent01a07a1d294281ae21669bade0d5a7a569745d19 (diff)
downloadchromium_src-ba93a0a13327c878692f388f5e39f64b1f36e564.zip
chromium_src-ba93a0a13327c878692f388f5e39f64b1f36e564.tar.gz
chromium_src-ba93a0a13327c878692f388f5e39f64b1f36e564.tar.bz2
Revert 193481 "Simplify ExtensionProcessManager to only load ext..."
> Simplify ExtensionProcessManager to only load extension background pages when a browser window is opened, and skip the other case of also watching for when extension system is initialized. This gets rid of a dependency on browser finder. > > BUG=157279 > Review URL: https://codereview.chromium.org/13811030 TBR=jam@chromium.org BUG=232062 Review URL: https://codereview.chromium.org/13846009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc33
-rw-r--r--chrome/browser/extensions/extension_process_manager.h5
2 files changed, 36 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index f29c401..7fadc78 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/background_info.h"
@@ -137,6 +138,8 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
Profile* original_profile = profile->GetOriginalProfile();
registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY,
content::NotificationService::AllSources());
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
+ content::Source<Profile>(original_profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(original_profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
@@ -552,13 +555,23 @@ void ExtensionProcessManager::Observe(
break;
ExtensionService* service = GetProfile()->GetExtensionService();
- if (!service)
+ if (!service || !service->is_ready())
+ break;
+
+ CreateBackgroundHostsForProfileStartup();
+ break;
+ }
+ case chrome::NOTIFICATION_EXTENSIONS_READY: {
+ // Don't load background hosts now if the loading should be deferred.
+ // Instead they will be loaded when a browser window for this profile
+ // (or an incognito profile from this profile) is ready.
+ if (DeferLoadingBackgroundHosts())
break;
- CHECK(service->is_ready());
CreateBackgroundHostsForProfileStartup();
break;
}
+
case chrome::NOTIFICATION_EXTENSION_LOADED: {
Profile* profile = content::Source<Profile>(source).ptr();
ExtensionService* service = profile->GetExtensionService();
@@ -759,6 +772,15 @@ void ExtensionProcessManager::ClearBackgroundPageData(
}
}
+bool ExtensionProcessManager::DeferLoadingBackgroundHosts() const {
+#if defined(OS_ANDROID)
+ return false;
+#else
+ return chrome::GetTotalBrowserCountForProfile(GetProfile()) == 0 &&
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList);
+#endif
+}
+
//
// IncognitoExtensionProcessManager
//
@@ -769,6 +791,13 @@ IncognitoExtensionProcessManager::IncognitoExtensionProcessManager(
original_manager_(extensions::ExtensionSystem::Get(
profile->GetOriginalProfile())->process_manager()) {
DCHECK(profile->IsOffTheRecord());
+
+ // The original profile will have its own ExtensionProcessManager to
+ // load the background pages of the spanning extensions. This process
+ // manager need only worry about the split mode extensions, which is handled
+ // in the NOTIFICATION_BROWSER_WINDOW_READY notification handler.
+ registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY,
+ content::Source<Profile>(profile->GetOriginalProfile()));
}
IncognitoExtensionProcessManager::~IncognitoExtensionProcessManager() {
diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h
index 0b65227..b0416eb 100644
--- a/chrome/browser/extensions/extension_process_manager.h
+++ b/chrome/browser/extensions/extension_process_manager.h
@@ -195,6 +195,11 @@ class ExtensionProcessManager : public content::NotificationObserver {
// Clears background page data for this extension.
void ClearBackgroundPageData(const std::string& extension_id);
+ // Returns true if loading background pages should be deferred. This is
+ // true if there are no browser windows open and the browser process was
+ // started to show the app launcher.
+ bool DeferLoadingBackgroundHosts() const;
+
// Contains all active extension-related RenderViewHost instances for all
// extensions. We also keep a cache of the host's view type, because that
// information is not accessible at registration/deregistration time.