1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/browser/event_router_factory.h"
7 #include "components/keyed_service/content/browser_context_dependency_manager.h"
8 #include "content/public/browser/browser_context.h"
9 #include "extensions/browser/event_router.h"
10 #include "extensions/browser/extension_prefs.h"
11 #include "extensions/browser/extension_prefs_factory.h"
12 #include "extensions/browser/extension_registry_factory.h"
13 #include "extensions/browser/extensions_browser_client.h"
15 using content::BrowserContext
;
17 namespace extensions
{
20 EventRouter
* EventRouterFactory::GetForBrowserContext(BrowserContext
* context
) {
21 return static_cast<EventRouter
*>(
22 GetInstance()->GetServiceForBrowserContext(context
, true));
26 EventRouterFactory
* EventRouterFactory::GetInstance() {
27 return base::Singleton
<EventRouterFactory
>::get();
30 EventRouterFactory::EventRouterFactory()
31 : BrowserContextKeyedServiceFactory(
33 BrowserContextDependencyManager::GetInstance()) {
34 DependsOn(ExtensionRegistryFactory::GetInstance());
35 DependsOn(ExtensionPrefsFactory::GetInstance());
38 EventRouterFactory::~EventRouterFactory() {
41 KeyedService
* EventRouterFactory::BuildServiceInstanceFor(
42 BrowserContext
* context
) const {
43 return new EventRouter(context
, ExtensionPrefs::Get(context
));
46 BrowserContext
* EventRouterFactory::GetBrowserContextToUse(
47 BrowserContext
* context
) const {
48 // Redirected in incognito.
49 return ExtensionsBrowserClient::Get()->GetOriginalContext(context
);
52 } // namespace extensions