| Index: chrome/browser/extensions/extension_webrequest_api.h
|
| diff --git a/chrome/browser/extensions/extension_webrequest_api.h b/chrome/browser/extensions/extension_webrequest_api.h
|
| index 891370274a6170ec4331f18bbffd9c625216e702..92a655849ef7d8658566d8315e0ddc1dcb653b23 100644
|
| --- a/chrome/browser/extensions/extension_webrequest_api.h
|
| +++ b/chrome/browser/extensions/extension_webrequest_api.h
|
| @@ -21,7 +21,7 @@
|
| #include "webkit/glue/resource_type.h"
|
|
|
| class DictionaryValue;
|
| -class ExtensionEventRouterForwarder;
|
| +class ExtensionInfoMap;
|
| class GURL;
|
| class ListValue;
|
| class StringValue;
|
| @@ -109,7 +109,7 @@ class ExtensionWebRequestEventRouter {
|
| // the given request. Returns net::ERR_IO_PENDING if an extension is
|
| // intercepting the request, OK otherwise.
|
| int OnBeforeRequest(ProfileId profile_id,
|
| - ExtensionEventRouterForwarder* event_router,
|
| + ExtensionInfoMap* extension_info_map,
|
| net::URLRequest* request,
|
| net::CompletionCallback* callback,
|
| GURL* new_url);
|
| @@ -119,7 +119,7 @@ class ExtensionWebRequestEventRouter {
|
| // Returns net::ERR_IO_PENDING if an extension is intercepting the request, OK
|
| // otherwise.
|
| int OnBeforeSendHeaders(ProfileId profile_id,
|
| - ExtensionEventRouterForwarder* event_router,
|
| + ExtensionInfoMap* extension_info_map,
|
| uint64 request_id,
|
| net::CompletionCallback* callback,
|
| net::HttpRequestHeaders* headers);
|
| @@ -127,7 +127,7 @@ class ExtensionWebRequestEventRouter {
|
| // Dispatches the onRequestSent event. This is fired for HTTP(s) requests
|
| // only.
|
| void OnRequestSent(ProfileId profile_id,
|
| - ExtensionEventRouterForwarder* event_router,
|
| + ExtensionInfoMap* extension_info_map,
|
| uint64 request_id,
|
| const net::HostPortPair& socket_address,
|
| const net::HttpRequestHeaders& headers);
|
| @@ -135,24 +135,24 @@ class ExtensionWebRequestEventRouter {
|
| // Dispatches the onBeforeRedirect event. This is fired for HTTP(s) requests
|
| // only.
|
| void OnBeforeRedirect(ProfileId profile_id,
|
| - ExtensionEventRouterForwarder* event_router,
|
| + ExtensionInfoMap* extension_info_map,
|
| net::URLRequest* request,
|
| const GURL& new_location);
|
|
|
| // Dispatches the onResponseStarted event indicating that the first bytes of
|
| // the response have arrived.
|
| void OnResponseStarted(ProfileId profile_id,
|
| - ExtensionEventRouterForwarder* event_router,
|
| + ExtensionInfoMap* extension_info_map,
|
| net::URLRequest* request);
|
|
|
| // Dispatches the onComplete event.
|
| void OnCompleted(ProfileId profile_id,
|
| - ExtensionEventRouterForwarder* event_router,
|
| + ExtensionInfoMap* extension_info_map,
|
| net::URLRequest* request);
|
|
|
| // Dispatches an onErrorOccurred event.
|
| void OnErrorOccurred(ProfileId profile_id,
|
| - ExtensionEventRouterForwarder* event_router,
|
| + ExtensionInfoMap* extension_info_map,
|
| net::URLRequest* request);
|
|
|
| // Notifications when objects are going away.
|
| @@ -178,7 +178,8 @@ class ExtensionWebRequestEventRouter {
|
| const std::string& event_name,
|
| const std::string& sub_event_name,
|
| const RequestFilter& filter,
|
| - int extra_info_spec);
|
| + int extra_info_spec,
|
| + base::WeakPtr<IPC::Message::Sender> ipc_sender);
|
|
|
| // Removes the listener for the given sub-event.
|
| void RemoveEventListener(
|
| @@ -186,6 +187,12 @@ class ExtensionWebRequestEventRouter {
|
| const std::string& extension_id,
|
| const std::string& sub_event_name);
|
|
|
| + // Called when an incognito profile is created or destroyed.
|
| + void OnOTRProfileCreated(ProfileId original_profile_id,
|
| + ProfileId otr_profile_id);
|
| + void OnOTRProfileDestroyed(ProfileId original_profile_id,
|
| + ProfileId otr_profile_id);
|
| +
|
| private:
|
| friend struct DefaultSingletonTraits<ExtensionWebRequestEventRouter>;
|
| struct EventListener;
|
| @@ -196,13 +203,13 @@ class ExtensionWebRequestEventRouter {
|
| typedef std::map<uint64, net::URLRequest*> HttpRequestMap;
|
| // Map of request_id -> bit vector of EventTypes already signaled
|
| typedef std::map<uint64, int> SignaledRequestMap;
|
| + typedef std::map<ProfileId, ProfileId> CrossProfileMap;
|
|
|
| ExtensionWebRequestEventRouter();
|
| ~ExtensionWebRequestEventRouter();
|
|
|
| bool DispatchEvent(
|
| ProfileId profile_id,
|
| - ExtensionEventRouterForwarder* event_router,
|
| net::URLRequest* request,
|
| const std::vector<const EventListener*>& listeners,
|
| const ListValue& args);
|
| @@ -211,6 +218,7 @@ class ExtensionWebRequestEventRouter {
|
| // on their filter parameters. |extra_info_spec| will contain the combined
|
| // set of extra_info_spec flags that every matching listener asked for.
|
| std::vector<const EventListener*> GetMatchingListeners(
|
| + ExtensionInfoMap* extension_info_map,
|
| ProfileId profile_id,
|
| const std::string& event_name,
|
| const GURL& url,
|
| @@ -221,11 +229,28 @@ class ExtensionWebRequestEventRouter {
|
|
|
| // Same as above, but retrieves the filter parameters from the request.
|
| std::vector<const EventListener*> GetMatchingListeners(
|
| + ExtensionInfoMap* extension_info_map,
|
| ProfileId profile_id,
|
| const std::string& event_name,
|
| net::URLRequest* request,
|
| int* extra_info_spec);
|
|
|
| + // Helper for the above functions. This is called twice: once for the profile
|
| + // of the event, the next for the cross profile (incognito if event is for
|
| + // normal profile, or vice versa).
|
| + void GetMatchingListenersImpl(
|
| + ExtensionInfoMap* extension_info_map,
|
| + ProfileId profile_id,
|
| + bool crosses_incognito,
|
| + const std::string& event_name,
|
| + const GURL& url,
|
| + int tab_id,
|
| + int window_id,
|
| + ResourceType::Type resource_type,
|
| + int* extra_info_spec,
|
| + std::vector<const ExtensionWebRequestEventRouter::EventListener*>*
|
| + matching_listeners);
|
| +
|
| // Decrements the count of event handlers blocking the given request. When the
|
| // count reaches 0, we stop blocking the request and proceed it using the
|
| // method requested by the extension with the highest precedence. Precedence
|
| @@ -233,8 +258,6 @@ class ExtensionWebRequestEventRouter {
|
| // method assumes ownership.
|
| void DecrementBlockCount(uint64 request_id, EventResponse* response);
|
|
|
| - void OnRequestDeleted(net::URLRequest* request);
|
| -
|
| // Sets the flag that |event_type| has been signaled for |request_id|.
|
| // Returns the value of the flag before setting it.
|
| bool GetAndSetSignaled(uint64 request_id, EventTypes event_type);
|
| @@ -258,16 +281,20 @@ class ExtensionWebRequestEventRouter {
|
| // signaled and should not be sent again.
|
| SignaledRequestMap signaled_requests_;
|
|
|
| + // A map of original profile -> corresponding incognito profile (and vice
|
| + // versa).
|
| + CrossProfileMap cross_profile_map_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter);
|
| };
|
|
|
| -class WebRequestAddEventListener : public SyncExtensionFunction {
|
| +class WebRequestAddEventListener : public SyncIOThreadExtensionFunction {
|
| public:
|
| virtual bool RunImpl();
|
| DECLARE_EXTENSION_FUNCTION_NAME("experimental.webRequest.addEventListener");
|
| };
|
|
|
| -class WebRequestEventHandled : public SyncExtensionFunction {
|
| +class WebRequestEventHandled : public SyncIOThreadExtensionFunction {
|
| public:
|
| virtual bool RunImpl();
|
| DECLARE_EXTENSION_FUNCTION_NAME("experimental.webRequest.eventHandled");
|
|
|