OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Helper classes and functions used for the WebRequest API. | 5 // Helper classes and functions used for the WebRequest API. |
6 | 6 |
7 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 7 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
8 #define CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 8 #define CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
9 | 9 |
10 #include <list> | 10 #include <list> |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 EventResponseDelta* CalculateOnBeforeSendHeadersDelta( | 207 EventResponseDelta* CalculateOnBeforeSendHeadersDelta( |
208 const std::string& extension_id, | 208 const std::string& extension_id, |
209 const base::Time& extension_install_time, | 209 const base::Time& extension_install_time, |
210 bool cancel, | 210 bool cancel, |
211 net::HttpRequestHeaders* old_headers, | 211 net::HttpRequestHeaders* old_headers, |
212 net::HttpRequestHeaders* new_headers); | 212 net::HttpRequestHeaders* new_headers); |
213 EventResponseDelta* CalculateOnHeadersReceivedDelta( | 213 EventResponseDelta* CalculateOnHeadersReceivedDelta( |
214 const std::string& extension_id, | 214 const std::string& extension_id, |
215 const base::Time& extension_install_time, | 215 const base::Time& extension_install_time, |
216 bool cancel, | 216 bool cancel, |
| 217 const GURL& new_url, |
217 const net::HttpResponseHeaders* old_response_headers, | 218 const net::HttpResponseHeaders* old_response_headers, |
218 ResponseHeaders* new_response_headers); | 219 ResponseHeaders* new_response_headers); |
219 // Destructively moves the auth credentials from |auth_credentials| to the | 220 // Destructively moves the auth credentials from |auth_credentials| to the |
220 // returned EventResponseDelta. | 221 // returned EventResponseDelta. |
221 EventResponseDelta* CalculateOnAuthRequiredDelta( | 222 EventResponseDelta* CalculateOnAuthRequiredDelta( |
222 const std::string& extension_id, | 223 const std::string& extension_id, |
223 const base::Time& extension_install_time, | 224 const base::Time& extension_install_time, |
224 bool cancel, | 225 bool cancel, |
225 scoped_ptr<net::AuthCredentials>* auth_credentials); | 226 scoped_ptr<net::AuthCredentials>* auth_credentials); |
226 | 227 |
227 // These functions merge the responses (the |deltas|) of request handlers. | 228 // These functions merge the responses (the |deltas|) of request handlers. |
228 // The |deltas| need to be sorted in decreasing order of precedence of | 229 // The |deltas| need to be sorted in decreasing order of precedence of |
229 // extensions. In case extensions had |deltas| that could not be honored, their | 230 // extensions. In case extensions had |deltas| that could not be honored, their |
230 // IDs are reported in |conflicting_extensions|. NetLog events that shall be | 231 // IDs are reported in |conflicting_extensions|. NetLog events that shall be |
231 // reported will be stored in |event_log_entries|. | 232 // reported will be stored in |event_log_entries|. |
232 | 233 |
233 // Stores in |canceled| whether any extension wanted to cancel the request. | 234 // Stores in |canceled| whether any extension wanted to cancel the request. |
234 void MergeCancelOfResponses( | 235 void MergeCancelOfResponses( |
235 const EventResponseDeltas& deltas, | 236 const EventResponseDeltas& deltas, |
236 bool* canceled, | 237 bool* canceled, |
237 const net::BoundNetLog* net_log); | 238 const net::BoundNetLog* net_log); |
238 // Stores in |*new_url| the redirect request of the extension with highest | 239 // Stores in |*new_url| the redirect request of the extension with highest |
239 // precedence. Extensions that did not command to redirect the request are | 240 // precedence. Extensions that did not command to redirect the request are |
240 // ignored in this logic. | 241 // ignored in this logic. |
| 242 void MergeRedirectUrlOfResponses( |
| 243 const EventResponseDeltas& deltas, |
| 244 GURL* new_url, |
| 245 extensions::ExtensionWarningSet* conflicting_extensions, |
| 246 const net::BoundNetLog* net_log); |
| 247 // Stores in |*new_url| the redirect request of the extension with highest |
| 248 // precedence. Extensions that did not command to redirect the request are |
| 249 // ignored in this logic. |
241 void MergeOnBeforeRequestResponses( | 250 void MergeOnBeforeRequestResponses( |
242 const EventResponseDeltas& deltas, | 251 const EventResponseDeltas& deltas, |
243 GURL* new_url, | 252 GURL* new_url, |
244 extensions::ExtensionWarningSet* conflicting_extensions, | 253 extensions::ExtensionWarningSet* conflicting_extensions, |
245 const net::BoundNetLog* net_log); | 254 const net::BoundNetLog* net_log); |
246 // Modifies the "Cookie" header in |request_headers| according to | 255 // Modifies the "Cookie" header in |request_headers| according to |
247 // |deltas.request_cookie_modifications|. Conflicts are currently ignored | 256 // |deltas.request_cookie_modifications|. Conflicts are currently ignored |
248 // silently. | 257 // silently. |
249 void MergeCookiesInOnBeforeSendHeadersResponses( | 258 void MergeCookiesInOnBeforeSendHeadersResponses( |
250 const EventResponseDeltas& deltas, | 259 const EventResponseDeltas& deltas, |
(...skipping 13 matching lines...) Expand all Loading... |
264 // currently ignored silently. | 273 // currently ignored silently. |
265 void MergeCookiesInOnHeadersReceivedResponses( | 274 void MergeCookiesInOnHeadersReceivedResponses( |
266 const EventResponseDeltas& deltas, | 275 const EventResponseDeltas& deltas, |
267 const net::HttpResponseHeaders* original_response_headers, | 276 const net::HttpResponseHeaders* original_response_headers, |
268 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, | 277 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, |
269 extensions::ExtensionWarningSet* conflicting_extensions, | 278 extensions::ExtensionWarningSet* conflicting_extensions, |
270 const net::BoundNetLog* net_log); | 279 const net::BoundNetLog* net_log); |
271 // Stores a copy of |original_response_header| into |override_response_headers| | 280 // Stores a copy of |original_response_header| into |override_response_headers| |
272 // that is modified according to |deltas|. If |deltas| does not instruct to | 281 // that is modified according to |deltas|. If |deltas| does not instruct to |
273 // modify the response headers, |override_response_headers| remains empty. | 282 // modify the response headers, |override_response_headers| remains empty. |
| 283 // Extension-initiated redirects are written to |override_response_headers| |
| 284 // (to request redirection) and |*allowed_unsafe_redirect_url| (to make sure |
| 285 // that the request is not cancelled with net::ERR_UNSAFE_REDIRECT). |
274 void MergeOnHeadersReceivedResponses( | 286 void MergeOnHeadersReceivedResponses( |
275 const EventResponseDeltas& deltas, | 287 const EventResponseDeltas& deltas, |
276 const net::HttpResponseHeaders* original_response_headers, | 288 const net::HttpResponseHeaders* original_response_headers, |
277 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, | 289 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, |
| 290 GURL* allowed_unsafe_redirect_url, |
278 extensions::ExtensionWarningSet* conflicting_extensions, | 291 extensions::ExtensionWarningSet* conflicting_extensions, |
279 const net::BoundNetLog* net_log); | 292 const net::BoundNetLog* net_log); |
280 // Merge the responses of blocked onAuthRequired handlers. The first | 293 // Merge the responses of blocked onAuthRequired handlers. The first |
281 // registered listener that supplies authentication credentials in a response, | 294 // registered listener that supplies authentication credentials in a response, |
282 // if any, will have its authentication credentials used. |request| must be | 295 // if any, will have its authentication credentials used. |request| must be |
283 // non-NULL, and contain |deltas| that are sorted in decreasing order of | 296 // non-NULL, and contain |deltas| that are sorted in decreasing order of |
284 // precedence. | 297 // precedence. |
285 // Returns whether authentication credentials are set. | 298 // Returns whether authentication credentials are set. |
286 bool MergeOnAuthRequiredResponses( | 299 bool MergeOnAuthRequiredResponses( |
287 const EventResponseDeltas& deltas, | 300 const EventResponseDeltas& deltas, |
(...skipping 26 matching lines...) Expand all Loading... |
314 scoped_refptr<const extensions::Extension> extension); | 327 scoped_refptr<const extensions::Extension> extension); |
315 | 328 |
316 // Whether a header is RFC 2616-compliant. | 329 // Whether a header is RFC 2616-compliant. |
317 bool IsValidHeaderName(const std::string& name); | 330 bool IsValidHeaderName(const std::string& name); |
318 // Whether a header value does not contain NUL or CRLF. | 331 // Whether a header value does not contain NUL or CRLF. |
319 bool IsValidHeaderValue(const std::string& value); | 332 bool IsValidHeaderValue(const std::string& value); |
320 | 333 |
321 } // namespace extension_web_request_api_helpers | 334 } // namespace extension_web_request_api_helpers |
322 | 335 |
323 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 336 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
OLD | NEW |