summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/chrome_notification_observer.cc
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-22 02:13:47 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-22 02:13:47 +0000
commit6b54fda654446046577e4b9c10c48eb61b022ebb (patch)
tree4707735b1e04dc6669d4baebc6e28dfa31f19c55 /chrome/browser/extensions/chrome_notification_observer.cc
parente25bbc6831ccc2d0a924c3b0d8ce79469beff32c (diff)
downloadchromium_src-6b54fda654446046577e4b9c10c48eb61b022ebb.zip
chromium_src-6b54fda654446046577e4b9c10c48eb61b022ebb.tar.gz
chromium_src-6b54fda654446046577e4b9c10c48eb61b022ebb.tar.bz2
Reland: Refactor code that defers extension background page loading
src/extensions depends on chrome::NOTIFICATION_PROFILE_CREATED to support deferred loading of extension background pages when the profile isn't ready yet. This is a layering violation. * Remove Chrome concepts like "browser window ready" and "profile created" from ProcessManager. Introduce ProcessManagerDelegate with a general concept of deferring background page loading. * Consolidate all the tricky Chrome-specific background page loading rules into ChromeProcessManagerDelegate. This keeps all the rules in one place. Annotate each block of special case code with the bug that inspired it. * Extend unit test coverage for ProcessManager. This will make it easier to eliminate chrome::NOTIFICATION_PROFILE_DESTROYED in ProcessManager in a later CL. (Original CL https://codereview.chromium.org/381283002 broke valgrind bots because it was initializing left-over BrowserContextKeyedServices from tests running earlier in the same process.) BUG=392658 TEST=unit_tests ProcessManagerTest, browser_tests ProcessManagerBrowserTest, manual Review URL: https://codereview.chromium.org/408523005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284593 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/chrome_notification_observer.cc')
-rw-r--r--chrome/browser/extensions/chrome_notification_observer.cc43
1 files changed, 0 insertions, 43 deletions
diff --git a/chrome/browser/extensions/chrome_notification_observer.cc b/chrome/browser/extensions/chrome_notification_observer.cc
index 5d966c8..c8e6016 100644
--- a/chrome/browser/extensions/chrome_notification_observer.cc
+++ b/chrome/browser/extensions/chrome_notification_observer.cc
@@ -4,59 +4,22 @@
#include "chrome/browser/extensions/chrome_notification_observer.h"
-#include "base/logging.h"
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/features/feature_channel.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
-#include "extensions/browser/extension_system.h"
-#include "extensions/browser/process_manager.h"
#include "extensions/common/extension_messages.h"
namespace extensions {
ChromeNotificationObserver::ChromeNotificationObserver() {
registrar_.Add(this,
- chrome::NOTIFICATION_BROWSER_WINDOW_READY,
- content::NotificationService::AllSources());
- registrar_.Add(this,
content::NOTIFICATION_RENDERER_PROCESS_CREATED,
content::NotificationService::AllBrowserContextsAndSources());
}
ChromeNotificationObserver::~ChromeNotificationObserver() {}
-void ChromeNotificationObserver::OnBrowserWindowReady(Browser* browser) {
- Profile* profile = browser->profile();
- DCHECK(profile);
-
- // Inform the process manager for this profile that the window is ready.
- // We continue to observe the notification in case browser windows open for
- // a related incognito profile or other regular profiles.
- extensions::ProcessManager* manager =
- ExtensionSystem::Get(profile)->process_manager();
- if (!manager) // Tests may not have a process manager.
- return;
- DCHECK_EQ(profile, manager->GetBrowserContext());
- manager->OnBrowserWindowReady();
-
- // For incognito profiles also inform the original profile's process manager
- // that the window is ready. This will usually be a no-op because the
- // original profile's process manager should have been informed when the
- // non-incognito window opened.
- if (profile->IsOffTheRecord()) {
- Profile* original_profile = profile->GetOriginalProfile();
- extensions::ProcessManager* original_manager =
- ExtensionSystem::Get(original_profile)->process_manager();
- DCHECK(original_manager);
- DCHECK_EQ(original_profile, original_manager->GetBrowserContext());
- original_manager->OnBrowserWindowReady();
- }
-}
-
void ChromeNotificationObserver::OnRendererProcessCreated(
content::RenderProcessHost* process) {
// Extensions need to know the channel for API restrictions. Send the channel
@@ -68,12 +31,6 @@ void ChromeNotificationObserver::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
- case chrome::NOTIFICATION_BROWSER_WINDOW_READY: {
- Browser* browser = content::Source<Browser>(source).ptr();
- OnBrowserWindowReady(browser);
- break;
- }
-
case content::NOTIFICATION_RENDERER_PROCESS_CREATED: {
content::RenderProcessHost* process =
content::Source<content::RenderProcessHost>(source).ptr();