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 11 matching lines...) Expand all Loading... |
22 class ProxyServer; | 22 class ProxyServer; |
23 class URLRequest; | 23 class URLRequest; |
24 } | 24 } |
25 | 25 |
26 namespace data_reduction_proxy { | 26 namespace data_reduction_proxy { |
27 | 27 |
28 #if defined(OS_ANDROID) | 28 #if defined(OS_ANDROID) |
29 extern const char kAndroidWebViewProtocolVersion[]; | 29 extern const char kAndroidWebViewProtocolVersion[]; |
30 #endif | 30 #endif |
31 | 31 |
32 extern const char kClientAndroidWebview[]; | 32 #define CLIENT_ENUMS_LIST \ |
33 extern const char kClientChromeAndroid[]; | 33 CLIENT_ENUM(UNKNOWN, "") \ |
34 extern const char kClientChromeIOS[]; | 34 CLIENT_ENUM(WEBVIEW_ANDROID, "webview") \ |
| 35 CLIENT_ENUM(CHROME_ANDROID, "android") \ |
| 36 CLIENT_ENUM(CHROME_IOS, "ios") \ |
| 37 CLIENT_ENUM(CHROME_MAC, "mac") \ |
| 38 CLIENT_ENUM(CHROME_CHROMEOS, "chromeos") \ |
| 39 CLIENT_ENUM(CHROME_LINUX, "linux") \ |
| 40 CLIENT_ENUM(CHROME_WINDOWS, "win") \ |
| 41 CLIENT_ENUM(CHROME_FREEBSD, "freebsd") \ |
| 42 CLIENT_ENUM(CHROME_OPENBSD, "openbsd") \ |
| 43 CLIENT_ENUM(CHROME_SOLARIS, "solaris") \ |
| 44 CLIENT_ENUM(CHROME_QNX, "qnx") |
| 45 |
| 46 #define CLIENT_ENUM(name, str_value) name, |
| 47 typedef enum { |
| 48 CLIENT_ENUMS_LIST |
| 49 } Client; |
| 50 #undef CLIENT_ENUM |
35 | 51 |
36 class DataReductionProxyParams; | 52 class DataReductionProxyParams; |
37 | 53 |
38 class DataReductionProxyAuthRequestHandler { | 54 class DataReductionProxyAuthRequestHandler { |
39 public: | 55 public: |
40 static bool IsKeySetOnCommandLine(); | 56 static bool IsKeySetOnCommandLine(); |
41 | 57 |
42 // Constructs a DataReductionProxyAuthRequestHandler object with the given | 58 // Constructs a DataReductionProxyAuthRequestHandler object with the given |
43 // client type, params, and network task runner. | 59 // client type, params, and network task runner. |
44 DataReductionProxyAuthRequestHandler( | 60 DataReductionProxyAuthRequestHandler( |
45 const std::string& client, | 61 Client client, |
46 DataReductionProxyParams* params, | 62 DataReductionProxyParams* params, |
47 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); | 63 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); |
48 | 64 |
49 virtual ~DataReductionProxyAuthRequestHandler(); | 65 virtual ~DataReductionProxyAuthRequestHandler(); |
50 | 66 |
51 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction | 67 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction |
52 // proxy authentication credentials. Only adds this header if the provided | 68 // proxy authentication credentials. Only adds this header if the provided |
53 // |proxy_server| is a data reduction proxy and not the data reduction proxy's | 69 // |proxy_server| is a data reduction proxy and not the data reduction proxy's |
54 // CONNECT server. Must be called on the IO thread. | 70 // CONNECT server. Must be called on the IO thread. |
55 void MaybeAddRequestHeader(net::URLRequest* request, | 71 void MaybeAddRequestHeader(net::URLRequest* request, |
(...skipping 26 matching lines...) Expand all Loading... |
82 const std::string& key); | 98 const std::string& key); |
83 // Visible for testing. | 99 // Visible for testing. |
84 virtual base::Time Now() const; | 100 virtual base::Time Now() const; |
85 virtual void RandBytes(void* output, size_t length); | 101 virtual void RandBytes(void* output, size_t length); |
86 | 102 |
87 // Visible for testing. | 103 // Visible for testing. |
88 virtual std::string GetDefaultKey() const; | 104 virtual std::string GetDefaultKey() const; |
89 | 105 |
90 // Visible for testing. | 106 // Visible for testing. |
91 DataReductionProxyAuthRequestHandler( | 107 DataReductionProxyAuthRequestHandler( |
92 const std::string& client, | 108 Client client, |
93 const std::string& version, | 109 const std::string& version, |
94 DataReductionProxyParams* params, | 110 DataReductionProxyParams* params, |
95 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); | 111 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner); |
96 | 112 |
97 private: | 113 private: |
98 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, | 114 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, |
99 Authorization); | 115 Authorization); |
100 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, | 116 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, |
101 AuthorizationBogusVersion); | 117 AuthorizationBogusVersion); |
102 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, | 118 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 164 |
149 DataReductionProxyParams* data_reduction_proxy_params_; | 165 DataReductionProxyParams* data_reduction_proxy_params_; |
150 | 166 |
151 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 167 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
152 | 168 |
153 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler); | 169 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler); |
154 }; | 170 }; |
155 | 171 |
156 } // namespace data_reduction_proxy | 172 } // namespace data_reduction_proxy |
157 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ
UEST_HANDLER_H_ | 173 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ
UEST_HANDLER_H_ |
OLD | NEW |