Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler.cc

Issue 533003002: Use chromium version for data reduction proxy version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "crypto/random.h" 20 #include "crypto/random.h"
20 #include "net/base/host_port_pair.h" 21 #include "net/base/host_port_pair.h"
21 #include "net/proxy/proxy_server.h" 22 #include "net/proxy/proxy_server.h"
22 #include "net/url_request/url_request.h" 23 #include "net/url_request/url_request.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 namespace data_reduction_proxy { 26 namespace data_reduction_proxy {
26 27
27 // The empty version for the authentication protocol. Currently used by 28 // The empty version for the authentication protocol. Currently used by
28 // Android webview. 29 // Android webview.
29 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
30 const char kAndroidWebViewProtocolVersion[] = ""; 31 const char kAndroidWebViewProtocolVersion[] = "";
31 #endif 32 #endif
32 33
33 // The clients supported by the data reduction proxy. 34 // The clients supported by the data reduction proxy.
34 const char kClientAndroidWebview[] = "webview"; 35 const char kClientAndroidWebview[] = "webview";
35 const char kClientChromeAndroid[] = "android"; 36 const char kClientChromeAndroid[] = "android";
36 const char kClientChromeIOS[] = "ios"; 37 const char kClientChromeIOS[] = "ios";
37 38
38 // static 39 // static
39 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() { 40 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() {
40 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 41 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
41 return command_line.HasSwitch( 42 return command_line.HasSwitch(
42 data_reduction_proxy::switches::kDataReductionProxyKey); 43 data_reduction_proxy::switches::kDataReductionProxyKey);
43 } 44 }
44 45
45 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( 46 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler(
46 const std::string& client, 47 const std::string& client,
48 DataReductionProxyParams* params,
49 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
50 : client_(client),
51 data_reduction_proxy_params_(params),
52 network_task_runner_(network_task_runner) {
53 GetChromiumBuildAndPatch(ChromiumVersion(), &build_number_, &patch_number_);
54 Init();
55 }
56
57 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler(
58 const std::string& client,
47 const std::string& version, 59 const std::string& version,
48 DataReductionProxyParams* params, 60 DataReductionProxyParams* params,
49 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) 61 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
50 : data_reduction_proxy_params_(params), 62 : client_(client),
63 data_reduction_proxy_params_(params),
51 network_task_runner_(network_task_runner) { 64 network_task_runner_(network_task_runner) {
52 client_ = client;
53 GetChromiumBuildAndPatch(version, &build_number_, &patch_number_); 65 GetChromiumBuildAndPatch(version, &build_number_, &patch_number_);
54 Init(); 66 Init();
55 } 67 }
56 68
69 std::string DataReductionProxyAuthRequestHandler::ChromiumVersion() const {
70 #if defined(PRODUCT_VERSION)
71 return PRODUCT_VERSION;
72 #else
73 return std::string();
74 #endif
75 }
76
77
57 void DataReductionProxyAuthRequestHandler::GetChromiumBuildAndPatch( 78 void DataReductionProxyAuthRequestHandler::GetChromiumBuildAndPatch(
58 const std::string& version, 79 const std::string& version,
59 std::string* build, 80 std::string* build,
60 std::string* patch) { 81 std::string* patch) const {
61 std::vector<std::string> version_parts; 82 std::vector<std::string> version_parts;
62 base::SplitString(version, '.', &version_parts); 83 base::SplitString(version, '.', &version_parts);
63 if (version_parts.size() != 4) 84 if (version_parts.size() != 4)
64 return; 85 return;
65 *build = version_parts[2]; 86 *build = version_parts[2];
66 *patch = version_parts[3]; 87 *patch = version_parts[3];
67 } 88 }
68 89
69 void DataReductionProxyAuthRequestHandler::Init() { 90 void DataReductionProxyAuthRequestHandler::Init() {
70 InitAuthenticationOnUI(GetDefaultKey()); 91 InitAuthenticationOnUI(GetDefaultKey());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if (data_reduction_proxy_params_ && 226 if (data_reduction_proxy_params_ &&
206 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) && 227 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) &&
207 net::HostPortPair::FromURL( 228 net::HostPortPair::FromURL(
208 data_reduction_proxy_params_->ssl_origin()).Equals( 229 data_reduction_proxy_params_->ssl_origin()).Equals(
209 proxy_server) == expect_ssl) { 230 proxy_server) == expect_ssl) {
210 AddAuthorizationHeader(request_headers); 231 AddAuthorizationHeader(request_headers);
211 } 232 }
212 } 233 }
213 234
214 } // namespace data_reduction_proxy 235 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698