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 CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTION_H
_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTION_H
_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTION_H
_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTION_H
_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h" | 14 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h" |
15 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" | 15 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" |
| 16 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" |
16 #include "chrome/common/extensions/api/events.h" | 17 #include "chrome/common/extensions/api/events.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 #include "unicode/regex.h" | 19 #include "unicode/regex.h" |
19 | 20 |
20 class WebRequestPermission; | 21 class WebRequestPermission; |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class DictionaryValue; | 24 class DictionaryValue; |
24 class Time; | 25 class Time; |
25 class Value; | 26 class Value; |
(...skipping 10 matching lines...) Expand all Loading... |
36 namespace net { | 37 namespace net { |
37 class URLRequest; | 38 class URLRequest; |
38 } | 39 } |
39 | 40 |
40 namespace extensions { | 41 namespace extensions { |
41 | 42 |
42 typedef linked_ptr<extension_web_request_api_helpers::EventResponseDelta> | 43 typedef linked_ptr<extension_web_request_api_helpers::EventResponseDelta> |
43 LinkedPtrEventResponseDelta; | 44 LinkedPtrEventResponseDelta; |
44 | 45 |
45 // Base class for all WebRequestActions of the declarative Web Request API. | 46 // Base class for all WebRequestActions of the declarative Web Request API. |
46 // | |
47 class WebRequestAction { | 47 class WebRequestAction { |
48 public: | 48 public: |
49 // Type identifiers for concrete WebRequestActions. | 49 // Type identifiers for concrete WebRequestActions. |
50 enum Type { | 50 enum Type { |
51 ACTION_CANCEL_REQUEST, | 51 ACTION_CANCEL_REQUEST, |
52 ACTION_REDIRECT_REQUEST, | 52 ACTION_REDIRECT_REQUEST, |
53 ACTION_REDIRECT_TO_TRANSPARENT_IMAGE, | 53 ACTION_REDIRECT_TO_TRANSPARENT_IMAGE, |
54 ACTION_REDIRECT_TO_EMPTY_DOCUMENT, | 54 ACTION_REDIRECT_TO_EMPTY_DOCUMENT, |
55 ACTION_REDIRECT_BY_REGEX_DOCUMENT, | 55 ACTION_REDIRECT_BY_REGEX_DOCUMENT, |
56 ACTION_SET_REQUEST_HEADER, | 56 ACTION_SET_REQUEST_HEADER, |
57 ACTION_REMOVE_REQUEST_HEADER, | 57 ACTION_REMOVE_REQUEST_HEADER, |
58 ACTION_ADD_RESPONSE_HEADER, | 58 ACTION_ADD_RESPONSE_HEADER, |
59 ACTION_REMOVE_RESPONSE_HEADER, | 59 ACTION_REMOVE_RESPONSE_HEADER, |
60 ACTION_IGNORE_RULES, | 60 ACTION_IGNORE_RULES, |
| 61 ACTION_MODIFY_REQUEST_COOKIE, |
| 62 ACTION_MODIFY_RESPONSE_COOKIE, |
61 }; | 63 }; |
62 | 64 |
63 WebRequestAction(); | 65 WebRequestAction(); |
64 virtual ~WebRequestAction(); | 66 virtual ~WebRequestAction(); |
65 | 67 |
66 // Returns a bit vector representing extensions::RequestStages. The bit vector | 68 // Returns a bit vector representing extensions::RequestStages. The bit vector |
67 // contains a 1 for each request stage during which the condition can be | 69 // contains a 1 for each request stage during which the condition can be |
68 // tested. | 70 // tested. |
69 virtual int GetStages() const = 0; | 71 virtual int GetStages() const = 0; |
70 | 72 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 RequestStages request_stage, | 384 RequestStages request_stage, |
383 const WebRequestRule::OptionalRequestData& optional_request_data, | 385 const WebRequestRule::OptionalRequestData& optional_request_data, |
384 const std::string& extension_id, | 386 const std::string& extension_id, |
385 const base::Time& extension_install_time) const OVERRIDE; | 387 const base::Time& extension_install_time) const OVERRIDE; |
386 | 388 |
387 private: | 389 private: |
388 int minimum_priority_; | 390 int minimum_priority_; |
389 DISALLOW_COPY_AND_ASSIGN(WebRequestIgnoreRulesAction); | 391 DISALLOW_COPY_AND_ASSIGN(WebRequestIgnoreRulesAction); |
390 }; | 392 }; |
391 | 393 |
392 // TODO(battre) Implement further actions: | 394 // Action that instructs to modify (add, edit, remove) a request cookie. |
393 // Redirect by RegEx, Cookie manipulations, ... | 395 class WebRequestRequestCookieAction : public WebRequestAction { |
| 396 public: |
| 397 typedef extension_web_request_api_helpers::RequestCookieModification |
| 398 RequestCookieModification; |
| 399 |
| 400 explicit WebRequestRequestCookieAction( |
| 401 linked_ptr<RequestCookieModification> request_cookie_modification); |
| 402 virtual ~WebRequestRequestCookieAction(); |
| 403 |
| 404 // Implementation of WebRequestAction: |
| 405 virtual int GetStages() const OVERRIDE; |
| 406 virtual Type GetType() const OVERRIDE; |
| 407 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 408 net::URLRequest* request, |
| 409 RequestStages request_stage, |
| 410 const WebRequestRule::OptionalRequestData& optional_request_data, |
| 411 const std::string& extension_id, |
| 412 const base::Time& extension_install_time) const OVERRIDE; |
| 413 |
| 414 private: |
| 415 linked_ptr<RequestCookieModification> request_cookie_modification_; |
| 416 DISALLOW_COPY_AND_ASSIGN(WebRequestRequestCookieAction); |
| 417 }; |
| 418 |
| 419 // Action that instructs to modify (add, edit, remove) a response cookie. |
| 420 class WebRequestResponseCookieAction : public WebRequestAction { |
| 421 public: |
| 422 typedef extension_web_request_api_helpers::ResponseCookieModification |
| 423 ResponseCookieModification; |
| 424 |
| 425 explicit WebRequestResponseCookieAction( |
| 426 linked_ptr<ResponseCookieModification> response_cookie_modification); |
| 427 virtual ~WebRequestResponseCookieAction(); |
| 428 |
| 429 // Implementation of WebRequestAction: |
| 430 virtual int GetStages() const OVERRIDE; |
| 431 virtual Type GetType() const OVERRIDE; |
| 432 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 433 net::URLRequest* request, |
| 434 RequestStages request_stage, |
| 435 const WebRequestRule::OptionalRequestData& optional_request_data, |
| 436 const std::string& extension_id, |
| 437 const base::Time& extension_install_time) const OVERRIDE; |
| 438 |
| 439 private: |
| 440 linked_ptr<ResponseCookieModification> response_cookie_modification_; |
| 441 DISALLOW_COPY_AND_ASSIGN(WebRequestResponseCookieAction); |
| 442 }; |
394 | 443 |
395 } // namespace extensions | 444 } // namespace extensions |
396 | 445 |
397 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO
N_H_ | 446 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO
N_H_ |
OLD | NEW |