diff options
Diffstat (limited to 'chromium/extensions/browser/renderer_startup_helper.h')
-rw-r--r-- | chromium/extensions/browser/renderer_startup_helper.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/chromium/extensions/browser/renderer_startup_helper.h b/chromium/extensions/browser/renderer_startup_helper.h new file mode 100644 index 00000000000..5aa66154d7e --- /dev/null +++ b/chromium/extensions/browser/renderer_startup_helper.h @@ -0,0 +1,75 @@ +// 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_RENDERER_STARTUP_HELPER_H_ +#define EXTENSIONS_BROWSER_RENDERER_STARTUP_HELPER_H_ + +#include "base/compiler_specific.h" +#include "base/macros.h" +#include "base/memory/singleton.h" +#include "components/keyed_service/content/browser_context_keyed_service_factory.h" +#include "components/keyed_service/core/keyed_service.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 (loaded extensions, 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 KeyedService, + public content::NotificationObserver { + public: + // This class sends messages to all renderers started for |browser_context|. + explicit RendererStartupHelper(content::BrowserContext* browser_context); + ~RendererStartupHelper() override; + + // content::NotificationObserver overrides: + 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 base::DefaultSingletonTraits<RendererStartupHelperFactory>; + + RendererStartupHelperFactory(); + ~RendererStartupHelperFactory() override; + + // BrowserContextKeyedServiceFactory implementation: + KeyedService* BuildServiceInstanceFor( + content::BrowserContext* profile) const override; + content::BrowserContext* GetBrowserContextToUse( + content::BrowserContext* context) const override; + bool ServiceIsCreatedWithBrowserContext() const override; + + DISALLOW_COPY_AND_ASSIGN(RendererStartupHelperFactory); +}; + +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_RENDERER_STARTUP_HELPER_H_ |