| OLD | NEW |
| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 232 |
| 233 profile_dependency_manager_->DestroyProfileServices(this); | 233 profile_dependency_manager_->DestroyProfileServices(this); |
| 234 | 234 |
| 235 if (host_content_settings_map_) | 235 if (host_content_settings_map_) |
| 236 host_content_settings_map_->ShutdownOnUIThread(); | 236 host_content_settings_map_->ShutdownOnUIThread(); |
| 237 | 237 |
| 238 DestroyTopSites(); | 238 DestroyTopSites(); |
| 239 DestroyHistoryService(); | 239 DestroyHistoryService(); |
| 240 // FaviconService depends on HistoryServce so destroying it later. | 240 // FaviconService depends on HistoryServce so destroying it later. |
| 241 DestroyFaviconService(); | 241 DestroyFaviconService(); |
| 242 DestroyWebDataService(); | |
| 243 | 242 |
| 244 if (pref_proxy_config_tracker_.get()) | 243 if (pref_proxy_config_tracker_.get()) |
| 245 pref_proxy_config_tracker_->DetachFromPrefService(); | 244 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 246 } | 245 } |
| 247 | 246 |
| 248 void TestingProfile::CreateFaviconService() { | 247 void TestingProfile::CreateFaviconService() { |
| 249 favicon_service_.reset(new FaviconService(this)); | 248 favicon_service_.reset(new FaviconService(this)); |
| 250 } | 249 } |
| 251 | 250 |
| 252 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { | 251 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 324 |
| 326 void TestingProfile::CreateAutocompleteClassifier() { | 325 void TestingProfile::CreateAutocompleteClassifier() { |
| 327 autocomplete_classifier_.reset(new AutocompleteClassifier(this)); | 326 autocomplete_classifier_.reset(new AutocompleteClassifier(this)); |
| 328 } | 327 } |
| 329 | 328 |
| 330 void TestingProfile::CreateProtocolHandlerRegistry() { | 329 void TestingProfile::CreateProtocolHandlerRegistry() { |
| 331 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, | 330 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, |
| 332 new ProtocolHandlerRegistry::Delegate()); | 331 new ProtocolHandlerRegistry::Delegate()); |
| 333 } | 332 } |
| 334 | 333 |
| 335 void TestingProfile::CreateWebDataService(bool delete_file) { | |
| 336 if (web_data_service_.get()) | |
| 337 web_data_service_->Shutdown(); | |
| 338 | |
| 339 if (delete_file) { | |
| 340 FilePath path = GetPath(); | |
| 341 path = path.Append(chrome::kWebDataFilename); | |
| 342 file_util::Delete(path, false); | |
| 343 } | |
| 344 | |
| 345 web_data_service_ = new WebDataService; | |
| 346 if (web_data_service_.get()) | |
| 347 web_data_service_->Init(GetPath()); | |
| 348 } | |
| 349 | |
| 350 void TestingProfile::BlockUntilBookmarkModelLoaded() { | 334 void TestingProfile::BlockUntilBookmarkModelLoaded() { |
| 351 DCHECK(bookmark_bar_model_.get()); | 335 DCHECK(bookmark_bar_model_.get()); |
| 352 if (bookmark_bar_model_->IsLoaded()) | 336 if (bookmark_bar_model_->IsLoaded()) |
| 353 return; | 337 return; |
| 354 BookmarkLoadObserver observer; | 338 BookmarkLoadObserver observer; |
| 355 bookmark_bar_model_->AddObserver(&observer); | 339 bookmark_bar_model_->AddObserver(&observer); |
| 356 MessageLoop::current()->Run(); | 340 MessageLoop::current()->Run(); |
| 357 bookmark_bar_model_->RemoveObserver(&observer); | 341 bookmark_bar_model_->RemoveObserver(&observer); |
| 358 DCHECK(bookmark_bar_model_->IsLoaded()); | 342 DCHECK(bookmark_bar_model_->IsLoaded()); |
| 359 } | 343 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 } | 469 } |
| 486 | 470 |
| 487 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { | 471 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { |
| 488 return autocomplete_classifier_.get(); | 472 return autocomplete_classifier_.get(); |
| 489 } | 473 } |
| 490 | 474 |
| 491 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() { | 475 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() { |
| 492 return NULL; | 476 return NULL; |
| 493 } | 477 } |
| 494 | 478 |
| 495 WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) { | |
| 496 return web_data_service_.get(); | |
| 497 } | |
| 498 | |
| 499 WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() { | |
| 500 return web_data_service_.get(); | |
| 501 } | |
| 502 | |
| 503 void TestingProfile::SetPrefService(PrefService* prefs) { | 479 void TestingProfile::SetPrefService(PrefService* prefs) { |
| 504 #if defined(ENABLE_PROTECTOR_SERVICE) | 480 #if defined(ENABLE_PROTECTOR_SERVICE) |
| 505 // ProtectorService binds itself very closely to the PrefService at the moment | 481 // ProtectorService binds itself very closely to the PrefService at the moment |
| 506 // of Profile creation and watches pref changes to update their backup. | 482 // of Profile creation and watches pref changes to update their backup. |
| 507 // For tests that replace the PrefService after TestingProfile creation, | 483 // For tests that replace the PrefService after TestingProfile creation, |
| 508 // ProtectorService is disabled to prevent further invalid memory accesses. | 484 // ProtectorService is disabled to prevent further invalid memory accesses. |
| 509 protector::ProtectorServiceFactory::GetInstance()-> | 485 protector::ProtectorServiceFactory::GetInstance()-> |
| 510 SetTestingFactory(this, NULL); | 486 SetTestingFactory(this, NULL); |
| 511 #endif | 487 #endif |
| 512 prefs_.reset(prefs); | 488 prefs_.reset(prefs); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 } | 682 } |
| 707 | 683 |
| 708 PrefService* TestingProfile::GetOffTheRecordPrefs() { | 684 PrefService* TestingProfile::GetOffTheRecordPrefs() { |
| 709 return NULL; | 685 return NULL; |
| 710 } | 686 } |
| 711 | 687 |
| 712 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { | 688 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { |
| 713 return GetExtensionSpecialStoragePolicy(); | 689 return GetExtensionSpecialStoragePolicy(); |
| 714 } | 690 } |
| 715 | 691 |
| 716 void TestingProfile::DestroyWebDataService() { | |
| 717 if (!web_data_service_.get()) | |
| 718 return; | |
| 719 | |
| 720 web_data_service_->Shutdown(); | |
| 721 } | |
| 722 | |
| 723 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { | 692 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { |
| 724 return true; | 693 return true; |
| 725 } | 694 } |
| OLD | NEW |