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/chromeos/printer_detector/printer_detector_factory.h" | 5 #include "chrome/browser/chromeos/printer_detector/printer_detector_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chromeos/printer_detector/printer_detector.h" | 8 #include "chrome/browser/chromeos/printer_detector/printer_detector.h" |
| 9 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" | |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 12 #include "extensions/browser/extensions_browser_client.h" | |
| 13 | 13 |
| 14 namespace chromeos { | 14 namespace chromeos { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 static base::LazyInstance<PrinterDetectorFactory>::DestructorAtExit g_factory = | 18 static base::LazyInstance<PrinterDetectorFactory>::DestructorAtExit g_factory = |
| 19 LAZY_INSTANCE_INITIALIZER; | 19 LAZY_INSTANCE_INITIALIZER; |
| 20 | 20 |
| 21 } // namespace | 21 } // namespace |
| 22 | 22 |
| 23 // static | 23 // static |
| 24 PrinterDetectorFactory* PrinterDetectorFactory::GetInstance() { | 24 PrinterDetectorFactory* PrinterDetectorFactory::GetInstance() { |
| 25 return g_factory.Pointer(); | 25 return g_factory.Pointer(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 PrinterDetector* PrinterDetectorFactory::Get(content::BrowserContext* context) { | 28 PrinterDetector* PrinterDetectorFactory::Get(content::BrowserContext* context) { |
| 29 return static_cast<PrinterDetector*>( | 29 return static_cast<PrinterDetector*>( |
| 30 GetServiceForBrowserContext(context, false)); | 30 GetServiceForBrowserContext(context, false)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 PrinterDetectorFactory::PrinterDetectorFactory() | 33 PrinterDetectorFactory::PrinterDetectorFactory() |
| 34 : BrowserContextKeyedServiceFactory( | 34 : BrowserContextKeyedServiceFactory( |
| 35 "PrinterDetectorFactory", | 35 "PrinterDetectorFactory", |
| 36 BrowserContextDependencyManager::GetInstance()) { | 36 BrowserContextDependencyManager::GetInstance()) { |
| 37 DependsOn( | 37 DependsOn(PrintersManagerFactory::GetInstance()); |
| 38 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | |
|
tbarzic
2017/03/15 18:43:43
doesn't legacy printer detector still depend on ex
Carlson
2017/03/15 23:06:16
Ugh, got tunnel vision there for a minute, thanks
| |
| 39 } | 38 } |
| 40 | 39 |
| 41 PrinterDetectorFactory::~PrinterDetectorFactory() { | 40 PrinterDetectorFactory::~PrinterDetectorFactory() { |
| 42 } | 41 } |
| 43 | 42 |
| 44 KeyedService* PrinterDetectorFactory::BuildServiceInstanceFor( | 43 KeyedService* PrinterDetectorFactory::BuildServiceInstanceFor( |
| 45 content::BrowserContext* context) const { | 44 content::BrowserContext* context) const { |
| 46 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 45 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 47 ::switches::kEnableNativeCups)) { | 46 ::switches::kEnableNativeCups)) { |
| 48 return PrinterDetector::CreateCups(Profile::FromBrowserContext(context)) | 47 return PrinterDetector::CreateCups(Profile::FromBrowserContext(context)) |
| 49 .release(); | 48 .release(); |
| 50 } else { | 49 } else { |
| 51 return PrinterDetector::CreateLegacy(Profile::FromBrowserContext(context)) | 50 return PrinterDetector::CreateLegacy(Profile::FromBrowserContext(context)) |
| 52 .release(); | 51 .release(); |
| 53 } | 52 } |
| 54 } | 53 } |
| 55 | 54 |
| 56 bool PrinterDetectorFactory::ServiceIsCreatedWithBrowserContext() const { | 55 bool PrinterDetectorFactory::ServiceIsCreatedWithBrowserContext() const { |
| 57 return true; | 56 return true; |
| 58 } | 57 } |
| 59 | 58 |
| 60 bool PrinterDetectorFactory::ServiceIsNULLWhileTesting() const { | 59 bool PrinterDetectorFactory::ServiceIsNULLWhileTesting() const { |
| 61 return true; | 60 return true; |
| 62 } | 61 } |
| 63 | 62 |
| 64 } // namespace chromeos | 63 } // namespace chromeos |
| OLD | NEW |