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/offscreen_presentation_manager_factory.h" |
| 6 |
| 7 #include "base/lazy_instance.h" |
| 8 |
| 9 #include "chrome/browser/media/router/offscreen_presentation_manager.h" |
| 10 #include "chrome/browser/profiles/incognito_helpers.h" |
| 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "content/public/browser/web_contents.h" |
| 14 |
| 15 namespace media_router { |
| 16 |
| 17 namespace { |
| 18 |
| 19 base::LazyInstance<OffscreenPresentationManagerFactory> service_factory = |
| 20 LAZY_INSTANCE_INITIALIZER; |
| 21 |
| 22 } // namespace |
| 23 |
| 24 // static |
| 25 OffscreenPresentationManager* |
| 26 OffscreenPresentationManagerFactory::GetOrCreateForControllerBrowserContext( |
| 27 content::WebContents* web_contents) { |
| 28 DCHECK(web_contents); |
| 29 return OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext( |
| 30 web_contents->GetBrowserContext()); |
| 31 } |
| 32 |
| 33 // static |
| 34 OffscreenPresentationManager* |
| 35 OffscreenPresentationManagerFactory::GetOrCreateForReceiverBrowserContext( |
| 36 content::WebContents* web_contents) { |
| 37 DCHECK(web_contents); |
| 38 DCHECK(web_contents->GetBrowserContext()->IsOffTheRecord()); |
| 39 return OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext( |
| 40 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
| 41 ->GetOriginalProfile()); |
| 42 } |
| 43 |
| 44 // static |
| 45 OffscreenPresentationManager* |
| 46 OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext( |
| 47 content::BrowserContext* context) { |
| 48 DCHECK(context); |
| 49 return static_cast<OffscreenPresentationManager*>( |
| 50 service_factory.Get().GetServiceForBrowserContext(context, true)); |
| 51 } |
| 52 |
| 53 OffscreenPresentationManagerFactory::OffscreenPresentationManagerFactory() |
| 54 : BrowserContextKeyedServiceFactory( |
| 55 "OffscreenPresentationManager", |
| 56 BrowserContextDependencyManager::GetInstance()) {} |
| 57 OffscreenPresentationManagerFactory::~OffscreenPresentationManagerFactory() {} |
| 58 |
| 59 content::BrowserContext* |
| 60 OffscreenPresentationManagerFactory::GetBrowserContextToUse( |
| 61 content::BrowserContext* context) const { |
| 62 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 63 } |
| 64 KeyedService* OffscreenPresentationManagerFactory::BuildServiceInstanceFor( |
| 65 content::BrowserContext* context) const { |
| 66 return new OffscreenPresentationManager; |
| 67 } |
| 68 |
| 69 } // namespace media_router |
OLD | NEW |