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

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

Issue 635013003: Expose data reduction proxy auth token for internal builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing comma in BUILD.gn Created 6 years, 2 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 "components/data_reduction_proxy/common/version.h"
20 #include "crypto/random.h" 20 #include "crypto/random.h"
21 #include "net/base/host_port_pair.h" 21 #include "net/base/host_port_pair.h"
22 #include "net/proxy/proxy_server.h" 22 #include "net/proxy/proxy_server.h"
23 #include "net/url_request/url_request.h" 23 #include "net/url_request/url_request.h"
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
26 #if !defined(OS_ANDROID) && !defined(OS_IOS)
27 #include "google_apis/google_api_keys.h"
28 #endif
29
26 namespace data_reduction_proxy { 30 namespace data_reduction_proxy {
27 31
28 // The empty version for the authentication protocol. Currently used by 32 // The empty version for the authentication protocol. Currently used by
29 // Android webview. 33 // Android webview.
30 #if defined(OS_ANDROID) 34 #if defined(OS_ANDROID)
31 const char kAndroidWebViewProtocolVersion[] = ""; 35 const char kAndroidWebViewProtocolVersion[] = "";
32 #endif 36 #endif
33 37
34 #define CLIENT_ENUM(name, str_value) \ 38 #define CLIENT_ENUM(name, str_value) \
35 case name: return str_value; 39 case name: return str_value;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 210
207 key_ = key; 211 key_ = key;
208 last_update_time_ = Now(); 212 last_update_time_ = Now();
209 ComputeCredentials(last_update_time_, &session_, &credentials_); 213 ComputeCredentials(last_update_time_, &session_, &credentials_);
210 } 214 }
211 215
212 std::string DataReductionProxyAuthRequestHandler::GetDefaultKey() const { 216 std::string DataReductionProxyAuthRequestHandler::GetDefaultKey() const {
213 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 217 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
214 std::string key = 218 std::string key =
215 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey); 219 command_line.GetSwitchValueASCII(switches::kDataReductionProxyKey);
216 #if defined(SPDY_PROXY_AUTH_VALUE) 220 #if defined(SPDY_PROXY_AUTH_VALUE)
bengr 2014/10/10 00:26:07 Is this ever defined outside of iOS and Android? I
Not at Google. Contact bengr 2014/10/10 18:55:43 Done.
217 if (key.empty()) 221 if (key.empty())
218 key = SPDY_PROXY_AUTH_VALUE; 222 key = SPDY_PROXY_AUTH_VALUE;
219 #endif 223 #endif
224
225 #if !defined(OS_ANDROID) && !defined(OS_IOS)
bengr 2014/10/10 00:26:07 Presuming this doesn't bloat WebView or Cronet, ca
Not at Google. Contact bengr 2014/10/10 18:55:43 It will increase the size by about 1.4M. Also the
226 // On Android and iOS this value is obtained from supplement.gypi. We avoid
bengr 2014/10/10 00:26:06 I wouldn't describe how internal code works. Inste
Not at Google. Contact bengr 2014/10/10 18:55:43 Done.
227 // this dependency when possible to reduce the size of this component.
228 if (key.empty()) {
229 key = google_apis::GetSpdyProxyAuthValue();
230 }
231 #endif
220 return key; 232 return key;
221 } 233 }
222 234
223 void DataReductionProxyAuthRequestHandler::MaybeAddRequestHeaderImpl( 235 void DataReductionProxyAuthRequestHandler::MaybeAddRequestHeaderImpl(
224 const net::HostPortPair& proxy_server, 236 const net::HostPortPair& proxy_server,
225 bool expect_ssl, 237 bool expect_ssl,
226 net::HttpRequestHeaders* request_headers) { 238 net::HttpRequestHeaders* request_headers) {
227 if (proxy_server.IsEmpty()) 239 if (proxy_server.IsEmpty())
228 return; 240 return;
229 if (data_reduction_proxy_params_ && 241 if (data_reduction_proxy_params_ &&
230 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) && 242 data_reduction_proxy_params_->IsDataReductionProxy(proxy_server, NULL) &&
231 net::HostPortPair::FromURL( 243 net::HostPortPair::FromURL(
232 data_reduction_proxy_params_->ssl_origin()).Equals( 244 data_reduction_proxy_params_->ssl_origin()).Equals(
233 proxy_server) == expect_ssl) { 245 proxy_server) == expect_ssl) {
234 AddAuthorizationHeader(request_headers); 246 AddAuthorizationHeader(request_headers);
235 } 247 }
236 } 248 }
237 249
238 } // namespace data_reduction_proxy 250 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698