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