Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile gdi. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "chrome/common/chrome_switches.h" 55 #include "chrome/common/chrome_switches.h"
56 #include "chrome/common/pref_names.h" 56 #include "chrome/common/pref_names.h"
57 #include "chrome/common/url_constants.h" 57 #include "chrome/common/url_constants.h"
58 #include "chrome/test/base/bookmark_load_observer.h" 58 #include "chrome/test/base/bookmark_load_observer.h"
59 #include "chrome/test/base/history_index_restore_observer.h" 59 #include "chrome/test/base/history_index_restore_observer.h"
60 #include "chrome/test/base/testing_pref_service_syncable.h" 60 #include "chrome/test/base/testing_pref_service_syncable.h"
61 #include "chrome/test/base/ui_test_utils.h" 61 #include "chrome/test/base/ui_test_utils.h"
62 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 62 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
63 #include "components/user_prefs/user_prefs.h" 63 #include "components/user_prefs/user_prefs.h"
64 #include "content/public/browser/browser_thread.h" 64 #include "content/public/browser/browser_thread.h"
65 #include "content/public/browser/cookie_store_factory.h"
65 #include "content/public/browser/notification_service.h" 66 #include "content/public/browser/notification_service.h"
66 #include "content/public/browser/render_process_host.h" 67 #include "content/public/browser/render_process_host.h"
67 #include "content/public/browser/storage_partition.h" 68 #include "content/public/browser/storage_partition.h"
68 #include "content/public/test/mock_resource_context.h" 69 #include "content/public/test/mock_resource_context.h"
69 #include "content/public/test/test_utils.h" 70 #include "content/public/test/test_utils.h"
70 #include "extensions/common/constants.h" 71 #include "extensions/common/constants.h"
71 #include "net/cookies/cookie_monster.h" 72 #include "net/cookies/cookie_monster.h"
72 #include "net/url_request/url_request_context.h" 73 #include "net/url_request/url_request_context.h"
73 #include "net/url_request/url_request_context_getter.h" 74 #include "net/url_request/url_request_context_getter.h"
74 #include "net/url_request/url_request_test_util.h" 75 #include "net/url_request/url_request_test_util.h"
(...skipping 29 matching lines...) Expand all
104 virtual void DoneRunOnMainThread() OVERRIDE { 105 virtual void DoneRunOnMainThread() OVERRIDE {
105 base::MessageLoop::current()->Quit(); 106 base::MessageLoop::current()->Quit();
106 } 107 }
107 108
108 private: 109 private:
109 virtual ~QuittingHistoryDBTask() {} 110 virtual ~QuittingHistoryDBTask() {}
110 111
111 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask); 112 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask);
112 }; 113 };
113 114
114 class TestExtensionURLRequestContext : public net::URLRequestContext {
115 public:
116 TestExtensionURLRequestContext() {
117 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL);
118 const char* schemes[] = {extensions::kExtensionScheme};
119 cookie_monster->SetCookieableSchemes(schemes, 1);
120 set_cookie_store(cookie_monster);
121 }
122
123 virtual ~TestExtensionURLRequestContext() {}
124 };
125
126 class TestExtensionURLRequestContextGetter
127 : public net::URLRequestContextGetter {
128 public:
129 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
130 if (!context_.get())
131 context_.reset(new TestExtensionURLRequestContext());
132 return context_.get();
133 }
134 virtual scoped_refptr<base::SingleThreadTaskRunner>
135 GetNetworkTaskRunner() const OVERRIDE {
136 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
137 }
138
139 protected:
140 virtual ~TestExtensionURLRequestContextGetter() {}
141
142 private:
143 scoped_ptr<net::URLRequestContext> context_;
144 };
145
146 BrowserContextKeyedService* CreateTestDesktopNotificationService( 115 BrowserContextKeyedService* CreateTestDesktopNotificationService(
147 content::BrowserContext* profile) { 116 content::BrowserContext* profile) {
148 #if defined(ENABLE_NOTIFICATIONS) 117 #if defined(ENABLE_NOTIFICATIONS)
149 return new DesktopNotificationService(static_cast<Profile*>(profile), NULL); 118 return new DesktopNotificationService(static_cast<Profile*>(profile), NULL);
150 #else 119 #else
151 return NULL; 120 return NULL;
152 #endif 121 #endif
153 } 122 }
154 123
155 } // namespace 124 } // namespace
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 extension_special_storage_policy_ = extension_special_storage_policy; 534 extension_special_storage_policy_ = extension_special_storage_policy;
566 } 535 }
567 536
568 ExtensionSpecialStoragePolicy* 537 ExtensionSpecialStoragePolicy*
569 TestingProfile::GetExtensionSpecialStoragePolicy() { 538 TestingProfile::GetExtensionSpecialStoragePolicy() {
570 if (!extension_special_storage_policy_.get()) 539 if (!extension_special_storage_policy_.get())
571 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL); 540 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL);
572 return extension_special_storage_policy_.get(); 541 return extension_special_storage_policy_.get();
573 } 542 }
574 543
575 net::CookieMonster* TestingProfile::GetCookieMonster() {
576 if (!GetRequestContext())
577 return NULL;
578 return GetRequestContext()->GetURLRequestContext()->cookie_store()->
579 GetCookieMonster();
580 }
581
582 void TestingProfile::CreateTestingPrefService() { 544 void TestingProfile::CreateTestingPrefService() {
583 DCHECK(!prefs_.get()); 545 DCHECK(!prefs_.get());
584 testing_prefs_ = new TestingPrefServiceSyncable(); 546 testing_prefs_ = new TestingPrefServiceSyncable();
585 prefs_.reset(testing_prefs_); 547 prefs_.reset(testing_prefs_);
586 user_prefs::UserPrefs::Set(this, prefs_.get()); 548 user_prefs::UserPrefs::Set(this, prefs_.get());
587 chrome::RegisterUserProfilePrefs(testing_prefs_->registry()); 549 chrome::RegisterUserProfilePrefs(testing_prefs_->registry());
588 } 550 }
589 551
590 void TestingProfile::CreateProfilePolicyConnector() { 552 void TestingProfile::CreateProfilePolicyConnector() {
591 scoped_ptr<policy::PolicyService> service; 553 scoped_ptr<policy::PolicyService> service;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 621
660 void TestingProfile::RequestMIDISysExPermission( 622 void TestingProfile::RequestMIDISysExPermission(
661 int render_process_id, 623 int render_process_id,
662 int render_view_id, 624 int render_view_id,
663 const GURL& requesting_frame, 625 const GURL& requesting_frame,
664 const MIDISysExPermissionCallback& callback) { 626 const MIDISysExPermissionCallback& callback) {
665 // Always reject requests for testing. 627 // Always reject requests for testing.
666 callback.Run(false); 628 callback.Run(false);
667 } 629 }
668 630
669 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() {
670 if (!extensions_request_context_.get())
671 extensions_request_context_ = new TestExtensionURLRequestContextGetter();
672 return extensions_request_context_.get();
673 }
674
675 net::SSLConfigService* TestingProfile::GetSSLConfigService() { 631 net::SSLConfigService* TestingProfile::GetSSLConfigService() {
676 if (!GetRequestContext()) 632 if (!GetRequestContext())
677 return NULL; 633 return NULL;
678 return GetRequestContext()->GetURLRequestContext()->ssl_config_service(); 634 return GetRequestContext()->GetURLRequestContext()->ssl_config_service();
679 } 635 }
680 636
681 net::URLRequestContextGetter* 637 net::URLRequestContextGetter*
682 TestingProfile::CreateRequestContextForStoragePartition( 638 TestingProfile::CreateRequestContextForStoragePartition(
683 const base::FilePath& partition_path, 639 const base::FilePath& partition_path,
684 bool in_memory, 640 bool in_memory,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 } 729 }
774 730
775 GURL TestingProfile::GetHomePage() { 731 GURL TestingProfile::GetHomePage() {
776 return GURL(chrome::kChromeUINewTabURL); 732 return GURL(chrome::kChromeUINewTabURL);
777 } 733 }
778 734
779 PrefService* TestingProfile::GetOffTheRecordPrefs() { 735 PrefService* TestingProfile::GetOffTheRecordPrefs() {
780 return NULL; 736 return NULL;
781 } 737 }
782 738
739 content::CookieStoreConfig TestingProfile::GetCookieStoreConfig() {
740 return content::CookieStoreConfig::InMemory();
741 }
742
783 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { 743 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() {
784 return GetExtensionSpecialStoragePolicy(); 744 return GetExtensionSpecialStoragePolicy();
785 } 745 }
786 746
787 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { 747 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) {
788 return true; 748 return true;
789 } 749 }
790 750
791 bool TestingProfile::IsGuestSession() const { 751 bool TestingProfile::IsGuestSession() const {
792 return false; 752 return false;
(...skipping 30 matching lines...) Expand all
823 783
824 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 784 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
825 DCHECK(!build_called_); 785 DCHECK(!build_called_);
826 build_called_ = true; 786 build_called_ = true;
827 return scoped_ptr<TestingProfile>(new TestingProfile( 787 return scoped_ptr<TestingProfile>(new TestingProfile(
828 path_, 788 path_,
829 delegate_, 789 delegate_,
830 extension_policy_, 790 extension_policy_,
831 pref_service_.Pass())); 791 pref_service_.Pass()));
832 } 792 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698