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

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

Issue 530153002: Add build and patch to Chrome-Proxy header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: using "" instead of string 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/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" 13 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" 14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h"
15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" 15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h"
16 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" 16 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
17 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " 17 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h "
18 #include "crypto/random.h" 18 #include "crypto/random.h"
19 #include "net/proxy/proxy_server.h" 19 #include "net/proxy/proxy_server.h"
20 #include "net/url_request/url_request.h" 20 #include "net/url_request/url_request.h"
21 #include "url/gurl.h" 21 #include "url/gurl.h"
22 22
23 namespace data_reduction_proxy { 23 namespace data_reduction_proxy {
24 24
25 // The empty version for the authentication protocol. Currently used by 25 // The empty version for the authentication protocol. Currently used by
26 // Android webview. 26 // Android webview.
27 #if defined(OS_ANDROID) 27 #if defined(OS_ANDROID)
28 const char kAndroidWebViewProtocolVersion[] = "0"; 28 const char kAndroidWebViewProtocolVersion[] = "";
29 #endif 29 #endif
30 30
31 // The clients supported by the data reduction proxy. 31 // The clients supported by the data reduction proxy.
32 const char kClientAndroidWebview[] = "webview"; 32 const char kClientAndroidWebview[] = "webview";
33 const char kClientChromeAndroid[] = "android"; 33 const char kClientChromeAndroid[] = "android";
34 const char kClientChromeIOS[] = "ios"; 34 const char kClientChromeIOS[] = "ios";
35 35
36 // static 36 // static
37 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() { 37 bool DataReductionProxyAuthRequestHandler::IsKeySetOnCommandLine() {
38 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 38 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
39 return command_line.HasSwitch( 39 return command_line.HasSwitch(
40 data_reduction_proxy::switches::kDataReductionProxyKey); 40 data_reduction_proxy::switches::kDataReductionProxyKey);
41 } 41 }
42 42
43 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler( 43 DataReductionProxyAuthRequestHandler::DataReductionProxyAuthRequestHandler(
44 const std::string& client, 44 const std::string& client,
45 const std::string& version, 45 const std::string& build_number,
46 const std::string& patch_number,
46 DataReductionProxyParams* params, 47 DataReductionProxyParams* params,
47 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) 48 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
48 : data_reduction_proxy_params_(params), 49 : data_reduction_proxy_params_(params),
49 network_task_runner_(network_task_runner) { 50 network_task_runner_(network_task_runner) {
50 client_ = client; 51 client_ = client;
51 version_ = version; 52 build_number_ = build_number;
53 patch_number_ = patch_number;
52 Init(); 54 Init();
53 } 55 }
54 56
55 void DataReductionProxyAuthRequestHandler::Init() { 57 void DataReductionProxyAuthRequestHandler::Init() {
56 InitAuthenticationOnUI(GetDefaultKey()); 58 InitAuthenticationOnUI(GetDefaultKey());
57 } 59 }
58 60
59 61
60 DataReductionProxyAuthRequestHandler::~DataReductionProxyAuthRequestHandler() { 62 DataReductionProxyAuthRequestHandler::~DataReductionProxyAuthRequestHandler() {
61 } 63 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ComputeCredentials(last_update_time_, &session_, &credentials_); 107 ComputeCredentials(last_update_time_, &session_, &credentials_);
106 } 108 }
107 const char kChromeProxyHeader[] = "Chrome-Proxy"; 109 const char kChromeProxyHeader[] = "Chrome-Proxy";
108 std::string header_value; 110 std::string header_value;
109 if (headers->HasHeader(kChromeProxyHeader)) { 111 if (headers->HasHeader(kChromeProxyHeader)) {
110 headers->GetHeader(kChromeProxyHeader, &header_value); 112 headers->GetHeader(kChromeProxyHeader, &header_value);
111 headers->RemoveHeader(kChromeProxyHeader); 113 headers->RemoveHeader(kChromeProxyHeader);
112 header_value += ", "; 114 header_value += ", ";
113 } 115 }
114 header_value += 116 header_value +=
115 "ps=" + session_ + ", sid=" + credentials_ + ", v=" + version_; 117 "ps=" + session_ + ", sid=" + credentials_ + ", b=" + build_number_ +
118 ", p=" + patch_number_;
116 if (!client_.empty()) 119 if (!client_.empty())
117 header_value += ", c=" + client_; 120 header_value += ", c=" + client_;
118 headers->SetHeader(kChromeProxyHeader, header_value); 121 headers->SetHeader(kChromeProxyHeader, header_value);
119 } 122 }
120 123
121 void DataReductionProxyAuthRequestHandler::InitAuthenticationOnUI( 124 void DataReductionProxyAuthRequestHandler::InitAuthenticationOnUI(
122 const std::string& key) { 125 const std::string& key) {
123 network_task_runner_->PostTask(FROM_HERE, base::Bind( 126 network_task_runner_->PostTask(FROM_HERE, base::Bind(
124 &DataReductionProxyAuthRequestHandler::InitAuthentication, 127 &DataReductionProxyAuthRequestHandler::InitAuthentication,
125 base::Unretained(this), 128 base::Unretained(this),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 std::string key = 170 std::string key =
168 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey); 171 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey);
169 #if defined(SPDY_PROXY_AUTH_VALUE) 172 #if defined(SPDY_PROXY_AUTH_VALUE)
170 if (key.empty()) 173 if (key.empty())
171 key = SPDY_PROXY_AUTH_VALUE; 174 key = SPDY_PROXY_AUTH_VALUE;
172 #endif 175 #endif
173 return key; 176 return key;
174 } 177 }
175 178
176 } // namespace data_reduction_proxy 179 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698