OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/history/shortcuts_backend_factory.h" | 5 #include "chrome/browser/history/shortcuts_backend_factory.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/history/shortcuts_backend.h" | 8 #include "chrome/browser/history/shortcuts_backend.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
11 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 11 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
12 | 12 |
13 using history::ShortcutsBackend; | 13 using history::ShortcutsBackend; |
14 | 14 |
15 // static | 15 // static |
16 scoped_refptr<ShortcutsBackend> ShortcutsBackendFactory::GetForProfile( | 16 scoped_refptr<ShortcutsBackend> ShortcutsBackendFactory::GetForProfile( |
17 Profile* profile) { | 17 Profile* profile) { |
18 return static_cast<ShortcutsBackend*>( | 18 return static_cast<ShortcutsBackend*>( |
19 GetInstance()->GetServiceForProfile(profile, true).get()); | 19 GetInstance()->GetServiceForBrowserContext(profile, true).get()); |
20 } | 20 } |
21 | 21 |
22 // static | 22 // static |
23 scoped_refptr<ShortcutsBackend> ShortcutsBackendFactory::GetForProfileIfExists( | 23 scoped_refptr<ShortcutsBackend> ShortcutsBackendFactory::GetForProfileIfExists( |
24 Profile* profile) { | 24 Profile* profile) { |
25 return static_cast<ShortcutsBackend*>( | 25 return static_cast<ShortcutsBackend*>( |
26 GetInstance()->GetServiceForProfile(profile, false).get()); | 26 GetInstance()->GetServiceForBrowserContext(profile, false).get()); |
27 } | 27 } |
28 | 28 |
29 // static | 29 // static |
30 ShortcutsBackendFactory* ShortcutsBackendFactory::GetInstance() { | 30 ShortcutsBackendFactory* ShortcutsBackendFactory::GetInstance() { |
31 return Singleton<ShortcutsBackendFactory>::get(); | 31 return Singleton<ShortcutsBackendFactory>::get(); |
32 } | 32 } |
33 | 33 |
34 // static | 34 // static |
35 scoped_refptr<RefcountedProfileKeyedService> | 35 scoped_refptr<RefcountedBrowserContextKeyedService> |
36 ShortcutsBackendFactory::BuildProfileForTesting( | 36 ShortcutsBackendFactory::BuildProfileForTesting( |
37 content::BrowserContext* profile) { | 37 content::BrowserContext* profile) { |
38 scoped_refptr<history::ShortcutsBackend> backend( | 38 scoped_refptr<history::ShortcutsBackend> backend( |
39 new ShortcutsBackend(static_cast<Profile*>(profile), false)); | 39 new ShortcutsBackend(static_cast<Profile*>(profile), false)); |
40 if (backend->Init()) | 40 if (backend->Init()) |
41 return backend; | 41 return backend; |
42 return NULL; | 42 return NULL; |
43 } | 43 } |
44 | 44 |
45 // static | 45 // static |
46 scoped_refptr<RefcountedProfileKeyedService> | 46 scoped_refptr<RefcountedBrowserContextKeyedService> |
47 ShortcutsBackendFactory::BuildProfileNoDatabaseForTesting( | 47 ShortcutsBackendFactory::BuildProfileNoDatabaseForTesting( |
48 content::BrowserContext* profile) { | 48 content::BrowserContext* profile) { |
49 scoped_refptr<history::ShortcutsBackend> backend( | 49 scoped_refptr<history::ShortcutsBackend> backend( |
50 new ShortcutsBackend(static_cast<Profile*>(profile), true)); | 50 new ShortcutsBackend(static_cast<Profile*>(profile), true)); |
51 if (backend->Init()) | 51 if (backend->Init()) |
52 return backend; | 52 return backend; |
53 return NULL; | 53 return NULL; |
54 } | 54 } |
55 | 55 |
56 ShortcutsBackendFactory::ShortcutsBackendFactory() | 56 ShortcutsBackendFactory::ShortcutsBackendFactory() |
57 : RefcountedProfileKeyedServiceFactory( | 57 : RefcountedBrowserContextKeyedServiceFactory( |
58 "ShortcutsBackend", | 58 "ShortcutsBackend", |
59 ProfileDependencyManager::GetInstance()) { | 59 BrowserContextDependencyManager::GetInstance()) { |
60 } | 60 } |
61 | 61 |
62 ShortcutsBackendFactory::~ShortcutsBackendFactory() {} | 62 ShortcutsBackendFactory::~ShortcutsBackendFactory() {} |
63 | 63 |
64 scoped_refptr<RefcountedProfileKeyedService> | 64 scoped_refptr<RefcountedBrowserContextKeyedService> |
65 ShortcutsBackendFactory::BuildServiceInstanceFor( | 65 ShortcutsBackendFactory::BuildServiceInstanceFor( |
66 content::BrowserContext* profile) const { | 66 content::BrowserContext* profile) const { |
67 scoped_refptr<history::ShortcutsBackend> backend( | 67 scoped_refptr<history::ShortcutsBackend> backend( |
68 new ShortcutsBackend(static_cast<Profile*>(profile), false)); | 68 new ShortcutsBackend(static_cast<Profile*>(profile), false)); |
69 if (backend->Init()) | 69 if (backend->Init()) |
70 return backend; | 70 return backend; |
71 return NULL; | 71 return NULL; |
72 } | 72 } |
73 | 73 |
74 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() const { | 74 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() const { |
75 return true; | 75 return true; |
76 } | 76 } |
OLD | NEW |