Chromium Code Reviews| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 11 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| 12 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" | 12 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" |
| 13 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" | 13 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" |
| 14 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" | 14 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" |
| 15 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " | 15 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " |
| 16 #include "crypto/random.h" | 16 #include "crypto/random.h" |
| 17 #include "net/proxy/proxy_server.h" | 17 #include "net/proxy/proxy_server.h" |
| 18 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 namespace data_reduction_proxy { | 21 namespace data_reduction_proxy { |
| 22 | 22 |
| 23 // The version of the authentication protocol. | |
| 24 const char kProtocolVersion[] = "0"; | |
| 25 | |
| 26 // The clients supported by the data reduction proxy. | 23 // The clients supported by the data reduction proxy. |
| 27 const char kClientAndroidWebview[] = "webview"; | 24 const char kClientAndroidWebview[] = "webview"; |
| 28 const char kClientChromeAndroid[] = "android"; | 25 const char kClientChromeAndroid[] = "android"; |
| 29 const char kClientChromeIOS[] = "ios"; | 26 const char kClientChromeIOS[] = "ios"; |
| 30 | 27 |
| 31 // static | 28 // static |
| 32 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() { | 29 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() { |
| 33 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 30 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 34 return command_line.HasSwitch( | 31 return command_line.HasSwitch( |
| 35 data_reduction_proxy::switches::kDataReductionProxyKey); | 32 data_reduction_proxy::switches::kDataReductionProxyKey); |
| 36 } | 33 } |
| 37 | 34 |
| 38 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( | 35 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( |
| 39 DataReductionProxyParams* params) | 36 DataReductionProxyParams* params, std::string version) |
| 40 : data_reduction_proxy_params_(params) { | 37 : data_reduction_proxy_params_(params) { |
| 41 version_ = kProtocolVersion; | 38 // The data reduction proxy only needs the build and patch number for the |
| 39 // version. | |
| 40 version_ = version.substr(version.find(".")).substr(version.find(".") + 1); | |
|
bengr
2014/07/30 00:16:47
Use SplitString. See: https://code.google.com/p/ch
megjablon
2014/07/30 20:37:17
Done.
| |
| 42 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 43 client_ = kClientChromeAndroid; | 42 client_ = kClientChromeAndroid; |
| 44 #elif defined(OS_IOS) | 43 #elif defined(OS_IOS) |
| 45 client_ = kClientChromeIOS; | 44 client_ = kClientChromeIOS; |
| 46 #endif | 45 #endif |
| 47 Init(); | 46 Init(); |
| 48 } | 47 } |
| 49 | 48 |
| 50 void DataReductionProxyAuthRequestHandler::Init() { | 49 void DataReductionProxyAuthRequestHandler::Init() { |
| 51 InitAuthentication(GetDefaultKey()); | 50 InitAuthentication(GetDefaultKey()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 std::string key = | 140 std::string key = |
| 142 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey); | 141 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey); |
| 143 #if defined(SPDY_PROXY_AUTH_VALUE) | 142 #if defined(SPDY_PROXY_AUTH_VALUE) |
| 144 if (key.empty()) | 143 if (key.empty()) |
| 145 key = SPDY_PROXY_AUTH_VALUE; | 144 key = SPDY_PROXY_AUTH_VALUE; |
| 146 #endif | 145 #endif |
| 147 return key; | 146 return key; |
| 148 } | 147 } |
| 149 | 148 |
| 150 } // namespace data_reduction_proxy | 149 } // namespace data_reduction_proxy |
| OLD | NEW |