| 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 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ | 6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 namespace net { | 50 namespace net { |
| 51 class AuthChallengeInfo; | 51 class AuthChallengeInfo; |
| 52 class AuthCredentials; | 52 class AuthCredentials; |
| 53 class HttpRequestHeaders; | 53 class HttpRequestHeaders; |
| 54 class HttpResponseHeaders; | 54 class HttpResponseHeaders; |
| 55 class URLRequest; | 55 class URLRequest; |
| 56 } | 56 } |
| 57 | 57 |
| 58 namespace extensions { | 58 namespace extensions { |
| 59 | |
| 60 class ExtensionNavigationUIData; | 59 class ExtensionNavigationUIData; |
| 61 class InfoMap; | 60 class InfoMap; |
| 62 class WebRequestEventDetails; | 61 class WebRequestEventDetails; |
| 63 class WebRequestRulesRegistry; | 62 class WebRequestRulesRegistry; |
| 64 class WebRequestEventRouterDelegate; | 63 class WebRequestEventRouterDelegate; |
| 65 | 64 |
| 66 // Support class for the WebRequest API. Lives on the UI thread. Most of the | 65 // Support class for the WebRequest API. Lives on the UI thread. Most of the |
| 67 // work is done by ExtensionWebRequestEventRouter below. This class observes | 66 // work is done by ExtensionWebRequestEventRouter below. This class observes |
| 68 // extensions::EventRouter to deal with event listeners. There is one instance | 67 // extensions::EventRouter to deal with event listeners. There is one instance |
| 69 // per BrowserContext which is shared with incognito. | 68 // per BrowserContext which is shared with incognito. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 void RegisterRulesRegistry( | 164 void RegisterRulesRegistry( |
| 166 void* browser_context, | 165 void* browser_context, |
| 167 int rules_registry_id, | 166 int rules_registry_id, |
| 168 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry); | 167 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry); |
| 169 | 168 |
| 170 // Dispatches the OnBeforeRequest event to any extensions whose filters match | 169 // Dispatches the OnBeforeRequest event to any extensions whose filters match |
| 171 // the given request. Returns net::ERR_IO_PENDING if an extension is | 170 // the given request. Returns net::ERR_IO_PENDING if an extension is |
| 172 // intercepting the request, OK otherwise. | 171 // intercepting the request, OK otherwise. |
| 173 int OnBeforeRequest(void* browser_context, | 172 int OnBeforeRequest(void* browser_context, |
| 174 const extensions::InfoMap* extension_info_map, | 173 const extensions::InfoMap* extension_info_map, |
| 175 ExtensionNavigationUIData* navigation_ui_data, | |
| 176 net::URLRequest* request, | 174 net::URLRequest* request, |
| 177 const net::CompletionCallback& callback, | 175 const net::CompletionCallback& callback, |
| 178 GURL* new_url); | 176 GURL* new_url); |
| 179 | 177 |
| 180 // Dispatches the onBeforeSendHeaders event. This is fired for HTTP(s) | 178 // Dispatches the onBeforeSendHeaders event. This is fired for HTTP(s) |
| 181 // requests only, and allows modification of the outgoing request headers. | 179 // requests only, and allows modification of the outgoing request headers. |
| 182 // Returns net::ERR_IO_PENDING if an extension is intercepting the request, OK | 180 // Returns net::ERR_IO_PENDING if an extension is intercepting the request, OK |
| 183 // otherwise. | 181 // otherwise. |
| 184 int OnBeforeSendHeaders(void* browser_context, | 182 int OnBeforeSendHeaders(void* browser_context, |
| 185 const extensions::InfoMap* extension_info_map, | 183 const extensions::InfoMap* extension_info_map, |
| 186 ExtensionNavigationUIData* navigation_ui_data, | |
| 187 net::URLRequest* request, | 184 net::URLRequest* request, |
| 188 const net::CompletionCallback& callback, | 185 const net::CompletionCallback& callback, |
| 189 net::HttpRequestHeaders* headers); | 186 net::HttpRequestHeaders* headers); |
| 190 | 187 |
| 191 // Dispatches the onSendHeaders event. This is fired for HTTP(s) requests | 188 // Dispatches the onSendHeaders event. This is fired for HTTP(s) requests |
| 192 // only. | 189 // only. |
| 193 void OnSendHeaders(void* browser_context, | 190 void OnSendHeaders(void* browser_context, |
| 194 const extensions::InfoMap* extension_info_map, | 191 const extensions::InfoMap* extension_info_map, |
| 195 ExtensionNavigationUIData* navigation_ui_data, | |
| 196 net::URLRequest* request, | 192 net::URLRequest* request, |
| 197 const net::HttpRequestHeaders& headers); | 193 const net::HttpRequestHeaders& headers); |
| 198 | 194 |
| 199 // Dispatches the onHeadersReceived event. This is fired for HTTP(s) | 195 // Dispatches the onHeadersReceived event. This is fired for HTTP(s) |
| 200 // requests only, and allows modification of incoming response headers. | 196 // requests only, and allows modification of incoming response headers. |
| 201 // Returns net::ERR_IO_PENDING if an extension is intercepting the request, | 197 // Returns net::ERR_IO_PENDING if an extension is intercepting the request, |
| 202 // OK otherwise. |original_response_headers| is reference counted. |callback| | 198 // OK otherwise. |original_response_headers| is reference counted. |callback| |
| 203 // |override_response_headers| and |allowed_unsafe_redirect_url| are owned by | 199 // |override_response_headers| and |allowed_unsafe_redirect_url| are owned by |
| 204 // a URLRequestJob. They are guaranteed to be valid until |callback| is called | 200 // a URLRequestJob. They are guaranteed to be valid until |callback| is called |
| 205 // or OnURLRequestDestroyed is called (whatever comes first). | 201 // or OnURLRequestDestroyed is called (whatever comes first). |
| 206 // Do not modify |original_response_headers| directly but write new ones | 202 // Do not modify |original_response_headers| directly but write new ones |
| 207 // into |override_response_headers|. | 203 // into |override_response_headers|. |
| 208 int OnHeadersReceived( | 204 int OnHeadersReceived( |
| 209 void* browser_context, | 205 void* browser_context, |
| 210 const extensions::InfoMap* extension_info_map, | 206 const extensions::InfoMap* extension_info_map, |
| 211 ExtensionNavigationUIData* navigation_ui_data, | |
| 212 net::URLRequest* request, | 207 net::URLRequest* request, |
| 213 const net::CompletionCallback& callback, | 208 const net::CompletionCallback& callback, |
| 214 const net::HttpResponseHeaders* original_response_headers, | 209 const net::HttpResponseHeaders* original_response_headers, |
| 215 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, | 210 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, |
| 216 GURL* allowed_unsafe_redirect_url); | 211 GURL* allowed_unsafe_redirect_url); |
| 217 | 212 |
| 218 // Dispatches the OnAuthRequired event to any extensions whose filters match | 213 // Dispatches the OnAuthRequired event to any extensions whose filters match |
| 219 // the given request. If the listener is not registered as "blocking", then | 214 // the given request. If the listener is not registered as "blocking", then |
| 220 // AUTH_REQUIRED_RESPONSE_OK is returned. Otherwise, | 215 // AUTH_REQUIRED_RESPONSE_OK is returned. Otherwise, |
| 221 // AUTH_REQUIRED_RESPONSE_IO_PENDING is returned and |callback| will be | 216 // AUTH_REQUIRED_RESPONSE_IO_PENDING is returned and |callback| will be |
| 222 // invoked later. | 217 // invoked later. |
| 223 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired( | 218 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired( |
| 224 void* browser_context, | 219 void* browser_context, |
| 225 const extensions::InfoMap* extension_info_map, | 220 const extensions::InfoMap* extension_info_map, |
| 226 ExtensionNavigationUIData* navigation_ui_data, | |
| 227 net::URLRequest* request, | 221 net::URLRequest* request, |
| 228 const net::AuthChallengeInfo& auth_info, | 222 const net::AuthChallengeInfo& auth_info, |
| 229 const net::NetworkDelegate::AuthCallback& callback, | 223 const net::NetworkDelegate::AuthCallback& callback, |
| 230 net::AuthCredentials* credentials); | 224 net::AuthCredentials* credentials); |
| 231 | 225 |
| 232 // Dispatches the onBeforeRedirect event. This is fired for HTTP(s) requests | 226 // Dispatches the onBeforeRedirect event. This is fired for HTTP(s) requests |
| 233 // only. | 227 // only. |
| 234 void OnBeforeRedirect(void* browser_context, | 228 void OnBeforeRedirect(void* browser_context, |
| 235 const extensions::InfoMap* extension_info_map, | 229 const extensions::InfoMap* extension_info_map, |
| 236 ExtensionNavigationUIData* navigation_ui_data, | |
| 237 net::URLRequest* request, | 230 net::URLRequest* request, |
| 238 const GURL& new_location); | 231 const GURL& new_location); |
| 239 | 232 |
| 240 // Dispatches the onResponseStarted event indicating that the first bytes of | 233 // Dispatches the onResponseStarted event indicating that the first bytes of |
| 241 // the response have arrived. | 234 // the response have arrived. |
| 242 void OnResponseStarted(void* browser_context, | 235 void OnResponseStarted(void* browser_context, |
| 243 const extensions::InfoMap* extension_info_map, | 236 const extensions::InfoMap* extension_info_map, |
| 244 ExtensionNavigationUIData* navigation_ui_data, | |
| 245 net::URLRequest* request, | 237 net::URLRequest* request, |
| 246 int net_error); | 238 int net_error); |
| 247 // Deprecated. | 239 // Deprecated. |
| 248 // TODO(maksims): Remove this. | 240 // TODO(maksims): Remove this. |
| 249 void OnResponseStarted(void* browser_context, | 241 void OnResponseStarted(void* browser_context, |
| 250 const extensions::InfoMap* extension_info_map, | 242 const extensions::InfoMap* extension_info_map, |
| 251 ExtensionNavigationUIData* navigation_ui_data, | |
| 252 net::URLRequest* request); | 243 net::URLRequest* request); |
| 253 | 244 |
| 254 // Dispatches the onComplete event. | 245 // Dispatches the onComplete event. |
| 255 void OnCompleted(void* browser_context, | 246 void OnCompleted(void* browser_context, |
| 256 const extensions::InfoMap* extension_info_map, | 247 const extensions::InfoMap* extension_info_map, |
| 257 ExtensionNavigationUIData* navigation_ui_data, | |
| 258 net::URLRequest* request, | 248 net::URLRequest* request, |
| 259 int net_error); | 249 int net_error); |
| 260 // Deprecated. | 250 // Deprecated. |
| 261 // TODO(maksims): Remove this. | 251 // TODO(maksims): Remove this. |
| 262 void OnCompleted(void* browser_context, | 252 void OnCompleted(void* browser_context, |
| 263 const extensions::InfoMap* extension_info_map, | 253 const extensions::InfoMap* extension_info_map, |
| 264 ExtensionNavigationUIData* navigation_ui_data, | |
| 265 net::URLRequest* request); | 254 net::URLRequest* request); |
| 266 | 255 |
| 267 // Dispatches an onErrorOccurred event. | 256 // Dispatches an onErrorOccurred event. |
| 268 void OnErrorOccurred(void* browser_context, | 257 void OnErrorOccurred(void* browser_context, |
| 269 const extensions::InfoMap* extension_info_map, | 258 const extensions::InfoMap* extension_info_map, |
| 270 ExtensionNavigationUIData* navigation_ui_data, | |
| 271 net::URLRequest* request, | 259 net::URLRequest* request, |
| 272 bool started, | 260 bool started, |
| 273 int net_error); | 261 int net_error); |
| 274 // Deprecated. | 262 // Deprecated. |
| 275 // TODO(maksims): Remove this. | 263 // TODO(maksims): Remove this. |
| 276 void OnErrorOccurred(void* browser_context, | 264 void OnErrorOccurred(void* browser_context, |
| 277 const extensions::InfoMap* extension_info_map, | 265 const extensions::InfoMap* extension_info_map, |
| 278 ExtensionNavigationUIData* navigation_ui_data, | |
| 279 net::URLRequest* request, | 266 net::URLRequest* request, |
| 280 bool started); | 267 bool started); |
| 281 | 268 |
| 282 // Notifications when objects are going away. | 269 // Notifications when objects are going away. |
| 283 void OnURLRequestDestroyed(void* browser_context, | 270 void OnURLRequestDestroyed(void* browser_context, |
| 284 const net::URLRequest* request); | 271 const net::URLRequest* request); |
| 285 | 272 |
| 286 // Called when an event listener handles a blocking event and responds. | 273 // Called when an event listener handles a blocking event and responds. |
| 287 void OnEventHandled(void* browser_context, | 274 void OnEventHandled(void* browser_context, |
| 288 const std::string& extension_id, | 275 const std::string& extension_id, |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 extensions::QuotaLimitHeuristics* heuristics) const override; | 627 extensions::QuotaLimitHeuristics* heuristics) const override; |
| 641 // Handle quota exceeded gracefully: Only warn the user but still execute the | 628 // Handle quota exceeded gracefully: Only warn the user but still execute the |
| 642 // function. | 629 // function. |
| 643 void OnQuotaExceeded(const std::string& error) override; | 630 void OnQuotaExceeded(const std::string& error) override; |
| 644 ResponseAction Run() override; | 631 ResponseAction Run() override; |
| 645 }; | 632 }; |
| 646 | 633 |
| 647 } // namespace extensions | 634 } // namespace extensions |
| 648 | 635 |
| 649 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ | 636 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ |
| OLD | NEW |