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. 4 5#include "chrome/browser/history/chrome_history_client_factory.h" 6 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" 13 14// static 15ChromeHistoryClient* ChromeHistoryClientFactory::GetForProfile( 16 Profile* profile) { 17 return static_cast<ChromeHistoryClient*>( 18 GetInstance()->GetServiceForBrowserContext(profile, true)); 19} 20 21// static 22ChromeHistoryClientFactory* ChromeHistoryClientFactory::GetInstance() { 23 return Singleton<ChromeHistoryClientFactory>::get(); 24} 25 26ChromeHistoryClientFactory::ChromeHistoryClientFactory() 27 : BrowserContextKeyedServiceFactory( 28 "ChromeHistoryClient", 29 BrowserContextDependencyManager::GetInstance()) { 30 DependsOn(BookmarkModelFactory::GetInstance()); 31} 32 33ChromeHistoryClientFactory::~ChromeHistoryClientFactory() { 34} 35 36KeyedService* ChromeHistoryClientFactory::BuildServiceInstanceFor( 37 content::BrowserContext* context) const { 38 Profile* profile = static_cast<Profile*>(context); 39 return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile), 40 profile, 41 profile->GetTopSites()); 42} 43 44content::BrowserContext* ChromeHistoryClientFactory::GetBrowserContextToUse( 45 content::BrowserContext* context) const { 46 return chrome::GetBrowserContextRedirectedInIncognito(context); 47} 48 49bool ChromeHistoryClientFactory::ServiceIsNULLWhileTesting() const { 50 return true; 51} 52