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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 profile_dependency_manager_->DestroyProfileServices(this); | 225 profile_dependency_manager_->DestroyProfileServices(this); |
226 | 226 |
227 if (host_content_settings_map_) | 227 if (host_content_settings_map_) |
228 host_content_settings_map_->ShutdownOnUIThread(); | 228 host_content_settings_map_->ShutdownOnUIThread(); |
229 | 229 |
230 DestroyTopSites(); | 230 DestroyTopSites(); |
231 DestroyHistoryService(); | 231 DestroyHistoryService(); |
232 // FaviconService depends on HistoryServce so destroying it later. | 232 // FaviconService depends on HistoryServce so destroying it later. |
233 DestroyFaviconService(); | 233 DestroyFaviconService(); |
234 DestroyWebDataService(); | |
235 | 234 |
236 if (pref_proxy_config_tracker_.get()) | 235 if (pref_proxy_config_tracker_.get()) |
237 pref_proxy_config_tracker_->DetachFromPrefService(); | 236 pref_proxy_config_tracker_->DetachFromPrefService(); |
238 } | 237 } |
239 | 238 |
240 void TestingProfile::CreateFaviconService() { | 239 void TestingProfile::CreateFaviconService() { |
241 favicon_service_.reset(new FaviconService(this)); | 240 favicon_service_.reset(new FaviconService(this)); |
242 } | 241 } |
243 | 242 |
244 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { | 243 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 316 |
318 void TestingProfile::CreateAutocompleteClassifier() { | 317 void TestingProfile::CreateAutocompleteClassifier() { |
319 autocomplete_classifier_.reset(new AutocompleteClassifier(this)); | 318 autocomplete_classifier_.reset(new AutocompleteClassifier(this)); |
320 } | 319 } |
321 | 320 |
322 void TestingProfile::CreateProtocolHandlerRegistry() { | 321 void TestingProfile::CreateProtocolHandlerRegistry() { |
323 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, | 322 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, |
324 new ProtocolHandlerRegistry::Delegate()); | 323 new ProtocolHandlerRegistry::Delegate()); |
325 } | 324 } |
326 | 325 |
327 void TestingProfile::CreateWebDataService(bool delete_file) { | |
328 if (web_data_service_.get()) | |
329 web_data_service_->Shutdown(); | |
330 | |
331 if (delete_file) { | |
332 FilePath path = GetPath(); | |
333 path = path.Append(chrome::kWebDataFilename); | |
334 file_util::Delete(path, false); | |
335 } | |
336 | |
337 web_data_service_ = new WebDataService; | |
338 if (web_data_service_.get()) | |
339 web_data_service_->Init(GetPath()); | |
340 } | |
341 | |
342 void TestingProfile::BlockUntilBookmarkModelLoaded() { | 326 void TestingProfile::BlockUntilBookmarkModelLoaded() { |
343 DCHECK(bookmark_bar_model_.get()); | 327 DCHECK(bookmark_bar_model_.get()); |
344 if (bookmark_bar_model_->IsLoaded()) | 328 if (bookmark_bar_model_->IsLoaded()) |
345 return; | 329 return; |
346 BookmarkLoadObserver observer; | 330 BookmarkLoadObserver observer; |
347 bookmark_bar_model_->AddObserver(&observer); | 331 bookmark_bar_model_->AddObserver(&observer); |
348 MessageLoop::current()->Run(); | 332 MessageLoop::current()->Run(); |
349 bookmark_bar_model_->RemoveObserver(&observer); | 333 bookmark_bar_model_->RemoveObserver(&observer); |
350 DCHECK(bookmark_bar_model_->IsLoaded()); | 334 DCHECK(bookmark_bar_model_->IsLoaded()); |
351 } | 335 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 } | 510 } |
527 | 511 |
528 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { | 512 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { |
529 return autocomplete_classifier_.get(); | 513 return autocomplete_classifier_.get(); |
530 } | 514 } |
531 | 515 |
532 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() { | 516 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() { |
533 return NULL; | 517 return NULL; |
534 } | 518 } |
535 | 519 |
536 WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) { | |
537 return web_data_service_.get(); | |
538 } | |
539 | |
540 WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() { | |
541 return web_data_service_.get(); | |
542 } | |
543 | |
544 void TestingProfile::SetPrefService(PrefService* prefs) { | 520 void TestingProfile::SetPrefService(PrefService* prefs) { |
545 // ProtectorService binds itself very closely to the PrefService at the moment | 521 // ProtectorService binds itself very closely to the PrefService at the moment |
546 // of Profile creation and watches pref changes to update their backup. | 522 // of Profile creation and watches pref changes to update their backup. |
547 // For tests that replace the PrefService after TestingProfile creation, | 523 // For tests that replace the PrefService after TestingProfile creation, |
548 // ProtectorService is disabled to prevent further invalid memory accesses. | 524 // ProtectorService is disabled to prevent further invalid memory accesses. |
549 protector::ProtectorServiceFactory::GetInstance()-> | 525 protector::ProtectorServiceFactory::GetInstance()-> |
550 SetTestingFactory(this, NULL); | 526 SetTestingFactory(this, NULL); |
551 prefs_.reset(prefs); | 527 prefs_.reset(prefs); |
552 } | 528 } |
553 | 529 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 } | 735 } |
760 | 736 |
761 PrefService* TestingProfile::GetOffTheRecordPrefs() { | 737 PrefService* TestingProfile::GetOffTheRecordPrefs() { |
762 return NULL; | 738 return NULL; |
763 } | 739 } |
764 | 740 |
765 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { | 741 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { |
766 return GetExtensionSpecialStoragePolicy(); | 742 return GetExtensionSpecialStoragePolicy(); |
767 } | 743 } |
768 | 744 |
769 void TestingProfile::DestroyWebDataService() { | |
770 if (!web_data_service_.get()) | |
771 return; | |
772 | |
773 web_data_service_->Shutdown(); | |
774 } | |
775 | |
776 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { | 745 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { |
777 return true; | 746 return true; |
778 } | 747 } |
OLD | NEW |