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 struct ApplyInfo { | |
battre
2012/12/17 11:46:06
add comment: // Information about request and its
Jeffrey Yasskin
2012/12/19 08:23:06
Done.
| |
82 const ExtensionInfoMap* extension_info_map; | |
83 const DeclarativeWebRequestData& request_data; | |
84 bool crosses_incognito; | |
85 // Modified by each applied action: | |
86 std::list<LinkedPtrEventResponseDelta>* deltas; | |
87 }; | |
88 | |
79 WebRequestAction(); | 89 WebRequestAction(); |
80 virtual ~WebRequestAction(); | 90 virtual ~WebRequestAction(); |
81 | 91 |
82 // Returns a bit vector representing extensions::RequestStage. The bit vector | 92 // Returns a bit vector representing extensions::RequestStage. The bit vector |
83 // contains a 1 for each request stage during which the condition can be | 93 // contains a 1 for each request stage during which the condition can be |
84 // tested. | 94 // tested. |
85 virtual int GetStages() const = 0; | 95 virtual int GetStages() const = 0; |
86 | 96 |
87 virtual Type GetType() const = 0; | 97 virtual Type GetType() const = 0; |
88 | 98 |
(...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 | 137 // 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 | 138 // be caught by schema validation. Sets |bad_message| and returns NULL |
129 // in case the input is syntactically unexpected. | 139 // in case the input is syntactically unexpected. |
130 static scoped_ptr<WebRequestAction> Create(const base::Value& json_action, | 140 static scoped_ptr<WebRequestAction> Create(const base::Value& json_action, |
131 std::string* error, | 141 std::string* error, |
132 bool* bad_message); | 142 bool* bad_message); |
133 | 143 |
134 // Returns a description of the modification to the request caused by | 144 // Returns a description of the modification to the request caused by |
135 // this action. | 145 // this action. |
136 virtual LinkedPtrEventResponseDelta CreateDelta( | 146 virtual LinkedPtrEventResponseDelta CreateDelta( |
137 const WebRequestRule::RequestData& request_data, | 147 const DeclarativeWebRequestData& request_data, |
138 const std::string& extension_id, | 148 const std::string& extension_id, |
139 const base::Time& extension_install_time) const = 0; | 149 const base::Time& extension_install_time) const = 0; |
150 | |
151 // Applies this action to a request, recording the results into | |
152 // apply_info.deltas. | |
153 void Apply(const std::string& extension_id, | |
154 base::Time extension_install_time, | |
155 const ApplyInfo& apply_info) const; | |
140 }; | 156 }; |
141 | 157 |
142 // Immutable container for multiple actions. | 158 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 | 159 |
184 // | 160 // |
185 // The following are concrete actions. | 161 // The following are concrete actions. |
186 // | 162 // |
187 | 163 |
188 // Action that instructs to cancel a network request. | 164 // Action that instructs to cancel a network request. |
189 class WebRequestCancelAction : public WebRequestAction { | 165 class WebRequestCancelAction : public WebRequestAction { |
190 public: | 166 public: |
191 WebRequestCancelAction(); | 167 WebRequestCancelAction(); |
192 virtual ~WebRequestCancelAction(); | 168 virtual ~WebRequestCancelAction(); |
193 | 169 |
194 // Implementation of WebRequestAction: | 170 // Implementation of WebRequestAction: |
195 virtual int GetStages() const OVERRIDE; | 171 virtual int GetStages() const OVERRIDE; |
196 virtual Type GetType() const OVERRIDE; | 172 virtual Type GetType() const OVERRIDE; |
197 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 173 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
198 virtual LinkedPtrEventResponseDelta CreateDelta( | 174 virtual LinkedPtrEventResponseDelta CreateDelta( |
199 const WebRequestRule::RequestData& request_data, | 175 const DeclarativeWebRequestData& request_data, |
200 const std::string& extension_id, | 176 const std::string& extension_id, |
201 const base::Time& extension_install_time) const OVERRIDE; | 177 const base::Time& extension_install_time) const OVERRIDE; |
202 | 178 |
203 private: | 179 private: |
204 DISALLOW_COPY_AND_ASSIGN(WebRequestCancelAction); | 180 DISALLOW_COPY_AND_ASSIGN(WebRequestCancelAction); |
205 }; | 181 }; |
206 | 182 |
207 // Action that instructs to redirect a network request. | 183 // Action that instructs to redirect a network request. |
208 class WebRequestRedirectAction : public WebRequestAction { | 184 class WebRequestRedirectAction : public WebRequestAction { |
209 public: | 185 public: |
210 explicit WebRequestRedirectAction(const GURL& redirect_url); | 186 explicit WebRequestRedirectAction(const GURL& redirect_url); |
211 virtual ~WebRequestRedirectAction(); | 187 virtual ~WebRequestRedirectAction(); |
212 | 188 |
213 // Implementation of WebRequestAction: | 189 // Implementation of WebRequestAction: |
214 virtual int GetStages() const OVERRIDE; | 190 virtual int GetStages() const OVERRIDE; |
215 virtual Type GetType() const OVERRIDE; | 191 virtual Type GetType() const OVERRIDE; |
216 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 192 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
217 virtual LinkedPtrEventResponseDelta CreateDelta( | 193 virtual LinkedPtrEventResponseDelta CreateDelta( |
218 const WebRequestRule::RequestData& request_data, | 194 const DeclarativeWebRequestData& request_data, |
219 const std::string& extension_id, | 195 const std::string& extension_id, |
220 const base::Time& extension_install_time) const OVERRIDE; | 196 const base::Time& extension_install_time) const OVERRIDE; |
221 | 197 |
222 private: | 198 private: |
223 GURL redirect_url_; // Target to which the request shall be redirected. | 199 GURL redirect_url_; // Target to which the request shall be redirected. |
224 | 200 |
225 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectAction); | 201 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectAction); |
226 }; | 202 }; |
227 | 203 |
228 // Action that instructs to redirect a network request to a transparent image. | 204 // Action that instructs to redirect a network request to a transparent image. |
229 class WebRequestRedirectToTransparentImageAction : public WebRequestAction { | 205 class WebRequestRedirectToTransparentImageAction : public WebRequestAction { |
230 public: | 206 public: |
231 WebRequestRedirectToTransparentImageAction(); | 207 WebRequestRedirectToTransparentImageAction(); |
232 virtual ~WebRequestRedirectToTransparentImageAction(); | 208 virtual ~WebRequestRedirectToTransparentImageAction(); |
233 | 209 |
234 // Implementation of WebRequestAction: | 210 // Implementation of WebRequestAction: |
235 virtual int GetStages() const OVERRIDE; | 211 virtual int GetStages() const OVERRIDE; |
236 virtual Type GetType() const OVERRIDE; | 212 virtual Type GetType() const OVERRIDE; |
237 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 213 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
238 virtual LinkedPtrEventResponseDelta CreateDelta( | 214 virtual LinkedPtrEventResponseDelta CreateDelta( |
239 const WebRequestRule::RequestData& request_data, | 215 const DeclarativeWebRequestData& request_data, |
240 const std::string& extension_id, | 216 const std::string& extension_id, |
241 const base::Time& extension_install_time) const OVERRIDE; | 217 const base::Time& extension_install_time) const OVERRIDE; |
242 | 218 |
243 private: | 219 private: |
244 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToTransparentImageAction); | 220 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToTransparentImageAction); |
245 }; | 221 }; |
246 | 222 |
247 | 223 |
248 // Action that instructs to redirect a network request to an empty document. | 224 // Action that instructs to redirect a network request to an empty document. |
249 class WebRequestRedirectToEmptyDocumentAction : public WebRequestAction { | 225 class WebRequestRedirectToEmptyDocumentAction : public WebRequestAction { |
250 public: | 226 public: |
251 WebRequestRedirectToEmptyDocumentAction(); | 227 WebRequestRedirectToEmptyDocumentAction(); |
252 virtual ~WebRequestRedirectToEmptyDocumentAction(); | 228 virtual ~WebRequestRedirectToEmptyDocumentAction(); |
253 | 229 |
254 // Implementation of WebRequestAction: | 230 // Implementation of WebRequestAction: |
255 virtual int GetStages() const OVERRIDE; | 231 virtual int GetStages() const OVERRIDE; |
256 virtual Type GetType() const OVERRIDE; | 232 virtual Type GetType() const OVERRIDE; |
257 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 233 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
258 virtual LinkedPtrEventResponseDelta CreateDelta( | 234 virtual LinkedPtrEventResponseDelta CreateDelta( |
259 const WebRequestRule::RequestData& request_data, | 235 const DeclarativeWebRequestData& request_data, |
260 const std::string& extension_id, | 236 const std::string& extension_id, |
261 const base::Time& extension_install_time) const OVERRIDE; | 237 const base::Time& extension_install_time) const OVERRIDE; |
262 | 238 |
263 private: | 239 private: |
264 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToEmptyDocumentAction); | 240 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToEmptyDocumentAction); |
265 }; | 241 }; |
266 | 242 |
267 // Action that instructs to redirect a network request. | 243 // Action that instructs to redirect a network request. |
268 class WebRequestRedirectByRegExAction : public WebRequestAction { | 244 class WebRequestRedirectByRegExAction : public WebRequestAction { |
269 public: | 245 public: |
270 // The |to_pattern| has to be passed in RE2 syntax with the exception that | 246 // The |to_pattern| has to be passed in RE2 syntax with the exception that |
271 // capture groups are referenced in Perl style ($1, $2, ...). | 247 // capture groups are referenced in Perl style ($1, $2, ...). |
272 explicit WebRequestRedirectByRegExAction(scoped_ptr<re2::RE2> from_pattern, | 248 explicit WebRequestRedirectByRegExAction(scoped_ptr<re2::RE2> from_pattern, |
273 const std::string& to_pattern); | 249 const std::string& to_pattern); |
274 virtual ~WebRequestRedirectByRegExAction(); | 250 virtual ~WebRequestRedirectByRegExAction(); |
275 | 251 |
276 // Conversion of capture group styles between Perl style ($1, $2, ...) and | 252 // Conversion of capture group styles between Perl style ($1, $2, ...) and |
277 // RE2 (\1, \2, ...). | 253 // RE2 (\1, \2, ...). |
278 static std::string PerlToRe2Style(const std::string& perl); | 254 static std::string PerlToRe2Style(const std::string& perl); |
279 | 255 |
280 // Implementation of WebRequestAction: | 256 // Implementation of WebRequestAction: |
281 virtual int GetStages() const OVERRIDE; | 257 virtual int GetStages() const OVERRIDE; |
282 virtual Type GetType() const OVERRIDE; | 258 virtual Type GetType() const OVERRIDE; |
283 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 259 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
284 virtual LinkedPtrEventResponseDelta CreateDelta( | 260 virtual LinkedPtrEventResponseDelta CreateDelta( |
285 const WebRequestRule::RequestData& request_data, | 261 const DeclarativeWebRequestData& request_data, |
286 const std::string& extension_id, | 262 const std::string& extension_id, |
287 const base::Time& extension_install_time) const OVERRIDE; | 263 const base::Time& extension_install_time) const OVERRIDE; |
288 | 264 |
289 private: | 265 private: |
290 scoped_ptr<re2::RE2> from_pattern_; | 266 scoped_ptr<re2::RE2> from_pattern_; |
291 std::string to_pattern_; | 267 std::string to_pattern_; |
292 | 268 |
293 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectByRegExAction); | 269 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectByRegExAction); |
294 }; | 270 }; |
295 | 271 |
296 // Action that instructs to set a request header. | 272 // Action that instructs to set a request header. |
297 class WebRequestSetRequestHeaderAction : public WebRequestAction { | 273 class WebRequestSetRequestHeaderAction : public WebRequestAction { |
298 public: | 274 public: |
299 WebRequestSetRequestHeaderAction(const std::string& name, | 275 WebRequestSetRequestHeaderAction(const std::string& name, |
300 const std::string& value); | 276 const std::string& value); |
301 virtual ~WebRequestSetRequestHeaderAction(); | 277 virtual ~WebRequestSetRequestHeaderAction(); |
302 | 278 |
303 // Implementation of WebRequestAction: | 279 // Implementation of WebRequestAction: |
304 virtual int GetStages() const OVERRIDE; | 280 virtual int GetStages() const OVERRIDE; |
305 virtual Type GetType() const OVERRIDE; | 281 virtual Type GetType() const OVERRIDE; |
306 virtual LinkedPtrEventResponseDelta CreateDelta( | 282 virtual LinkedPtrEventResponseDelta CreateDelta( |
307 const WebRequestRule::RequestData& request_data, | 283 const DeclarativeWebRequestData& request_data, |
308 const std::string& extension_id, | 284 const std::string& extension_id, |
309 const base::Time& extension_install_time) const OVERRIDE; | 285 const base::Time& extension_install_time) const OVERRIDE; |
310 | 286 |
311 private: | 287 private: |
312 std::string name_; | 288 std::string name_; |
313 std::string value_; | 289 std::string value_; |
314 DISALLOW_COPY_AND_ASSIGN(WebRequestSetRequestHeaderAction); | 290 DISALLOW_COPY_AND_ASSIGN(WebRequestSetRequestHeaderAction); |
315 }; | 291 }; |
316 | 292 |
317 // Action that instructs to remove a request header. | 293 // Action that instructs to remove a request header. |
318 class WebRequestRemoveRequestHeaderAction : public WebRequestAction { | 294 class WebRequestRemoveRequestHeaderAction : public WebRequestAction { |
319 public: | 295 public: |
320 explicit WebRequestRemoveRequestHeaderAction(const std::string& name); | 296 explicit WebRequestRemoveRequestHeaderAction(const std::string& name); |
321 virtual ~WebRequestRemoveRequestHeaderAction(); | 297 virtual ~WebRequestRemoveRequestHeaderAction(); |
322 | 298 |
323 // Implementation of WebRequestAction: | 299 // Implementation of WebRequestAction: |
324 virtual int GetStages() const OVERRIDE; | 300 virtual int GetStages() const OVERRIDE; |
325 virtual Type GetType() const OVERRIDE; | 301 virtual Type GetType() const OVERRIDE; |
326 virtual LinkedPtrEventResponseDelta CreateDelta( | 302 virtual LinkedPtrEventResponseDelta CreateDelta( |
327 const WebRequestRule::RequestData& request_data, | 303 const DeclarativeWebRequestData& request_data, |
328 const std::string& extension_id, | 304 const std::string& extension_id, |
329 const base::Time& extension_install_time) const OVERRIDE; | 305 const base::Time& extension_install_time) const OVERRIDE; |
330 | 306 |
331 private: | 307 private: |
332 std::string name_; | 308 std::string name_; |
333 DISALLOW_COPY_AND_ASSIGN(WebRequestRemoveRequestHeaderAction); | 309 DISALLOW_COPY_AND_ASSIGN(WebRequestRemoveRequestHeaderAction); |
334 }; | 310 }; |
335 | 311 |
336 // Action that instructs to add a response header. | 312 // Action that instructs to add a response header. |
337 class WebRequestAddResponseHeaderAction : public WebRequestAction { | 313 class WebRequestAddResponseHeaderAction : public WebRequestAction { |
338 public: | 314 public: |
339 WebRequestAddResponseHeaderAction(const std::string& name, | 315 WebRequestAddResponseHeaderAction(const std::string& name, |
340 const std::string& value); | 316 const std::string& value); |
341 virtual ~WebRequestAddResponseHeaderAction(); | 317 virtual ~WebRequestAddResponseHeaderAction(); |
342 | 318 |
343 // Implementation of WebRequestAction: | 319 // Implementation of WebRequestAction: |
344 virtual int GetStages() const OVERRIDE; | 320 virtual int GetStages() const OVERRIDE; |
345 virtual Type GetType() const OVERRIDE; | 321 virtual Type GetType() const OVERRIDE; |
346 virtual LinkedPtrEventResponseDelta CreateDelta( | 322 virtual LinkedPtrEventResponseDelta CreateDelta( |
347 const WebRequestRule::RequestData& request_data, | 323 const DeclarativeWebRequestData& request_data, |
348 const std::string& extension_id, | 324 const std::string& extension_id, |
349 const base::Time& extension_install_time) const OVERRIDE; | 325 const base::Time& extension_install_time) const OVERRIDE; |
350 | 326 |
351 private: | 327 private: |
352 std::string name_; | 328 std::string name_; |
353 std::string value_; | 329 std::string value_; |
354 DISALLOW_COPY_AND_ASSIGN(WebRequestAddResponseHeaderAction); | 330 DISALLOW_COPY_AND_ASSIGN(WebRequestAddResponseHeaderAction); |
355 }; | 331 }; |
356 | 332 |
357 // Action that instructs to remove a response header. | 333 // Action that instructs to remove a response header. |
358 class WebRequestRemoveResponseHeaderAction : public WebRequestAction { | 334 class WebRequestRemoveResponseHeaderAction : public WebRequestAction { |
359 public: | 335 public: |
360 explicit WebRequestRemoveResponseHeaderAction(const std::string& name, | 336 explicit WebRequestRemoveResponseHeaderAction(const std::string& name, |
361 const std::string& value, | 337 const std::string& value, |
362 bool has_value); | 338 bool has_value); |
363 virtual ~WebRequestRemoveResponseHeaderAction(); | 339 virtual ~WebRequestRemoveResponseHeaderAction(); |
364 | 340 |
365 // Implementation of WebRequestAction: | 341 // Implementation of WebRequestAction: |
366 virtual int GetStages() const OVERRIDE; | 342 virtual int GetStages() const OVERRIDE; |
367 virtual Type GetType() const OVERRIDE; | 343 virtual Type GetType() const OVERRIDE; |
368 virtual LinkedPtrEventResponseDelta CreateDelta( | 344 virtual LinkedPtrEventResponseDelta CreateDelta( |
369 const WebRequestRule::RequestData& request_data, | 345 const DeclarativeWebRequestData& request_data, |
370 const std::string& extension_id, | 346 const std::string& extension_id, |
371 const base::Time& extension_install_time) const OVERRIDE; | 347 const base::Time& extension_install_time) const OVERRIDE; |
372 | 348 |
373 private: | 349 private: |
374 std::string name_; | 350 std::string name_; |
375 std::string value_; | 351 std::string value_; |
376 bool has_value_; | 352 bool has_value_; |
377 DISALLOW_COPY_AND_ASSIGN(WebRequestRemoveResponseHeaderAction); | 353 DISALLOW_COPY_AND_ASSIGN(WebRequestRemoveResponseHeaderAction); |
378 }; | 354 }; |
379 | 355 |
380 // Action that instructs to ignore rules below a certain priority. | 356 // Action that instructs to ignore rules below a certain priority. |
381 class WebRequestIgnoreRulesAction : public WebRequestAction { | 357 class WebRequestIgnoreRulesAction : public WebRequestAction { |
382 public: | 358 public: |
383 explicit WebRequestIgnoreRulesAction(int minimum_priority); | 359 explicit WebRequestIgnoreRulesAction(int minimum_priority); |
384 virtual ~WebRequestIgnoreRulesAction(); | 360 virtual ~WebRequestIgnoreRulesAction(); |
385 | 361 |
386 // Implementation of WebRequestAction: | 362 // Implementation of WebRequestAction: |
387 virtual int GetStages() const OVERRIDE; | 363 virtual int GetStages() const OVERRIDE; |
388 virtual Type GetType() const OVERRIDE; | 364 virtual Type GetType() const OVERRIDE; |
389 virtual int GetMinimumPriority() const OVERRIDE; | 365 virtual int GetMinimumPriority() const OVERRIDE; |
390 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; | 366 virtual HostPermissionsStrategy GetHostPermissionsStrategy() const OVERRIDE; |
391 virtual LinkedPtrEventResponseDelta CreateDelta( | 367 virtual LinkedPtrEventResponseDelta CreateDelta( |
392 const WebRequestRule::RequestData& request_data, | 368 const DeclarativeWebRequestData& request_data, |
393 const std::string& extension_id, | 369 const std::string& extension_id, |
394 const base::Time& extension_install_time) const OVERRIDE; | 370 const base::Time& extension_install_time) const OVERRIDE; |
395 | 371 |
396 private: | 372 private: |
397 int minimum_priority_; | 373 int minimum_priority_; |
398 DISALLOW_COPY_AND_ASSIGN(WebRequestIgnoreRulesAction); | 374 DISALLOW_COPY_AND_ASSIGN(WebRequestIgnoreRulesAction); |
399 }; | 375 }; |
400 | 376 |
401 // Action that instructs to modify (add, edit, remove) a request cookie. | 377 // Action that instructs to modify (add, edit, remove) a request cookie. |
402 class WebRequestRequestCookieAction : public WebRequestAction { | 378 class WebRequestRequestCookieAction : public WebRequestAction { |
403 public: | 379 public: |
404 typedef extension_web_request_api_helpers::RequestCookieModification | 380 typedef extension_web_request_api_helpers::RequestCookieModification |
405 RequestCookieModification; | 381 RequestCookieModification; |
406 | 382 |
407 explicit WebRequestRequestCookieAction( | 383 explicit WebRequestRequestCookieAction( |
408 linked_ptr<RequestCookieModification> request_cookie_modification); | 384 linked_ptr<RequestCookieModification> request_cookie_modification); |
409 virtual ~WebRequestRequestCookieAction(); | 385 virtual ~WebRequestRequestCookieAction(); |
410 | 386 |
411 // Implementation of WebRequestAction: | 387 // Implementation of WebRequestAction: |
412 virtual int GetStages() const OVERRIDE; | 388 virtual int GetStages() const OVERRIDE; |
413 virtual Type GetType() const OVERRIDE; | 389 virtual Type GetType() const OVERRIDE; |
414 virtual LinkedPtrEventResponseDelta CreateDelta( | 390 virtual LinkedPtrEventResponseDelta CreateDelta( |
415 const WebRequestRule::RequestData& request_data, | 391 const DeclarativeWebRequestData& request_data, |
416 const std::string& extension_id, | 392 const std::string& extension_id, |
417 const base::Time& extension_install_time) const OVERRIDE; | 393 const base::Time& extension_install_time) const OVERRIDE; |
418 | 394 |
419 private: | 395 private: |
420 linked_ptr<RequestCookieModification> request_cookie_modification_; | 396 linked_ptr<RequestCookieModification> request_cookie_modification_; |
421 DISALLOW_COPY_AND_ASSIGN(WebRequestRequestCookieAction); | 397 DISALLOW_COPY_AND_ASSIGN(WebRequestRequestCookieAction); |
422 }; | 398 }; |
423 | 399 |
424 // Action that instructs to modify (add, edit, remove) a response cookie. | 400 // Action that instructs to modify (add, edit, remove) a response cookie. |
425 class WebRequestResponseCookieAction : public WebRequestAction { | 401 class WebRequestResponseCookieAction : public WebRequestAction { |
426 public: | 402 public: |
427 typedef extension_web_request_api_helpers::ResponseCookieModification | 403 typedef extension_web_request_api_helpers::ResponseCookieModification |
428 ResponseCookieModification; | 404 ResponseCookieModification; |
429 | 405 |
430 explicit WebRequestResponseCookieAction( | 406 explicit WebRequestResponseCookieAction( |
431 linked_ptr<ResponseCookieModification> response_cookie_modification); | 407 linked_ptr<ResponseCookieModification> response_cookie_modification); |
432 virtual ~WebRequestResponseCookieAction(); | 408 virtual ~WebRequestResponseCookieAction(); |
433 | 409 |
434 // Implementation of WebRequestAction: | 410 // Implementation of WebRequestAction: |
435 virtual int GetStages() const OVERRIDE; | 411 virtual int GetStages() const OVERRIDE; |
436 virtual Type GetType() const OVERRIDE; | 412 virtual Type GetType() const OVERRIDE; |
437 virtual LinkedPtrEventResponseDelta CreateDelta( | 413 virtual LinkedPtrEventResponseDelta CreateDelta( |
438 const WebRequestRule::RequestData& request_data, | 414 const DeclarativeWebRequestData& request_data, |
439 const std::string& extension_id, | 415 const std::string& extension_id, |
440 const base::Time& extension_install_time) const OVERRIDE; | 416 const base::Time& extension_install_time) const OVERRIDE; |
441 | 417 |
442 private: | 418 private: |
443 linked_ptr<ResponseCookieModification> response_cookie_modification_; | 419 linked_ptr<ResponseCookieModification> response_cookie_modification_; |
444 DISALLOW_COPY_AND_ASSIGN(WebRequestResponseCookieAction); | 420 DISALLOW_COPY_AND_ASSIGN(WebRequestResponseCookieAction); |
445 }; | 421 }; |
446 | 422 |
447 } // namespace extensions | 423 } // namespace extensions |
448 | 424 |
449 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO N_H_ | 425 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO N_H_ |
OLD | NEW |