| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/history_service_factory.h" | 5 #include "chrome/browser/history/history_service_factory.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 9 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
| 10 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" |
| 9 #include "chrome/browser/history/chrome_history_client.h" | 11 #include "chrome/browser/history/chrome_history_client.h" |
| 10 #include "chrome/browser/history/chrome_history_client_factory.h" | 12 #include "chrome/browser/history/chrome_history_client_factory.h" |
| 11 #include "chrome/browser/history/history_service.h" | 13 #include "chrome/browser/history/history_service.h" |
| 12 #include "chrome/browser/profiles/incognito_helpers.h" | 14 #include "chrome/browser/profiles/incognito_helpers.h" |
| 13 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 14 #include "components/bookmarks/browser/bookmark_model.h" | 16 #include "components/bookmarks/browser/bookmark_model.h" |
| 15 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 17 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 16 | 18 |
| 17 // static | 19 // static |
| 18 HistoryService* HistoryServiceFactory::GetForProfile( | 20 HistoryService* HistoryServiceFactory::GetForProfile( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // static | 56 // static |
| 55 void HistoryServiceFactory::ShutdownForProfile(Profile* profile) { | 57 void HistoryServiceFactory::ShutdownForProfile(Profile* profile) { |
| 56 HistoryServiceFactory* factory = GetInstance(); | 58 HistoryServiceFactory* factory = GetInstance(); |
| 57 factory->BrowserContextDestroyed(profile); | 59 factory->BrowserContextDestroyed(profile); |
| 58 } | 60 } |
| 59 | 61 |
| 60 HistoryServiceFactory::HistoryServiceFactory() | 62 HistoryServiceFactory::HistoryServiceFactory() |
| 61 : BrowserContextKeyedServiceFactory( | 63 : BrowserContextKeyedServiceFactory( |
| 62 "HistoryService", BrowserContextDependencyManager::GetInstance()) { | 64 "HistoryService", BrowserContextDependencyManager::GetInstance()) { |
| 63 DependsOn(ChromeHistoryClientFactory::GetInstance()); | 65 DependsOn(ChromeHistoryClientFactory::GetInstance()); |
| 66 DependsOn(ChromeBookmarkClientFactory::GetInstance()); |
| 64 } | 67 } |
| 65 | 68 |
| 66 HistoryServiceFactory::~HistoryServiceFactory() { | 69 HistoryServiceFactory::~HistoryServiceFactory() { |
| 67 } | 70 } |
| 68 | 71 |
| 69 KeyedService* HistoryServiceFactory::BuildServiceInstanceFor( | 72 KeyedService* HistoryServiceFactory::BuildServiceInstanceFor( |
| 70 content::BrowserContext* context) const { | 73 content::BrowserContext* context) const { |
| 71 Profile* profile = static_cast<Profile*>(context); | 74 Profile* profile = static_cast<Profile*>(context); |
| 72 scoped_ptr<HistoryService> history_service(new HistoryService( | 75 scoped_ptr<HistoryService> history_service(new HistoryService( |
| 73 ChromeHistoryClientFactory::GetForProfile(profile), profile)); | 76 ChromeHistoryClientFactory::GetForProfile(profile), profile)); |
| 74 if (!history_service->Init(profile->GetPath())) | 77 if (!history_service->Init(profile->GetPath())) |
| 75 return NULL; | 78 return NULL; |
| 79 ChromeBookmarkClientFactory::GetForProfile(profile) |
| 80 ->SetHistoryService(history_service.get()); |
| 76 return history_service.release(); | 81 return history_service.release(); |
| 77 } | 82 } |
| 78 | 83 |
| 79 content::BrowserContext* HistoryServiceFactory::GetBrowserContextToUse( | 84 content::BrowserContext* HistoryServiceFactory::GetBrowserContextToUse( |
| 80 content::BrowserContext* context) const { | 85 content::BrowserContext* context) const { |
| 81 return chrome::GetBrowserContextRedirectedInIncognito(context); | 86 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 82 } | 87 } |
| 83 | 88 |
| 84 bool HistoryServiceFactory::ServiceIsNULLWhileTesting() const { | 89 bool HistoryServiceFactory::ServiceIsNULLWhileTesting() const { |
| 85 return true; | 90 return true; |
| 86 } | 91 } |
| OLD | NEW |