Componentize component_updater: Copy over test data with executable bit.
[chromium-blink-merge.git] / chrome / browser / autocomplete / shortcuts_backend_factory.cc
blob57534465bc3d3ecd8da5900226509e64bde4c50d
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/profiles/profile.h"
10 #include "chrome/common/pref_names.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<RefcountedBrowserContextKeyedService>
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<RefcountedBrowserContextKeyedService>
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()) {
60 ShortcutsBackendFactory::~ShortcutsBackendFactory() {}
62 scoped_refptr<RefcountedBrowserContextKeyedService>
63 ShortcutsBackendFactory::BuildServiceInstanceFor(
64 content::BrowserContext* profile) const {
65 scoped_refptr<ShortcutsBackend> backend(
66 new ShortcutsBackend(static_cast<Profile*>(profile), false));
67 if (backend->Init())
68 return backend;
69 return NULL;
72 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() const {
73 return true;