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

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: Fix compilation of unit tests 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"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // TopSitesImpl::Shutdown schedules some tasks (from TopSitesBackend) that 487 // TopSitesImpl::Shutdown schedules some tasks (from TopSitesBackend) that
488 // need to be run to properly shutdown. Run all pending tasks now. This is 488 // need to be run to properly shutdown. Run all pending tasks now. This is
489 // normally handled by browser_process shutdown. 489 // normally handled by browser_process shutdown.
490 if (base::MessageLoop::current()) 490 if (base::MessageLoop::current())
491 base::MessageLoop::current()->RunUntilIdle(); 491 base::MessageLoop::current()->RunUntilIdle();
492 } 492 }
493 } 493 }
494 494
495 static KeyedService* BuildBookmarkModel(content::BrowserContext* context) { 495 static KeyedService* BuildBookmarkModel(content::BrowserContext* context) {
496 Profile* profile = static_cast<Profile*>(context); 496 Profile* profile = static_cast<Profile*>(context);
497 BookmarkModel* bookmark_model = new BookmarkModel(profile); 497 ChromeBookmarkClient* bookmark_client = new ChromeBookmarkClient(profile);
498 bookmark_model->Load(profile->GetIOTaskRunner()); 498 bookmark_client->model()->Load(
499 return bookmark_model; 499 profile->GetPrefs(),
500 profile->GetPath(),
501 profile->GetIOTaskRunner(),
502 content::BrowserThread::GetMessageLoopProxyForThread(
503 content::BrowserThread::UI));
504 return bookmark_client;
500 } 505 }
501 506
502 void TestingProfile::CreateBookmarkModel(bool delete_file) { 507 void TestingProfile::CreateBookmarkModel(bool delete_file) {
503 if (delete_file) { 508 if (delete_file) {
504 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); 509 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName);
505 base::DeleteFile(path, false); 510 base::DeleteFile(path, false);
506 } 511 }
507 // This will create a bookmark model. 512 // This will create a bookmark model.
508 BookmarkModel* bookmark_service = static_cast<BookmarkModel*>( 513 ChromeBookmarkClient* bookmark_client = static_cast<ChromeBookmarkClient*>(
509 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( 514 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
510 this, BuildBookmarkModel)); 515 this, BuildBookmarkModel));
511 516
512 HistoryService* history_service = 517 HistoryService* history_service =
513 HistoryServiceFactory::GetForProfileWithoutCreating(this); 518 HistoryServiceFactory::GetForProfileWithoutCreating(this);
514 if (history_service) { 519 if (history_service) {
520 BookmarkService* bookmark_service = bookmark_client->model();
515 history_service->history_backend_->bookmark_service_ = bookmark_service; 521 history_service->history_backend_->bookmark_service_ = bookmark_service;
516 history_service->history_backend_->expirer_.bookmark_service_ = 522 history_service->history_backend_->expirer_.bookmark_service_ =
517 bookmark_service; 523 bookmark_service;
518 } 524 }
519 } 525 }
520 526
521 static KeyedService* BuildWebDataService(content::BrowserContext* profile) { 527 static KeyedService* BuildWebDataService(content::BrowserContext* profile) {
522 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); 528 return new WebDataServiceWrapper(static_cast<Profile*>(profile));
523 } 529 }
524 530
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 path_, 965 path_,
960 delegate_, 966 delegate_,
961 extension_policy_, 967 extension_policy_,
962 pref_service_.Pass(), 968 pref_service_.Pass(),
963 incognito_, 969 incognito_,
964 guest_session_, 970 guest_session_,
965 managed_user_id_, 971 managed_user_id_,
966 policy_service_.Pass(), 972 policy_service_.Pass(),
967 testing_factories_)); 973 testing_factories_));
968 } 974 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698