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