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

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 1198963014: Change ownership of BookmarkClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_managed_and_supervised_nodes
Patch Set: Rebase Created 5 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 unified diff | Download patch
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | components/bookmarks/browser/bookmark_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/prefs/testing_pref_store.h" 12 #include "base/prefs/testing_pref_store.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
18 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" 18 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 20 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
21 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
22 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
24 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" 23 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h"
25 #include "chrome/browser/favicon/fallback_icon_service_factory.h" 24 #include "chrome/browser/favicon/fallback_icon_service_factory.h"
26 #include "chrome/browser/favicon/favicon_service_factory.h" 25 #include "chrome/browser/favicon/favicon_service_factory.h"
27 #include "chrome/browser/history/chrome_history_client.h" 26 #include "chrome/browser/history/chrome_history_client.h"
28 #include "chrome/browser/history/history_service_factory.h" 27 #include "chrome/browser/history/history_service_factory.h"
29 #include "chrome/browser/history/web_history_service_factory.h" 28 #include "chrome/browser/history/web_history_service_factory.h"
30 #include "chrome/browser/net/pref_proxy_config_tracker.h" 29 #include "chrome/browser/net/pref_proxy_config_tracker.h"
31 #include "chrome/browser/net/proxy_service_factory.h" 30 #include "chrome/browser/net/proxy_service_factory.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 HistoryServiceFactory::GetForProfile(profile, 202 HistoryServiceFactory::GetForProfile(profile,
204 ServiceAccessType::IMPLICIT_ACCESS), 203 ServiceAccessType::IMPLICIT_ACCESS),
205 content::BrowserThread::GetBlockingPool(), profile->GetPath(), 204 content::BrowserThread::GetBlockingPool(), profile->GetPath(),
206 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), 205 profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
207 SchemeSet())); 206 SchemeSet()));
208 in_memory_url_index->Init(); 207 in_memory_url_index->Init();
209 return in_memory_url_index.Pass(); 208 return in_memory_url_index.Pass();
210 } 209 }
211 210
212 scoped_ptr<KeyedService> BuildBookmarkModel(content::BrowserContext* context) { 211 scoped_ptr<KeyedService> BuildBookmarkModel(content::BrowserContext* context) {
213 Profile* profile = static_cast<Profile*>(context); 212 Profile* profile = Profile::FromBrowserContext(context);
214 ChromeBookmarkClient* bookmark_client = 213 scoped_ptr<BookmarkModel> bookmark_model(
215 ChromeBookmarkClientFactory::GetForProfile(profile); 214 new BookmarkModel(make_scoped_ptr(new ChromeBookmarkClient(profile))));
216 scoped_ptr<BookmarkModel> bookmark_model(new BookmarkModel(bookmark_client));
217 bookmark_client->Init(bookmark_model.get());
218 bookmark_model->Load(profile->GetPrefs(), 215 bookmark_model->Load(profile->GetPrefs(),
219 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), 216 profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
220 profile->GetPath(), 217 profile->GetPath(),
221 profile->GetIOTaskRunner(), 218 profile->GetIOTaskRunner(),
222 content::BrowserThread::GetMessageLoopProxyForThread( 219 content::BrowserThread::GetMessageLoopProxyForThread(
223 content::BrowserThread::UI)); 220 content::BrowserThread::UI));
224 return bookmark_model.Pass(); 221 return bookmark_model.Pass();
225 } 222 }
226 223
227 scoped_ptr<KeyedService> BuildChromeBookmarkClient(
228 content::BrowserContext* context) {
229 return make_scoped_ptr(
230 new ChromeBookmarkClient(static_cast<Profile*>(context)));
231 }
232
233 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type, 224 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type,
234 sql::InitStatus status) { 225 sql::InitStatus status) {
235 NOTREACHED(); 226 NOTREACHED();
236 } 227 }
237 228
238 scoped_ptr<KeyedService> BuildWebDataService(content::BrowserContext* context) { 229 scoped_ptr<KeyedService> BuildWebDataService(content::BrowserContext* context) {
239 const base::FilePath& context_path = context->GetPath(); 230 const base::FilePath& context_path = context->GetPath();
240 return make_scoped_ptr(new WebDataServiceWrapper( 231 return make_scoped_ptr(new WebDataServiceWrapper(
241 context_path, g_browser_process->GetApplicationLocale(), 232 context_path, g_browser_process->GetApplicationLocale(),
242 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 233 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 base::ThreadTaskRunnerHandle::Get()->PostTask( 576 base::ThreadTaskRunnerHandle::Get()->PostTask(
586 FROM_HERE, base::MessageLoop::QuitClosure()); 577 FROM_HERE, base::MessageLoop::QuitClosure());
587 base::MessageLoop::current()->Run(); 578 base::MessageLoop::current()->Run();
588 } 579 }
589 580
590 void TestingProfile::CreateBookmarkModel(bool delete_file) { 581 void TestingProfile::CreateBookmarkModel(bool delete_file) {
591 if (delete_file) { 582 if (delete_file) {
592 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); 583 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName);
593 base::DeleteFile(path, false); 584 base::DeleteFile(path, false);
594 } 585 }
595 ChromeBookmarkClientFactory::GetInstance()->SetTestingFactory(
596 this, BuildChromeBookmarkClient);
597 // This creates the BookmarkModel. 586 // This creates the BookmarkModel.
598 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( 587 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
599 this, BuildBookmarkModel)); 588 this, BuildBookmarkModel));
600 } 589 }
601 590
602 void TestingProfile::CreateWebDataService() { 591 void TestingProfile::CreateWebDataService() {
603 WebDataServiceFactory::GetInstance()->SetTestingFactory( 592 WebDataServiceFactory::GetInstance()->SetTestingFactory(
604 this, BuildWebDataService); 593 this, BuildWebDataService);
605 } 594 }
606 595
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 #if defined(ENABLE_EXTENSIONS) 1053 #if defined(ENABLE_EXTENSIONS)
1065 extension_policy_, 1054 extension_policy_,
1066 #endif 1055 #endif
1067 pref_service_.Pass(), 1056 pref_service_.Pass(),
1068 original_profile, 1057 original_profile,
1069 guest_session_, 1058 guest_session_,
1070 supervised_user_id_, 1059 supervised_user_id_,
1071 policy_service_.Pass(), 1060 policy_service_.Pass(),
1072 testing_factories_); 1061 testing_factories_);
1073 } 1062 }
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | components/bookmarks/browser/bookmark_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698