OLD | NEW |
(Empty) | |
| 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/history_client_factory.h" |
| 6 |
| 7 #include "chrome/browser/profiles/incognito_helpers.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "components/history/core/browser/history_client.h" |
| 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 11 |
| 12 using history::HistoryClient; |
| 13 |
| 14 // static |
| 15 HistoryClient* HistoryClientFactory::GetForProfile(Profile* profile) { |
| 16 return static_cast<history::HistoryClient*>( |
| 17 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 18 } |
| 19 |
| 20 // static |
| 21 HistoryClient* HistoryClientFactory::GetForProfileIfExists(Profile* profile) { |
| 22 return static_cast<history::HistoryClient*>( |
| 23 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 24 } |
| 25 |
| 26 // static |
| 27 HistoryClientFactory* HistoryClientFactory::GetInstance() { |
| 28 return Singleton<HistoryClientFactory>::get(); |
| 29 } |
| 30 |
| 31 HistoryClientFactory::HistoryClientFactory() |
| 32 : BrowserContextKeyedServiceFactory( |
| 33 "HistoryClient", |
| 34 BrowserContextDependencyManager::GetInstance()) { |
| 35 } |
| 36 |
| 37 HistoryClientFactory::~HistoryClientFactory() { |
| 38 } |
| 39 |
| 40 KeyedService* HistoryClientFactory::BuildServiceInstanceFor( |
| 41 content::BrowserContext* context) const { |
| 42 return new HistoryClient(); |
| 43 } |
| 44 |
| 45 content::BrowserContext* HistoryClientFactory::GetBrowserContextToUse( |
| 46 content::BrowserContext* context) const { |
| 47 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 48 } |
| 49 |
| 50 bool HistoryClientFactory::ServiceIsNULLWhileTesting() const { |
| 51 return true; |
| 52 } |
OLD | NEW |