| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.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/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| 15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" | 15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" |
| 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" | 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
| 17 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" | 17 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" |
| 18 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h
" | 18 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h
" |
| 19 #include "components/data_reduction_proxy/common/version.h" | 19 #include "components/data_reduction_proxy/common/version.h" |
| 20 #include "crypto/random.h" | 20 #include "crypto/random.h" |
| 21 #include "google_apis/google_api_keys.h" |
| 21 #include "net/base/host_port_pair.h" | 22 #include "net/base/host_port_pair.h" |
| 22 #include "net/proxy/proxy_server.h" | 23 #include "net/proxy/proxy_server.h" |
| 23 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 25 | 26 |
| 26 namespace data_reduction_proxy { | 27 namespace data_reduction_proxy { |
| 27 | 28 |
| 28 // The empty version for the authentication protocol. Currently used by | 29 // The empty version for the authentication protocol. Currently used by |
| 29 // Android webview. | 30 // Android webview. |
| 30 #if defined(OS_ANDROID) | 31 #if defined(OS_ANDROID) |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 211 } |
| 211 | 212 |
| 212 std::string DataReductionProxyAuthRequestHandler::GetDefaultKey() const { | 213 std::string DataReductionProxyAuthRequestHandler::GetDefaultKey() const { |
| 213 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 214 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 214 std::string key = | 215 std::string key = |
| 215 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey); | 216 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey); |
| 216 #if defined(SPDY_PROXY_AUTH_VALUE) | 217 #if defined(SPDY_PROXY_AUTH_VALUE) |
| 217 if (key.empty()) | 218 if (key.empty()) |
| 218 key = SPDY_PROXY_AUTH_VALUE; | 219 key = SPDY_PROXY_AUTH_VALUE; |
| 219 #endif | 220 #endif |
| 221 if (key.empty()) { |
| 222 key = google_apis::GetSpdyProxyAuthValue(); |
| 223 } |
| 220 return key; | 224 return key; |
| 221 } | 225 } |
| 222 | 226 |
| 223 void DataReductionProxyAuthRequestHandler::MaybeAddRequestHeaderImpl( | 227 void DataReductionProxyAuthRequestHandler::MaybeAddRequestHeaderImpl( |
| 224 const net::HostPortPair& proxy_server, | 228 const net::HostPortPair& proxy_server, |
| 225 bool expect_ssl, | 229 bool expect_ssl, |
| 226 net::HttpRequestHeaders* request_headers) { | 230 net::HttpRequestHeaders* request_headers) { |
| 227 if (proxy_server.IsEmpty()) | 231 if (proxy_server.IsEmpty()) |
| 228 return; | 232 return; |
| 229 if (data_reduction_proxy_params_ && | 233 if (data_reduction_proxy_params_ && |
| 230 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) && | 234 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) && |
| 231 net::HostPortPair::FromURL( | 235 net::HostPortPair::FromURL( |
| 232 data_reduction_proxy_params_->ssl_origin()).Equals( | 236 data_reduction_proxy_params_->ssl_origin()).Equals( |
| 233 proxy_server) == expect_ssl) { | 237 proxy_server) == expect_ssl) { |
| 234 AddAuthorizationHeader(request_headers); | 238 AddAuthorizationHeader(request_headers); |
| 235 } | 239 } |
| 236 } | 240 } |
| 237 | 241 |
| 238 } // namespace data_reduction_proxy | 242 } // namespace data_reduction_proxy |
| OLD | NEW |