Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: extensions/browser/api/web_request/web_request_api.h

Issue 670173002: Fix webrequest api for webview in webui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scoped_refptr not testable Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/strings/string_util.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "content/public/common/resource_type.h" 18 #include "content/public/common/resource_type.h"
18 #include "extensions/browser/api/declarative/rules_registry.h" 19 #include "extensions/browser/api/declarative/rules_registry.h"
19 #include "extensions/browser/api/declarative_webrequest/request_stage.h" 20 #include "extensions/browser/api/declarative_webrequest/request_stage.h"
20 #include "extensions/browser/api/web_request/web_request_api_helpers.h" 21 #include "extensions/browser/api/web_request/web_request_api_helpers.h"
21 #include "extensions/browser/api/web_request/web_request_permissions.h" 22 #include "extensions/browser/api/web_request/web_request_permissions.h"
22 #include "extensions/browser/browser_context_keyed_api_factory.h" 23 #include "extensions/browser/browser_context_keyed_api_factory.h"
23 #include "extensions/browser/event_router.h" 24 #include "extensions/browser/event_router.h"
24 #include "extensions/browser/extension_function.h" 25 #include "extensions/browser/extension_function.h"
25 #include "extensions/common/url_pattern_set.h" 26 #include "extensions/common/url_pattern_set.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 // respective rules registry. 482 // respective rules registry.
482 std::map<RulesRegistryKey, 483 std::map<RulesRegistryKey,
483 scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_; 484 scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_;
484 485
485 scoped_ptr<extensions::WebRequestEventRouterDelegate> 486 scoped_ptr<extensions::WebRequestEventRouterDelegate>
486 web_request_event_router_delegate_; 487 web_request_event_router_delegate_;
487 488
488 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter); 489 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter);
489 }; 490 };
490 491
492 class WebRequestInternalFunction : public SyncIOThreadExtensionFunction {
493 public:
494 WebRequestInternalFunction() {}
495
496 protected:
497 ~WebRequestInternalFunction() override {}
498
499 const std::string& extension_id_safe() const {
500 return extension() ? extension_id() : base::EmptyString();
501 }
502 };
503
491 class WebRequestInternalAddEventListenerFunction 504 class WebRequestInternalAddEventListenerFunction
492 : public SyncIOThreadExtensionFunction { 505 : public WebRequestInternalFunction {
493 public: 506 public:
494 DECLARE_EXTENSION_FUNCTION("webRequestInternal.addEventListener", 507 DECLARE_EXTENSION_FUNCTION("webRequestInternal.addEventListener",
495 WEBREQUESTINTERNAL_ADDEVENTLISTENER) 508 WEBREQUESTINTERNAL_ADDEVENTLISTENER)
496 509
497 protected: 510 protected:
498 ~WebRequestInternalAddEventListenerFunction() override {} 511 ~WebRequestInternalAddEventListenerFunction() override {}
499 512
500 // ExtensionFunction: 513 // ExtensionFunction:
501 bool RunSync() override; 514 bool RunSync() override;
502 }; 515 };
503 516
504 class WebRequestInternalEventHandledFunction 517 class WebRequestInternalEventHandledFunction
505 : public SyncIOThreadExtensionFunction { 518 : public WebRequestInternalFunction {
506 public: 519 public:
507 DECLARE_EXTENSION_FUNCTION("webRequestInternal.eventHandled", 520 DECLARE_EXTENSION_FUNCTION("webRequestInternal.eventHandled",
508 WEBREQUESTINTERNAL_EVENTHANDLED) 521 WEBREQUESTINTERNAL_EVENTHANDLED)
509 522
510 protected: 523 protected:
511 ~WebRequestInternalEventHandledFunction() override {} 524 ~WebRequestInternalEventHandledFunction() override {}
512 525
513 // Unblocks the network request and sets |error_| such that the developer 526 // Unblocks the network request and sets |error_| such that the developer
514 // console will show the respective error message. Use this function to handle 527 // console will show the respective error message. Use this function to handle
515 // incorrect requests from the extension that cannot be detected by the schema 528 // incorrect requests from the extension that cannot be detected by the schema
516 // validator. 529 // validator.
517 void RespondWithError( 530 void RespondWithError(
518 const std::string& event_name, 531 const std::string& event_name,
519 const std::string& sub_event_name, 532 const std::string& sub_event_name,
520 uint64 request_id, 533 uint64 request_id,
521 scoped_ptr<ExtensionWebRequestEventRouter::EventResponse> response, 534 scoped_ptr<ExtensionWebRequestEventRouter::EventResponse> response,
522 const std::string& error); 535 const std::string& error);
523 536
524 // ExtensionFunction: 537 // ExtensionFunction:
525 bool RunSync() override; 538 bool RunSync() override;
526 }; 539 };
527 540
528 class WebRequestHandlerBehaviorChangedFunction 541 class WebRequestHandlerBehaviorChangedFunction
529 : public SyncIOThreadExtensionFunction { 542 : public WebRequestInternalFunction {
530 public: 543 public:
531 DECLARE_EXTENSION_FUNCTION("webRequest.handlerBehaviorChanged", 544 DECLARE_EXTENSION_FUNCTION("webRequest.handlerBehaviorChanged",
532 WEBREQUEST_HANDLERBEHAVIORCHANGED) 545 WEBREQUEST_HANDLERBEHAVIORCHANGED)
533 546
534 protected: 547 protected:
535 ~WebRequestHandlerBehaviorChangedFunction() override {} 548 ~WebRequestHandlerBehaviorChangedFunction() override {}
536 549
537 // ExtensionFunction: 550 // ExtensionFunction:
538 void GetQuotaLimitHeuristics( 551 void GetQuotaLimitHeuristics(
539 extensions::QuotaLimitHeuristics* heuristics) const override; 552 extensions::QuotaLimitHeuristics* heuristics) const override;
540 // Handle quota exceeded gracefully: Only warn the user but still execute the 553 // Handle quota exceeded gracefully: Only warn the user but still execute the
541 // function. 554 // function.
542 void OnQuotaExceeded(const std::string& error) override; 555 void OnQuotaExceeded(const std::string& error) override;
543 bool RunSync() override; 556 bool RunSync() override;
544 }; 557 };
545 558
546 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_ 559 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698