| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/chrome_history_client_factory.h" | 5 #include "chrome/browser/history/chrome_history_client_factory.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 9 #include "chrome/browser/history/chrome_history_client.h" | 9 #include "chrome/browser/history/chrome_history_client.h" |
| 10 #include "chrome/browser/profiles/incognito_helpers.h" | 10 #include "chrome/browser/profiles/incognito_helpers.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 ChromeHistoryClient* ChromeHistoryClientFactory::GetForProfile( | 15 history::HistoryClient* ChromeHistoryClientFactory::GetForProfile( |
| 16 Profile* profile) { | 16 Profile* profile) { |
| 17 return static_cast<ChromeHistoryClient*>( | 17 return static_cast<history::HistoryClient*>( |
| 18 GetInstance()->GetServiceForBrowserContext(profile, true)); | 18 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 // static | 21 // static |
| 22 ChromeHistoryClient* ChromeHistoryClientFactory::GetForProfileWithoutCreating( | |
| 23 Profile* profile) { | |
| 24 return static_cast<ChromeHistoryClient*>( | |
| 25 GetInstance()->GetServiceForBrowserContext(profile, false)); | |
| 26 } | |
| 27 | |
| 28 // static | |
| 29 ChromeHistoryClientFactory* ChromeHistoryClientFactory::GetInstance() { | 22 ChromeHistoryClientFactory* ChromeHistoryClientFactory::GetInstance() { |
| 30 return Singleton<ChromeHistoryClientFactory>::get(); | 23 return Singleton<ChromeHistoryClientFactory>::get(); |
| 31 } | 24 } |
| 32 | 25 |
| 33 ChromeHistoryClientFactory::ChromeHistoryClientFactory() | 26 ChromeHistoryClientFactory::ChromeHistoryClientFactory() |
| 34 : BrowserContextKeyedServiceFactory( | 27 : BrowserContextKeyedServiceFactory( |
| 35 "ChromeHistoryClient", | 28 "ChromeHistoryClient", |
| 36 BrowserContextDependencyManager::GetInstance()) { | 29 BrowserContextDependencyManager::GetInstance()) { |
| 37 DependsOn(BookmarkModelFactory::GetInstance()); | 30 DependsOn(BookmarkModelFactory::GetInstance()); |
| 38 } | 31 } |
| 39 | 32 |
| 40 ChromeHistoryClientFactory::~ChromeHistoryClientFactory() { | 33 ChromeHistoryClientFactory::~ChromeHistoryClientFactory() { |
| 41 } | 34 } |
| 42 | 35 |
| 43 KeyedService* ChromeHistoryClientFactory::BuildServiceInstanceFor( | 36 KeyedService* ChromeHistoryClientFactory::BuildServiceInstanceFor( |
| 44 content::BrowserContext* context) const { | 37 content::BrowserContext* context) const { |
| 45 Profile* profile = static_cast<Profile*>(context); | 38 Profile* profile = Profile::FromBrowserContext(context); |
| 46 return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile)); | 39 return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile)); |
| 47 } | 40 } |
| 48 | 41 |
| 49 content::BrowserContext* ChromeHistoryClientFactory::GetBrowserContextToUse( | 42 content::BrowserContext* ChromeHistoryClientFactory::GetBrowserContextToUse( |
| 50 content::BrowserContext* context) const { | 43 content::BrowserContext* context) const { |
| 51 return chrome::GetBrowserContextRedirectedInIncognito(context); | 44 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 52 } | 45 } |
| 53 | 46 |
| 54 bool ChromeHistoryClientFactory::ServiceIsNULLWhileTesting() const { | 47 bool ChromeHistoryClientFactory::ServiceIsNULLWhileTesting() const { |
| 55 return true; | 48 return true; |
| 56 } | 49 } |
| OLD | NEW |