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 "chrome/browser/media/router/media_router_mojo_impl_factory.h"
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"
12 using content::BrowserContext
;
14 namespace media_router
{
18 base::LazyInstance
<MediaRouterMojoImplFactory
> service_factory
=
19 LAZY_INSTANCE_INITIALIZER
;
24 MediaRouterMojoImpl
* MediaRouterMojoImplFactory::GetApiForBrowserContext(
25 BrowserContext
* context
) {
28 return static_cast<MediaRouterMojoImpl
*>(
29 service_factory
.Get().GetServiceForBrowserContext(context
, true));
32 MediaRouterMojoImplFactory::MediaRouterMojoImplFactory()
33 : BrowserContextKeyedServiceFactory(
34 "MediaRouterMojoImpl",
35 BrowserContextDependencyManager::GetInstance()) {
36 // MediaRouterMojoImpl depends on ProcessManager.
37 DependsOn(extensions::ProcessManagerFactory::GetInstance());
40 MediaRouterMojoImplFactory::~MediaRouterMojoImplFactory() {
43 KeyedService
* MediaRouterMojoImplFactory::BuildServiceInstanceFor(
44 BrowserContext
* context
) const {
45 return new MediaRouterMojoImpl(extensions::ProcessManager::Get(context
));
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.
56 } // namespace media_router