| 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/declarative_rule.h" |
| 14 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h" | 15 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.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/browser/extensions/api/web_request/web_request_api_helpers.h" |
| 17 #include "chrome/common/extensions/api/events.h" | 17 #include "chrome/common/extensions/api/events.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 | 19 |
| 20 class ExtensionInfoMap; |
| 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; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace extension_web_request_api_helpers { | 29 namespace extension_web_request_api_helpers { |
| 29 struct EventResponseDelta; | 30 struct EventResponseDelta; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace extensions { | 33 namespace extensions { |
| 33 class Extension; | 34 class Extension; |
| 35 struct DeclarativeWebRequestData; |
| 34 } | 36 } |
| 35 | 37 |
| 36 namespace net { | 38 namespace net { |
| 37 class URLRequest; | 39 class URLRequest; |
| 38 } | 40 } |
| 39 | 41 |
| 40 namespace re2 { | 42 namespace re2 { |
| 41 class RE2; | 43 class RE2; |
| 42 } | 44 } |
| 43 | 45 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 69 enum HostPermissionsStrategy { | 71 enum HostPermissionsStrategy { |
| 70 STRATEGY_NONE, // Do not check host permissions. | 72 STRATEGY_NONE, // Do not check host permissions. |
| 71 STRATEGY_DEFAULT, // Check host permissions in HasPermission, | 73 STRATEGY_DEFAULT, // Check host permissions in HasPermission, |
| 72 // before creating the delta. | 74 // before creating the delta. |
| 73 STRATEGY_ALLOW_SAME_DOMAIN, // Skip host permission checks if the request | 75 STRATEGY_ALLOW_SAME_DOMAIN, // Skip host permission checks if the request |
| 74 // URL and new URL have the same domain. | 76 // URL and new URL have the same domain. |
| 75 // Do these checks in DeltaHasPermission, | 77 // Do these checks in DeltaHasPermission, |
| 76 // after creating the delta. | 78 // after creating the delta. |
| 77 }; | 79 }; |
| 78 | 80 |
| 81 // Information necessary to decide how to apply a WebRequestAction |
| 82 // inside a matching rule. |
| 83 struct ApplyInfo { |
| 84 const ExtensionInfoMap* extension_info_map; |
| 85 const DeclarativeWebRequestData& request_data; |
| 86 bool crosses_incognito; |
| 87 // Modified by each applied action: |
| 88 std::list<LinkedPtrEventResponseDelta>* deltas; |
| 89 }; |
| 90 |
| 79 WebRequestAction(); | 91 WebRequestAction(); |
| 80 virtual ~WebRequestAction(); | 92 virtual ~WebRequestAction(); |
| 81 | 93 |
| 82 // Returns a bit vector representing extensions::RequestStage. The bit vector | 94 // Returns a bit vector representing extensions::RequestStage. The bit vector |
| 83 // contains a 1 for each request stage during which the condition can be | 95 // contains a 1 for each request stage during which the condition can be |
| 84 // tested. | 96 // tested. |
| 85 virtual int GetStages() const = 0; | 97 virtual int GetStages() const = 0; |
| 86 | 98 |
| 87 virtual Type GetType() const = 0; | 99 virtual Type GetType() const = 0; |
| 88 | 100 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Sets |error| and returns NULL in case of a semantic error that cannot | 139 // Sets |error| and returns NULL in case of a semantic error that cannot |
| 128 // be caught by schema validation. Sets |bad_message| and returns NULL | 140 // be caught by schema validation. Sets |bad_message| and returns NULL |
| 129 // in case the input is syntactically unexpected. | 141 // in case the input is syntactically unexpected. |
| 130 static scoped_ptr<WebRequestAction> Create(const base::Value& json_action, | 142 static scoped_ptr<WebRequestAction> Create(const base::Value& json_action, |
| 131 std::string* error, | 143 std::string* error, |
| 132 bool* bad_message); | 144 bool* bad_message); |
| 133 | 145 |
| 134 // Returns a description of the modification to the request caused by | 146 // Returns a description of the modification to the request caused by |
| 135 // this action. | 147 // this action. |
| 136 virtual LinkedPtrEventResponseDelta CreateDelta( | 148 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 137 const WebRequestRule::RequestData& request_data, | 149 const DeclarativeWebRequestData& request_data, |
| 138 const std::string& extension_id, | 150 const std::string& extension_id, |
| 139 const base::Time& extension_install_time) const = 0; | 151 const base::Time& extension_install_time) const = 0; |
| 152 |
| 153 // Applies this action to a request, recording the results into |
| 154 // apply_info.deltas. |
| 155 void Apply(const std::string& extension_id, |
| 156 base::Time extension_install_time, |
| 157 ApplyInfo* apply_info) const; |
| 140 }; | 158 }; |
| 141 | 159 |
| 142 // Immutable container for multiple actions. | 160 typedef DeclarativeActionSet<WebRequestAction> WebRequestActionSet; |
| 143 // | |
| 144 // TODO(battre): As WebRequestActionSet can become the single owner of all | |
| 145 // actions, we can optimize here by making some of them singletons (e.g. Cancel | |
| 146 // actions). | |
| 147 class WebRequestActionSet { | |
| 148 public: | |
| 149 typedef std::vector<linked_ptr<json_schema_compiler::any::Any> > AnyVector; | |
| 150 typedef std::vector<linked_ptr<WebRequestAction> > Actions; | |
| 151 | |
| 152 explicit WebRequestActionSet(const Actions& actions); | |
| 153 virtual ~WebRequestActionSet(); | |
| 154 | |
| 155 // Factory method that instantiates a WebRequestActionSet according to | |
| 156 // |actions| which represents the array of actions received from the | |
| 157 // extension API. | |
| 158 static scoped_ptr<WebRequestActionSet> Create(const AnyVector& actions, | |
| 159 std::string* error, | |
| 160 bool* bad_message); | |
| 161 | |
| 162 // Returns a description of the modifications to |request_data.request| caused | |
| 163 // by the |actions_| that can be executed at |request.stage|. If |extension| | |
| 164 // is not NULL, permissions of extensions are checked. | |
| 165 std::list<LinkedPtrEventResponseDelta> CreateDeltas( | |
| 166 const ExtensionInfoMap* extension_info_map, | |
| 167 const std::string& extension_id, | |
| 168 const WebRequestRule::RequestData& request_data, | |
| 169 bool crosses_incognito, | |
| 170 const base::Time& extension_install_time) const; | |
| 171 | |
| 172 // Returns the minimum priority of rules that may be evaluated after | |
| 173 // this rule. Defaults to MIN_INT. | |
| 174 int GetMinimumPriority() const; | |
| 175 | |
| 176 const Actions& actions() const { return actions_; } | |
| 177 | |
| 178 private: | |
| 179 Actions actions_; | |
| 180 | |
| 181 DISALLOW_COPY_AND_ASSIGN(WebRequestActionSet); | |
| 182 }; | |
| 183 | 161 |
| 184 // | 162 // |
| 185 // The following are concrete actions. | 163 // The following are concrete actions. |
| 186 // | 164 // |
| 187 | 165 |
| 188 // Action that instructs to cancel a network request. | 166 // Action that instructs to cancel a network request. |
| 189 class WebRequestCancelAction : public WebRequestAction { | 167 class WebRequestCancelAction : public WebRequestAction { |
| 190 public: | 168 public: |
| 191 WebRequestCancelAction(); | 169 WebRequestCancelAction(); |
| 192 virtual ~WebRequestCancelAction(); | 170 virtual ~WebRequestCancelAction(); |
| 193 | 171 |
| 194 // Implementation of WebRequestAction: | 172 // Implementation of WebRequestAction: |
| 195 virtual int GetStages() const OVERRIDE; | 173 virtual int GetStages() const OVERRIDE; |
| 196 virtual Type GetType() const OVERRIDE; | 174 virtual Type GetType() const OVERRIDE; |
| 197 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 175 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
| 198 virtual LinkedPtrEventResponseDelta CreateDelta( | 176 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 199 const WebRequestRule::RequestData& request_data, | 177 const DeclarativeWebRequestData& request_data, |
| 200 const std::string& extension_id, | 178 const std::string& extension_id, |
| 201 const base::Time& extension_install_time) const OVERRIDE; | 179 const base::Time& extension_install_time) const OVERRIDE; |
| 202 | 180 |
| 203 private: | 181 private: |
| 204 DISALLOW_COPY_AND_ASSIGN(WebRequestCancelAction); | 182 DISALLOW_COPY_AND_ASSIGN(WebRequestCancelAction); |
| 205 }; | 183 }; |
| 206 | 184 |
| 207 // Action that instructs to redirect a network request. | 185 // Action that instructs to redirect a network request. |
| 208 class WebRequestRedirectAction : public WebRequestAction { | 186 class WebRequestRedirectAction : public WebRequestAction { |
| 209 public: | 187 public: |
| 210 explicit WebRequestRedirectAction(const GURL& redirect_url); | 188 explicit WebRequestRedirectAction(const GURL& redirect_url); |
| 211 virtual ~WebRequestRedirectAction(); | 189 virtual ~WebRequestRedirectAction(); |
| 212 | 190 |
| 213 // Implementation of WebRequestAction: | 191 // Implementation of WebRequestAction: |
| 214 virtual int GetStages() const OVERRIDE; | 192 virtual int GetStages() const OVERRIDE; |
| 215 virtual Type GetType() const OVERRIDE; | 193 virtual Type GetType() const OVERRIDE; |
| 216 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 194 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
| 217 virtual LinkedPtrEventResponseDelta CreateDelta( | 195 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 218 const WebRequestRule::RequestData& request_data, | 196 const DeclarativeWebRequestData& request_data, |
| 219 const std::string& extension_id, | 197 const std::string& extension_id, |
| 220 const base::Time& extension_install_time) const OVERRIDE; | 198 const base::Time& extension_install_time) const OVERRIDE; |
| 221 | 199 |
| 222 private: | 200 private: |
| 223 GURL redirect_url_; // Target to which the request shall be redirected. | 201 GURL redirect_url_; // Target to which the request shall be redirected. |
| 224 | 202 |
| 225 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectAction); | 203 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectAction); |
| 226 }; | 204 }; |
| 227 | 205 |
| 228 // Action that instructs to redirect a network request to a transparent image. | 206 // Action that instructs to redirect a network request to a transparent image. |
| 229 class WebRequestRedirectToTransparentImageAction : public WebRequestAction { | 207 class WebRequestRedirectToTransparentImageAction : public WebRequestAction { |
| 230 public: | 208 public: |
| 231 WebRequestRedirectToTransparentImageAction(); | 209 WebRequestRedirectToTransparentImageAction(); |
| 232 virtual ~WebRequestRedirectToTransparentImageAction(); | 210 virtual ~WebRequestRedirectToTransparentImageAction(); |
| 233 | 211 |
| 234 // Implementation of WebRequestAction: | 212 // Implementation of WebRequestAction: |
| 235 virtual int GetStages() const OVERRIDE; | 213 virtual int GetStages() const OVERRIDE; |
| 236 virtual Type GetType() const OVERRIDE; | 214 virtual Type GetType() const OVERRIDE; |
| 237 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 215 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
| 238 virtual LinkedPtrEventResponseDelta CreateDelta( | 216 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 239 const WebRequestRule::RequestData& request_data, | 217 const DeclarativeWebRequestData& request_data, |
| 240 const std::string& extension_id, | 218 const std::string& extension_id, |
| 241 const base::Time& extension_install_time) const OVERRIDE; | 219 const base::Time& extension_install_time) const OVERRIDE; |
| 242 | 220 |
| 243 private: | 221 private: |
| 244 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToTransparentImageAction); | 222 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToTransparentImageAction); |
| 245 }; | 223 }; |
| 246 | 224 |
| 247 | 225 |
| 248 // Action that instructs to redirect a network request to an empty document. | 226 // Action that instructs to redirect a network request to an empty document. |
| 249 class WebRequestRedirectToEmptyDocumentAction : public WebRequestAction { | 227 class WebRequestRedirectToEmptyDocumentAction : public WebRequestAction { |
| 250 public: | 228 public: |
| 251 WebRequestRedirectToEmptyDocumentAction(); | 229 WebRequestRedirectToEmptyDocumentAction(); |
| 252 virtual ~WebRequestRedirectToEmptyDocumentAction(); | 230 virtual ~WebRequestRedirectToEmptyDocumentAction(); |
| 253 | 231 |
| 254 // Implementation of WebRequestAction: | 232 // Implementation of WebRequestAction: |
| 255 virtual int GetStages() const OVERRIDE; | 233 virtual int GetStages() const OVERRIDE; |
| 256 virtual Type GetType() const OVERRIDE; | 234 virtual Type GetType() const OVERRIDE; |
| 257 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 235 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
| 258 virtual LinkedPtrEventResponseDelta CreateDelta( | 236 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 259 const WebRequestRule::RequestData& request_data, | 237 const DeclarativeWebRequestData& request_data, |
| 260 const std::string& extension_id, | 238 const std::string& extension_id, |
| 261 const base::Time& extension_install_time) const OVERRIDE; | 239 const base::Time& extension_install_time) const OVERRIDE; |
| 262 | 240 |
| 263 private: | 241 private: |
| 264 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToEmptyDocumentAction); | 242 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToEmptyDocumentAction); |
| 265 }; | 243 }; |
| 266 | 244 |
| 267 // Action that instructs to redirect a network request. | 245 // Action that instructs to redirect a network request. |
| 268 class WebRequestRedirectByRegExAction : public WebRequestAction { | 246 class WebRequestRedirectByRegExAction : public WebRequestAction { |
| 269 public: | 247 public: |
| 270 // The |to_pattern| has to be passed in RE2 syntax with the exception that | 248 // The |to_pattern| has to be passed in RE2 syntax with the exception that |
| 271 // capture groups are referenced in Perl style ($1, $2, ...). | 249 // capture groups are referenced in Perl style ($1, $2, ...). |
| 272 explicit WebRequestRedirectByRegExAction(scoped_ptr<re2::RE2> from_pattern, | 250 explicit WebRequestRedirectByRegExAction(scoped_ptr<re2::RE2> from_pattern, |
| 273 const std::string& to_pattern); | 251 const std::string& to_pattern); |
| 274 virtual ~WebRequestRedirectByRegExAction(); | 252 virtual ~WebRequestRedirectByRegExAction(); |
| 275 | 253 |
| 276 // Conversion of capture group styles between Perl style ($1, $2, ...) and | 254 // Conversion of capture group styles between Perl style ($1, $2, ...) and |
| 277 // RE2 (\1, \2, ...). | 255 // RE2 (\1, \2, ...). |
| 278 static std::string PerlToRe2Style(const std::string& perl); | 256 static std::string PerlToRe2Style(const std::string& perl); |
| 279 | 257 |
| 280 // Implementation of WebRequestAction: | 258 // Implementation of WebRequestAction: |
| 281 virtual int GetStages() const OVERRIDE; | 259 virtual int GetStages() const OVERRIDE; |
| 282 virtual Type GetType() const OVERRIDE; | 260 virtual Type GetType() const OVERRIDE; |
| 283 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 261 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
| 284 virtual LinkedPtrEventResponseDelta CreateDelta( | 262 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 285 const WebRequestRule::RequestData& request_data, | 263 const DeclarativeWebRequestData& request_data, |
| 286 const std::string& extension_id, | 264 const std::string& extension_id, |
| 287 const base::Time& extension_install_time) const OVERRIDE; | 265 const base::Time& extension_install_time) const OVERRIDE; |
| 288 | 266 |
| 289 private: | 267 private: |
| 290 scoped_ptr<re2::RE2> from_pattern_; | 268 scoped_ptr<re2::RE2> from_pattern_; |
| 291 std::string to_pattern_; | 269 std::string to_pattern_; |
| 292 | 270 |
| 293 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectByRegExAction); | 271 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectByRegExAction); |
| 294 }; | 272 }; |
| 295 | 273 |
| 296 // Action that instructs to set a request header. | 274 // Action that instructs to set a request header. |
| 297 class WebRequestSetRequestHeaderAction : public WebRequestAction { | 275 class WebRequestSetRequestHeaderAction : public WebRequestAction { |
| 298 public: | 276 public: |
| 299 WebRequestSetRequestHeaderAction(const std::string& name, | 277 WebRequestSetRequestHeaderAction(const std::string& name, |
| 300 const std::string& value); | 278 const std::string& value); |
| 301 virtual ~WebRequestSetRequestHeaderAction(); | 279 virtual ~WebRequestSetRequestHeaderAction(); |
| 302 | 280 |
| 303 // Implementation of WebRequestAction: | 281 // Implementation of WebRequestAction: |
| 304 virtual int GetStages() const OVERRIDE; | 282 virtual int GetStages() const OVERRIDE; |
| 305 virtual Type GetType() const OVERRIDE; | 283 virtual Type GetType() const OVERRIDE; |
| 306 virtual LinkedPtrEventResponseDelta CreateDelta( | 284 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 307 const WebRequestRule::RequestData& request_data, | 285 const DeclarativeWebRequestData& request_data, |
| 308 const std::string& extension_id, | 286 const std::string& extension_id, |
| 309 const base::Time& extension_install_time) const OVERRIDE; | 287 const base::Time& extension_install_time) const OVERRIDE; |
| 310 | 288 |
| 311 private: | 289 private: |
| 312 std::string name_; | 290 std::string name_; |
| 313 std::string value_; | 291 std::string value_; |
| 314 DISALLOW_COPY_AND_ASSIGN(WebRequestSetRequestHeaderAction); | 292 DISALLOW_COPY_AND_ASSIGN(WebRequestSetRequestHeaderAction); |
| 315 }; | 293 }; |
| 316 | 294 |
| 317 // Action that instructs to remove a request header. | 295 // Action that instructs to remove a request header. |
| 318 class WebRequestRemoveRequestHeaderAction : public WebRequestAction { | 296 class WebRequestRemoveRequestHeaderAction : public WebRequestAction { |
| 319 public: | 297 public: |
| 320 explicit WebRequestRemoveRequestHeaderAction(const std::string& name); | 298 explicit WebRequestRemoveRequestHeaderAction(const std::string& name); |
| 321 virtual ~WebRequestRemoveRequestHeaderAction(); | 299 virtual ~WebRequestRemoveRequestHeaderAction(); |
| 322 | 300 |
| 323 // Implementation of WebRequestAction: | 301 // Implementation of WebRequestAction: |
| 324 virtual int GetStages() const OVERRIDE; | 302 virtual int GetStages() const OVERRIDE; |
| 325 virtual Type GetType() const OVERRIDE; | 303 virtual Type GetType() const OVERRIDE; |
| 326 virtual LinkedPtrEventResponseDelta CreateDelta( | 304 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 327 const WebRequestRule::RequestData& request_data, | 305 const DeclarativeWebRequestData& request_data, |
| 328 const std::string& extension_id, | 306 const std::string& extension_id, |
| 329 const base::Time& extension_install_time) const OVERRIDE; | 307 const base::Time& extension_install_time) const OVERRIDE; |
| 330 | 308 |
| 331 private: | 309 private: |
| 332 std::string name_; | 310 std::string name_; |
| 333 DISALLOW_COPY_AND_ASSIGN(WebRequestRemoveRequestHeaderAction); | 311 DISALLOW_COPY_AND_ASSIGN(WebRequestRemoveRequestHeaderAction); |
| 334 }; | 312 }; |
| 335 | 313 |
| 336 // Action that instructs to add a response header. | 314 // Action that instructs to add a response header. |
| 337 class WebRequestAddResponseHeaderAction : public WebRequestAction { | 315 class WebRequestAddResponseHeaderAction : public WebRequestAction { |
| 338 public: | 316 public: |
| 339 WebRequestAddResponseHeaderAction(const std::string& name, | 317 WebRequestAddResponseHeaderAction(const std::string& name, |
| 340 const std::string& value); | 318 const std::string& value); |
| 341 virtual ~WebRequestAddResponseHeaderAction(); | 319 virtual ~WebRequestAddResponseHeaderAction(); |
| 342 | 320 |
| 343 // Implementation of WebRequestAction: | 321 // Implementation of WebRequestAction: |
| 344 virtual int GetStages() const OVERRIDE; | 322 virtual int GetStages() const OVERRIDE; |
| 345 virtual Type GetType() const OVERRIDE; | 323 virtual Type GetType() const OVERRIDE; |
| 346 virtual LinkedPtrEventResponseDelta CreateDelta( | 324 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 347 const WebRequestRule::RequestData& request_data, | 325 const DeclarativeWebRequestData& request_data, |
| 348 const std::string& extension_id, | 326 const std::string& extension_id, |
| 349 const base::Time& extension_install_time) const OVERRIDE; | 327 const base::Time& extension_install_time) const OVERRIDE; |
| 350 | 328 |
| 351 private: | 329 private: |
| 352 std::string name_; | 330 std::string name_; |
| 353 std::string value_; | 331 std::string value_; |
| 354 DISALLOW_COPY_AND_ASSIGN(WebRequestAddResponseHeaderAction); | 332 DISALLOW_COPY_AND_ASSIGN(WebRequestAddResponseHeaderAction); |
| 355 }; | 333 }; |
| 356 | 334 |
| 357 // Action that instructs to remove a response header. | 335 // Action that instructs to remove a response header. |
| 358 class WebRequestRemoveResponseHeaderAction : public WebRequestAction { | 336 class WebRequestRemoveResponseHeaderAction : public WebRequestAction { |
| 359 public: | 337 public: |
| 360 explicit WebRequestRemoveResponseHeaderAction(const std::string& name, | 338 explicit WebRequestRemoveResponseHeaderAction(const std::string& name, |
| 361 const std::string& value, | 339 const std::string& value, |
| 362 bool has_value); | 340 bool has_value); |
| 363 virtual ~WebRequestRemoveResponseHeaderAction(); | 341 virtual ~WebRequestRemoveResponseHeaderAction(); |
| 364 | 342 |
| 365 // Implementation of WebRequestAction: | 343 // Implementation of WebRequestAction: |
| 366 virtual int GetStages() const OVERRIDE; | 344 virtual int GetStages() const OVERRIDE; |
| 367 virtual Type GetType() const OVERRIDE; | 345 virtual Type GetType() const OVERRIDE; |
| 368 virtual LinkedPtrEventResponseDelta CreateDelta( | 346 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 369 const WebRequestRule::RequestData& request_data, | 347 const DeclarativeWebRequestData& request_data, |
| 370 const std::string& extension_id, | 348 const std::string& extension_id, |
| 371 const base::Time& extension_install_time) const OVERRIDE; | 349 const base::Time& extension_install_time) const OVERRIDE; |
| 372 | 350 |
| 373 private: | 351 private: |
| 374 std::string name_; | 352 std::string name_; |
| 375 std::string value_; | 353 std::string value_; |
| 376 bool has_value_; | 354 bool has_value_; |
| 377 DISALLOW_COPY_AND_ASSIGN(WebRequestRemoveResponseHeaderAction); | 355 DISALLOW_COPY_AND_ASSIGN(WebRequestRemoveResponseHeaderAction); |
| 378 }; | 356 }; |
| 379 | 357 |
| 380 // Action that instructs to ignore rules below a certain priority. | 358 // Action that instructs to ignore rules below a certain priority. |
| 381 class WebRequestIgnoreRulesAction : public WebRequestAction { | 359 class WebRequestIgnoreRulesAction : public WebRequestAction { |
| 382 public: | 360 public: |
| 383 explicit WebRequestIgnoreRulesAction(int minimum_priority); | 361 explicit WebRequestIgnoreRulesAction(int minimum_priority); |
| 384 virtual ~WebRequestIgnoreRulesAction(); | 362 virtual ~WebRequestIgnoreRulesAction(); |
| 385 | 363 |
| 386 // Implementation of WebRequestAction: | 364 // Implementation of WebRequestAction: |
| 387 virtual int GetStages() const OVERRIDE; | 365 virtual int GetStages() const OVERRIDE; |
| 388 virtual Type GetType() const OVERRIDE; | 366 virtual Type GetType() const OVERRIDE; |
| 389 virtual int GetMinimumPriority() const OVERRIDE; | 367 virtual int GetMinimumPriority() const OVERRIDE; |
| 390 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 368 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
| 391 virtual LinkedPtrEventResponseDelta CreateDelta( | 369 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 392 const WebRequestRule::RequestData& request_data, | 370 const DeclarativeWebRequestData& request_data, |
| 393 const std::string& extension_id, | 371 const std::string& extension_id, |
| 394 const base::Time& extension_install_time) const OVERRIDE; | 372 const base::Time& extension_install_time) const OVERRIDE; |
| 395 | 373 |
| 396 private: | 374 private: |
| 397 int minimum_priority_; | 375 int minimum_priority_; |
| 398 DISALLOW_COPY_AND_ASSIGN(WebRequestIgnoreRulesAction); | 376 DISALLOW_COPY_AND_ASSIGN(WebRequestIgnoreRulesAction); |
| 399 }; | 377 }; |
| 400 | 378 |
| 401 // Action that instructs to modify (add, edit, remove) a request cookie. | 379 // Action that instructs to modify (add, edit, remove) a request cookie. |
| 402 class WebRequestRequestCookieAction : public WebRequestAction { | 380 class WebRequestRequestCookieAction : public WebRequestAction { |
| 403 public: | 381 public: |
| 404 typedef extension_web_request_api_helpers::RequestCookieModification | 382 typedef extension_web_request_api_helpers::RequestCookieModification |
| 405 RequestCookieModification; | 383 RequestCookieModification; |
| 406 | 384 |
| 407 explicit WebRequestRequestCookieAction( | 385 explicit WebRequestRequestCookieAction( |
| 408 linked_ptr<RequestCookieModification> request_cookie_modification); | 386 linked_ptr<RequestCookieModification> request_cookie_modification); |
| 409 virtual ~WebRequestRequestCookieAction(); | 387 virtual ~WebRequestRequestCookieAction(); |
| 410 | 388 |
| 411 // Implementation of WebRequestAction: | 389 // Implementation of WebRequestAction: |
| 412 virtual int GetStages() const OVERRIDE; | 390 virtual int GetStages() const OVERRIDE; |
| 413 virtual Type GetType() const OVERRIDE; | 391 virtual Type GetType() const OVERRIDE; |
| 414 virtual LinkedPtrEventResponseDelta CreateDelta( | 392 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 415 const WebRequestRule::RequestData& request_data, | 393 const DeclarativeWebRequestData& request_data, |
| 416 const std::string& extension_id, | 394 const std::string& extension_id, |
| 417 const base::Time& extension_install_time) const OVERRIDE; | 395 const base::Time& extension_install_time) const OVERRIDE; |
| 418 | 396 |
| 419 private: | 397 private: |
| 420 linked_ptr<RequestCookieModification> request_cookie_modification_; | 398 linked_ptr<RequestCookieModification> request_cookie_modification_; |
| 421 DISALLOW_COPY_AND_ASSIGN(WebRequestRequestCookieAction); | 399 DISALLOW_COPY_AND_ASSIGN(WebRequestRequestCookieAction); |
| 422 }; | 400 }; |
| 423 | 401 |
| 424 // Action that instructs to modify (add, edit, remove) a response cookie. | 402 // Action that instructs to modify (add, edit, remove) a response cookie. |
| 425 class WebRequestResponseCookieAction : public WebRequestAction { | 403 class WebRequestResponseCookieAction : public WebRequestAction { |
| 426 public: | 404 public: |
| 427 typedef extension_web_request_api_helpers::ResponseCookieModification | 405 typedef extension_web_request_api_helpers::ResponseCookieModification |
| 428 ResponseCookieModification; | 406 ResponseCookieModification; |
| 429 | 407 |
| 430 explicit WebRequestResponseCookieAction( | 408 explicit WebRequestResponseCookieAction( |
| 431 linked_ptr<ResponseCookieModification> response_cookie_modification); | 409 linked_ptr<ResponseCookieModification> response_cookie_modification); |
| 432 virtual ~WebRequestResponseCookieAction(); | 410 virtual ~WebRequestResponseCookieAction(); |
| 433 | 411 |
| 434 // Implementation of WebRequestAction: | 412 // Implementation of WebRequestAction: |
| 435 virtual int GetStages() const OVERRIDE; | 413 virtual int GetStages() const OVERRIDE; |
| 436 virtual Type GetType() const OVERRIDE; | 414 virtual Type GetType() const OVERRIDE; |
| 437 virtual LinkedPtrEventResponseDelta CreateDelta( | 415 virtual LinkedPtrEventResponseDelta CreateDelta( |
| 438 const WebRequestRule::RequestData& request_data, | 416 const DeclarativeWebRequestData& request_data, |
| 439 const std::string& extension_id, | 417 const std::string& extension_id, |
| 440 const base::Time& extension_install_time) const OVERRIDE; | 418 const base::Time& extension_install_time) const OVERRIDE; |
| 441 | 419 |
| 442 private: | 420 private: |
| 443 linked_ptr<ResponseCookieModification> response_cookie_modification_; | 421 linked_ptr<ResponseCookieModification> response_cookie_modification_; |
| 444 DISALLOW_COPY_AND_ASSIGN(WebRequestResponseCookieAction); | 422 DISALLOW_COPY_AND_ASSIGN(WebRequestResponseCookieAction); |
| 445 }; | 423 }; |
| 446 | 424 |
| 447 } // namespace extensions | 425 } // namespace extensions |
| 448 | 426 |
| 449 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO
N_H_ | 427 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO
N_H_ |
| OLD | NEW |