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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/history_service_factory.cc
===================================================================
--- chrome/browser/history/history_service_factory.cc (revision 0)
+++ chrome/browser/history/history_service_factory.cc (revision 0)
@@ -0,0 +1,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;
+}
Property changes on: chrome\browser\history\history_service_factory.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698