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

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

Issue 242693003: Introduce BookmarkClient interface to abstract embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 8 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
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 "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/message_loop/message_loop_proxy.h" 12 #include "base/message_loop/message_loop_proxy.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/prefs/testing_pref_store.h" 14 #include "base/prefs/testing_pref_store.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
18 #include "chrome/browser/bookmarks/bookmark_model.h" 18 #include "chrome/browser/bookmarks/bookmark_model.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/browser_process.h" 21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/content_settings/host_content_settings_map.h" 23 #include "chrome/browser/content_settings/host_content_settings_map.h"
23 #include "chrome/browser/extensions/extension_service.h" 24 #include "chrome/browser/extensions/extension_service.h"
24 #include "chrome/browser/extensions/extension_special_storage_policy.h" 25 #include "chrome/browser/extensions/extension_special_storage_policy.h"
25 #include "chrome/browser/extensions/extension_system_factory.h" 26 #include "chrome/browser/extensions/extension_system_factory.h"
26 #include "chrome/browser/extensions/test_extension_system.h" 27 #include "chrome/browser/extensions/test_extension_system.h"
27 #include "chrome/browser/favicon/favicon_service.h" 28 #include "chrome/browser/favicon/favicon_service.h"
28 #include "chrome/browser/favicon/favicon_service_factory.h" 29 #include "chrome/browser/favicon/favicon_service_factory.h"
29 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 30 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // TopSitesImpl::Shutdown schedules some tasks (from TopSitesBackend) that 488 // TopSitesImpl::Shutdown schedules some tasks (from TopSitesBackend) that
488 // need to be run to properly shutdown. Run all pending tasks now. This is 489 // need to be run to properly shutdown. Run all pending tasks now. This is
489 // normally handled by browser_process shutdown. 490 // normally handled by browser_process shutdown.
490 if (base::MessageLoop::current()) 491 if (base::MessageLoop::current())
491 base::MessageLoop::current()->RunUntilIdle(); 492 base::MessageLoop::current()->RunUntilIdle();
492 } 493 }
493 } 494 }
494 495
495 static KeyedService* BuildBookmarkModel(content::BrowserContext* context) { 496 static KeyedService* BuildBookmarkModel(content::BrowserContext* context) {
496 Profile* profile = static_cast<Profile*>(context); 497 Profile* profile = static_cast<Profile*>(context);
497 BookmarkModel* bookmark_model = new BookmarkModel(profile); 498 ChromeBookmarkClient* bookmark_client = new ChromeBookmarkClient(profile);
498 bookmark_model->Load(profile->GetIOTaskRunner()); 499 bookmark_client->model()->Load(
499 return bookmark_model; 500 profile->GetPrefs(),
501 profile->GetPath(),
502 profile->GetIOTaskRunner(),
503 content::BrowserThread::GetMessageLoopProxyForThread(
504 content::BrowserThread::UI));
505 return bookmark_client;
500 } 506 }
501 507
502 void TestingProfile::CreateBookmarkModel(bool delete_file) { 508 void TestingProfile::CreateBookmarkModel(bool delete_file) {
503 if (delete_file) { 509 if (delete_file) {
504 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); 510 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName);
505 base::DeleteFile(path, false); 511 base::DeleteFile(path, false);
506 } 512 }
507 // This will create a bookmark model. 513 // This will create a bookmark model.
508 BookmarkModel* bookmark_service = static_cast<BookmarkModel*>( 514 ChromeBookmarkClient* bookmark_client = static_cast<ChromeBookmarkClient*>(
509 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( 515 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
510 this, BuildBookmarkModel)); 516 this, BuildBookmarkModel));
511 517
512 HistoryService* history_service = 518 HistoryService* history_service =
513 HistoryServiceFactory::GetForProfileWithoutCreating(this); 519 HistoryServiceFactory::GetForProfileWithoutCreating(this);
514 if (history_service) { 520 if (history_service) {
521 BookmarkService* bookmark_service = bookmark_client->model();
515 history_service->history_backend_->bookmark_service_ = bookmark_service; 522 history_service->history_backend_->bookmark_service_ = bookmark_service;
516 history_service->history_backend_->expirer_.bookmark_service_ = 523 history_service->history_backend_->expirer_.bookmark_service_ =
517 bookmark_service; 524 bookmark_service;
518 } 525 }
519 } 526 }
520 527
521 static KeyedService* BuildWebDataService(content::BrowserContext* profile) { 528 static KeyedService* BuildWebDataService(content::BrowserContext* profile) {
522 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); 529 return new WebDataServiceWrapper(static_cast<Profile*>(profile));
523 } 530 }
524 531
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 path_, 970 path_,
964 delegate_, 971 delegate_,
965 extension_policy_, 972 extension_policy_,
966 pref_service_.Pass(), 973 pref_service_.Pass(),
967 incognito_, 974 incognito_,
968 guest_session_, 975 guest_session_,
969 managed_user_id_, 976 managed_user_id_,
970 policy_service_.Pass(), 977 policy_service_.Pass(),
971 testing_factories_)); 978 testing_factories_));
972 } 979 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698