blob: ca809b04611298541079b3a5af054f9989141ade (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/common/pref_names.h"
// static
scoped_refptr<HistoryService> HistoryServiceFactory::GetForProfile(
Profile* profile, Profile::ServiceAccessType sat) {
// If saving history is disabled, only allow explicit access.
if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
sat != Profile::EXPLICIT_ACCESS)
return NULL;
return static_cast<HistoryService*>(
GetInstance()->GetServiceForProfile(profile, true).get());
}
// static
scoped_refptr<HistoryService>
HistoryServiceFactory::GetForProfileIfExists(Profile* profile) {
return static_cast<HistoryService*>(
GetInstance()->GetServiceForProfile(profile, false).get());
}
// static
HistoryServiceFactory* HistoryServiceFactory::GetInstance() {
return Singleton<HistoryServiceFactory>::get();
}
// static
void HistoryServiceFactory::ShutdownForProfile(Profile* profile) {
HistoryServiceFactory* factory = GetInstance();
factory->ProfileDestroyed(profile);
}
HistoryServiceFactory::HistoryServiceFactory()
: RefcountedProfileKeyedServiceFactory(
"HistoryService", ProfileDependencyManager::GetInstance()) {
DependsOn(BookmarkModelFactory::GetInstance());
}
HistoryServiceFactory::~HistoryServiceFactory() {
}
scoped_refptr<RefcountedProfileKeyedService>
HistoryServiceFactory::BuildServiceInstanceFor(Profile* profile) const {
scoped_refptr<HistoryService> history_service(
new HistoryService(profile));
if (!history_service->Init(profile->GetPath(),
BookmarkModelFactory::GetForProfile(profile))) {
return NULL;
}
return history_service;
}
bool HistoryServiceFactory::ServiceRedirectedInIncognito() {
return true;
}
bool HistoryServiceFactory::ServiceIsNULLWhileTesting() {
return true;
}
|