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

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

Issue 568583002: Introduce WebRequestEventRouterDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename the delegate to WebRequestEventRouterDelegate. Created 6 years, 3 months 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 CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_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>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 class AuthChallengeInfo; 47 class AuthChallengeInfo;
48 class HttpRequestHeaders; 48 class HttpRequestHeaders;
49 class HttpResponseHeaders; 49 class HttpResponseHeaders;
50 class URLRequest; 50 class URLRequest;
51 } 51 }
52 52
53 namespace extensions { 53 namespace extensions {
54 54
55 class InfoMap; 55 class InfoMap;
56 class WebRequestRulesRegistry; 56 class WebRequestRulesRegistry;
57 class WebRequestEventRouterDelegate;
57 58
58 // Support class for the WebRequest API. Lives on the UI thread. Most of the 59 // Support class for the WebRequest API. Lives on the UI thread. Most of the
59 // work is done by ExtensionWebRequestEventRouter below. This class observes 60 // work is done by ExtensionWebRequestEventRouter below. This class observes
60 // extensions::EventRouter to deal with event listeners. There is one instance 61 // extensions::EventRouter to deal with event listeners. There is one instance
61 // per BrowserContext which is shared with incognito. 62 // per BrowserContext which is shared with incognito.
62 class WebRequestAPI : public BrowserContextKeyedAPI, 63 class WebRequestAPI : public BrowserContextKeyedAPI,
63 public EventRouter::Observer { 64 public EventRouter::Observer {
64 public: 65 public:
65 explicit WebRequestAPI(content::BrowserContext* context); 66 explicit WebRequestAPI(content::BrowserContext* context);
66 virtual ~WebRequestAPI(); 67 virtual ~WebRequestAPI();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 void SendMessages(void* profile, const BlockedRequest& blocked_request); 404 void SendMessages(void* profile, const BlockedRequest& blocked_request);
404 405
405 // Called when the RulesRegistry is ready to unblock a request that was 406 // Called when the RulesRegistry is ready to unblock a request that was
406 // waiting for said event. 407 // waiting for said event.
407 void OnRulesRegistryReady( 408 void OnRulesRegistryReady(
408 void* profile, 409 void* profile,
409 const std::string& event_name, 410 const std::string& event_name,
410 uint64 request_id, 411 uint64 request_id,
411 extensions::RequestStage request_stage); 412 extensions::RequestStage request_stage);
412 413
414 // Extracts from |request| information for the keys requestId, url, method,
415 // frameId, tabId, type, and timeStamp and writes these into |out| to be
416 // passed on to extensions.
417 void ExtractRequestInfo(net::URLRequest* request, base::DictionaryValue* out);
418
419 void ExtractRequestInfoDetails(
420 net::URLRequest* request,
421 bool* is_main_frame,
422 int* frame_id,
423 bool* parent_is_main_frame,
424 int* parent_frame_id,
425 int* tab_id,
426 int* window_id,
427 int* render_process_host_id,
428 int* routing_id,
429 content::ResourceType* resource_type) const;
430
413 // Sets the flag that |event_type| has been signaled for |request_id|. 431 // Sets the flag that |event_type| has been signaled for |request_id|.
414 // Returns the value of the flag before setting it. 432 // Returns the value of the flag before setting it.
415 bool GetAndSetSignaled(uint64 request_id, EventTypes event_type); 433 bool GetAndSetSignaled(uint64 request_id, EventTypes event_type);
416 434
417 // Clears the flag that |event_type| has been signaled for |request_id|. 435 // Clears the flag that |event_type| has been signaled for |request_id|.
418 void ClearSignaled(uint64 request_id, EventTypes event_type); 436 void ClearSignaled(uint64 request_id, EventTypes event_type);
419 437
420 // Returns whether |request| represents a top level window navigation. 438 // Returns whether |request| represents a top level window navigation.
421 bool IsPageLoad(net::URLRequest* request) const; 439 bool IsPageLoad(net::URLRequest* request) const;
422 440
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 475
458 CallbacksForPageLoad callbacks_for_page_load_; 476 CallbacksForPageLoad callbacks_for_page_load_;
459 477
460 typedef std::pair<void*, extensions::RulesRegistryService::WebViewKey> 478 typedef std::pair<void*, extensions::RulesRegistryService::WebViewKey>
461 RulesRegistryKey; 479 RulesRegistryKey;
462 // Maps each profile (and OTRProfile) and a webview key to its respective 480 // Maps each profile (and OTRProfile) and a webview key to its respective
463 // rules registry. 481 // rules registry.
464 std::map<RulesRegistryKey, 482 std::map<RulesRegistryKey,
465 scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_; 483 scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_;
466 484
485 scoped_ptr<extensions::WebRequestEventRouterDelegate>
486 web_request_event_router_delegate_;
487
467 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter); 488 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter);
468 }; 489 };
469 490
470 class WebRequestInternalAddEventListenerFunction 491 class WebRequestInternalAddEventListenerFunction
471 : public SyncIOThreadExtensionFunction { 492 : public SyncIOThreadExtensionFunction {
472 public: 493 public:
473 DECLARE_EXTENSION_FUNCTION("webRequestInternal.addEventListener", 494 DECLARE_EXTENSION_FUNCTION("webRequestInternal.addEventListener",
474 WEBREQUESTINTERNAL_ADDEVENTLISTENER) 495 WEBREQUESTINTERNAL_ADDEVENTLISTENER)
475 496
476 protected: 497 protected:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 // function. 541 // function.
521 virtual void OnQuotaExceeded(const std::string& error) OVERRIDE; 542 virtual void OnQuotaExceeded(const std::string& error) OVERRIDE;
522 virtual bool RunSync() OVERRIDE; 543 virtual bool RunSync() OVERRIDE;
523 }; 544 };
524 545
525 // Send updates to |host| with information about what webRequest-related 546 // Send updates to |host| with information about what webRequest-related
526 // extensions are installed. 547 // extensions are installed.
527 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host); 548 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host);
528 549
529 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ 550 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698