Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/media/router/media_router_mojo_impl_factory.h" | 5 #include "chrome/browser/media/router/media_router_factory.h" |
| 6 | 6 |
| 7 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
| 8 #if defined(OS_ANDROID) | |
| 9 #else | |
| 7 #include "chrome/browser/media/router/media_router_mojo_impl.h" | 10 #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" | 11 #include "extensions/browser/process_manager.h" |
| 10 #include "extensions/browser/process_manager_factory.h" | 12 #include "extensions/browser/process_manager_factory.h" |
| 13 #endif | |
| 11 | 14 |
| 12 using content::BrowserContext; | 15 using content::BrowserContext; |
| 13 | 16 |
| 14 namespace media_router { | 17 namespace media_router { |
| 15 | 18 |
| 16 namespace { | 19 namespace { |
| 17 | 20 |
| 18 base::LazyInstance<MediaRouterMojoImplFactory> service_factory = | 21 #if !defined(OS_ANDROID) |
| 22 base::LazyInstance<MediaRouterFactory> service_factory = | |
| 19 LAZY_INSTANCE_INITIALIZER; | 23 LAZY_INSTANCE_INITIALIZER; |
| 24 #endif | |
| 20 | 25 |
| 21 } // namespace | 26 } // namespace |
| 22 | 27 |
| 23 // static | 28 // static |
| 24 MediaRouterMojoImpl* MediaRouterMojoImplFactory::GetApiForBrowserContext( | 29 MediaRouter* MediaRouterFactory::GetApiForBrowserContext( |
| 25 BrowserContext* context) { | 30 BrowserContext* context) { |
| 26 DCHECK(context); | 31 DCHECK(context); |
| 27 | 32 #if defined(OS_ANDROID) |
| 33 return nullptr; | |
| 34 #else | |
| 28 return static_cast<MediaRouterMojoImpl*>( | 35 return static_cast<MediaRouterMojoImpl*>( |
|
imcheng
2015/07/13 22:04:14
Is the static_cast still needed?
whywhat
2015/07/15 12:41:04
Don't think so. Removed.
| |
| 29 service_factory.Get().GetServiceForBrowserContext(context, true)); | 36 service_factory.Get().GetServiceForBrowserContext(context, true)); |
| 37 #endif | |
| 30 } | 38 } |
| 31 | 39 |
| 32 MediaRouterMojoImplFactory::MediaRouterMojoImplFactory() | 40 MediaRouterFactory::MediaRouterFactory() |
| 33 : BrowserContextKeyedServiceFactory( | 41 : BrowserContextKeyedServiceFactory( |
| 34 "MediaRouterMojoImpl", | 42 "MediaRouter", |
| 35 BrowserContextDependencyManager::GetInstance()) { | 43 BrowserContextDependencyManager::GetInstance()) { |
| 36 // MediaRouterMojoImpl depends on ProcessManager. | 44 #if !defined(OS_ANDROID) |
| 45 // MediaRouter depends on ProcessManager. | |
|
imcheng
2015/07/13 22:04:14
Maybe clarify that this is true for desktop versio
whywhat
2015/07/15 12:41:04
Done.
| |
| 37 DependsOn(extensions::ProcessManagerFactory::GetInstance()); | 46 DependsOn(extensions::ProcessManagerFactory::GetInstance()); |
| 47 #endif | |
| 38 } | 48 } |
| 39 | 49 |
| 40 MediaRouterMojoImplFactory::~MediaRouterMojoImplFactory() { | 50 MediaRouterFactory::~MediaRouterFactory() { |
| 41 } | 51 } |
| 42 | 52 |
| 43 KeyedService* MediaRouterMojoImplFactory::BuildServiceInstanceFor( | 53 KeyedService* MediaRouterFactory::BuildServiceInstanceFor( |
| 44 BrowserContext* context) const { | 54 BrowserContext* context) const { |
| 55 #if defined(OS_ANDROID) | |
| 56 return nullptr; | |
| 57 #else | |
| 45 return new MediaRouterMojoImpl(extensions::ProcessManager::Get(context)); | 58 return new MediaRouterMojoImpl(extensions::ProcessManager::Get(context)); |
| 59 #endif | |
| 46 } | 60 } |
| 47 | 61 |
| 48 BrowserContext* MediaRouterMojoImplFactory::GetBrowserContextToUse( | 62 BrowserContext* MediaRouterFactory::GetBrowserContextToUse( |
| 49 BrowserContext* context) const { | 63 BrowserContext* context) const { |
| 50 // Always use the input context. This means that an incognito context will | 64 // Always use the input context. This means that an incognito context will |
| 51 // have its own MediaRouterMojoImpl service, rather than sharing it with its | 65 // have its own MediaRouter service, rather than sharing it with its |
| 52 // original non-incognito context. | 66 // original non-incognito context. |
| 53 return context; | 67 return context; |
| 54 } | 68 } |
| 55 | 69 |
| 56 } // namespace media_router | 70 } // namespace media_router |
| OLD | NEW |