| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
| 15 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h" | 15 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h" |
| 16 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" | 16 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" |
| 17 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" |
| 17 #include "chrome/common/extensions/api/events.h" | 18 #include "chrome/common/extensions/api/events.h" |
| 18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 19 #include "unicode/regex.h" | 20 #include "unicode/regex.h" |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class DictionaryValue; | 23 class DictionaryValue; |
| 23 class Time; | 24 class Time; |
| 24 class Value; | 25 class Value; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace extension_web_request_api_helpers { | 28 namespace extension_web_request_api_helpers { |
| 28 struct EventResponseDelta; | 29 struct EventResponseDelta; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace net { | 32 namespace net { |
| 32 class URLRequest; | 33 class URLRequest; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace extensions { | 36 namespace extensions { |
| 36 | 37 |
| 37 typedef linked_ptr<extension_web_request_api_helpers::EventResponseDelta> | 38 typedef linked_ptr<extension_web_request_api_helpers::EventResponseDelta> |
| 38 LinkedPtrEventResponseDelta; | 39 LinkedPtrEventResponseDelta; |
| 39 | 40 |
| 40 // Base class for all WebRequestActions of the declarative Web Request API. | 41 // Base class for all WebRequestActions of the declarative Web Request API. |
| 41 // | |
| 42 // TODO(battre): Add method that corresponds to executing the action. | |
| 43 class WebRequestAction { | 42 class WebRequestAction { |
| 44 public: | 43 public: |
| 45 // Type identifiers for concrete WebRequestActions. | 44 // Type identifiers for concrete WebRequestActions. |
| 46 enum Type { | 45 enum Type { |
| 47 ACTION_CANCEL_REQUEST, | 46 ACTION_CANCEL_REQUEST, |
| 48 ACTION_REDIRECT_REQUEST, | 47 ACTION_REDIRECT_REQUEST, |
| 49 ACTION_REDIRECT_TO_TRANSPARENT_IMAGE, | 48 ACTION_REDIRECT_TO_TRANSPARENT_IMAGE, |
| 50 ACTION_REDIRECT_TO_EMPTY_DOCUMENT, | 49 ACTION_REDIRECT_TO_EMPTY_DOCUMENT, |
| 51 ACTION_REDIRECT_BY_REGEX_DOCUMENT, | 50 ACTION_REDIRECT_BY_REGEX_DOCUMENT, |
| 52 ACTION_SET_REQUEST_HEADER, | 51 ACTION_SET_REQUEST_HEADER, |
| 53 ACTION_REMOVE_REQUEST_HEADER, | 52 ACTION_REMOVE_REQUEST_HEADER, |
| 54 ACTION_ADD_RESPONSE_HEADER, | 53 ACTION_ADD_RESPONSE_HEADER, |
| 55 ACTION_REMOVE_RESPONSE_HEADER, | 54 ACTION_REMOVE_RESPONSE_HEADER, |
| 56 ACTION_IGNORE_RULES, | 55 ACTION_IGNORE_RULES, |
| 56 ACTION_MODIFY_COOKIE, |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 WebRequestAction(); | 59 WebRequestAction(); |
| 60 virtual ~WebRequestAction(); | 60 virtual ~WebRequestAction(); |
| 61 | 61 |
| 62 // Returns a bit vector representing extensions::RequestStages. The bit vector | 62 // Returns a bit vector representing extensions::RequestStages. The bit vector |
| 63 // contains a 1 for each request stage during which the condition can be | 63 // contains a 1 for each request stage during which the condition can be |
| 64 // tested. | 64 // tested. |
| 65 virtual int GetStages() const = 0; | 65 virtual int GetStages() const = 0; |
| 66 | 66 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 RequestStages request_stage, | 356 RequestStages request_stage, |
| 357 const WebRequestRule::OptionalRequestData& optional_request_data, | 357 const WebRequestRule::OptionalRequestData& optional_request_data, |
| 358 const std::string& extension_id, | 358 const std::string& extension_id, |
| 359 const base::Time& extension_install_time) const OVERRIDE; | 359 const base::Time& extension_install_time) const OVERRIDE; |
| 360 | 360 |
| 361 private: | 361 private: |
| 362 int minimum_priority_; | 362 int minimum_priority_; |
| 363 DISALLOW_COPY_AND_ASSIGN(WebRequestIgnoreRulesAction); | 363 DISALLOW_COPY_AND_ASSIGN(WebRequestIgnoreRulesAction); |
| 364 }; | 364 }; |
| 365 | 365 |
| 366 // TODO(battre) Implement further actions: | 366 // Action that instructs to modify (add, edit, remove) a cookie. |
| 367 // Redirect by RegEx, Cookie manipulations, ... | 367 class WebRequestCookieAction : public WebRequestAction { |
| 368 public: |
| 369 typedef extension_web_request_api_helpers::RequestCookieModification |
| 370 RequestCookieModification; |
| 371 typedef extension_web_request_api_helpers::ResponseCookieModification |
| 372 ResponseCookieModification; |
| 373 |
| 374 WebRequestCookieAction( |
| 375 linked_ptr<RequestCookieModification> request_cookie_modification, |
| 376 linked_ptr<ResponseCookieModification> response_cookie_modification); |
| 377 virtual ~WebRequestCookieAction(); |
| 378 |
| 379 // Implementation of WebRequestAction: |
| 380 virtual int GetStages() const OVERRIDE; |
| 381 virtual Type GetType() const OVERRIDE; |
| 382 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 383 net::URLRequest* request, |
| 384 RequestStages request_stage, |
| 385 const WebRequestRule::OptionalRequestData& optional_request_data, |
| 386 const std::string& extension_id, |
| 387 const base::Time& extension_install_time) const OVERRIDE; |
| 388 |
| 389 private: |
| 390 linked_ptr<RequestCookieModification> request_cookie_modification_; |
| 391 linked_ptr<ResponseCookieModification> response_cookie_modification_; |
| 392 }; |
| 368 | 393 |
| 369 } // namespace extensions | 394 } // namespace extensions |
| 370 | 395 |
| 371 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO
N_H_ | 396 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO
N_H_ |
| OLD | NEW |