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

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: android webview init fix merged in. Created 7 years, 3 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 19 matching lines...) Expand all
30 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 30 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
31 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h" 31 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h"
32 #include "chrome/browser/history/history_backend.h" 32 #include "chrome/browser/history/history_backend.h"
33 #include "chrome/browser/history/history_db_task.h" 33 #include "chrome/browser/history/history_db_task.h"
34 #include "chrome/browser/history/history_service.h" 34 #include "chrome/browser/history/history_service.h"
35 #include "chrome/browser/history/history_service_factory.h" 35 #include "chrome/browser/history/history_service_factory.h"
36 #include "chrome/browser/history/shortcuts_backend.h" 36 #include "chrome/browser/history/shortcuts_backend.h"
37 #include "chrome/browser/history/shortcuts_backend_factory.h" 37 #include "chrome/browser/history/shortcuts_backend_factory.h"
38 #include "chrome/browser/history/top_sites.h" 38 #include "chrome/browser/history/top_sites.h"
39 #include "chrome/browser/history/web_history_service_factory.h" 39 #include "chrome/browser/history/web_history_service_factory.h"
40 #include "chrome/browser/net/cookie_store_util.h"
40 #include "chrome/browser/net/pref_proxy_config_tracker.h" 41 #include "chrome/browser/net/pref_proxy_config_tracker.h"
41 #include "chrome/browser/net/proxy_service_factory.h" 42 #include "chrome/browser/net/proxy_service_factory.h"
42 #include "chrome/browser/notifications/desktop_notification_service.h" 43 #include "chrome/browser/notifications/desktop_notification_service.h"
43 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 44 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
44 #include "chrome/browser/policy/profile_policy_connector.h" 45 #include "chrome/browser/policy/profile_policy_connector.h"
45 #include "chrome/browser/policy/profile_policy_connector_factory.h" 46 #include "chrome/browser/policy/profile_policy_connector_factory.h"
46 #include "chrome/browser/prefs/browser_prefs.h" 47 #include "chrome/browser/prefs/browser_prefs.h"
47 #include "chrome/browser/prefs/pref_service_syncable.h" 48 #include "chrome/browser/prefs/pref_service_syncable.h"
48 #include "chrome/browser/prerender/prerender_manager.h" 49 #include "chrome/browser/prerender/prerender_manager.h"
49 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" 50 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
50 #include "chrome/browser/profiles/storage_partition_descriptor.h" 51 #include "chrome/browser/profiles/storage_partition_descriptor.h"
51 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 52 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
52 #include "chrome/browser/webdata/web_data_service.h" 53 #include "chrome/browser/webdata/web_data_service.h"
53 #include "chrome/browser/webdata/web_data_service_factory.h" 54 #include "chrome/browser/webdata/web_data_service_factory.h"
54 #include "chrome/common/chrome_constants.h" 55 #include "chrome/common/chrome_constants.h"
55 #include "chrome/common/chrome_switches.h" 56 #include "chrome/common/chrome_switches.h"
56 #include "chrome/common/pref_names.h" 57 #include "chrome/common/pref_names.h"
57 #include "chrome/common/url_constants.h" 58 #include "chrome/common/url_constants.h"
58 #include "chrome/test/base/bookmark_load_observer.h" 59 #include "chrome/test/base/bookmark_load_observer.h"
59 #include "chrome/test/base/history_index_restore_observer.h" 60 #include "chrome/test/base/history_index_restore_observer.h"
60 #include "chrome/test/base/testing_pref_service_syncable.h" 61 #include "chrome/test/base/testing_pref_service_syncable.h"
61 #include "chrome/test/base/ui_test_utils.h" 62 #include "chrome/test/base/ui_test_utils.h"
62 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 63 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
63 #include "components/user_prefs/user_prefs.h" 64 #include "components/user_prefs/user_prefs.h"
64 #include "content/public/browser/browser_thread.h" 65 #include "content/public/browser/browser_thread.h"
66 #include "content/public/browser/cookie_store_factory.h"
65 #include "content/public/browser/notification_service.h" 67 #include "content/public/browser/notification_service.h"
66 #include "content/public/browser/render_process_host.h" 68 #include "content/public/browser/render_process_host.h"
67 #include "content/public/browser/storage_partition.h" 69 #include "content/public/browser/storage_partition.h"
68 #include "content/public/test/mock_resource_context.h" 70 #include "content/public/test/mock_resource_context.h"
69 #include "content/public/test/test_utils.h" 71 #include "content/public/test/test_utils.h"
70 #include "extensions/common/constants.h" 72 #include "extensions/common/constants.h"
71 #include "net/cookies/cookie_monster.h" 73 #include "net/cookies/cookie_monster.h"
72 #include "net/url_request/url_request_context.h" 74 #include "net/url_request/url_request_context.h"
73 #include "net/url_request/url_request_context_getter.h" 75 #include "net/url_request/url_request_context_getter.h"
74 #include "net/url_request/url_request_test_util.h" 76 #include "net/url_request/url_request_test_util.h"
(...skipping 29 matching lines...) Expand all
104 virtual void DoneRunOnMainThread() OVERRIDE { 106 virtual void DoneRunOnMainThread() OVERRIDE {
105 base::MessageLoop::current()->Quit(); 107 base::MessageLoop::current()->Quit();
106 } 108 }
107 109
108 private: 110 private:
109 virtual ~QuittingHistoryDBTask() {} 111 virtual ~QuittingHistoryDBTask() {}
110 112
111 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask); 113 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask);
112 }; 114 };
113 115
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( 116 BrowserContextKeyedService* CreateTestDesktopNotificationService(
147 content::BrowserContext* profile) { 117 content::BrowserContext* profile) {
148 #if defined(ENABLE_NOTIFICATIONS) 118 #if defined(ENABLE_NOTIFICATIONS)
149 return new DesktopNotificationService(static_cast<Profile*>(profile), NULL); 119 return new DesktopNotificationService(static_cast<Profile*>(profile), NULL);
150 #else 120 #else
151 return NULL; 121 return NULL;
152 #endif 122 #endif
153 } 123 }
154 124
155 } // namespace 125 } // namespace
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 extension_special_storage_policy_ = extension_special_storage_policy; 555 extension_special_storage_policy_ = extension_special_storage_policy;
586 } 556 }
587 557
588 ExtensionSpecialStoragePolicy* 558 ExtensionSpecialStoragePolicy*
589 TestingProfile::GetExtensionSpecialStoragePolicy() { 559 TestingProfile::GetExtensionSpecialStoragePolicy() {
590 if (!extension_special_storage_policy_.get()) 560 if (!extension_special_storage_policy_.get())
591 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL); 561 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL);
592 return extension_special_storage_policy_.get(); 562 return extension_special_storage_policy_.get();
593 } 563 }
594 564
595 net::CookieMonster* TestingProfile::GetCookieMonster() {
596 if (!GetRequestContext())
597 return NULL;
598 return GetRequestContext()->GetURLRequestContext()->cookie_store()->
599 GetCookieMonster();
600 }
601
602 void TestingProfile::CreateTestingPrefService() { 565 void TestingProfile::CreateTestingPrefService() {
603 DCHECK(!prefs_.get()); 566 DCHECK(!prefs_.get());
604 testing_prefs_ = new TestingPrefServiceSyncable(); 567 testing_prefs_ = new TestingPrefServiceSyncable();
605 prefs_.reset(testing_prefs_); 568 prefs_.reset(testing_prefs_);
606 user_prefs::UserPrefs::Set(this, prefs_.get()); 569 user_prefs::UserPrefs::Set(this, prefs_.get());
607 chrome::RegisterUserProfilePrefs(testing_prefs_->registry()); 570 chrome::RegisterUserProfilePrefs(testing_prefs_->registry());
608 } 571 }
609 572
610 void TestingProfile::CreateProfilePolicyConnector() { 573 void TestingProfile::CreateProfilePolicyConnector() {
611 scoped_ptr<policy::PolicyService> service; 574 scoped_ptr<policy::PolicyService> service;
(...skipping 24 matching lines...) Expand all
636 } 599 }
637 600
638 history::TopSites* TestingProfile::GetTopSitesWithoutCreating() { 601 history::TopSites* TestingProfile::GetTopSitesWithoutCreating() {
639 return top_sites_.get(); 602 return top_sites_.get();
640 } 603 }
641 604
642 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() { 605 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() {
643 return NULL; 606 return NULL;
644 } 607 }
645 608
609 void TestingProfile::OverrideCookieStoreConfigs(
610 const base::FilePath& partition_path,
611 bool in_memory_partition,
612 bool is_default_partition,
613 CookieSchemeMap* configs) {
614 // Force this to be in-memory.
615 chrome_browser_net::SetCookieStoreConfigs(
616 base::FilePath(), true, is_default_partition,
617 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
618 GetSpecialStoragePolicy(), NULL, configs);
619 }
620
646 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { 621 net::URLRequestContextGetter* TestingProfile::GetRequestContext() {
647 return GetDefaultStoragePartition(this)->GetURLRequestContext(); 622 return GetDefaultStoragePartition(this)->GetURLRequestContext();
648 } 623 }
649 624
650 net::URLRequestContextGetter* TestingProfile::CreateRequestContext( 625 net::URLRequestContextGetter* TestingProfile::CreateRequestContext(
651 content::ProtocolHandlerMap* protocol_handlers) { 626 content::ProtocolHandlerMap* protocol_handlers) {
652 return new net::TestURLRequestContextGetter( 627 return new net::TestURLRequestContextGetter(
653 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 628 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
654 } 629 }
655 630
(...skipping 23 matching lines...) Expand all
679 654
680 void TestingProfile::RequestMIDISysExPermission( 655 void TestingProfile::RequestMIDISysExPermission(
681 int render_process_id, 656 int render_process_id,
682 int render_view_id, 657 int render_view_id,
683 const GURL& requesting_frame, 658 const GURL& requesting_frame,
684 const MIDISysExPermissionCallback& callback) { 659 const MIDISysExPermissionCallback& callback) {
685 // Always reject requests for testing. 660 // Always reject requests for testing.
686 callback.Run(false); 661 callback.Run(false);
687 } 662 }
688 663
689 net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() {
690 if (!extensions_request_context_.get())
691 extensions_request_context_ = new TestExtensionURLRequestContextGetter();
692 return extensions_request_context_.get();
693 }
694
695 net::SSLConfigService* TestingProfile::GetSSLConfigService() { 664 net::SSLConfigService* TestingProfile::GetSSLConfigService() {
696 if (!GetRequestContext()) 665 if (!GetRequestContext())
697 return NULL; 666 return NULL;
698 return GetRequestContext()->GetURLRequestContext()->ssl_config_service(); 667 return GetRequestContext()->GetURLRequestContext()->ssl_config_service();
699 } 668 }
700 669
701 net::URLRequestContextGetter* 670 net::URLRequestContextGetter*
702 TestingProfile::CreateRequestContextForStoragePartition( 671 TestingProfile::CreateRequestContextForStoragePartition(
703 const base::FilePath& partition_path, 672 const base::FilePath& partition_path,
704 bool in_memory, 673 bool in_memory,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 DCHECK(!build_called_); 825 DCHECK(!build_called_);
857 build_called_ = true; 826 build_called_ = true;
858 return scoped_ptr<TestingProfile>(new TestingProfile( 827 return scoped_ptr<TestingProfile>(new TestingProfile(
859 path_, 828 path_,
860 delegate_, 829 delegate_,
861 extension_policy_, 830 extension_policy_,
862 pref_service_.Pass(), 831 pref_service_.Pass(),
863 incognito_, 832 incognito_,
864 testing_factories_)); 833 testing_factories_));
865 } 834 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698