| 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 // respective rules registry. | 469 // respective rules registry. |
| 470 std::map<RulesRegistryKey, | 470 std::map<RulesRegistryKey, |
| 471 scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_; | 471 scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_; |
| 472 | 472 |
| 473 std::unique_ptr<extensions::WebRequestEventRouterDelegate> | 473 std::unique_ptr<extensions::WebRequestEventRouterDelegate> |
| 474 web_request_event_router_delegate_; | 474 web_request_event_router_delegate_; |
| 475 | 475 |
| 476 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter); | 476 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter); |
| 477 }; | 477 }; |
| 478 | 478 |
| 479 class WebRequestInternalFunction : public SyncIOThreadExtensionFunction { | 479 class WebRequestInternalFunction : public IOThreadExtensionFunction { |
| 480 public: | 480 public: |
| 481 WebRequestInternalFunction() {} | 481 WebRequestInternalFunction() {} |
| 482 | 482 |
| 483 protected: | 483 protected: |
| 484 ~WebRequestInternalFunction() override {} | 484 ~WebRequestInternalFunction() override {} |
| 485 | 485 |
| 486 const std::string& extension_id_safe() const { | 486 const std::string& extension_id_safe() const { |
| 487 return extension() ? extension_id() : base::EmptyString(); | 487 return extension() ? extension_id() : base::EmptyString(); |
| 488 } | 488 } |
| 489 }; | 489 }; |
| 490 | 490 |
| 491 class WebRequestInternalAddEventListenerFunction | 491 class WebRequestInternalAddEventListenerFunction |
| 492 : public WebRequestInternalFunction { | 492 : public WebRequestInternalFunction { |
| 493 public: | 493 public: |
| 494 DECLARE_EXTENSION_FUNCTION("webRequestInternal.addEventListener", | 494 DECLARE_EXTENSION_FUNCTION("webRequestInternal.addEventListener", |
| 495 WEBREQUESTINTERNAL_ADDEVENTLISTENER) | 495 WEBREQUESTINTERNAL_ADDEVENTLISTENER) |
| 496 | 496 |
| 497 protected: | 497 protected: |
| 498 ~WebRequestInternalAddEventListenerFunction() override {} | 498 ~WebRequestInternalAddEventListenerFunction() override {} |
| 499 | 499 |
| 500 // ExtensionFunction: | 500 // ExtensionFunction: |
| 501 bool RunSync() override; | 501 ResponseAction Run() override; |
| 502 }; | 502 }; |
| 503 | 503 |
| 504 class WebRequestInternalEventHandledFunction | 504 class WebRequestInternalEventHandledFunction |
| 505 : public WebRequestInternalFunction { | 505 : public WebRequestInternalFunction { |
| 506 public: | 506 public: |
| 507 DECLARE_EXTENSION_FUNCTION("webRequestInternal.eventHandled", | 507 DECLARE_EXTENSION_FUNCTION("webRequestInternal.eventHandled", |
| 508 WEBREQUESTINTERNAL_EVENTHANDLED) | 508 WEBREQUESTINTERNAL_EVENTHANDLED) |
| 509 | 509 |
| 510 protected: | 510 protected: |
| 511 ~WebRequestInternalEventHandledFunction() override {} | 511 ~WebRequestInternalEventHandledFunction() override {} |
| 512 | 512 |
| 513 // Unblocks the network request and sets |error_| such that the developer | 513 private: |
| 514 // console will show the respective error message. Use this function to handle | 514 // Unblocks the network request. Use this function when handling incorrect |
| 515 // incorrect requests from the extension that cannot be detected by the schema | 515 // requests from the extension that cannot be detected by the schema |
| 516 // validator. | 516 // validator. |
| 517 void RespondWithError( | 517 void OnError( |
| 518 const std::string& event_name, | 518 const std::string& event_name, |
| 519 const std::string& sub_event_name, | 519 const std::string& sub_event_name, |
| 520 uint64_t request_id, | 520 uint64_t request_id, |
| 521 std::unique_ptr<ExtensionWebRequestEventRouter::EventResponse> response, | 521 std::unique_ptr<ExtensionWebRequestEventRouter::EventResponse> response); |
| 522 const std::string& error); | |
| 523 | 522 |
| 524 // ExtensionFunction: | 523 // ExtensionFunction: |
| 525 bool RunSync() override; | 524 ResponseAction Run() override; |
| 526 }; | 525 }; |
| 527 | 526 |
| 528 class WebRequestHandlerBehaviorChangedFunction | 527 class WebRequestHandlerBehaviorChangedFunction |
| 529 : public WebRequestInternalFunction { | 528 : public WebRequestInternalFunction { |
| 530 public: | 529 public: |
| 531 DECLARE_EXTENSION_FUNCTION("webRequest.handlerBehaviorChanged", | 530 DECLARE_EXTENSION_FUNCTION("webRequest.handlerBehaviorChanged", |
| 532 WEBREQUEST_HANDLERBEHAVIORCHANGED) | 531 WEBREQUEST_HANDLERBEHAVIORCHANGED) |
| 533 | 532 |
| 534 protected: | 533 protected: |
| 535 ~WebRequestHandlerBehaviorChangedFunction() override {} | 534 ~WebRequestHandlerBehaviorChangedFunction() override {} |
| 536 | 535 |
| 537 // ExtensionFunction: | 536 // ExtensionFunction: |
| 538 void GetQuotaLimitHeuristics( | 537 void GetQuotaLimitHeuristics( |
| 539 extensions::QuotaLimitHeuristics* heuristics) const override; | 538 extensions::QuotaLimitHeuristics* heuristics) const override; |
| 540 // Handle quota exceeded gracefully: Only warn the user but still execute the | 539 // Handle quota exceeded gracefully: Only warn the user but still execute the |
| 541 // function. | 540 // function. |
| 542 void OnQuotaExceeded(const std::string& error) override; | 541 void OnQuotaExceeded(const std::string& error) override; |
| 543 bool RunSync() override; | 542 ResponseAction Run() override; |
| 544 }; | 543 }; |
| 545 | 544 |
| 546 } // namespace extensions | 545 } // namespace extensions |
| 547 | 546 |
| 548 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ | 547 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ |
| OLD | NEW |