| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 230 |
| 231 profile_dependency_manager_->DestroyProfileServices(this); | 231 profile_dependency_manager_->DestroyProfileServices(this); |
| 232 | 232 |
| 233 if (host_content_settings_map_) | 233 if (host_content_settings_map_) |
| 234 host_content_settings_map_->ShutdownOnUIThread(); | 234 host_content_settings_map_->ShutdownOnUIThread(); |
| 235 | 235 |
| 236 DestroyTopSites(); | 236 DestroyTopSites(); |
| 237 DestroyHistoryService(); | 237 DestroyHistoryService(); |
| 238 // FaviconService depends on HistoryServce so destroying it later. | 238 // FaviconService depends on HistoryServce so destroying it later. |
| 239 DestroyFaviconService(); | 239 DestroyFaviconService(); |
| 240 DestroyWebDataService(); | |
| 241 | 240 |
| 242 if (pref_proxy_config_tracker_.get()) | 241 if (pref_proxy_config_tracker_.get()) |
| 243 pref_proxy_config_tracker_->DetachFromPrefService(); | 242 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 244 } | 243 } |
| 245 | 244 |
| 246 void TestingProfile::CreateFaviconService() { | 245 void TestingProfile::CreateFaviconService() { |
| 247 favicon_service_.reset(new FaviconService(this)); | 246 favicon_service_.reset(new FaviconService(this)); |
| 248 } | 247 } |
| 249 | 248 |
| 250 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { | 249 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 322 |
| 324 void TestingProfile::CreateAutocompleteClassifier() { | 323 void TestingProfile::CreateAutocompleteClassifier() { |
| 325 autocomplete_classifier_.reset(new AutocompleteClassifier(this)); | 324 autocomplete_classifier_.reset(new AutocompleteClassifier(this)); |
| 326 } | 325 } |
| 327 | 326 |
| 328 void TestingProfile::CreateProtocolHandlerRegistry() { | 327 void TestingProfile::CreateProtocolHandlerRegistry() { |
| 329 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, | 328 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, |
| 330 new ProtocolHandlerRegistry::Delegate()); | 329 new ProtocolHandlerRegistry::Delegate()); |
| 331 } | 330 } |
| 332 | 331 |
| 333 void TestingProfile::CreateWebDataService(bool delete_file) { | |
| 334 if (web_data_service_.get()) | |
| 335 web_data_service_->Shutdown(); | |
| 336 | |
| 337 if (delete_file) { | |
| 338 FilePath path = GetPath(); | |
| 339 path = path.Append(chrome::kWebDataFilename); | |
| 340 file_util::Delete(path, false); | |
| 341 } | |
| 342 | |
| 343 web_data_service_ = new WebDataService; | |
| 344 if (web_data_service_.get()) | |
| 345 web_data_service_->Init(GetPath()); | |
| 346 } | |
| 347 | |
| 348 void TestingProfile::BlockUntilBookmarkModelLoaded() { | 332 void TestingProfile::BlockUntilBookmarkModelLoaded() { |
| 349 DCHECK(bookmark_bar_model_.get()); | 333 DCHECK(bookmark_bar_model_.get()); |
| 350 if (bookmark_bar_model_->IsLoaded()) | 334 if (bookmark_bar_model_->IsLoaded()) |
| 351 return; | 335 return; |
| 352 BookmarkLoadObserver observer; | 336 BookmarkLoadObserver observer; |
| 353 bookmark_bar_model_->AddObserver(&observer); | 337 bookmark_bar_model_->AddObserver(&observer); |
| 354 MessageLoop::current()->Run(); | 338 MessageLoop::current()->Run(); |
| 355 bookmark_bar_model_->RemoveObserver(&observer); | 339 bookmark_bar_model_->RemoveObserver(&observer); |
| 356 DCHECK(bookmark_bar_model_->IsLoaded()); | 340 DCHECK(bookmark_bar_model_->IsLoaded()); |
| 357 } | 341 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 475 } |
| 492 | 476 |
| 493 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { | 477 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { |
| 494 return autocomplete_classifier_.get(); | 478 return autocomplete_classifier_.get(); |
| 495 } | 479 } |
| 496 | 480 |
| 497 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() { | 481 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() { |
| 498 return NULL; | 482 return NULL; |
| 499 } | 483 } |
| 500 | 484 |
| 501 WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) { | |
| 502 return web_data_service_.get(); | |
| 503 } | |
| 504 | |
| 505 WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() { | |
| 506 return web_data_service_.get(); | |
| 507 } | |
| 508 | |
| 509 void TestingProfile::SetPrefService(PrefService* prefs) { | 485 void TestingProfile::SetPrefService(PrefService* prefs) { |
| 510 #if defined(ENABLE_PROTECTOR_SERVICE) | 486 #if defined(ENABLE_PROTECTOR_SERVICE) |
| 511 // ProtectorService binds itself very closely to the PrefService at the moment | 487 // ProtectorService binds itself very closely to the PrefService at the moment |
| 512 // of Profile creation and watches pref changes to update their backup. | 488 // of Profile creation and watches pref changes to update their backup. |
| 513 // For tests that replace the PrefService after TestingProfile creation, | 489 // For tests that replace the PrefService after TestingProfile creation, |
| 514 // ProtectorService is disabled to prevent further invalid memory accesses. | 490 // ProtectorService is disabled to prevent further invalid memory accesses. |
| 515 protector::ProtectorServiceFactory::GetInstance()-> | 491 protector::ProtectorServiceFactory::GetInstance()-> |
| 516 SetTestingFactory(this, NULL); | 492 SetTestingFactory(this, NULL); |
| 517 #endif | 493 #endif |
| 518 prefs_.reset(prefs); | 494 prefs_.reset(prefs); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } | 700 } |
| 725 | 701 |
| 726 PrefService* TestingProfile::GetOffTheRecordPrefs() { | 702 PrefService* TestingProfile::GetOffTheRecordPrefs() { |
| 727 return NULL; | 703 return NULL; |
| 728 } | 704 } |
| 729 | 705 |
| 730 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { | 706 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { |
| 731 return GetExtensionSpecialStoragePolicy(); | 707 return GetExtensionSpecialStoragePolicy(); |
| 732 } | 708 } |
| 733 | 709 |
| 734 void TestingProfile::DestroyWebDataService() { | |
| 735 if (!web_data_service_.get()) | |
| 736 return; | |
| 737 | |
| 738 web_data_service_->Shutdown(); | |
| 739 } | |
| 740 | |
| 741 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { | 710 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { |
| 742 return true; | 711 return true; |
| 743 } | 712 } |
| OLD | NEW |