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" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 namespace data_reduction_proxy { | 26 namespace data_reduction_proxy { |
27 | 27 |
28 // The empty version for the authentication protocol. Currently used by | 28 // The empty version for the authentication protocol. Currently used by |
29 // Android webview. | 29 // Android webview. |
30 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
31 const char kAndroidWebViewProtocolVersion[] = ""; | 31 const char kAndroidWebViewProtocolVersion[] = ""; |
32 #endif | 32 #endif |
33 | 33 |
34 // The clients supported by the data reduction proxy. | 34 #define CLIENT_ENUM(name, str_value) \ |
35 const char kClientAndroidWebview[] = "webview"; | 35 case name: return str_value; |
36 const char kClientChromeAndroid[] = "android"; | 36 const char* GetString(Client client) { |
37 const char kClientChromeIOS[] = "ios"; | 37 switch (client) { |
38 CLIENT_ENUMS_LIST | |
39 } | |
40 NOTREACHED(); | |
41 return ""; | |
42 } | |
43 #undef CLIENT_ENUM | |
38 | 44 |
39 // static | 45 // static |
40 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() { | 46 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() { |
41 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 47 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
42 return command_line.HasSwitch( | 48 return command_line.HasSwitch( |
43 data_reduction_proxy::switches::kDataReductionProxyKey); | 49 data_reduction_proxy::switches::kDataReductionProxyKey); |
44 } | 50 } |
45 | 51 |
46 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( | 52 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( |
47 const std::string& client, | 53 const Client client, |
48 DataReductionProxyParams* params, | 54 DataReductionProxyParams* params, |
49 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) | 55 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) |
50 : client_(client), | 56 : client_(GetString(client)), |
51 data_reduction_proxy_params_(params), | 57 data_reduction_proxy_params_(params), |
52 network_task_runner_(network_task_runner) { | 58 network_task_runner_(network_task_runner) { |
53 GetChromiumBuildAndPatch(ChromiumVersion(), &build_number_, &patch_number_); | 59 GetChromiumBuildAndPatch(ChromiumVersion(), &build_number_, &patch_number_); |
54 Init(); | 60 Init(); |
55 } | 61 } |
56 | 62 |
57 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( | 63 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( |
58 const std::string& client, | 64 const Client client, |
bengr
2014/10/02 17:36:07
"const" isn't needed here.
Not at Google. Contact bengr
2014/10/02 18:07:44
Done.
| |
59 const std::string& version, | 65 const std::string& version, |
60 DataReductionProxyParams* params, | 66 DataReductionProxyParams* params, |
61 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) | 67 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) |
62 : client_(client), | 68 : client_(GetString(client)), |
63 data_reduction_proxy_params_(params), | 69 data_reduction_proxy_params_(params), |
64 network_task_runner_(network_task_runner) { | 70 network_task_runner_(network_task_runner) { |
65 GetChromiumBuildAndPatch(version, &build_number_, &patch_number_); | 71 GetChromiumBuildAndPatch(version, &build_number_, &patch_number_); |
66 Init(); | 72 Init(); |
67 } | 73 } |
68 | 74 |
69 std::string DataReductionProxyAuthRequestHandler::ChromiumVersion() const { | 75 std::string DataReductionProxyAuthRequestHandler::ChromiumVersion() const { |
70 #if defined(PRODUCT_VERSION) | 76 #if defined(PRODUCT_VERSION) |
71 return PRODUCT_VERSION; | 77 return PRODUCT_VERSION; |
72 #else | 78 #else |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 if (data_reduction_proxy_params_ && | 232 if (data_reduction_proxy_params_ && |
227 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) && | 233 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) && |
228 net::HostPortPair::FromURL( | 234 net::HostPortPair::FromURL( |
229 data_reduction_proxy_params_->ssl_origin()).Equals( | 235 data_reduction_proxy_params_->ssl_origin()).Equals( |
230 proxy_server) == expect_ssl) { | 236 proxy_server) == expect_ssl) { |
231 AddAuthorizationHeader(request_headers); | 237 AddAuthorizationHeader(request_headers); |
232 } | 238 } |
233 } | 239 } |
234 | 240 |
235 } // namespace data_reduction_proxy | 241 } // namespace data_reduction_proxy |
OLD | NEW |