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