Resurrect ExtensionProcessManager. Move the code for starting extension
instances from ExtensionsService to the manager.
Unlike ExtensionsService, EPM is not shared between an incognito Profile and
its parent.
Review URL: http://codereview.chromium.org/109044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15454 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h
new file mode 100644
index 0000000..73be45dd
--- /dev/null
+++ b/chrome/browser/extensions/extension_process_manager.h
@@ -0,0 +1,59 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
+
+#include <list>
+
+#include "base/ref_counted.h"
+#include "chrome/common/notification_observer.h"
+
+class Browser;
+class BrowsingInstance;
+class Extension;
+class ExtensionHost;
+class ExtensionView;
+class GURL;
+class Profile;
+class SiteInstance;
+
+// Manages dynamic state of running Chromium extensions. There is one instance
+// of this class per Profile (including OTR).
+class ExtensionProcessManager : public NotificationObserver {
+ public:
+ ExtensionProcessManager(Profile* profile);
+ ~ExtensionProcessManager();
+
+ // Creates a new ExtensionView, grouping it in the appropriate SiteInstance
+ // (and therefore process) based on the URL and profile.
+ ExtensionView* CreateView(Extension* extension,
+ const GURL& url,
+ Browser* browser);
+
+ // Creates a new UI-less extension instance. Like CreateView, but not
+ // displayed anywhere.
+ void CreateBackgroundHost(Extension* extension, const GURL& url);
+
+ // Returns the SiteInstance that the given URL belongs to.
+ SiteInstance* GetSiteInstanceForURL(const GURL& url);
+
+ // NotificationObserver:
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ private:
+ // The list of running viewless background extensions.
+ typedef std::list<ExtensionHost*> ExtensionHostList;
+ ExtensionHostList background_hosts_;
+
+ // The BrowsingInstance shared by all extensions in this profile. This
+ // controls process grouping.
+ scoped_refptr<BrowsingInstance> browsing_instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_