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

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

Issue 849323002: Componentize HistoryDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android compilation Created 5 years, 11 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
« no previous file with comments | « chrome/browser/history/history_service.cc ('k') | chrome/browser/history/history_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/history/history_service_factory.h" 5 #include "chrome/browser/history/history_service_factory.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 9 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
10 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" 10 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
11 #include "chrome/browser/history/chrome_history_client.h" 11 #include "chrome/browser/history/chrome_history_client.h"
12 #include "chrome/browser/history/chrome_history_client_factory.h" 12 #include "chrome/browser/history/chrome_history_client_factory.h"
13 #include "chrome/browser/history/history_service.h" 13 #include "chrome/browser/history/history_service.h"
14 #include "chrome/browser/profiles/incognito_helpers.h" 14 #include "chrome/browser/profiles/incognito_helpers.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "components/bookmarks/browser/bookmark_model.h" 17 #include "components/bookmarks/browser/bookmark_model.h"
18 #include "components/history/content/browser/history_database_helper.h"
19 #include "components/history/core/browser/history_database_params.h"
18 #include "components/keyed_service/content/browser_context_dependency_manager.h" 20 #include "components/keyed_service/content/browser_context_dependency_manager.h"
19 #include "components/keyed_service/core/service_access_type.h" 21 #include "components/keyed_service/core/service_access_type.h"
20 22
21 // static 23 // static
22 HistoryService* HistoryServiceFactory::GetForProfile(Profile* profile, 24 HistoryService* HistoryServiceFactory::GetForProfile(Profile* profile,
23 ServiceAccessType sat) { 25 ServiceAccessType sat) {
24 // If saving history is disabled, only allow explicit access. 26 // If saving history is disabled, only allow explicit access.
25 if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) && 27 if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
26 sat != ServiceAccessType::EXPLICIT_ACCESS) 28 sat != ServiceAccessType::EXPLICIT_ACCESS)
27 return NULL; 29 return NULL;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 71 }
70 72
71 HistoryServiceFactory::~HistoryServiceFactory() { 73 HistoryServiceFactory::~HistoryServiceFactory() {
72 } 74 }
73 75
74 KeyedService* HistoryServiceFactory::BuildServiceInstanceFor( 76 KeyedService* HistoryServiceFactory::BuildServiceInstanceFor(
75 content::BrowserContext* context) const { 77 content::BrowserContext* context) const {
76 Profile* profile = static_cast<Profile*>(context); 78 Profile* profile = static_cast<Profile*>(context);
77 scoped_ptr<HistoryService> history_service(new HistoryService( 79 scoped_ptr<HistoryService> history_service(new HistoryService(
78 ChromeHistoryClientFactory::GetForProfile(profile), profile)); 80 ChromeHistoryClientFactory::GetForProfile(profile), profile));
79 if (!history_service->Init(profile->GetPath())) 81 if (!history_service->Init(
80 return NULL; 82 history::HistoryDatabaseParamsForPath(profile->GetPath()))) {
83 return nullptr;
84 }
81 ChromeBookmarkClientFactory::GetForProfile(profile) 85 ChromeBookmarkClientFactory::GetForProfile(profile)
82 ->SetHistoryService(history_service.get()); 86 ->SetHistoryService(history_service.get());
83 return history_service.release(); 87 return history_service.release();
84 } 88 }
85 89
86 content::BrowserContext* HistoryServiceFactory::GetBrowserContextToUse( 90 content::BrowserContext* HistoryServiceFactory::GetBrowserContextToUse(
87 content::BrowserContext* context) const { 91 content::BrowserContext* context) const {
88 return chrome::GetBrowserContextRedirectedInIncognito(context); 92 return chrome::GetBrowserContextRedirectedInIncognito(context);
89 } 93 }
90 94
91 bool HistoryServiceFactory::ServiceIsNULLWhileTesting() const { 95 bool HistoryServiceFactory::ServiceIsNULLWhileTesting() const {
92 return true; 96 return true;
93 } 97 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history_service.cc ('k') | chrome/browser/history/history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698