1 // Copyright 2014 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.
5 #include "chrome/browser/history/chrome_history_client_factory.h"
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/history/chrome_history_client.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 ChromeHistoryClient* ChromeHistoryClientFactory::GetForProfile(
17 return static_cast<ChromeHistoryClient*>(
18 GetInstance()->GetServiceForBrowserContext(profile, true));
22 ChromeHistoryClientFactory* ChromeHistoryClientFactory::GetInstance() {
23 return Singleton<ChromeHistoryClientFactory>::get();
26 ChromeHistoryClientFactory::ChromeHistoryClientFactory()
27 : BrowserContextKeyedServiceFactory(
28 "ChromeHistoryClient",
29 BrowserContextDependencyManager::GetInstance()) {
30 DependsOn(BookmarkModelFactory::GetInstance());
33 ChromeHistoryClientFactory::~ChromeHistoryClientFactory() {
36 KeyedService* ChromeHistoryClientFactory::BuildServiceInstanceFor(
37 content::BrowserContext* context) const {
38 Profile* profile = static_cast<Profile*>(context);
39 return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile),
41 profile->GetTopSites());
44 content::BrowserContext* ChromeHistoryClientFactory::GetBrowserContextToUse(
45 content::BrowserContext* context) const {
46 return chrome::GetBrowserContextRedirectedInIncognito(context);
49 bool ChromeHistoryClientFactory::ServiceIsNULLWhileTesting() const {