| 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 10 matching lines...) Expand all Loading... |
| 261 // Modifies the "Set-Cookie" headers in |override_response_headers| according to | 270 // Modifies the "Set-Cookie" headers in |override_response_headers| according to |
| 262 // |deltas.response_cookie_modifications|. If |override_response_headers| is | 271 // |deltas.response_cookie_modifications|. If |override_response_headers| is |
| 263 // NULL, a copy of |original_response_headers| is created. Conflicts are | 272 // NULL, a copy of |original_response_headers| is created. Conflicts are |
| 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); |
| 280 // Stores in |*new_url| the redirect request of the extension with highest |
| 281 // precedence. |
| 271 // Stores a copy of |original_response_header| into |override_response_headers| | 282 // Stores a copy of |original_response_header| into |override_response_headers| |
| 272 // that is modified according to |deltas|. If |deltas| does not instruct to | 283 // that is modified according to |deltas|. If |deltas| does not instruct to |
| 273 // modify the response headers, |override_response_headers| remains empty. | 284 // modify the response headers, |override_response_headers| remains empty. |
| 274 void MergeOnHeadersReceivedResponses( | 285 void MergeOnHeadersReceivedResponses( |
| 275 const EventResponseDeltas& deltas, | 286 const EventResponseDeltas& deltas, |
| 287 GURL* new_url, |
| 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, |
| 278 extensions::ExtensionWarningSet* conflicting_extensions, | 290 extensions::ExtensionWarningSet* conflicting_extensions, |
| 279 const net::BoundNetLog* net_log); | 291 const net::BoundNetLog* net_log); |
| 280 // Merge the responses of blocked onAuthRequired handlers. The first | 292 // Merge the responses of blocked onAuthRequired handlers. The first |
| 281 // registered listener that supplies authentication credentials in a response, | 293 // registered listener that supplies authentication credentials in a response, |
| 282 // if any, will have its authentication credentials used. |request| must be | 294 // if any, will have its authentication credentials used. |request| must be |
| 283 // non-NULL, and contain |deltas| that are sorted in decreasing order of | 295 // non-NULL, and contain |deltas| that are sorted in decreasing order of |
| 284 // precedence. | 296 // precedence. |
| 285 // Returns whether authentication credentials are set. | 297 // Returns whether authentication credentials are set. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 309 // Tells renderer processes that the web request or declarative web request | 321 // Tells renderer processes that the web request or declarative web request |
| 310 // API has been used by |extension| in profile |profile_id| to collect | 322 // API has been used by |extension| in profile |profile_id| to collect |
| 311 // UMA statistics on Page Load Times. Needs to be called on the UI thread. | 323 // UMA statistics on Page Load Times. Needs to be called on the UI thread. |
| 312 void NotifyWebRequestAPIUsed( | 324 void NotifyWebRequestAPIUsed( |
| 313 void* profile_id, | 325 void* profile_id, |
| 314 scoped_refptr<const extensions::Extension> extension); | 326 scoped_refptr<const extensions::Extension> extension); |
| 315 | 327 |
| 316 } // namespace extension_web_request_api_helpers | 328 } // namespace extension_web_request_api_helpers |
| 317 | 329 |
| 318 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 330 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
| OLD | NEW |