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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/history/history.h" | 25 #include "chrome/browser/history/history.h" |
26 #include "chrome/browser/history/history_backend.h" | 26 #include "chrome/browser/history/history_backend.h" |
27 #include "chrome/browser/history/top_sites.h" | 27 #include "chrome/browser/history/top_sites.h" |
28 #include "chrome/browser/net/proxy_service_factory.h" | 28 #include "chrome/browser/net/proxy_service_factory.h" |
29 #include "chrome/browser/notifications/desktop_notification_service.h" | 29 #include "chrome/browser/notifications/desktop_notification_service.h" |
30 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 30 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
31 #include "chrome/browser/prefs/browser_prefs.h" | 31 #include "chrome/browser/prefs/browser_prefs.h" |
32 #include "chrome/browser/prefs/testing_pref_store.h" | 32 #include "chrome/browser/prefs/testing_pref_store.h" |
33 #include "chrome/browser/prerender/prerender_manager.h" | 33 #include "chrome/browser/prerender/prerender_manager.h" |
34 #include "chrome/browser/profiles/profile_dependency_manager.h" | 34 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 35 #include "chrome/browser/protector/protector_service_factory.h" |
35 #include "chrome/browser/search_engines/template_url_fetcher.h" | 36 #include "chrome/browser/search_engines/template_url_fetcher.h" |
36 #include "chrome/browser/search_engines/template_url_service.h" | 37 #include "chrome/browser/search_engines/template_url_service.h" |
37 #include "chrome/browser/search_engines/template_url_service_factory.h" | 38 #include "chrome/browser/search_engines/template_url_service_factory.h" |
38 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" | 39 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" |
39 #include "chrome/browser/sync/profile_sync_service_mock.h" | 40 #include "chrome/browser/sync/profile_sync_service_mock.h" |
40 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 41 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
41 #include "chrome/common/chrome_constants.h" | 42 #include "chrome/common/chrome_constants.h" |
42 #include "chrome/common/chrome_notification_types.h" | 43 #include "chrome/common/chrome_notification_types.h" |
43 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
44 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 | 531 |
531 WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) { | 532 WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) { |
532 return web_data_service_.get(); | 533 return web_data_service_.get(); |
533 } | 534 } |
534 | 535 |
535 WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() { | 536 WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() { |
536 return web_data_service_.get(); | 537 return web_data_service_.get(); |
537 } | 538 } |
538 | 539 |
539 void TestingProfile::SetPrefService(PrefService* prefs) { | 540 void TestingProfile::SetPrefService(PrefService* prefs) { |
| 541 // ProtectorService binds itself very closely to the PrefService at the moment |
| 542 // of Profile creation and watches pref changes to update their backup. |
| 543 // For tests that replace the PrefService after TestingProfile creation, |
| 544 // ProtectorService is disabled to prevent further invalid memory accesses. |
| 545 protector::ProtectorServiceFactory::GetInstance()-> |
| 546 SetTestingFactory(this, NULL); |
540 prefs_.reset(prefs); | 547 prefs_.reset(prefs); |
541 } | 548 } |
542 | 549 |
543 void TestingProfile::CreateTestingPrefService() { | 550 void TestingProfile::CreateTestingPrefService() { |
544 DCHECK(!prefs_.get()); | 551 DCHECK(!prefs_.get()); |
545 testing_prefs_ = new TestingPrefService(); | 552 testing_prefs_ = new TestingPrefService(); |
546 prefs_.reset(testing_prefs_); | 553 prefs_.reset(testing_prefs_); |
547 Profile::RegisterUserPrefs(prefs_.get()); | 554 Profile::RegisterUserPrefs(prefs_.get()); |
548 browser::RegisterUserPrefs(prefs_.get()); | 555 browser::RegisterUserPrefs(prefs_.get()); |
549 } | 556 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 void TestingProfile::DestroyWebDataService() { | 765 void TestingProfile::DestroyWebDataService() { |
759 if (!web_data_service_.get()) | 766 if (!web_data_service_.get()) |
760 return; | 767 return; |
761 | 768 |
762 web_data_service_->Shutdown(); | 769 web_data_service_->Shutdown(); |
763 } | 770 } |
764 | 771 |
765 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { | 772 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { |
766 return true; | 773 return true; |
767 } | 774 } |
OLD | NEW |