| 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 23 matching lines...) Expand all Loading... |
| 34 #include "chrome/browser/history/shortcuts_backend.h" | 34 #include "chrome/browser/history/shortcuts_backend.h" |
| 35 #include "chrome/browser/history/shortcuts_backend_factory.h" | 35 #include "chrome/browser/history/shortcuts_backend_factory.h" |
| 36 #include "chrome/browser/history/top_sites.h" | 36 #include "chrome/browser/history/top_sites.h" |
| 37 #include "chrome/browser/net/proxy_service_factory.h" | 37 #include "chrome/browser/net/proxy_service_factory.h" |
| 38 #include "chrome/browser/notifications/desktop_notification_service.h" | 38 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 39 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 39 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 40 #include "chrome/browser/prefs/browser_prefs.h" | 40 #include "chrome/browser/prefs/browser_prefs.h" |
| 41 #include "chrome/browser/prerender/prerender_manager.h" | 41 #include "chrome/browser/prerender/prerender_manager.h" |
| 42 #include "chrome/browser/profiles/profile_dependency_manager.h" | 42 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 43 #include "chrome/browser/profiles/storage_partition_descriptor.h" | 43 #include "chrome/browser/profiles/storage_partition_descriptor.h" |
| 44 #include "chrome/browser/protector/protector_service_factory.h" | |
| 45 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | 44 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
| 46 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" | 45 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" |
| 47 #include "chrome/browser/webdata/web_data_service.h" | 46 #include "chrome/browser/webdata/web_data_service.h" |
| 48 #include "chrome/browser/webdata/web_data_service_factory.h" | 47 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 49 #include "chrome/common/chrome_constants.h" | 48 #include "chrome/common/chrome_constants.h" |
| 50 #include "chrome/common/chrome_notification_types.h" | 49 #include "chrome/common/chrome_notification_types.h" |
| 51 #include "chrome/common/chrome_switches.h" | 50 #include "chrome/common/chrome_switches.h" |
| 52 #include "chrome/common/url_constants.h" | 51 #include "chrome/common/url_constants.h" |
| 53 #include "chrome/test/base/bookmark_load_observer.h" | 52 #include "chrome/test/base/bookmark_load_observer.h" |
| 54 #include "chrome/test/base/history_index_restore_observer.h" | 53 #include "chrome/test/base/history_index_restore_observer.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 policy::PolicyServiceImpl::Providers providers; | 547 policy::PolicyServiceImpl::Providers providers; |
| 549 policy_service_.reset(new policy::PolicyServiceImpl(providers)); | 548 policy_service_.reset(new policy::PolicyServiceImpl(providers)); |
| 550 #else | 549 #else |
| 551 policy_service_.reset(new policy::PolicyServiceStub()); | 550 policy_service_.reset(new policy::PolicyServiceStub()); |
| 552 #endif | 551 #endif |
| 553 } | 552 } |
| 554 return policy_service_.get(); | 553 return policy_service_.get(); |
| 555 } | 554 } |
| 556 | 555 |
| 557 void TestingProfile::SetPrefService(PrefService* prefs) { | 556 void TestingProfile::SetPrefService(PrefService* prefs) { |
| 558 #if defined(ENABLE_PROTECTOR_SERVICE) | |
| 559 // ProtectorService binds itself very closely to the PrefService at the moment | |
| 560 // of Profile creation and watches pref changes to update their backup. | |
| 561 // For tests that replace the PrefService after TestingProfile creation, | |
| 562 // ProtectorService is disabled to prevent further invalid memory accesses. | |
| 563 protector::ProtectorServiceFactory::GetInstance()-> | |
| 564 SetTestingFactory(this, NULL); | |
| 565 #endif | |
| 566 prefs_.reset(prefs); | 557 prefs_.reset(prefs); |
| 567 } | 558 } |
| 568 | 559 |
| 569 void TestingProfile::CreateTestingPrefService() { | 560 void TestingProfile::CreateTestingPrefService() { |
| 570 DCHECK(!prefs_.get()); | 561 DCHECK(!prefs_.get()); |
| 571 testing_prefs_ = new TestingPrefService(); | 562 testing_prefs_ = new TestingPrefService(); |
| 572 prefs_.reset(testing_prefs_); | 563 prefs_.reset(testing_prefs_); |
| 573 Profile::RegisterUserPrefs(prefs_.get()); | 564 Profile::RegisterUserPrefs(prefs_.get()); |
| 574 chrome::RegisterUserPrefs(prefs_.get()); | 565 chrome::RegisterUserPrefs(prefs_.get()); |
| 575 } | 566 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 | 799 |
| 809 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { | 800 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { |
| 810 DCHECK(!build_called_); | 801 DCHECK(!build_called_); |
| 811 build_called_ = true; | 802 build_called_ = true; |
| 812 return scoped_ptr<TestingProfile>(new TestingProfile( | 803 return scoped_ptr<TestingProfile>(new TestingProfile( |
| 813 path_, | 804 path_, |
| 814 delegate_, | 805 delegate_, |
| 815 extension_policy_, | 806 extension_policy_, |
| 816 pref_service_.Pass())); | 807 pref_service_.Pass())); |
| 817 } | 808 } |
| OLD | NEW |