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

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

Issue 10399087: Converting BookmarkModel and HistoryService to ProfileKeyedServices. This just performs the initial… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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/history_service_factory.h"
6
7 #include "chrome/browser/bookmarks/bookmark_model.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/history/history.h"
10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile_dependency_manager.h"
12 #include "chrome/common/pref_names.h"
13
14 // static
15 scoped_refptr<HistoryService> HistoryServiceFactory::GetForProfile(
16 Profile* profile, Profile::ServiceAccessType sat) {
17 // If saving history is disabled, only allow explicit access.
18 if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
19 sat != Profile::EXPLICIT_ACCESS)
20 return NULL;
21
22 return static_cast<HistoryService*>(
23 GetInstance()->GetServiceForProfile(profile, true).get());
24 }
25
26 // static
27 scoped_refptr<HistoryService>
28 HistoryServiceFactory::GetForProfileIfExists(Profile* profile) {
29 return static_cast<HistoryService*>(
30 GetInstance()->GetServiceForProfile(profile, false).get());
31 }
32
33 // static
34 HistoryServiceFactory* HistoryServiceFactory::GetInstance() {
35 return Singleton<HistoryServiceFactory>::get();
36 }
37
38 // static
39 void HistoryServiceFactory::ShutdownForProfile(Profile* profile) {
40 HistoryServiceFactory* factory = GetInstance();
41 factory->ProfileDestroyed(profile);
42 }
43
44 HistoryServiceFactory::HistoryServiceFactory()
45 : RefcountedProfileKeyedServiceFactory(
46 "HistoryService", ProfileDependencyManager::GetInstance()) {
47 DependsOn(BookmarkModelFactory::GetInstance());
48 }
49
50 HistoryServiceFactory::~HistoryServiceFactory() {
51 }
52
53 scoped_refptr<RefcountedProfileKeyedService>
54 HistoryServiceFactory::BuildServiceInstanceFor(Profile* profile) const {
55 scoped_refptr<HistoryService> history_service(
56 new HistoryService(profile));
57 if (!history_service->Init(profile->GetPath(),
58 BookmarkModelFactory::GetForProfile(profile))) {
59 return NULL;
60 }
61 return history_service;
62 }
63
64 bool HistoryServiceFactory::ServiceRedirectedInIncognito() {
65 return true;
66 }
67
68 bool HistoryServiceFactory::ServiceIsNULLWhileTesting() {
69 return true;
70 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history_service_factory.h ('k') | chrome/browser/history/in_memory_url_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698