Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h

Issue 10852002: Revert 149852 - Migrate WebRequestRedirectByRegExAction to use RE2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_webrequest/request_stages.h" 14 #include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h"
15 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.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 #include "unicode/regex.h"
19 20
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;
34 } 35 }
35 36
36 namespace net { 37 namespace net {
37 class URLRequest; 38 class URLRequest;
38 } 39 }
39 40
40 namespace re2 {
41 class RE2;
42 }
43
44 namespace extensions { 41 namespace extensions {
45 42
46 typedef linked_ptr<extension_web_request_api_helpers::EventResponseDelta> 43 typedef linked_ptr<extension_web_request_api_helpers::EventResponseDelta>
47 LinkedPtrEventResponseDelta; 44 LinkedPtrEventResponseDelta;
48 45
49 // Base class for all WebRequestActions of the declarative Web Request API. 46 // Base class for all WebRequestActions of the declarative Web Request API.
50 class WebRequestAction { 47 class WebRequestAction {
51 public: 48 public:
52 // Type identifiers for concrete WebRequestActions. 49 // Type identifiers for concrete WebRequestActions.
53 enum Type { 50 enum Type {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 const std::string& extension_id, 241 const std::string& extension_id,
245 const base::Time& extension_install_time) const OVERRIDE; 242 const base::Time& extension_install_time) const OVERRIDE;
246 243
247 private: 244 private:
248 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToEmptyDocumentAction); 245 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToEmptyDocumentAction);
249 }; 246 };
250 247
251 // Action that instructs to redirect a network request. 248 // Action that instructs to redirect a network request.
252 class WebRequestRedirectByRegExAction : public WebRequestAction { 249 class WebRequestRedirectByRegExAction : public WebRequestAction {
253 public: 250 public:
254 // The |to_pattern| has to be passed in RE2 syntax with the exception that 251 // The |to_pattern| has to be passed in ICU syntax.
255 // capture groups are referenced in Perl style ($1, $2, ...). 252 // TODO(battre): Change this to Perl style when migrated to RE2.
256 WebRequestRedirectByRegExAction(scoped_ptr<re2::RE2> from_pattern, 253 explicit WebRequestRedirectByRegExAction(
257 const std::string& to_pattern); 254 scoped_ptr<icu::RegexPattern> from_pattern,
255 const std::string& to_pattern);
258 virtual ~WebRequestRedirectByRegExAction(); 256 virtual ~WebRequestRedirectByRegExAction();
259 257
260 // Conversion of capture group styles between Perl style ($1, $2, ...) and 258 // Conversion of capture group styles between Perl style ($1, $2, ...) and
261 // RE2 (\1, \2, ...). 259 // RE2 (\1, \2, ...).
262 static std::string PerlToRe2Style(const std::string& perl); 260 static std::string PerlToRe2Style(const std::string& perl);
263 261
264 // Implementation of WebRequestAction: 262 // Implementation of WebRequestAction:
265 virtual int GetStages() const OVERRIDE; 263 virtual int GetStages() const OVERRIDE;
266 virtual Type GetType() const OVERRIDE; 264 virtual Type GetType() const OVERRIDE;
267 virtual LinkedPtrEventResponseDelta CreateDelta( 265 virtual LinkedPtrEventResponseDelta CreateDelta(
268 net::URLRequest* request, 266 net::URLRequest* request,
269 RequestStages request_stage, 267 RequestStages request_stage,
270 const WebRequestRule::OptionalRequestData& optional_request_data, 268 const WebRequestRule::OptionalRequestData& optional_request_data,
271 const std::string& extension_id, 269 const std::string& extension_id,
272 const base::Time& extension_install_time) const OVERRIDE; 270 const base::Time& extension_install_time) const OVERRIDE;
273 271
274 private: 272 private:
275 scoped_ptr<re2::RE2> from_pattern_; 273 scoped_ptr<icu::RegexPattern> from_pattern_;
276 std::string to_pattern_; 274 icu::UnicodeString to_pattern_;
277 275
278 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectByRegExAction); 276 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectByRegExAction);
279 }; 277 };
280 278
281 // Action that instructs to set a request header. 279 // Action that instructs to set a request header.
282 class WebRequestSetRequestHeaderAction : public WebRequestAction { 280 class WebRequestSetRequestHeaderAction : public WebRequestAction {
283 public: 281 public:
284 WebRequestSetRequestHeaderAction(const std::string& name, 282 WebRequestSetRequestHeaderAction(const std::string& name,
285 const std::string& value); 283 const std::string& value);
286 virtual ~WebRequestSetRequestHeaderAction(); 284 virtual ~WebRequestSetRequestHeaderAction();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 const base::Time& extension_install_time) const OVERRIDE; 437 const base::Time& extension_install_time) const OVERRIDE;
440 438
441 private: 439 private:
442 linked_ptr<ResponseCookieModification> response_cookie_modification_; 440 linked_ptr<ResponseCookieModification> response_cookie_modification_;
443 DISALLOW_COPY_AND_ASSIGN(WebRequestResponseCookieAction); 441 DISALLOW_COPY_AND_ASSIGN(WebRequestResponseCookieAction);
444 }; 442 };
445 443
446 } // namespace extensions 444 } // namespace extensions
447 445
448 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO N_H_ 446 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO N_H_
OLDNEW
« no previous file with comments | « chrome/browser/DEPS ('k') | chrome/browser/extensions/api/declarative_webrequest/webrequest_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698