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