| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "chrome/common/chrome_constants.h" | 54 #include "chrome/common/chrome_constants.h" |
| 55 #include "chrome/common/chrome_switches.h" | 55 #include "chrome/common/chrome_switches.h" |
| 56 #include "chrome/common/url_constants.h" | 56 #include "chrome/common/url_constants.h" |
| 57 #include "chrome/test/base/bookmark_load_observer.h" | 57 #include "chrome/test/base/bookmark_load_observer.h" |
| 58 #include "chrome/test/base/history_index_restore_observer.h" | 58 #include "chrome/test/base/history_index_restore_observer.h" |
| 59 #include "chrome/test/base/testing_pref_service_syncable.h" | 59 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 60 #include "chrome/test/base/ui_test_utils.h" | 60 #include "chrome/test/base/ui_test_utils.h" |
| 61 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 61 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 62 #include "components/user_prefs/user_prefs.h" | 62 #include "components/user_prefs/user_prefs.h" |
| 63 #include "content/public/browser/browser_thread.h" | 63 #include "content/public/browser/browser_thread.h" |
| 64 #include "content/public/browser/cookie_store_factory.h" |
| 64 #include "content/public/browser/notification_service.h" | 65 #include "content/public/browser/notification_service.h" |
| 65 #include "content/public/browser/render_process_host.h" | 66 #include "content/public/browser/render_process_host.h" |
| 66 #include "content/public/browser/storage_partition.h" | 67 #include "content/public/browser/storage_partition.h" |
| 67 #include "content/public/test/mock_resource_context.h" | 68 #include "content/public/test/mock_resource_context.h" |
| 68 #include "content/public/test/test_utils.h" | 69 #include "content/public/test/test_utils.h" |
| 69 #include "extensions/common/constants.h" | 70 #include "extensions/common/constants.h" |
| 70 #include "net/cookies/cookie_monster.h" | 71 #include "net/cookies/cookie_monster.h" |
| 71 #include "net/url_request/url_request_context.h" | 72 #include "net/url_request/url_request_context.h" |
| 72 #include "net/url_request/url_request_context_getter.h" | 73 #include "net/url_request/url_request_context_getter.h" |
| 73 #include "net/url_request/url_request_test_util.h" | 74 #include "net/url_request/url_request_test_util.h" |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 extension_special_storage_policy_ = extension_special_storage_policy; | 555 extension_special_storage_policy_ = extension_special_storage_policy; |
| 555 } | 556 } |
| 556 | 557 |
| 557 ExtensionSpecialStoragePolicy* | 558 ExtensionSpecialStoragePolicy* |
| 558 TestingProfile::GetExtensionSpecialStoragePolicy() { | 559 TestingProfile::GetExtensionSpecialStoragePolicy() { |
| 559 if (!extension_special_storage_policy_.get()) | 560 if (!extension_special_storage_policy_.get()) |
| 560 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL); | 561 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL); |
| 561 return extension_special_storage_policy_.get(); | 562 return extension_special_storage_policy_.get(); |
| 562 } | 563 } |
| 563 | 564 |
| 564 net::CookieMonster* TestingProfile::GetCookieMonster() { | |
| 565 if (!GetRequestContext()) | |
| 566 return NULL; | |
| 567 return GetRequestContext()->GetURLRequestContext()->cookie_store()-> | |
| 568 GetCookieMonster(); | |
| 569 } | |
| 570 | |
| 571 void TestingProfile::CreateTestingPrefService() { | 565 void TestingProfile::CreateTestingPrefService() { |
| 572 DCHECK(!prefs_.get()); | 566 DCHECK(!prefs_.get()); |
| 573 testing_prefs_ = new TestingPrefServiceSyncable(); | 567 testing_prefs_ = new TestingPrefServiceSyncable(); |
| 574 prefs_.reset(testing_prefs_); | 568 prefs_.reset(testing_prefs_); |
| 575 user_prefs::UserPrefs::Set(this, prefs_.get()); | 569 user_prefs::UserPrefs::Set(this, prefs_.get()); |
| 576 chrome::RegisterUserProfilePrefs(testing_prefs_->registry()); | 570 chrome::RegisterUserProfilePrefs(testing_prefs_->registry()); |
| 577 } | 571 } |
| 578 | 572 |
| 579 void TestingProfile::CreateProfilePolicyConnector() { | 573 void TestingProfile::CreateProfilePolicyConnector() { |
| 580 scoped_ptr<policy::PolicyService> service; | 574 scoped_ptr<policy::PolicyService> service; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 642 |
| 649 void TestingProfile::RequestMIDISysExPermission( | 643 void TestingProfile::RequestMIDISysExPermission( |
| 650 int render_process_id, | 644 int render_process_id, |
| 651 int render_view_id, | 645 int render_view_id, |
| 652 const GURL& requesting_frame, | 646 const GURL& requesting_frame, |
| 653 const MIDISysExPermissionCallback& callback) { | 647 const MIDISysExPermissionCallback& callback) { |
| 654 // Always reject requests for testing. | 648 // Always reject requests for testing. |
| 655 callback.Run(false); | 649 callback.Run(false); |
| 656 } | 650 } |
| 657 | 651 |
| 658 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { | |
| 659 if (!extensions_request_context_.get()) | |
| 660 extensions_request_context_ = new TestExtensionURLRequestContextGetter(); | |
| 661 return extensions_request_context_.get(); | |
| 662 } | |
| 663 | |
| 664 net::SSLConfigService* TestingProfile::GetSSLConfigService() { | 652 net::SSLConfigService* TestingProfile::GetSSLConfigService() { |
| 665 if (!GetRequestContext()) | 653 if (!GetRequestContext()) |
| 666 return NULL; | 654 return NULL; |
| 667 return GetRequestContext()->GetURLRequestContext()->ssl_config_service(); | 655 return GetRequestContext()->GetURLRequestContext()->ssl_config_service(); |
| 668 } | 656 } |
| 669 | 657 |
| 670 net::URLRequestContextGetter* | 658 net::URLRequestContextGetter* |
| 671 TestingProfile::CreateRequestContextForStoragePartition( | 659 TestingProfile::CreateRequestContextForStoragePartition( |
| 672 const base::FilePath& partition_path, | 660 const base::FilePath& partition_path, |
| 673 bool in_memory, | 661 bool in_memory, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 } | 750 } |
| 763 | 751 |
| 764 GURL TestingProfile::GetHomePage() { | 752 GURL TestingProfile::GetHomePage() { |
| 765 return GURL(chrome::kChromeUINewTabURL); | 753 return GURL(chrome::kChromeUINewTabURL); |
| 766 } | 754 } |
| 767 | 755 |
| 768 PrefService* TestingProfile::GetOffTheRecordPrefs() { | 756 PrefService* TestingProfile::GetOffTheRecordPrefs() { |
| 769 return NULL; | 757 return NULL; |
| 770 } | 758 } |
| 771 | 759 |
| 760 content::CookieStoreConfig TestingProfile::GetCookieStoreConfig() { |
| 761 return content::CookieStoreConfig::InMemory(); |
| 762 } |
| 763 |
| 772 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { | 764 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { |
| 773 return GetExtensionSpecialStoragePolicy(); | 765 return GetExtensionSpecialStoragePolicy(); |
| 774 } | 766 } |
| 775 | 767 |
| 776 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { | 768 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { |
| 777 return true; | 769 return true; |
| 778 } | 770 } |
| 779 | 771 |
| 780 bool TestingProfile::IsGuestSession() const { | 772 bool TestingProfile::IsGuestSession() const { |
| 781 return false; | 773 return false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 812 | 804 |
| 813 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { | 805 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { |
| 814 DCHECK(!build_called_); | 806 DCHECK(!build_called_); |
| 815 build_called_ = true; | 807 build_called_ = true; |
| 816 return scoped_ptr<TestingProfile>(new TestingProfile( | 808 return scoped_ptr<TestingProfile>(new TestingProfile( |
| 817 path_, | 809 path_, |
| 818 delegate_, | 810 delegate_, |
| 819 extension_policy_, | 811 extension_policy_, |
| 820 pref_service_.Pass())); | 812 pref_service_.Pass())); |
| 821 } | 813 } |
| OLD | NEW |