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

Side by Side Diff: content/shell/shell_browser_context.cc

Issue 11308362: Add StoragePartition's ProtocolHandlers at URLRequestContext construction time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Eliminate OffTheRecordProfileIOData::Handle::GetMainRequestContextGetter Created 7 years, 11 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 "content/shell/shell_browser_context.h" 5 #include "content/shell/shell_browser_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/storage_partition.h"
16 #include "content/public/common/content_switches.h"
15 #include "content/shell/shell_download_manager_delegate.h" 17 #include "content/shell/shell_download_manager_delegate.h"
16 #include "content/shell/shell_resource_context.h" 18 #include "content/shell/shell_resource_context.h"
17 #include "content/shell/shell_switches.h" 19 #include "content/shell/shell_switches.h"
18 #include "content/shell/shell_url_request_context_getter.h" 20 #include "content/shell/shell_url_request_context_getter.h"
19 #include "content/public/common/content_switches.h"
20 21
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 #include "base/base_paths_win.h" 23 #include "base/base_paths_win.h"
23 #elif defined(OS_LINUX) 24 #elif defined(OS_LINUX)
24 #include "base/nix/xdg_util.h" 25 #include "base/nix/xdg_util.h"
25 #elif defined(OS_MACOSX) 26 #elif defined(OS_MACOSX)
26 #include "base/base_paths_mac.h" 27 #include "base/base_paths_mac.h"
27 #endif 28 #endif
28 29
29 namespace content { 30 namespace content {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (cmd_line->HasSwitch(switches::kDumpRenderTree)) { 94 if (cmd_line->HasSwitch(switches::kDumpRenderTree)) {
94 download_manager_delegate_->SetDownloadBehaviorForTesting( 95 download_manager_delegate_->SetDownloadBehaviorForTesting(
95 path_.Append(FILE_PATH_LITERAL("downloads"))); 96 path_.Append(FILE_PATH_LITERAL("downloads")));
96 } 97 }
97 } 98 }
98 99
99 return download_manager_delegate_.get(); 100 return download_manager_delegate_.get();
100 } 101 }
101 102
102 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { 103 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() {
103 if (!url_request_getter_) { 104 content::StoragePartition* storage_partition =
mmenke 2013/01/25 18:38:58 nit: content not needed.
104 url_request_getter_ = new ShellURLRequestContextGetter( 105 BrowserContext::GetStoragePartition(this, NULL);
105 ignore_certificate_errors_, 106 return storage_partition->GetURLRequestContext();
106 GetPath(), 107 }
107 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), 108
108 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE)); 109 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
109 } 110 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
110 return url_request_getter_; 111 blob_protocol_handler,
112 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
113 file_system_protocol_handler,
114 scoped_ptr<net::URLRequestJobFactory::Interceptor>
115 developer_protocol_handler) {
116 DCHECK(!url_request_getter_);
117 url_request_getter_ = new ShellURLRequestContextGetter(
118 ignore_certificate_errors_,
119 GetPath(),
120 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
121 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
122 blob_protocol_handler.Pass(),
123 file_system_protocol_handler.Pass(),
124 developer_protocol_handler.Pass());
125 return url_request_getter_.get();
111 } 126 }
112 127
113 net::URLRequestContextGetter* 128 net::URLRequestContextGetter*
114 ShellBrowserContext::GetRequestContextForRenderProcess( 129 ShellBrowserContext::GetRequestContextForRenderProcess(
115 int renderer_child_id) { 130 int renderer_child_id) {
116 return GetRequestContext(); 131 return GetRequestContext();
117 } 132 }
118 133
119 net::URLRequestContextGetter* 134 net::URLRequestContextGetter*
120 ShellBrowserContext::GetMediaRequestContext() { 135 ShellBrowserContext::GetMediaRequestContext() {
121 return GetRequestContext(); 136 return GetRequestContext();
122 } 137 }
123 138
124 net::URLRequestContextGetter* 139 net::URLRequestContextGetter*
125 ShellBrowserContext::GetMediaRequestContextForRenderProcess( 140 ShellBrowserContext::GetMediaRequestContextForRenderProcess(
126 int renderer_child_id) { 141 int renderer_child_id) {
127 return GetRequestContext(); 142 return GetRequestContext();
128 } 143 }
129 144
130 net::URLRequestContextGetter* 145 net::URLRequestContextGetter*
131 ShellBrowserContext::GetMediaRequestContextForStoragePartition( 146 ShellBrowserContext::GetMediaRequestContextForStoragePartition(
132 const FilePath& partition_path, 147 const FilePath& partition_path,
133 bool in_memory) { 148 bool in_memory) {
134 return GetRequestContext(); 149 return GetRequestContext();
135 } 150 }
136 151
137 net::URLRequestContextGetter* 152 net::URLRequestContextGetter*
138 ShellBrowserContext::GetRequestContextForStoragePartition( 153 ShellBrowserContext::CreateRequestContextForStoragePartition(
139 const FilePath& partition_path, 154 const FilePath& partition_path,
140 bool in_memory) { 155 bool in_memory,
156 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
157 blob_protocol_handler,
158 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
159 file_system_protocol_handler,
160 scoped_ptr<net::URLRequestJobFactory::Interceptor>
161 developer_protocol_handler) {
141 return NULL; 162 return NULL;
142 } 163 }
143 164
144 ResourceContext* ShellBrowserContext::GetResourceContext() { 165 ResourceContext* ShellBrowserContext::GetResourceContext() {
145 if (!resource_context_.get()) { 166 if (!resource_context_) {
146 resource_context_.reset(new ShellResourceContext( 167 ShellURLRequestContextGetter* getter =
147 static_cast<ShellURLRequestContextGetter*>(GetRequestContext()))); 168 static_cast<ShellURLRequestContextGetter*>(GetRequestContext());
169 if (!resource_context_)
170 resource_context_.reset(new ShellResourceContext(getter));
148 } 171 }
149 return resource_context_.get(); 172 return resource_context_.get();
150 } 173 }
151 174
152 GeolocationPermissionContext* 175 GeolocationPermissionContext*
153 ShellBrowserContext::GetGeolocationPermissionContext() { 176 ShellBrowserContext::GetGeolocationPermissionContext() {
154 return NULL; 177 return NULL;
155 } 178 }
156 179
157 SpeechRecognitionPreferences* 180 SpeechRecognitionPreferences*
158 ShellBrowserContext::GetSpeechRecognitionPreferences() { 181 ShellBrowserContext::GetSpeechRecognitionPreferences() {
159 return NULL; 182 return NULL;
160 } 183 }
161 184
162 quota::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { 185 quota::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() {
163 return NULL; 186 return NULL;
164 } 187 }
165 188
166 } // namespace content 189 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698