OLD | NEW |
---|---|
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" |
(...skipping 15 matching lines...) Expand all Loading... | |
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. |
36 explicit DataReductionProxyAuthRequestHandler( | 36 explicit DataReductionProxyAuthRequestHandler( |
Lei Zhang
2014/08/01 19:11:57
nit: no longer explicit.
megjablon
2014/08/01 20:35:26
Done.
| |
37 const std::string& client, | |
38 const std::string& version, | |
37 DataReductionProxyParams* params); | 39 DataReductionProxyParams* params); |
38 | 40 |
39 virtual ~DataReductionProxyAuthRequestHandler(); | 41 virtual ~DataReductionProxyAuthRequestHandler(); |
40 | 42 |
41 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction | 43 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction |
42 // proxy authentication credentials. Only adds this header if the provided | 44 // proxy authentication credentials. Only adds this header if the provided |
43 // |proxy_server| is a data reduction proxy. | 45 // |proxy_server| is a data reduction proxy. |
44 void MaybeAddRequestHeader(net::URLRequest* request, | 46 void MaybeAddRequestHeader(net::URLRequest* request, |
45 const net::ProxyServer& proxy_server, | 47 const net::ProxyServer& proxy_server, |
46 net::HttpRequestHeaders* request_headers); | 48 net::HttpRequestHeaders* request_headers); |
47 | 49 |
48 // Sets a new authentication key. This must be called for platforms that do | 50 // 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 | 51 // not have a default key defined. See the constructor implementation for |
50 // those platforms. Client is the canonical name for the client. Client names | 52 // those platforms. Client is the canonical name for the client. Client names |
Lei Zhang
2014/08/01 19:11:57
Update the comment...
megjablon
2014/08/01 20:35:26
Done.
| |
51 // should be defined in this file as one of |kClient...|. Version is the | 53 // should be defined in this file as one of |kClient...|. Version is the |
52 // authentication protocol version that the client uses, which should be | 54 // authentication protocol version that the client uses, which should be |
53 // |kProtocolVersion| unless the client expects to be handled differently from | 55 // |kProtocolVersion| unless the client expects to be handled differently from |
54 // the standard behavior. | 56 // the standard behavior. |
55 void SetKey(const std::string& key, | 57 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 Loading... | |
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_ |
OLD | NEW |