OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/printing/printer_pref_manager_factory.h" | 5 #include "chrome/browser/chromeos/printing/printer_pref_manager_factory.h" |
6 | 6 |
7 #include "chrome/browser/profiles/incognito_helpers.h" | 7 #include "chrome/browser/profiles/incognito_helpers.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
11 | 11 |
12 namespace chromeos { | 12 namespace chromeos { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 base::LazyInstance<PrinterPrefManagerFactory> g_printer_pref_manager = | 16 base::LazyInstance<PrinterPrefManagerFactory> g_printer_pref_manager = |
17 LAZY_INSTANCE_INITIALIZER; | 17 LAZY_INSTANCE_INITIALIZER; |
18 | 18 |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 // static | 21 // static |
22 PrinterPrefManager* PrinterPrefManagerFactory::GetForBrowserContext( | 22 PrinterPrefManager* PrinterPrefManagerFactory::GetForBrowserContext( |
23 content::BrowserContext* context) { | 23 content::BrowserContext* context) { |
24 DCHECK(!context->IsOffTheRecord()); | |
25 return static_cast<PrinterPrefManager*>( | 24 return static_cast<PrinterPrefManager*>( |
26 GetInstance()->GetServiceForBrowserContext(context, true)); | 25 GetInstance()->GetServiceForBrowserContext(context, true)); |
27 } | 26 } |
28 | 27 |
29 // static | 28 // static |
30 PrinterPrefManagerFactory* PrinterPrefManagerFactory::GetInstance() { | 29 PrinterPrefManagerFactory* PrinterPrefManagerFactory::GetInstance() { |
31 return g_printer_pref_manager.Pointer(); | 30 return g_printer_pref_manager.Pointer(); |
32 } | 31 } |
33 | 32 |
34 content::BrowserContext* PrinterPrefManagerFactory::GetBrowserContextToUse( | 33 content::BrowserContext* PrinterPrefManagerFactory::GetBrowserContextToUse( |
35 content::BrowserContext* context) const { | 34 content::BrowserContext* context) const { |
36 return chrome::GetBrowserContextRedirectedInIncognito(context); | 35 return chrome::GetBrowserContextRedirectedInIncognito(context); |
37 } | 36 } |
38 | 37 |
39 PrinterPrefManagerFactory::PrinterPrefManagerFactory() | 38 PrinterPrefManagerFactory::PrinterPrefManagerFactory() |
40 : BrowserContextKeyedServiceFactory( | 39 : BrowserContextKeyedServiceFactory( |
41 "PrinterPrefManager", | 40 "PrinterPrefManager", |
42 BrowserContextDependencyManager::GetInstance()) {} | 41 BrowserContextDependencyManager::GetInstance()) {} |
43 | 42 |
44 PrinterPrefManagerFactory::~PrinterPrefManagerFactory() {} | 43 PrinterPrefManagerFactory::~PrinterPrefManagerFactory() {} |
45 | 44 |
46 PrinterPrefManager* PrinterPrefManagerFactory::BuildServiceInstanceFor( | 45 PrinterPrefManager* PrinterPrefManagerFactory::BuildServiceInstanceFor( |
47 content::BrowserContext* browser_context) const { | 46 content::BrowserContext* browser_context) const { |
48 Profile* profile = Profile::FromBrowserContext(browser_context); | 47 Profile* profile = Profile::FromBrowserContext(browser_context); |
49 return new PrinterPrefManager(profile); | 48 return new PrinterPrefManager(profile); |
50 } | 49 } |
51 | 50 |
52 } // namespace chromeos | 51 } // namespace chromeos |
OLD | NEW |