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 "content/shell/shell_url_request_context_getter.h" | 5 #include "content/shell/shell_url_request_context_getter.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
15 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
16 #include "content/shell/shell_network_delegate.h" | 16 #include "content/shell/shell_network_delegate.h" |
17 #include "content/shell/shell_switches.h" | 17 #include "content/shell/shell_switches.h" |
18 #include "net/base/cert_verifier.h" | 18 #include "net/base/cert_verifier.h" |
19 #include "net/base/default_server_bound_cert_store.h" | 19 #include "net/base/default_server_bound_cert_store.h" |
20 #include "net/base/host_resolver.h" | 20 #include "net/base/host_resolver.h" |
21 #include "net/base/mapped_host_resolver.h" | 21 #include "net/base/mapped_host_resolver.h" |
22 #include "net/base/server_bound_cert_service.h" | 22 #include "net/base/server_bound_cert_service.h" |
23 #include "net/base/ssl_config_service_defaults.h" | 23 #include "net/base/ssl_config_service_defaults.h" |
24 #include "net/cookies/cookie_monster.h" | 24 #include "net/cookies/cookie_monster.h" |
25 #include "net/http/http_auth_handler_factory.h" | 25 #include "net/http/http_auth_handler_factory.h" |
26 #include "net/http/http_cache.h" | 26 #include "net/http/http_cache.h" |
27 #include "net/http/http_network_session.h" | 27 #include "net/http/http_network_session.h" |
28 #include "net/http/http_server_properties_impl.h" | 28 #include "net/http/http_server_properties_impl.h" |
29 #include "net/proxy/proxy_service.h" | 29 #include "net/proxy/proxy_service.h" |
| 30 #include "net/url_request/data_protocol_handler.h" |
| 31 #include "net/url_request/file_protocol_handler.h" |
30 #include "net/url_request/protocol_intercept_job_factory.h" | 32 #include "net/url_request/protocol_intercept_job_factory.h" |
31 #include "net/url_request/static_http_user_agent_settings.h" | 33 #include "net/url_request/static_http_user_agent_settings.h" |
32 #include "net/url_request/url_request_context.h" | 34 #include "net/url_request/url_request_context.h" |
33 #include "net/url_request/url_request_context_storage.h" | 35 #include "net/url_request/url_request_context_storage.h" |
34 #include "net/url_request/url_request_job_factory_impl.h" | 36 #include "net/url_request/url_request_job_factory_impl.h" |
35 | 37 |
36 namespace content { | 38 namespace content { |
37 | 39 |
38 ShellURLRequestContextGetter::ShellURLRequestContextGetter( | 40 ShellURLRequestContextGetter::ShellURLRequestContextGetter( |
39 bool ignore_certificate_errors, | 41 bool ignore_certificate_errors, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 storage_->set_host_resolver(host_resolver.Pass()); | 166 storage_->set_host_resolver(host_resolver.Pass()); |
165 network_session_params.host_resolver = | 167 network_session_params.host_resolver = |
166 url_request_context_->host_resolver(); | 168 url_request_context_->host_resolver(); |
167 | 169 |
168 net::HttpCache* main_cache = new net::HttpCache( | 170 net::HttpCache* main_cache = new net::HttpCache( |
169 network_session_params, main_backend); | 171 network_session_params, main_backend); |
170 storage_->set_http_transaction_factory(main_cache); | 172 storage_->set_http_transaction_factory(main_cache); |
171 | 173 |
172 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 174 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
173 new net::URLRequestJobFactoryImpl()); | 175 new net::URLRequestJobFactoryImpl()); |
| 176 // Keep ProtocolHandlers added in sync with |
| 177 // ShellContentBrowserClient::IsHandledURL(). |
174 bool set_protocol = job_factory->SetProtocolHandler( | 178 bool set_protocol = job_factory->SetProtocolHandler( |
175 chrome::kBlobScheme, blob_protocol_handler_.release()); | 179 chrome::kBlobScheme, blob_protocol_handler_.release()); |
176 DCHECK(set_protocol); | 180 DCHECK(set_protocol); |
177 set_protocol = job_factory->SetProtocolHandler( | 181 set_protocol = job_factory->SetProtocolHandler( |
178 chrome::kFileSystemScheme, file_system_protocol_handler_.release()); | 182 chrome::kFileSystemScheme, file_system_protocol_handler_.release()); |
179 DCHECK(set_protocol); | 183 DCHECK(set_protocol); |
180 set_protocol = job_factory->SetProtocolHandler( | 184 set_protocol = job_factory->SetProtocolHandler( |
181 chrome::kChromeUIScheme, chrome_protocol_handler_.release()); | 185 chrome::kChromeUIScheme, chrome_protocol_handler_.release()); |
182 DCHECK(set_protocol); | 186 DCHECK(set_protocol); |
183 set_protocol = job_factory->SetProtocolHandler( | 187 set_protocol = job_factory->SetProtocolHandler( |
184 chrome::kChromeDevToolsScheme, | 188 chrome::kChromeDevToolsScheme, |
185 chrome_devtools_protocol_handler_.release()); | 189 chrome_devtools_protocol_handler_.release()); |
186 DCHECK(set_protocol); | 190 DCHECK(set_protocol); |
| 191 set_protocol = job_factory->SetProtocolHandler( |
| 192 chrome::kDataScheme, |
| 193 new net::DataProtocolHandler); |
| 194 DCHECK(set_protocol); |
| 195 set_protocol = job_factory->SetProtocolHandler( |
| 196 chrome::kFileScheme, |
| 197 new net::FileProtocolHandler); |
| 198 DCHECK(set_protocol); |
187 storage_->set_job_factory(new net::ProtocolInterceptJobFactory( | 199 storage_->set_job_factory(new net::ProtocolInterceptJobFactory( |
188 job_factory.PassAs<net::URLRequestJobFactory>(), | 200 job_factory.PassAs<net::URLRequestJobFactory>(), |
189 developer_protocol_handler_.Pass())); | 201 developer_protocol_handler_.Pass())); |
190 } | 202 } |
191 | 203 |
192 return url_request_context_.get(); | 204 return url_request_context_.get(); |
193 } | 205 } |
194 | 206 |
195 scoped_refptr<base::SingleThreadTaskRunner> | 207 scoped_refptr<base::SingleThreadTaskRunner> |
196 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { | 208 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { |
197 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 209 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
198 } | 210 } |
199 | 211 |
200 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { | 212 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
201 return url_request_context_->host_resolver(); | 213 return url_request_context_->host_resolver(); |
202 } | 214 } |
203 | 215 |
204 } // namespace content | 216 } // namespace content |
OLD | NEW |