Revert of Remove OneClickSigninHelper since it is no longer used. (patchset #5 id...
[chromium-blink-merge.git] / chrome / browser / autocomplete / shortcuts_backend_factory.cc
blob3b8bdfabae2b7773173d26b6927519669b953bb3
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.
5 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/autocomplete/shortcuts_backend.h"
9 #include "chrome/browser/history/history_service_factory.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 // static
14 scoped_refptr<ShortcutsBackend> ShortcutsBackendFactory::GetForProfile(
15 Profile* profile) {
16 return static_cast<ShortcutsBackend*>(
17 GetInstance()->GetServiceForBrowserContext(profile, true).get());
20 // static
21 scoped_refptr<ShortcutsBackend> ShortcutsBackendFactory::GetForProfileIfExists(
22 Profile* profile) {
23 return static_cast<ShortcutsBackend*>(
24 GetInstance()->GetServiceForBrowserContext(profile, false).get());
27 // static
28 ShortcutsBackendFactory* ShortcutsBackendFactory::GetInstance() {
29 return Singleton<ShortcutsBackendFactory>::get();
32 // static
33 scoped_refptr<RefcountedKeyedService>
34 ShortcutsBackendFactory::BuildProfileForTesting(
35 content::BrowserContext* profile) {
36 scoped_refptr<ShortcutsBackend> backend(
37 new ShortcutsBackend(static_cast<Profile*>(profile), false));
38 if (backend->Init())
39 return backend;
40 return NULL;
43 // static
44 scoped_refptr<RefcountedKeyedService>
45 ShortcutsBackendFactory::BuildProfileNoDatabaseForTesting(
46 content::BrowserContext* profile) {
47 scoped_refptr<ShortcutsBackend> backend(
48 new ShortcutsBackend(static_cast<Profile*>(profile), true));
49 if (backend->Init())
50 return backend;
51 return NULL;
54 ShortcutsBackendFactory::ShortcutsBackendFactory()
55 : RefcountedBrowserContextKeyedServiceFactory(
56 "ShortcutsBackend",
57 BrowserContextDependencyManager::GetInstance()) {
58 DependsOn(HistoryServiceFactory::GetInstance());
61 ShortcutsBackendFactory::~ShortcutsBackendFactory() {}
63 scoped_refptr<RefcountedKeyedService>
64 ShortcutsBackendFactory::BuildServiceInstanceFor(
65 content::BrowserContext* profile) const {
66 scoped_refptr<ShortcutsBackend> backend(
67 new ShortcutsBackend(static_cast<Profile*>(profile), false));
68 if (backend->Init())
69 return backend;
70 return NULL;
73 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() const {
74 return true;