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

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

Issue 10560013: Persist declarative rules to the extension state store. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RegisterKey Created 8 years, 6 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 | Annotate | Revision Log
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 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "base/memory/weak_ptr.h"
16 #include "base/time.h" 17 #include "base/time.h"
17 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h" 18 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h"
18 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" 19 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
19 #include "chrome/browser/extensions/extension_function.h" 20 #include "chrome/browser/extensions/extension_function.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/common/extensions/url_pattern_set.h" 22 #include "chrome/common/extensions/url_pattern_set.h"
22 #include "ipc/ipc_sender.h" 23 #include "ipc/ipc_sender.h"
23 #include "net/base/completion_callback.h" 24 #include "net/base/completion_callback.h"
24 #include "net/base/network_delegate.h" 25 #include "net/base/network_delegate.h"
25 #include "net/http/http_request_headers.h" 26 #include "net/http/http_request_headers.h"
(...skipping 21 matching lines...) Expand all
47 class AuthCredentials; 48 class AuthCredentials;
48 class AuthChallengeInfo; 49 class AuthChallengeInfo;
49 class HttpRequestHeaders; 50 class HttpRequestHeaders;
50 class HttpResponseHeaders; 51 class HttpResponseHeaders;
51 class URLRequest; 52 class URLRequest;
52 } 53 }
53 54
54 // This class observes network events and routes them to the appropriate 55 // This class observes network events and routes them to the appropriate
55 // extensions listening to those events. All methods must be called on the IO 56 // extensions listening to those events. All methods must be called on the IO
56 // thread unless otherwise specified. 57 // thread unless otherwise specified.
57 class ExtensionWebRequestEventRouter { 58 class ExtensionWebRequestEventRouter
59 : public base::SupportsWeakPtr<ExtensionWebRequestEventRouter> {
58 public: 60 public:
59 struct BlockedRequest; 61 struct BlockedRequest;
60 62
61 enum EventTypes { 63 enum EventTypes {
62 kInvalidEvent = 0, 64 kInvalidEvent = 0,
63 kOnBeforeRequest = 1 << 0, 65 kOnBeforeRequest = 1 << 0,
64 kOnBeforeSendHeaders = 1 << 1, 66 kOnBeforeSendHeaders = 1 << 1,
65 kOnSendHeaders = 1 << 2, 67 kOnSendHeaders = 1 << 2,
66 kOnHeadersReceived = 1 << 3, 68 kOnHeadersReceived = 1 << 3,
67 kOnBeforeRedirect = 1 << 4, 69 kOnBeforeRedirect = 1 << 4,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // mostly relevant in case the caller passes |call_callback| = false 329 // mostly relevant in case the caller passes |call_callback| = false
328 // and wants to return the correct network error code himself. 330 // and wants to return the correct network error code himself.
329 int ExecuteDeltas(void* profile, uint64 request_id, bool call_callback); 331 int ExecuteDeltas(void* profile, uint64 request_id, bool call_callback);
330 332
331 // Evaluates the rules of the declarative webrequest API and stores 333 // Evaluates the rules of the declarative webrequest API and stores
332 // modifications to the request that result from WebRequestActions as 334 // modifications to the request that result from WebRequestActions as
333 // deltas in |blocked_requests_|. |original_response_headers| should only be 335 // deltas in |blocked_requests_|. |original_response_headers| should only be
334 // set for the OnHeadersReceived stage and NULL otherwise. Returns whether any 336 // set for the OnHeadersReceived stage and NULL otherwise. Returns whether any
335 // deltas were generated. 337 // deltas were generated.
336 bool ProcessDeclarativeRules( 338 bool ProcessDeclarativeRules(
339 void* profile,
340 const std::string& event_name,
337 net::URLRequest* request, 341 net::URLRequest* request,
338 extensions::RequestStages request_stage, 342 extensions::RequestStages request_stage,
339 net::HttpResponseHeaders* original_response_headers); 343 net::HttpResponseHeaders* original_response_headers);
340 344
341 // Sets the flag that |event_type| has been signaled for |request_id|. 345 // Sets the flag that |event_type| has been signaled for |request_id|.
342 // Returns the value of the flag before setting it. 346 // Returns the value of the flag before setting it.
343 bool GetAndSetSignaled(uint64 request_id, EventTypes event_type); 347 bool GetAndSetSignaled(uint64 request_id, EventTypes event_type);
344 348
345 // Clears the flag that |event_type| has been signaled for |request_id|. 349 // Clears the flag that |event_type| has been signaled for |request_id|.
346 void ClearSignaled(uint64 request_id, EventTypes event_type); 350 void ClearSignaled(uint64 request_id, EventTypes event_type);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 virtual void OnQuotaExceeded() OVERRIDE; 419 virtual void OnQuotaExceeded() OVERRIDE;
416 virtual bool RunImpl() OVERRIDE; 420 virtual bool RunImpl() OVERRIDE;
417 }; 421 };
418 422
419 // Send updates to |host| with information about what webRequest-related 423 // Send updates to |host| with information about what webRequest-related
420 // extensions are installed. 424 // extensions are installed.
421 // TODO(mpcomplete): remove. http://crbug.com/100411 425 // TODO(mpcomplete): remove. http://crbug.com/100411
422 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host); 426 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host);
423 427
424 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ 428 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698