Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: chrome/test/base/testing_profile.cc

Issue 306293006: Introduce ChromeBookmarkClientFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@364865
Patch Set: Add missing dependency in components/policy/policy_browser.gypi Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | components/bookmarks.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/testing_profile.cc
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 62b8d78d750996a8cebe40c1815cbadb42918a88..a5869374ddd65f5673c02185105d60ecb23709bb 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/autocomplete/autocomplete_classifier.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/chrome_bookmark_client.h"
+#include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
@@ -501,15 +502,21 @@ void TestingProfile::DestroyTopSites() {
static KeyedService* BuildBookmarkModel(content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
ChromeBookmarkClient* bookmark_client =
- new ChromeBookmarkClient(profile, false);
- bookmark_client->model()->Load(
- profile->GetPrefs(),
- profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
- profile->GetPath(),
- profile->GetIOTaskRunner(),
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::UI));
- return bookmark_client;
+ ChromeBookmarkClientFactory::GetForProfile(profile);
+ BookmarkModel* bookmark_model = new BookmarkModel(bookmark_client, false);
+ bookmark_client->Init(bookmark_model);
+ bookmark_model->Load(profile->GetPrefs(),
+ profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
+ profile->GetPath(),
+ profile->GetIOTaskRunner(),
+ content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::UI));
+ return bookmark_model;
+}
+
+static KeyedService* BuildChromeBookmarkClient(
+ content::BrowserContext* context) {
+ return new ChromeBookmarkClient(static_cast<Profile*>(context));
}
static KeyedService* BuildChromeHistoryClient(
@@ -523,11 +530,13 @@ void TestingProfile::CreateBookmarkModel(bool delete_file) {
base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName);
base::DeleteFile(path, false);
}
- // This will create a bookmark model.
ChromeHistoryClientFactory::GetInstance()->SetTestingFactory(
this, BuildChromeHistoryClient);
- BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
- this, BuildBookmarkModel);
+ ChromeBookmarkClientFactory::GetInstance()->SetTestingFactory(
+ this, BuildChromeBookmarkClient);
+ // This creates the BookmarkModel.
+ ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
+ this, BuildBookmarkModel));
}
static KeyedService* BuildWebDataService(content::BrowserContext* profile) {
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | components/bookmarks.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698