| 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_CONDITIO
N_ATTRIBUTE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_ATTRIBUTE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_ATTRIBUTE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_ATTRIBUTE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class URLRequest; | 24 class URLRequest; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace extensions { | 27 namespace extensions { |
| 28 | 28 |
| 29 // Base class for all condition attributes of the declarative Web Request API | 29 // Base class for all condition attributes of the declarative Web Request API |
| 30 // except for condition attribute to test URLPatterns. | 30 // except for condition attribute to test URLPatterns. |
| 31 class WebRequestConditionAttribute { | 31 class WebRequestConditionAttribute { |
| 32 public: | 32 public: |
| 33 enum Type { | 33 enum Type { |
| 34 CONDITION_RESOURCE_TYPE | 34 CONDITION_RESOURCE_TYPE, |
| 35 CONDITION_CONTENT_TYPE |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 WebRequestConditionAttribute(); | 38 WebRequestConditionAttribute(); |
| 38 virtual ~WebRequestConditionAttribute(); | 39 virtual ~WebRequestConditionAttribute(); |
| 39 | 40 |
| 40 // Factory method that creates a WebRequestConditionAttribute for the JSON | 41 // Factory method that creates a WebRequestConditionAttribute for the JSON |
| 41 // dictionary {|name|: |value|} passed by the extension API. Sets |error| and | 42 // dictionary {|name|: |value|} passed by the extension API. Sets |error| and |
| 42 // returns NULL if something fails. | 43 // returns NULL if something fails. |
| 43 // The ownership of |value| remains at the caller. | 44 // The ownership of |value| remains at the caller. |
| 44 static scoped_ptr<WebRequestConditionAttribute> Create( | 45 static scoped_ptr<WebRequestConditionAttribute> Create( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 94 |
| 94 private: | 95 private: |
| 95 explicit WebRequestConditionAttributeResourceType( | 96 explicit WebRequestConditionAttributeResourceType( |
| 96 const std::vector<ResourceType::Type>& types); | 97 const std::vector<ResourceType::Type>& types); |
| 97 | 98 |
| 98 std::vector<ResourceType::Type> types_; | 99 std::vector<ResourceType::Type> types_; |
| 99 | 100 |
| 100 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType); | 101 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResourceType); |
| 101 }; | 102 }; |
| 102 | 103 |
| 104 // Condition that checks whether a response's Content-Type header has a |
| 105 // certain MIME media type. |
| 106 class WebRequestConditionAttributeContentType |
| 107 : public WebRequestConditionAttribute { |
| 108 public: |
| 109 virtual ~WebRequestConditionAttributeContentType(); |
| 110 |
| 111 static bool IsMatchingType(const std::string& instance_type); |
| 112 |
| 113 // Factory method, see WebRequestConditionAttribute::Create. |
| 114 static scoped_ptr<WebRequestConditionAttribute> Create( |
| 115 const std::string& name, |
| 116 const base::Value* value, |
| 117 std::string* error); |
| 118 |
| 119 // Implementation of WebRequestConditionAttribute: |
| 120 virtual int GetStages() const OVERRIDE; |
| 121 virtual bool IsFulfilled(const WebRequestRule::RequestData& request_data) |
| 122 OVERRIDE; |
| 123 virtual Type GetType() const OVERRIDE; |
| 124 |
| 125 private: |
| 126 explicit WebRequestConditionAttributeContentType( |
| 127 const std::vector<std::string>& content_types); |
| 128 |
| 129 std::vector<std::string> content_types_; |
| 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeContentType); |
| 132 }; |
| 133 |
| 103 } // namespace extensions | 134 } // namespace extensions |
| 104 | 135 |
| 105 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI
TION_ATTRIBUTE_H_ | 136 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI
TION_ATTRIBUTE_H_ |
| OLD | NEW |