| 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_CORE_BROWSER_DATA_REDUCTION_PROXY_AUTH_R
EQUEST_HANDLER_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_AUTH_R
EQUEST_HANDLER_H_ |
| 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_AUTH_R
EQUEST_HANDLER_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_AUTH_R
EQUEST_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 DataReductionProxyConfig* config); | 73 DataReductionProxyConfig* config); |
| 74 | 74 |
| 75 virtual ~DataReductionProxyRequestOptions(); | 75 virtual ~DataReductionProxyRequestOptions(); |
| 76 | 76 |
| 77 // Sets |key_| to the default key and initializes the credentials, version, | 77 // Sets |key_| to the default key and initializes the credentials, version, |
| 78 // client, and lo-fi header values. Generates the |header_value_| string, | 78 // client, and lo-fi header values. Generates the |header_value_| string, |
| 79 // which is concatenated to the Chrome-proxy header. | 79 // which is concatenated to the Chrome-proxy header. |
| 80 void Init(); | 80 void Init(); |
| 81 | 81 |
| 82 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction | 82 // Adds a 'Chrome-Proxy' header to |request_headers| with the data reduction |
| 83 // proxy authentication credentials. Only adds this header if the | 83 // proxy authentication credentials. |
| 84 // provided |proxy_server| is a data reduction proxy. | 84 void AddRequestHeader(net::HttpRequestHeaders* request_headers); |
| 85 void MaybeAddRequestHeader(const net::ProxyServer& proxy_server, | |
| 86 net::HttpRequestHeaders* request_headers); | |
| 87 | 85 |
| 88 // Stores the supplied key and sets up credentials suitable for authenticating | 86 // Stores the supplied key and sets up credentials suitable for authenticating |
| 89 // with the data reduction proxy. | 87 // with the data reduction proxy. |
| 90 // This can be called more than once. For example on a platform that does not | 88 // This can be called more than once. For example on a platform that does not |
| 91 // have a default key defined, this function will be called some time after | 89 // have a default key defined, this function will be called some time after |
| 92 // this class has been constructed. Android WebView is a platform that does | 90 // this class has been constructed. Android WebView is a platform that does |
| 93 // this. The caller needs to make sure |this| pointer is valid when | 91 // this. The caller needs to make sure |this| pointer is valid when |
| 94 // SetKeyOnIO is called. | 92 // SetKeyOnIO is called. |
| 95 void SetKeyOnIO(const std::string& key); | 93 void SetKeyOnIO(const std::string& key); |
| 96 | 94 |
| 97 // Sets the credentials for sending to the Data Reduction Proxy. | 95 // Sets the credentials for sending to the Data Reduction Proxy. |
| 98 void SetSecureSession(const std::string& secure_session); | 96 void SetSecureSession(const std::string& secure_session); |
| 99 | 97 |
| 100 // Retrieves the credentials for sending to the Data Reduction Proxy. | 98 // Retrieves the credentials for sending to the Data Reduction Proxy. |
| 101 const std::string& GetSecureSession() const; | 99 const std::string& GetSecureSession() const; |
| 102 | 100 |
| 103 // Invalidates the secure session credentials. | 101 // Invalidates the secure session credentials. |
| 104 void Invalidate(); | 102 void Invalidate(); |
| 105 | 103 |
| 106 // Parses |request_headers| and returns the value of the session key. | 104 // Parses |request_headers| and returns the value of the session key. |
| 107 std::string GetSessionKeyFromRequestHeaders( | 105 std::string GetSessionKeyFromRequestHeaders( |
| 108 const net::HttpRequestHeaders& request_headers) const; | 106 const net::HttpRequestHeaders& request_headers) const; |
| 109 | 107 |
| 110 protected: | 108 protected: |
| 111 void SetHeader(net::HttpRequestHeaders* headers); | |
| 112 | |
| 113 // Returns a UTF16 string that's the hash of the configured authentication | 109 // Returns a UTF16 string that's the hash of the configured authentication |
| 114 // |key| and |salt|. Returns an empty UTF16 string if no key is configured or | 110 // |key| and |salt|. Returns an empty UTF16 string if no key is configured or |
| 115 // the data reduction proxy feature isn't available. | 111 // the data reduction proxy feature isn't available. |
| 116 static base::string16 AuthHashForSalt(int64_t salt, const std::string& key); | 112 static base::string16 AuthHashForSalt(int64_t salt, const std::string& key); |
| 117 // Visible for testing. | 113 // Visible for testing. |
| 118 virtual base::Time Now() const; | 114 virtual base::Time Now() const; |
| 119 virtual void RandBytes(void* output, size_t length) const; | 115 virtual void RandBytes(void* output, size_t length) const; |
| 120 | 116 |
| 121 // Visible for testing. | 117 // Visible for testing. |
| 122 virtual std::string GetDefaultKey() const; | 118 virtual std::string GetDefaultKey() const; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 DataReductionProxyConfig* data_reduction_proxy_config_; | 173 DataReductionProxyConfig* data_reduction_proxy_config_; |
| 178 | 174 |
| 179 // Enforce usage on the IO thread. | 175 // Enforce usage on the IO thread. |
| 180 base::ThreadChecker thread_checker_; | 176 base::ThreadChecker thread_checker_; |
| 181 | 177 |
| 182 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyRequestOptions); | 178 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyRequestOptions); |
| 183 }; | 179 }; |
| 184 | 180 |
| 185 } // namespace data_reduction_proxy | 181 } // namespace data_reduction_proxy |
| 186 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_AUT
H_REQUEST_HANDLER_H_ | 182 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_AUT
H_REQUEST_HANDLER_H_ |
| OLD | NEW |