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 | |
122 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { | 117 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { |
123 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 118 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
124 | 119 |
125 if (!url_request_context_) { | 120 if (!url_request_context_) { |
126 const base::CommandLine& command_line = | 121 const base::CommandLine& command_line = |
127 *base::CommandLine::ForCurrentProcess(); | 122 *base::CommandLine::ForCurrentProcess(); |
128 | 123 |
129 url_request_context_.reset(new net::URLRequestContext()); | 124 url_request_context_.reset(new net::URLRequestContext()); |
130 url_request_context_->set_net_log(net_log_); | 125 url_request_context_->set_net_log(net_log_); |
131 network_delegate_ = CreateNetworkDelegate(); | 126 network_delegate_ = CreateNetworkDelegate(); |
132 url_request_context_->set_network_delegate(network_delegate_.get()); | 127 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()); | |
137 storage_.reset( | 128 storage_.reset( |
138 new net::URLRequestContextStorage(url_request_context_.get())); | 129 new net::URLRequestContextStorage(url_request_context_.get())); |
139 storage_->set_cookie_store(CreateCookieStore(CookieStoreConfig())); | 130 storage_->set_cookie_store(CreateCookieStore(CookieStoreConfig())); |
140 storage_->set_channel_id_service(base::WrapUnique( | 131 storage_->set_channel_id_service(base::WrapUnique( |
141 new net::ChannelIDService(new net::DefaultChannelIDStore(NULL), | 132 new net::ChannelIDService(new net::DefaultChannelIDStore(NULL), |
142 base::WorkerPool::GetTaskRunner(true)))); | 133 base::WorkerPool::GetTaskRunner(true)))); |
143 storage_->set_http_user_agent_settings(base::WrapUnique( | 134 storage_->set_http_user_agent_settings(base::WrapUnique( |
144 new net::StaticHttpUserAgentSettings("en-us,en", GetShellUserAgent()))); | 135 new net::StaticHttpUserAgentSettings("en-us,en", GetShellUserAgent()))); |
145 | 136 |
146 std::unique_ptr<net::HostResolver> host_resolver( | 137 std::unique_ptr<net::HostResolver> host_resolver( |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 scoped_refptr<base::SingleThreadTaskRunner> | 258 scoped_refptr<base::SingleThreadTaskRunner> |
268 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { | 259 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { |
269 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 260 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
270 } | 261 } |
271 | 262 |
272 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { | 263 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
273 return url_request_context_->host_resolver(); | 264 return url_request_context_->host_resolver(); |
274 } | 265 } |
275 | 266 |
276 } // namespace content | 267 } // namespace content |
OLD | NEW |