OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/app_list/app_list_prefs_factory.h" | 5 #include "chrome/browser/ui/app_list/app_list_prefs_factory.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/app_list/app_list_prefs.h" | 9 #include "chrome/browser/ui/app_list/app_list_prefs.h" |
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
12 #include "extensions/browser/extensions_browser_client.h" | 12 #include "extensions/browser/extensions_browser_client.h" |
13 | 13 |
14 namespace app_list { | 14 namespace app_list { |
15 | 15 |
16 // static | 16 // static |
17 AppListPrefs* AppListPrefsFactory::GetForBrowserContext( | 17 AppListPrefs* AppListPrefsFactory::GetForBrowserContext( |
18 content::BrowserContext* context) { | 18 content::BrowserContext* context) { |
19 return static_cast<AppListPrefs*>( | 19 return static_cast<AppListPrefs*>( |
20 GetInstance()->GetServiceForBrowserContext(context, true)); | 20 GetInstance()->GetServiceForBrowserContext(context, true)); |
21 } | 21 } |
22 | 22 |
23 // static | 23 // static |
24 AppListPrefsFactory* AppListPrefsFactory::GetInstance() { | 24 AppListPrefsFactory* AppListPrefsFactory::GetInstance() { |
25 return Singleton<AppListPrefsFactory>::get(); | 25 return base::Singleton<AppListPrefsFactory>::get(); |
26 } | 26 } |
27 | 27 |
28 void AppListPrefsFactory::SetInstanceForTesting( | 28 void AppListPrefsFactory::SetInstanceForTesting( |
29 content::BrowserContext* context, | 29 content::BrowserContext* context, |
30 scoped_ptr<AppListPrefs> prefs) { | 30 scoped_ptr<AppListPrefs> prefs) { |
31 Associate(context, prefs.Pass()); | 31 Associate(context, prefs.Pass()); |
32 } | 32 } |
33 | 33 |
34 AppListPrefsFactory::AppListPrefsFactory() | 34 AppListPrefsFactory::AppListPrefsFactory() |
35 : BrowserContextKeyedServiceFactory( | 35 : BrowserContextKeyedServiceFactory( |
36 "AppListPrefs", | 36 "AppListPrefs", |
37 BrowserContextDependencyManager::GetInstance()) { | 37 BrowserContextDependencyManager::GetInstance()) { |
38 } | 38 } |
39 | 39 |
40 AppListPrefsFactory::~AppListPrefsFactory() { | 40 AppListPrefsFactory::~AppListPrefsFactory() { |
41 } | 41 } |
42 | 42 |
43 KeyedService* AppListPrefsFactory::BuildServiceInstanceFor( | 43 KeyedService* AppListPrefsFactory::BuildServiceInstanceFor( |
44 content::BrowserContext* context) const { | 44 content::BrowserContext* context) const { |
45 return AppListPrefs::Create(Profile::FromBrowserContext(context)->GetPrefs()); | 45 return AppListPrefs::Create(Profile::FromBrowserContext(context)->GetPrefs()); |
46 } | 46 } |
47 | 47 |
48 content::BrowserContext* AppListPrefsFactory::GetBrowserContextToUse( | 48 content::BrowserContext* AppListPrefsFactory::GetBrowserContextToUse( |
49 content::BrowserContext* context) const { | 49 content::BrowserContext* context) const { |
50 return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext( | 50 return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext( |
51 context); | 51 context); |
52 } | 52 } |
53 | 53 |
54 } // namespace app_list | 54 } // namespace app_list |
OLD | NEW |