| 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/core/browser/data_reduction_proxy_auth
_request_handler.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth
_request_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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 switch (client) { | 41 switch (client) { |
| 42 CLIENT_ENUMS_LIST | 42 CLIENT_ENUMS_LIST |
| 43 } | 43 } |
| 44 NOTREACHED(); | 44 NOTREACHED(); |
| 45 return ""; | 45 return ""; |
| 46 } | 46 } |
| 47 #undef CLIENT_ENUM | 47 #undef CLIENT_ENUM |
| 48 | 48 |
| 49 // static | 49 // static |
| 50 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() { | 50 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() { |
| 51 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 51 const base::CommandLine& command_line = |
| 52 *base::CommandLine::ForCurrentProcess(); |
| 52 return command_line.HasSwitch( | 53 return command_line.HasSwitch( |
| 53 data_reduction_proxy::switches::kDataReductionProxyKey); | 54 data_reduction_proxy::switches::kDataReductionProxyKey); |
| 54 } | 55 } |
| 55 | 56 |
| 56 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( | 57 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( |
| 57 Client client, | 58 Client client, |
| 58 DataReductionProxyParams* params, | 59 DataReductionProxyParams* params, |
| 59 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) | 60 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) |
| 60 : client_(GetString(client)), | 61 : client_(GetString(client)), |
| 61 data_reduction_proxy_params_(params), | 62 data_reduction_proxy_params_(params), |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 208 |
| 208 if (key.empty()) | 209 if (key.empty()) |
| 209 return; | 210 return; |
| 210 | 211 |
| 211 key_ = key; | 212 key_ = key; |
| 212 last_update_time_ = Now(); | 213 last_update_time_ = Now(); |
| 213 ComputeCredentials(last_update_time_, &session_, &credentials_); | 214 ComputeCredentials(last_update_time_, &session_, &credentials_); |
| 214 } | 215 } |
| 215 | 216 |
| 216 std::string DataReductionProxyAuthRequestHandler::GetDefaultKey() const { | 217 std::string DataReductionProxyAuthRequestHandler::GetDefaultKey() const { |
| 217 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 218 const base::CommandLine& command_line = |
| 219 *base::CommandLine::ForCurrentProcess(); |
| 218 std::string key = | 220 std::string key = |
| 219 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey); | 221 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey); |
| 220 // Android and iOS get the default key from a preprocessor constant. All other | 222 // Android and iOS get the default key from a preprocessor constant. All other |
| 221 // platforms get the key from google_apis | 223 // platforms get the key from google_apis |
| 222 #if defined(OS_ANDROID) || defined(OS_IOS) | 224 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 223 #if defined(SPDY_PROXY_AUTH_VALUE) | 225 #if defined(SPDY_PROXY_AUTH_VALUE) |
| 224 if (key.empty()) | 226 if (key.empty()) |
| 225 key = SPDY_PROXY_AUTH_VALUE; | 227 key = SPDY_PROXY_AUTH_VALUE; |
| 226 #endif | 228 #endif |
| 227 #else | 229 #else |
| (...skipping 13 matching lines...) Expand all Loading... |
| 241 if (data_reduction_proxy_params_ && | 243 if (data_reduction_proxy_params_ && |
| 242 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) && | 244 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) && |
| 243 net::HostPortPair::FromURL( | 245 net::HostPortPair::FromURL( |
| 244 data_reduction_proxy_params_->ssl_origin()).Equals( | 246 data_reduction_proxy_params_->ssl_origin()).Equals( |
| 245 proxy_server) == expect_ssl) { | 247 proxy_server) == expect_ssl) { |
| 246 AddAuthorizationHeader(request_headers); | 248 AddAuthorizationHeader(request_headers); |
| 247 } | 249 } |
| 248 } | 250 } |
| 249 | 251 |
| 250 } // namespace data_reduction_proxy | 252 } // namespace data_reduction_proxy |
| OLD | NEW |