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

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

Issue 1233673002: Fix componentization of chrome/browser/bookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix "gn check" and compilation on Mac Created 5 years, 5 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_tests_unit.gypi ('k') | components/bookmarks.gypi » ('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/in_memory_url_index_factory.h" 17 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
19 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 19 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
20 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" 20 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
21 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" 24 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h"
24 #include "chrome/browser/favicon/fallback_icon_service_factory.h" 25 #include "chrome/browser/favicon/fallback_icon_service_factory.h"
25 #include "chrome/browser/favicon/favicon_service_factory.h" 26 #include "chrome/browser/favicon/favicon_service_factory.h"
26 #include "chrome/browser/history/chrome_history_client.h" 27 #include "chrome/browser/history/chrome_history_client.h"
27 #include "chrome/browser/history/history_service_factory.h" 28 #include "chrome/browser/history/history_service_factory.h"
28 #include "chrome/browser/history/web_history_service_factory.h" 29 #include "chrome/browser/history/web_history_service_factory.h"
29 #include "chrome/browser/net/pref_proxy_config_tracker.h" 30 #include "chrome/browser/net/pref_proxy_config_tracker.h"
30 #include "chrome/browser/net/proxy_service_factory.h" 31 #include "chrome/browser/net/proxy_service_factory.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 HistoryServiceFactory::GetForProfile(profile, 204 HistoryServiceFactory::GetForProfile(profile,
204 ServiceAccessType::IMPLICIT_ACCESS), 205 ServiceAccessType::IMPLICIT_ACCESS),
205 content::BrowserThread::GetBlockingPool(), profile->GetPath(), 206 content::BrowserThread::GetBlockingPool(), profile->GetPath(),
206 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), 207 profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
207 SchemeSet())); 208 SchemeSet()));
208 in_memory_url_index->Init(); 209 in_memory_url_index->Init();
209 return in_memory_url_index.Pass(); 210 return in_memory_url_index.Pass();
210 } 211 }
211 212
212 scoped_ptr<KeyedService> BuildBookmarkModel(content::BrowserContext* context) { 213 scoped_ptr<KeyedService> BuildBookmarkModel(content::BrowserContext* context) {
213 Profile* profile = static_cast<Profile*>(context); 214 Profile* profile = Profile::FromBrowserContext(context);
214 ChromeBookmarkClient* bookmark_client = 215 ChromeBookmarkClient* bookmark_client =
215 ChromeBookmarkClientFactory::GetForProfile(profile); 216 ChromeBookmarkClientFactory::GetForProfile(profile);
216 scoped_ptr<BookmarkModel> bookmark_model(new BookmarkModel(bookmark_client)); 217 scoped_ptr<BookmarkModel> bookmark_model(new BookmarkModel(bookmark_client));
217 bookmark_client->Init(bookmark_model.get()); 218 bookmark_client->Init(bookmark_model.get());
218 bookmark_model->Load(profile->GetPrefs(), 219 bookmark_model->Load(profile->GetPrefs(),
219 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), 220 profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
220 profile->GetPath(), 221 profile->GetPath(),
221 profile->GetIOTaskRunner(), 222 profile->GetIOTaskRunner(),
222 content::BrowserThread::GetMessageLoopProxyForThread( 223 content::BrowserThread::GetMessageLoopProxyForThread(
223 content::BrowserThread::UI)); 224 content::BrowserThread::UI));
224 return bookmark_model.Pass(); 225 return bookmark_model.Pass();
225 } 226 }
226 227
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, 228 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type,
234 sql::InitStatus status) { 229 sql::InitStatus status) {
235 NOTREACHED(); 230 NOTREACHED();
236 } 231 }
237 232
238 scoped_ptr<KeyedService> BuildWebDataService(content::BrowserContext* context) { 233 scoped_ptr<KeyedService> BuildWebDataService(content::BrowserContext* context) {
239 const base::FilePath& context_path = context->GetPath(); 234 const base::FilePath& context_path = context->GetPath();
240 return make_scoped_ptr(new WebDataServiceWrapper( 235 return make_scoped_ptr(new WebDataServiceWrapper(
241 context_path, g_browser_process->GetApplicationLocale(), 236 context_path, g_browser_process->GetApplicationLocale(),
242 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 237 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 base::ThreadTaskRunnerHandle::Get()->PostTask( 580 base::ThreadTaskRunnerHandle::Get()->PostTask(
586 FROM_HERE, base::MessageLoop::QuitClosure()); 581 FROM_HERE, base::MessageLoop::QuitClosure());
587 base::MessageLoop::current()->Run(); 582 base::MessageLoop::current()->Run();
588 } 583 }
589 584
590 void TestingProfile::CreateBookmarkModel(bool delete_file) { 585 void TestingProfile::CreateBookmarkModel(bool delete_file) {
591 if (delete_file) { 586 if (delete_file) {
592 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); 587 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName);
593 base::DeleteFile(path, false); 588 base::DeleteFile(path, false);
594 } 589 }
590 ManagedBookmarkServiceFactory::GetInstance()->SetTestingFactory(
591 this, ManagedBookmarkServiceFactory::GetDefaultFactory());
595 ChromeBookmarkClientFactory::GetInstance()->SetTestingFactory( 592 ChromeBookmarkClientFactory::GetInstance()->SetTestingFactory(
596 this, BuildChromeBookmarkClient); 593 this, ChromeBookmarkClientFactory::GetDefaultFactory());
597 // This creates the BookmarkModel. 594 // This creates the BookmarkModel.
598 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( 595 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
599 this, BuildBookmarkModel)); 596 this, BuildBookmarkModel));
600 } 597 }
601 598
602 void TestingProfile::CreateWebDataService() { 599 void TestingProfile::CreateWebDataService() {
603 WebDataServiceFactory::GetInstance()->SetTestingFactory( 600 WebDataServiceFactory::GetInstance()->SetTestingFactory(
604 this, BuildWebDataService); 601 this, BuildWebDataService);
605 } 602 }
606 603
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 #if defined(ENABLE_EXTENSIONS) 1061 #if defined(ENABLE_EXTENSIONS)
1065 extension_policy_, 1062 extension_policy_,
1066 #endif 1063 #endif
1067 pref_service_.Pass(), 1064 pref_service_.Pass(),
1068 original_profile, 1065 original_profile,
1069 guest_session_, 1066 guest_session_,
1070 supervised_user_id_, 1067 supervised_user_id_,
1071 policy_service_.Pass(), 1068 policy_service_.Pass(),
1072 testing_factories_); 1069 testing_factories_);
1073 } 1070 }
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | components/bookmarks.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698