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/usb/usb_chooser_context_factory.h" |
| 6 |
| 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 8 #include "chrome/browser/profiles/incognito_helpers.h" |
| 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/usb/usb_chooser_context.h" |
| 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 12 |
| 13 UsbChooserContextFactory::UsbChooserContextFactory() |
| 14 : BrowserContextKeyedServiceFactory( |
| 15 "UsbChooserContext", |
| 16 BrowserContextDependencyManager::GetInstance()) { |
| 17 DependsOn(HostContentSettingsMapFactory::GetInstance()); |
| 18 } |
| 19 |
| 20 UsbChooserContextFactory::~UsbChooserContextFactory() {} |
| 21 |
| 22 KeyedService* UsbChooserContextFactory::BuildServiceInstanceFor( |
| 23 content::BrowserContext* context) const { |
| 24 return new UsbChooserContext(Profile::FromBrowserContext(context)); |
| 25 } |
| 26 |
| 27 // static |
| 28 UsbChooserContextFactory* UsbChooserContextFactory::GetInstance() { |
| 29 return base::Singleton<UsbChooserContextFactory>::get(); |
| 30 } |
| 31 |
| 32 // static |
| 33 UsbChooserContext* UsbChooserContextFactory::GetForProfile(Profile* profile) { |
| 34 return static_cast<UsbChooserContext*>( |
| 35 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 36 } |
| 37 |
| 38 content::BrowserContext* UsbChooserContextFactory::GetBrowserContextToUse( |
| 39 content::BrowserContext* context) const { |
| 40 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 41 } |
OLD | NEW |