| 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 EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 7 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
| 8 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 8 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // precedence. Extensions that did not command to redirect the request are | 266 // precedence. Extensions that did not command to redirect the request are |
| 267 // ignored in this logic. | 267 // ignored in this logic. |
| 268 void MergeOnBeforeRequestResponses( | 268 void MergeOnBeforeRequestResponses( |
| 269 const EventResponseDeltas& deltas, | 269 const EventResponseDeltas& deltas, |
| 270 GURL* new_url, | 270 GURL* new_url, |
| 271 extensions::WarningSet* conflicting_extensions, | 271 extensions::WarningSet* conflicting_extensions, |
| 272 const net::NetLogWithSource* net_log); | 272 const net::NetLogWithSource* net_log); |
| 273 // Modifies the "Cookie" header in |request_headers| according to | 273 // Modifies the "Cookie" header in |request_headers| according to |
| 274 // |deltas.request_cookie_modifications|. Conflicts are currently ignored | 274 // |deltas.request_cookie_modifications|. Conflicts are currently ignored |
| 275 // silently. | 275 // silently. |
| 276 // Stores in |request_cookies_modified| whether the request cookies were |
| 277 // modified. |
| 276 void MergeCookiesInOnBeforeSendHeadersResponses( | 278 void MergeCookiesInOnBeforeSendHeadersResponses( |
| 277 const EventResponseDeltas& deltas, | 279 const EventResponseDeltas& deltas, |
| 278 net::HttpRequestHeaders* request_headers, | 280 net::HttpRequestHeaders* request_headers, |
| 279 extensions::WarningSet* conflicting_extensions, | 281 extensions::WarningSet* conflicting_extensions, |
| 280 const net::NetLogWithSource* net_log); | 282 const net::NetLogWithSource* net_log, |
| 283 bool* request_cookies_modified); |
| 284 |
| 281 // Modifies the headers in |request_headers| according to |deltas|. Conflicts | 285 // Modifies the headers in |request_headers| according to |deltas|. Conflicts |
| 282 // are tried to be resolved. | 286 // are tried to be resolved. |
| 287 // Stores in |request_headers_modified| whether the request headers (excluding |
| 288 // the cookie header) were modified. |
| 289 // Stores in |request_cookies_modified| whether the request cookies were |
| 290 // modified. |
| 283 void MergeOnBeforeSendHeadersResponses( | 291 void MergeOnBeforeSendHeadersResponses( |
| 284 const EventResponseDeltas& deltas, | 292 const EventResponseDeltas& deltas, |
| 285 net::HttpRequestHeaders* request_headers, | 293 net::HttpRequestHeaders* request_headers, |
| 286 extensions::WarningSet* conflicting_extensions, | 294 extensions::WarningSet* conflicting_extensions, |
| 287 const net::NetLogWithSource* net_log); | 295 const net::NetLogWithSource* net_log, |
| 296 bool* request_headers_modified, |
| 297 bool* request_cookies_modified); |
| 298 |
| 288 // Modifies the "Set-Cookie" headers in |override_response_headers| according to | 299 // Modifies the "Set-Cookie" headers in |override_response_headers| according to |
| 289 // |deltas.response_cookie_modifications|. If |override_response_headers| is | 300 // |deltas.response_cookie_modifications|. If |override_response_headers| is |
| 290 // NULL, a copy of |original_response_headers| is created. Conflicts are | 301 // NULL, a copy of |original_response_headers| is created. Conflicts are |
| 291 // currently ignored silently. | 302 // currently ignored silently. |
| 303 // Stores in |response_cookies_modified| whether the response cookies were |
| 304 // modified. |
| 292 void MergeCookiesInOnHeadersReceivedResponses( | 305 void MergeCookiesInOnHeadersReceivedResponses( |
| 293 const EventResponseDeltas& deltas, | 306 const EventResponseDeltas& deltas, |
| 294 const net::HttpResponseHeaders* original_response_headers, | 307 const net::HttpResponseHeaders* original_response_headers, |
| 295 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, | 308 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, |
| 296 extensions::WarningSet* conflicting_extensions, | 309 extensions::WarningSet* conflicting_extensions, |
| 297 const net::NetLogWithSource* net_log); | 310 const net::NetLogWithSource* net_log, |
| 311 bool* response_cookies_modified); |
| 298 // Stores a copy of |original_response_header| into |override_response_headers| | 312 // Stores a copy of |original_response_header| into |override_response_headers| |
| 299 // that is modified according to |deltas|. If |deltas| does not instruct to | 313 // that is modified according to |deltas|. If |deltas| does not instruct to |
| 300 // modify the response headers, |override_response_headers| remains empty. | 314 // modify the response headers, |override_response_headers| remains empty. |
| 301 // Extension-initiated redirects are written to |override_response_headers| | 315 // Extension-initiated redirects are written to |override_response_headers| |
| 302 // (to request redirection) and |*allowed_unsafe_redirect_url| (to make sure | 316 // (to request redirection) and |*allowed_unsafe_redirect_url| (to make sure |
| 303 // that the request is not cancelled with net::ERR_UNSAFE_REDIRECT). | 317 // that the request is not cancelled with net::ERR_UNSAFE_REDIRECT). |
| 318 // Stores in |response_headers_modified| whether the response headers (excluding |
| 319 // the cookie header) were modified. |
| 320 // Stores in |response_cookies_modified| whether the response cookies were |
| 321 // modified. |
| 304 void MergeOnHeadersReceivedResponses( | 322 void MergeOnHeadersReceivedResponses( |
| 305 const EventResponseDeltas& deltas, | 323 const EventResponseDeltas& deltas, |
| 306 const net::HttpResponseHeaders* original_response_headers, | 324 const net::HttpResponseHeaders* original_response_headers, |
| 307 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, | 325 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, |
| 308 GURL* allowed_unsafe_redirect_url, | 326 GURL* allowed_unsafe_redirect_url, |
| 309 extensions::WarningSet* conflicting_extensions, | 327 extensions::WarningSet* conflicting_extensions, |
| 310 const net::NetLogWithSource* net_log); | 328 const net::NetLogWithSource* net_log, |
| 329 bool* response_headers_modified, |
| 330 bool* response_cookies_modified); |
| 311 // Merge the responses of blocked onAuthRequired handlers. The first | 331 // Merge the responses of blocked onAuthRequired handlers. The first |
| 312 // registered listener that supplies authentication credentials in a response, | 332 // registered listener that supplies authentication credentials in a response, |
| 313 // if any, will have its authentication credentials used. |request| must be | 333 // if any, will have its authentication credentials used. |request| must be |
| 314 // non-NULL, and contain |deltas| that are sorted in decreasing order of | 334 // non-NULL, and contain |deltas| that are sorted in decreasing order of |
| 315 // precedence. | 335 // precedence. |
| 316 // Returns whether authentication credentials are set. | 336 // Returns whether authentication credentials are set. |
| 317 bool MergeOnAuthRequiredResponses( | 337 bool MergeOnAuthRequiredResponses( |
| 318 const EventResponseDeltas& deltas, | 338 const EventResponseDeltas& deltas, |
| 319 net::AuthCredentials* auth_credentials, | 339 net::AuthCredentials* auth_credentials, |
| 320 extensions::WarningSet* conflicting_extensions, | 340 extensions::WarningSet* conflicting_extensions, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 339 | 359 |
| 340 // Stores a |content::ResourceType| representation in |types| if |type_str| is | 360 // Stores a |content::ResourceType| representation in |types| if |type_str| is |
| 341 // a resource type handled by the web request API. Returns true in case of | 361 // a resource type handled by the web request API. Returns true in case of |
| 342 // success. | 362 // success. |
| 343 bool ParseResourceType(const std::string& type_str, | 363 bool ParseResourceType(const std::string& type_str, |
| 344 std::vector<content::ResourceType>* types); | 364 std::vector<content::ResourceType>* types); |
| 345 | 365 |
| 346 } // namespace extension_web_request_api_helpers | 366 } // namespace extension_web_request_api_helpers |
| 347 | 367 |
| 348 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 368 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
| OLD | NEW |