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

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

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: Addressing Lei comments 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 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_ 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_ 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace net { 14 namespace net {
15 class HttpRequestHeaders; 15 class HttpRequestHeaders;
16 class HttpResponseHeaders; 16 class HttpResponseHeaders;
17 class ProxyServer; 17 class ProxyServer;
18 class URLRequest; 18 class URLRequest;
19 } 19 }
20 20
21 namespace data_reduction_proxy { 21 namespace data_reduction_proxy {
22 22
23 extern const char kProtocolVersion[]; 23 extern const char kAndroidWebViewProtocolVersion[];
24 24
25 extern const char kClientAndroidWebview[]; 25 extern const char kClientAndroidWebview[];
26 extern const char kClientChromeAndroid[]; 26 extern const char kClientChromeAndroid[];
27 extern const char kClientChromeIOS[]; 27 extern const char kClientChromeIOS[];
28 28
29 class DataReductionProxyParams; 29 class DataReductionProxyParams;
30 30
31 class DataReductionProxyAuthRequestHandler { 31 class DataReductionProxyAuthRequestHandler {
32 public: 32 public:
33 static bool IsKeySetOnCommandLine(); 33 static bool IsKeySetOnCommandLine();
34 34
35 // Constructs an authentication request handler. 35 // Constructs an authentication request handler. Client is the canonical name
36 explicit DataReductionProxyAuthRequestHandler( 36 // for the client. Client names should be defined in this file as one of
37 // |kClient...|. Version is the authentication protocol version that the
38 // client uses, which should be |kProtocolVersion| unless the client expects
39 // to be handled differently from the standard behavior.
40 DataReductionProxyAuthRequestHandler(
41 const std::string& client,
42 const std::string& version,
37 DataReductionProxyParams* params); 43 DataReductionProxyParams* params);
38 44
39 virtual ~DataReductionProxyAuthRequestHandler(); 45 virtual ~DataReductionProxyAuthRequestHandler();
40 46
41 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction 47 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction
42 // proxy authentication credentials. Only adds this header if the provided 48 // proxy authentication credentials. Only adds this header if the provided
43 // |proxy_server| is a data reduction proxy. 49 // |proxy_server| is a data reduction proxy.
44 void MaybeAddRequestHeader(net::URLRequest* request, 50 void MaybeAddRequestHeader(net::URLRequest* request,
45 const net::ProxyServer& proxy_server, 51 const net::ProxyServer& proxy_server,
46 net::HttpRequestHeaders* request_headers); 52 net::HttpRequestHeaders* request_headers);
47 53
48 // Sets a new authentication key. This must be called for platforms that do 54 // Sets a new authentication key. This must be called for platforms that do
49 // not have a default key defined. See the constructor implementation for 55 // not have a default key defined. See the constructor implementation for
50 // those platforms. Client is the canonical name for the client. Client names 56 // those platforms.
51 // should be defined in this file as one of |kClient...|. Version is the 57 void SetKey(const std::string& key);
52 // authentication protocol version that the client uses, which should be
53 // |kProtocolVersion| unless the client expects to be handled differently from
54 // the standard behavior.
55 void SetKey(const std::string& key,
56 const std::string& client,
57 const std::string& version);
58 58
59 protected: 59 protected:
60 void Init(); 60 void Init();
61 void InitAuthentication(const std::string& key); 61 void InitAuthentication(const std::string& key);
62 62
63 void AddAuthorizationHeader(net::HttpRequestHeaders* headers); 63 void AddAuthorizationHeader(net::HttpRequestHeaders* headers);
64 64
65 // Returns a UTF16 string that's the hash of the configured authentication 65 // Returns a UTF16 string that's the hash of the configured authentication
66 // |key| and |salt|. Returns an empty UTF16 string if no key is configured or 66 // |key| and |salt|. Returns an empty UTF16 string if no key is configured or
67 // the data reduction proxy feature isn't available. 67 // the data reduction proxy feature isn't available.
(...skipping 21 matching lines...) Expand all
89 std::string client_; 89 std::string client_;
90 std::string version_; 90 std::string version_;
91 91
92 DataReductionProxyParams* data_reduction_proxy_params_; 92 DataReductionProxyParams* data_reduction_proxy_params_;
93 93
94 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler); 94 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler);
95 }; 95 };
96 96
97 } // namespace data_reduction_proxy 97 } // namespace data_reduction_proxy
98 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ UEST_HANDLER_H_ 98 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ UEST_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698