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

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

Issue 430643002: Correcting the version field in the Chrome-Proxy header to be the chromium build and patch number. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Trybot test fix Created 6 years, 4 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/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. 23 // The empty version for the authentication protocol. Currently used by
24 const char kProtocolVersion[] = "0"; 24 // Android webview.
25 #if defined(OS_ANDROID)
26 const char kAndroidWebViewProtocolVersion[] = "0";
27 #endif
25 28
26 // The clients supported by the data reduction proxy. 29 // The clients supported by the data reduction proxy.
27 const char kClientAndroidWebview[] = "webview"; 30 const char kClientAndroidWebview[] = "webview";
28 const char kClientChromeAndroid[] = "android"; 31 const char kClientChromeAndroid[] = "android";
29 const char kClientChromeIOS[] = "ios"; 32 const char kClientChromeIOS[] = "ios";
30 33
31 // static 34 // static
32 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() { 35 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() {
33 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 36 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
34 return command_line.HasSwitch( 37 return command_line.HasSwitch(
35 data_reduction_proxy::switches::kDataReductionProxyKey); 38 data_reduction_proxy::switches::kDataReductionProxyKey);
36 } 39 }
37 40
38 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( 41 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler(
42 const std::string& client,
43 const std::string& version,
39 DataReductionProxyParams* params) 44 DataReductionProxyParams* params)
40 : data_reduction_proxy_params_(params) { 45 : data_reduction_proxy_params_(params) {
41 version_ = kProtocolVersion; 46 client_ = client;
42 #if defined(OS_ANDROID) 47 version_ = version;
43 client_ = kClientChromeAndroid;
44 #elif defined(OS_IOS)
45 client_ = kClientChromeIOS;
46 #endif
47 Init(); 48 Init();
48 } 49 }
49 50
50 void DataReductionProxyAuthRequestHandler::Init() { 51 void DataReductionProxyAuthRequestHandler::Init() {
51 InitAuthentication(GetDefaultKey()); 52 InitAuthentication(GetDefaultKey());
52 } 53 }
53 54
54 55
55 DataReductionProxyAuthRequestHandler::~DataReductionProxyAuthRequestHandler() { 56 DataReductionProxyAuthRequestHandler::~DataReductionProxyAuthRequestHandler() {
56 } 57 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 static_cast<long long>(timestamp), 120 static_cast<long long>(timestamp),
120 rand[0], 121 rand[0],
121 rand[1], 122 rand[1],
122 rand[2]); 123 rand[2]);
123 credentials_ = base::UTF16ToUTF8(AuthHashForSalt(timestamp, key_)); 124 credentials_ = base::UTF16ToUTF8(AuthHashForSalt(timestamp, key_));
124 125
125 DVLOG(1) << "session: [" << session_ << "] " 126 DVLOG(1) << "session: [" << session_ << "] "
126 << "password: [" << credentials_ << "]"; 127 << "password: [" << credentials_ << "]";
127 } 128 }
128 129
129 void DataReductionProxyAuthRequestHandler::SetKey(const std::string& key, 130 void DataReductionProxyAuthRequestHandler::SetKey(const std::string& key) {
130 const std::string& client,
131 const std::string& version) {
132 client_ = client;
133 version_ = version;
134 if (!key.empty()) 131 if (!key.empty())
135 InitAuthentication(key); 132 InitAuthentication(key);
136 } 133 }
137 134
138 135
139 std::string DataReductionProxyAuthRequestHandler::GetDefaultKey() const { 136 std::string DataReductionProxyAuthRequestHandler::GetDefaultKey() const {
140 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 137 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
141 std::string key = 138 std::string key =
142 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey); 139 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey);
143 #if defined(SPDY_PROXY_AUTH_VALUE) 140 #if defined(SPDY_PROXY_AUTH_VALUE)
144 if (key.empty()) 141 if (key.empty())
145 key = SPDY_PROXY_AUTH_VALUE; 142 key = SPDY_PROXY_AUTH_VALUE;
146 #endif 143 #endif
147 return key; 144 return key;
148 } 145 }
149 146
150 } // namespace data_reduction_proxy 147 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698