Chromium Code Reviews| Index: chrome/test/base/testing_profile.cc |
| diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc |
| index f2d7420ad36aa020c6bfe58846dbab9a7c156fbd..024260db94ee6aefe3ecefd427388834215a468f 100644 |
| --- a/chrome/test/base/testing_profile.cc |
| +++ b/chrome/test/base/testing_profile.cc |
| @@ -29,6 +29,8 @@ |
| #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
| #include "chrome/browser/geolocation/chrome_geolocation_permission_context_factory.h" |
| #include "chrome/browser/guest_view/guest_view_manager.h" |
| +#include "chrome/browser/history/chrome_history_client.h" |
| +#include "chrome/browser/history/chrome_history_client_factory.h" |
| #include "chrome/browser/history/history_backend.h" |
| #include "chrome/browser/history/history_db_task.h" |
| #include "chrome/browser/history/history_service.h" |
| @@ -425,8 +427,10 @@ void TestingProfile::CreateFaviconService() { |
| this, BuildFaviconService); |
| } |
| -static KeyedService* BuildHistoryService(content::BrowserContext* profile) { |
| - return new HistoryService(NULL, static_cast<Profile*>(profile)); |
| +static KeyedService* BuildHistoryService(content::BrowserContext* context) { |
| + Profile* profile = static_cast<Profile*>(context); |
| + return new HistoryService( |
| + ChromeHistoryClientFactory::GetForProfile(profile), profile); |
| } |
| bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
| @@ -441,9 +445,7 @@ bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
| HistoryService* history_service = static_cast<HistoryService*>( |
| HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| this, BuildHistoryService)); |
| - if (!history_service->Init(this->GetPath(), |
| - BookmarkModelFactory::GetForProfile(this), |
| - no_db)) { |
| + if (!history_service->Init(this->GetPath(), no_db)) { |
| HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); |
| } |
| // Disable WebHistoryService by default, since it makes network requests. |
| @@ -507,24 +509,23 @@ static KeyedService* BuildBookmarkModel(content::BrowserContext* context) { |
| return bookmark_client; |
| } |
| +static KeyedService* BuildChromeHistoryClient( |
| + content::BrowserContext* context) { |
| + Profile* profile = static_cast<Profile*>(context); |
| + return new ChromeHistoryClient( |
| + BookmarkModelFactory::GetForProfile(profile)); |
|
blundell
2014/06/02 13:02:36
Is this needed? i.e., is it different from what Ch
sdefresne
2014/06/03 10:42:04
Yes this is required, since ChromeHistoryClientFac
|
| +} |
| + |
| void TestingProfile::CreateBookmarkModel(bool delete_file) { |
| if (delete_file) { |
| base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); |
| base::DeleteFile(path, false); |
| } |
| // This will create a bookmark model. |
| - BookmarkModel* bookmark_service = |
| - static_cast<ChromeBookmarkClient*>( |
| - BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( |
| - this, BuildBookmarkModel))->model(); |
| - |
| - HistoryService* history_service = |
| - HistoryServiceFactory::GetForProfileWithoutCreating(this); |
| - if (history_service) { |
| - history_service->history_backend_->bookmark_service_ = bookmark_service; |
| - history_service->history_backend_->expirer_.bookmark_service_ = |
| - bookmark_service; |
| - } |
| + ChromeHistoryClientFactory::GetInstance()->SetTestingFactory( |
| + this, BuildChromeHistoryClient); |
| + BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( |
| + this, BuildBookmarkModel); |
| } |
| static KeyedService* BuildWebDataService(content::BrowserContext* profile) { |