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

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

Issue 285233012: Abstract history dependencies on bookmarks through HistoryClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 return new FaviconService(static_cast<Profile*>(profile)); 419 return new FaviconService(static_cast<Profile*>(profile));
420 } 420 }
421 421
422 void TestingProfile::CreateFaviconService() { 422 void TestingProfile::CreateFaviconService() {
423 // It is up to the caller to create the history service if one is needed. 423 // It is up to the caller to create the history service if one is needed.
424 FaviconServiceFactory::GetInstance()->SetTestingFactory( 424 FaviconServiceFactory::GetInstance()->SetTestingFactory(
425 this, BuildFaviconService); 425 this, BuildFaviconService);
426 } 426 }
427 427
428 static KeyedService* BuildHistoryService(content::BrowserContext* profile) { 428 static KeyedService* BuildHistoryService(content::BrowserContext* profile) {
429 // TODO(sdefresne): should we also create a ChromeHistoryClient?
429 return new HistoryService(NULL, static_cast<Profile*>(profile)); 430 return new HistoryService(NULL, static_cast<Profile*>(profile));
430 } 431 }
431 432
432 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 433 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
433 DestroyHistoryService(); 434 DestroyHistoryService();
434 if (delete_file) { 435 if (delete_file) {
435 base::FilePath path = GetPath(); 436 base::FilePath path = GetPath();
436 path = path.Append(chrome::kHistoryFilename); 437 path = path.Append(chrome::kHistoryFilename);
437 if (!base::DeleteFile(path, false) || base::PathExists(path)) 438 if (!base::DeleteFile(path, false) || base::PathExists(path))
438 return false; 439 return false;
439 } 440 }
440 // This will create and init the history service. 441 // This will create and init the history service.
441 HistoryService* history_service = static_cast<HistoryService*>( 442 HistoryService* history_service = static_cast<HistoryService*>(
442 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( 443 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(
443 this, BuildHistoryService)); 444 this, BuildHistoryService));
444 if (!history_service->Init(this->GetPath(), 445 if (!history_service->Init(this->GetPath(), no_db)) {
445 BookmarkModelFactory::GetForProfile(this),
446 no_db)) {
447 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); 446 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL);
448 } 447 }
449 // Disable WebHistoryService by default, since it makes network requests. 448 // Disable WebHistoryService by default, since it makes network requests.
450 WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, NULL); 449 WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, NULL);
451 return true; 450 return true;
452 } 451 }
453 452
454 void TestingProfile::DestroyHistoryService() { 453 void TestingProfile::DestroyHistoryService() {
455 HistoryService* history_service = 454 HistoryService* history_service =
456 HistoryServiceFactory::GetForProfileWithoutCreating(this); 455 HistoryServiceFactory::GetForProfileWithoutCreating(this);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 content::BrowserThread::UI)); 505 content::BrowserThread::UI));
507 return bookmark_client; 506 return bookmark_client;
508 } 507 }
509 508
510 void TestingProfile::CreateBookmarkModel(bool delete_file) { 509 void TestingProfile::CreateBookmarkModel(bool delete_file) {
511 if (delete_file) { 510 if (delete_file) {
512 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); 511 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName);
513 base::DeleteFile(path, false); 512 base::DeleteFile(path, false);
514 } 513 }
515 // This will create a bookmark model. 514 // This will create a bookmark model.
516 BookmarkModel* bookmark_service = 515 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
517 static_cast<ChromeBookmarkClient*>( 516 this, BuildBookmarkModel);
518 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
519 this, BuildBookmarkModel))->model();
520
521 HistoryService* history_service =
522 HistoryServiceFactory::GetForProfileWithoutCreating(this);
523 if (history_service) {
524 history_service->history_backend_->bookmark_service_ = bookmark_service;
blundell 2014/06/02 09:39:30 I think that you should create and wire up a Chrom
sdefresne 2014/06/02 12:59:12 Done.
525 history_service->history_backend_->expirer_.bookmark_service_ =
526 bookmark_service;
527 }
528 } 517 }
529 518
530 static KeyedService* BuildWebDataService(content::BrowserContext* profile) { 519 static KeyedService* BuildWebDataService(content::BrowserContext* profile) {
531 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); 520 return new WebDataServiceWrapper(static_cast<Profile*>(profile));
532 } 521 }
533 522
534 void TestingProfile::CreateWebDataService() { 523 void TestingProfile::CreateWebDataService() {
535 WebDataServiceFactory::GetInstance()->SetTestingFactory( 524 WebDataServiceFactory::GetInstance()->SetTestingFactory(
536 this, BuildWebDataService); 525 this, BuildWebDataService);
537 } 526 }
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 path_, 961 path_,
973 delegate_, 962 delegate_,
974 extension_policy_, 963 extension_policy_,
975 pref_service_.Pass(), 964 pref_service_.Pass(),
976 incognito_, 965 incognito_,
977 guest_session_, 966 guest_session_,
978 managed_user_id_, 967 managed_user_id_,
979 policy_service_.Pass(), 968 policy_service_.Pass(),
980 testing_factories_)); 969 testing_factories_));
981 } 970 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698