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 "extensions/browser/api/printer_provider/printer_provider_api_factory.h"
7 #include "components/keyed_service/content/browser_context_dependency_manager.h"
8 #include "extensions/browser/api/printer_provider/printer_provider_api.h"
9 #include "extensions/browser/api/printer_provider_internal/printer_provider_internal_api.h"
10 #include "extensions/browser/extension_registry_factory.h"
11 #include "extensions/browser/extensions_browser_client.h"
15 static base::LazyInstance
<extensions::PrinterProviderAPIFactory
> g_api_factory
=
16 LAZY_INSTANCE_INITIALIZER
;
20 namespace extensions
{
23 PrinterProviderAPIFactory
* PrinterProviderAPIFactory::GetInstance() {
24 return g_api_factory
.Pointer();
27 PrinterProviderAPI
* PrinterProviderAPIFactory::GetForBrowserContext(
28 content::BrowserContext
* context
) {
29 return static_cast<PrinterProviderAPI
*>(
30 GetServiceForBrowserContext(context
, true));
33 PrinterProviderAPIFactory::PrinterProviderAPIFactory()
34 : BrowserContextKeyedServiceFactory(
36 BrowserContextDependencyManager::GetInstance()) {
37 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
38 DependsOn(PrinterProviderInternalAPI::GetFactoryInstance());
39 DependsOn(ExtensionRegistryFactory::GetInstance());
42 PrinterProviderAPIFactory::~PrinterProviderAPIFactory() {
45 KeyedService
* PrinterProviderAPIFactory::BuildServiceInstanceFor(
46 content::BrowserContext
* context
) const {
47 return PrinterProviderAPI::Create(context
);
50 content::BrowserContext
* PrinterProviderAPIFactory::GetBrowserContextToUse(
51 content::BrowserContext
* context
) const {
52 return ExtensionsBrowserClient::Get()->GetOriginalContext(context
);
55 } // namespace extensions