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
diff --git a/extensions/browser/extensions_browser_client.h b/extensions/browser/extensions_browser_client.h
index 293b2af..cb810b66 100644
--- a/extensions/browser/extensions_browser_client.h
+++ b/extensions/browser/extensions_browser_client.h
@@ -41,6 +41,7 @@
 class ExtensionSystem;
 class ExtensionSystemProvider;
 class InfoMap;
+class ProcessManagerDelegate;
 class RuntimeAPIDelegate;
 
 // Interface to allow the extensions module to make browser-process-specific
@@ -133,12 +134,9 @@
       content::BrowserContext* context,
       std::vector<ExtensionPrefsObserver*>* observers) const = 0;
 
-  // Returns true if loading background pages should be deferred.
-  virtual bool DeferLoadingBackgroundHosts(
-      content::BrowserContext* context) const = 0;
-
-  virtual bool IsBackgroundPageAllowed(
-      content::BrowserContext* context) const = 0;
+  // Returns the ProcessManagerDelegate shared across all BrowserContexts. May
+  // return NULL in tests or for simple embedders.
+  virtual ProcessManagerDelegate* GetProcessManagerDelegate() const = 0;
 
   // Creates a new ExtensionHostDelegate instance.
   virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() = 0;