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

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

Issue 10701043: Make ShortcutsBackend a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
Property Changes:
Added: svn:eol-style
+ LF
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 "chrome/browser/history/shortcuts_backend.h"
8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile_dependency_manager.h"
10 #include "chrome/common/pref_names.h"
11
12 using history::ShortcutsBackend;
13
14 // static
15 scoped_refptr<ShortcutsBackend> ShortcutsBackendFactory::GetForProfile(
16 Profile* profile) {
17 return static_cast<ShortcutsBackend*>(
18 GetInstance()->GetServiceForProfile(profile, true).get());
19 }
20
21 // static
22 scoped_refptr<ShortcutsBackend> ShortcutsBackendFactory::GetForProfileIfExists(
23 Profile* profile) {
24 return static_cast<ShortcutsBackend*>(
25 GetInstance()->GetServiceForProfile(profile, false).get());
26 }
27
28 // static
29 ShortcutsBackendFactory* ShortcutsBackendFactory::GetInstance() {
30 return Singleton<ShortcutsBackendFactory>::get();
31 }
32
33 // static
34 scoped_refptr<RefcountedProfileKeyedService>
35 ShortcutsBackendFactory::GetForProfileForTesting(Profile* profile) {
36 scoped_refptr<history::ShortcutsBackend> backend(
37 new ShortcutsBackend(profile, false));
38 if (backend->Init())
39 return backend;
40 return NULL;
41 }
42
43 scoped_refptr<RefcountedProfileKeyedService>
44 ShortcutsBackendFactory::GetForProfileNoDatabaseForTesting(Profile* profile) {
45 scoped_refptr<history::ShortcutsBackend> backend(
46 new ShortcutsBackend(profile, true));
47 if (backend->Init())
48 return backend;
49 return NULL;
50 }
51
52 ShortcutsBackendFactory::ShortcutsBackendFactory()
53 : RefcountedProfileKeyedServiceFactory(
54 "ShortcutsBackend",
55 ProfileDependencyManager::GetInstance()) {
56 }
57
58 ShortcutsBackendFactory::~ShortcutsBackendFactory() {}
59
60 scoped_refptr<RefcountedProfileKeyedService>
61 ShortcutsBackendFactory::BuildServiceInstanceFor(Profile* profile) const {
62 scoped_refptr<history::ShortcutsBackend> backend(
63 new ShortcutsBackend(profile, false));
64 if (backend->Init())
65 return backend;
66 return NULL;
67 }
68
69 bool ShortcutsBackendFactory::ServiceIsNULLWhileTesting() {
70 return true;
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698