OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "chrome/browser/media/router/media_router_mojo_impl_factory.h" | |
6 | |
7 #include "chrome/browser/media/router/media_router_mojo_impl.h" | |
8 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
9 #include "extensions/browser/process_manager.h" | |
10 #include "extensions/browser/process_manager_factory.h" | |
11 | |
12 using content::BrowserContext; | |
13 | |
14 namespace media_router { | |
15 | |
16 namespace { | |
17 | |
18 base::LazyInstance<MediaRouterMojoImplFactory> service_factory = | |
19 LAZY_INSTANCE_INITIALIZER; | |
20 | |
21 } // namespace | |
22 | |
23 // static | |
24 MediaRouterMojoImpl* MediaRouterMojoImplFactory::GetApiForBrowserContext( | |
25 BrowserContext* context) { | |
26 DCHECK(context); | |
27 | |
28 return static_cast<MediaRouterMojoImpl*>( | |
29 service_factory.Get().GetServiceForBrowserContext(context, true)); | |
30 } | |
31 | |
32 MediaRouterMojoImplFactory::MediaRouterMojoImplFactory() | |
33 : BrowserContextKeyedServiceFactory( | |
34 "MediaRouterMojoImpl", | |
35 BrowserContextDependencyManager::GetInstance()) { | |
36 // MediaRouterMojoImpl depends on ProcessManager. | |
37 DependsOn(extensions::ProcessManagerFactory::GetInstance()); | |
38 } | |
39 | |
40 MediaRouterMojoImplFactory::~MediaRouterMojoImplFactory() { | |
41 } | |
42 | |
43 KeyedService* MediaRouterMojoImplFactory::BuildServiceInstanceFor( | |
44 BrowserContext* context) const { | |
45 return new MediaRouterMojoImpl(extensions::ProcessManager::Get(context)); | |
46 } | |
47 | |
48 BrowserContext* MediaRouterMojoImplFactory::GetBrowserContextToUse( | |
49 BrowserContext* context) const { | |
50 // Always use the input context. This means that an incognito context will | |
51 // have its own MediaRouterMojoImpl service, rather than sharing it with its | |
52 // original non-incognito context. | |
53 return context; | |
54 } | |
55 | |
56 } // namespace media_router | |
OLD | NEW |