OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/shell_url_request_context_getter.h" | 5 #include "content/shell/browser/shell_url_request_context_getter.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 file_task_runner_); | 107 file_task_runner_); |
108 } | 108 } |
109 | 109 |
110 std::unique_ptr<net::ProxyService> | 110 std::unique_ptr<net::ProxyService> |
111 ShellURLRequestContextGetter::GetProxyService() { | 111 ShellURLRequestContextGetter::GetProxyService() { |
112 // TODO(jam): use v8 if possible, look at chrome code. | 112 // TODO(jam): use v8 if possible, look at chrome code. |
113 return net::ProxyService::CreateUsingSystemProxyResolver( | 113 return net::ProxyService::CreateUsingSystemProxyResolver( |
114 std::move(proxy_config_service_), 0, url_request_context_->net_log()); | 114 std::move(proxy_config_service_), 0, url_request_context_->net_log()); |
115 } | 115 } |
116 | 116 |
| 117 bool ShellURLRequestContextGetter::ShouldEnableReferrerPolicyHeader() { |
| 118 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 119 switches::kEnableExperimentalWebPlatformFeatures); |
| 120 } |
| 121 |
117 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { | 122 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { |
118 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 123 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
119 | 124 |
120 if (!url_request_context_) { | 125 if (!url_request_context_) { |
121 const base::CommandLine& command_line = | 126 const base::CommandLine& command_line = |
122 *base::CommandLine::ForCurrentProcess(); | 127 *base::CommandLine::ForCurrentProcess(); |
123 | 128 |
124 url_request_context_.reset(new net::URLRequestContext()); | 129 url_request_context_.reset(new net::URLRequestContext()); |
125 url_request_context_->set_net_log(net_log_); | 130 url_request_context_->set_net_log(net_log_); |
126 network_delegate_ = CreateNetworkDelegate(); | 131 network_delegate_ = CreateNetworkDelegate(); |
127 url_request_context_->set_network_delegate(network_delegate_.get()); | 132 url_request_context_->set_network_delegate(network_delegate_.get()); |
| 133 // TODO(estark): Remove this once the Referrer-Policy header is no |
| 134 // longer an experimental feature. https://crbug.com/619228 |
| 135 url_request_context_->set_enable_referrer_policy_header( |
| 136 ShouldEnableReferrerPolicyHeader()); |
128 storage_.reset( | 137 storage_.reset( |
129 new net::URLRequestContextStorage(url_request_context_.get())); | 138 new net::URLRequestContextStorage(url_request_context_.get())); |
130 storage_->set_cookie_store(CreateCookieStore(CookieStoreConfig())); | 139 storage_->set_cookie_store(CreateCookieStore(CookieStoreConfig())); |
131 storage_->set_channel_id_service(base::WrapUnique( | 140 storage_->set_channel_id_service(base::WrapUnique( |
132 new net::ChannelIDService(new net::DefaultChannelIDStore(NULL), | 141 new net::ChannelIDService(new net::DefaultChannelIDStore(NULL), |
133 base::WorkerPool::GetTaskRunner(true)))); | 142 base::WorkerPool::GetTaskRunner(true)))); |
134 storage_->set_http_user_agent_settings(base::WrapUnique( | 143 storage_->set_http_user_agent_settings(base::WrapUnique( |
135 new net::StaticHttpUserAgentSettings("en-us,en", GetShellUserAgent()))); | 144 new net::StaticHttpUserAgentSettings("en-us,en", GetShellUserAgent()))); |
136 | 145 |
137 std::unique_ptr<net::HostResolver> host_resolver( | 146 std::unique_ptr<net::HostResolver> host_resolver( |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 scoped_refptr<base::SingleThreadTaskRunner> | 267 scoped_refptr<base::SingleThreadTaskRunner> |
259 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { | 268 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { |
260 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 269 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
261 } | 270 } |
262 | 271 |
263 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { | 272 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
264 return url_request_context_->host_resolver(); | 273 return url_request_context_->host_resolver(); |
265 } | 274 } |
266 | 275 |
267 } // namespace content | 276 } // namespace content |
OLD | NEW |