Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(989)

Side by Side Diff: chrome/browser/history/shortcuts_backend_factory.cc

Issue 200493006: Move the ShortcutsBackend from history to autocomplete so that it can fully (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698