summaryrefslogtreecommitdiffstats
path: root/extensions/browser/renderer_startup_helper.h
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 01:38:41 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 01:38:41 +0000
commit44366da197a0ed0892cb6db95f622145c2700181 (patch)
tree23e0a89bcc1cb2dddf12399a51a6cc024c2c3620 /extensions/browser/renderer_startup_helper.h
parent0dd36070368c0aefa196cb22f7e978fcf9ed0c76 (diff)
downloadchromium_src-44366da197a0ed0892cb6db95f622145c2700181.zip
chromium_src-44366da197a0ed0892cb6db95f622145c2700181.tar.gz
chromium_src-44366da197a0ed0892cb6db95f622145c2700181.tar.bz2
Extract extension-related renderer setup from ExtensionService
Move it into a new class RendererStartupHelper. This allows app_shell and other clients of the src/extensions module use it without running code in src/chrome. Also ensure extension processes are added to the extensions::ProcessMap in app_shell. BUG=334710 TEST=Existing extensions browser_tests. Also, running app_shell manually still loads an extension. Review URL: https://codereview.chromium.org/145003006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/browser/renderer_startup_helper.h')
-rw-r--r--extensions/browser/renderer_startup_helper.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/extensions/browser/renderer_startup_helper.h b/extensions/browser/renderer_startup_helper.h
new file mode 100644
index 0000000..7fcc70f
--- /dev/null
+++ b/extensions/browser/renderer_startup_helper.h
@@ -0,0 +1,74 @@
+// Copyright 2014 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 EXTENSIONS_BROWSER_RENDER_PROCESS_HELPER_H_
+#define EXTENSIONS_BROWSER_RENDER_PROCESS_HELPER_H_
+
+#include "base/compiler_specific.h"
+#include "base/memory/singleton.h"
+#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
+#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+namespace content {
+class BrowserContext;
+class RenderProcessHost;
+}
+
+namespace extensions {
+
+// Informs renderers about extensions-related data (channel, available
+// functions, etc.) when they start. Sends this information to both extension
+// and non-extension renderers, as the non-extension renderers may have content
+// scripts. Lives on the UI thread. Shared between incognito and non-incognito
+// browser contexts.
+class RendererStartupHelper : public BrowserContextKeyedService,
+ public content::NotificationObserver {
+ public:
+ // This class sends messages to all renderers started for |browser_context|.
+ explicit RendererStartupHelper(content::BrowserContext* browser_context);
+ virtual ~RendererStartupHelper();
+
+ // content::NotificationObserver overrides:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ private:
+ content::BrowserContext* browser_context_; // Not owned.
+
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(RendererStartupHelper);
+};
+
+// Factory for RendererStartupHelpers. Declared here because this header is
+// rarely included and it's probably cheaper to put it here than to make the
+// compiler generate another object file.
+class RendererStartupHelperFactory : public BrowserContextKeyedServiceFactory {
+ public:
+ static RendererStartupHelper* GetForBrowserContext(
+ content::BrowserContext* context);
+ static RendererStartupHelperFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<RendererStartupHelperFactory>;
+
+ RendererStartupHelperFactory();
+ virtual ~RendererStartupHelperFactory();
+
+ // BrowserContextKeyedServiceFactory implementation:
+ virtual BrowserContextKeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const OVERRIDE;
+ virtual content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const OVERRIDE;
+ virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(RendererStartupHelperFactory);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_RENDER_PROCESS_HELPER_H_