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

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

Issue 10873029: Migrate WebRequestRedirectByRegExAction to use RE2 and roll RE2 to revision 97:401ab4168e8e (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT 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_stage.h" 14 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.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"
20 19
21 class WebRequestPermission; 20 class WebRequestPermission;
22 21
23 namespace base { 22 namespace base {
24 class DictionaryValue; 23 class DictionaryValue;
25 class Time; 24 class Time;
26 class Value; 25 class Value;
27 } 26 }
28 27
29 namespace extension_web_request_api_helpers { 28 namespace extension_web_request_api_helpers {
30 struct EventResponseDelta; 29 struct EventResponseDelta;
31 } 30 }
32 31
33 namespace extensions { 32 namespace extensions {
34 class Extension; 33 class Extension;
35 } 34 }
36 35
37 namespace net { 36 namespace net {
38 class URLRequest; 37 class URLRequest;
39 } 38 }
40 39
40 namespace re2 {
41 class RE2;
42 }
43
41 namespace extensions { 44 namespace extensions {
42 45
43 typedef linked_ptr<extension_web_request_api_helpers::EventResponseDelta> 46 typedef linked_ptr<extension_web_request_api_helpers::EventResponseDelta>
44 LinkedPtrEventResponseDelta; 47 LinkedPtrEventResponseDelta;
45 48
46 // Base class for all WebRequestActions of the declarative Web Request API. 49 // Base class for all WebRequestActions of the declarative Web Request API.
47 class WebRequestAction { 50 class WebRequestAction {
48 public: 51 public:
49 // Type identifiers for concrete WebRequestActions. 52 // Type identifiers for concrete WebRequestActions.
50 enum Type { 53 enum Type {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 const std::string& extension_id, 232 const std::string& extension_id,
230 const base::Time& extension_install_time) const OVERRIDE; 233 const base::Time& extension_install_time) const OVERRIDE;
231 234
232 private: 235 private:
233 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToEmptyDocumentAction); 236 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectToEmptyDocumentAction);
234 }; 237 };
235 238
236 // Action that instructs to redirect a network request. 239 // Action that instructs to redirect a network request.
237 class WebRequestRedirectByRegExAction : public WebRequestAction { 240 class WebRequestRedirectByRegExAction : public WebRequestAction {
238 public: 241 public:
239 // The |to_pattern| has to be passed in ICU syntax. 242 // The |to_pattern| has to be passed in RE2 syntax with the exception that
240 // TODO(battre): Change this to Perl style when migrated to RE2. 243 // capture groups are referenced in Perl style ($1, $2, ...).
241 explicit WebRequestRedirectByRegExAction( 244 explicit WebRequestRedirectByRegExAction(scoped_ptr<re2::RE2> from_pattern,
242 scoped_ptr<icu::RegexPattern> from_pattern, 245 const std::string& to_pattern);
243 const std::string& to_pattern);
244 virtual ~WebRequestRedirectByRegExAction(); 246 virtual ~WebRequestRedirectByRegExAction();
245 247
246 // Conversion of capture group styles between Perl style ($1, $2, ...) and 248 // Conversion of capture group styles between Perl style ($1, $2, ...) and
247 // RE2 (\1, \2, ...). 249 // RE2 (\1, \2, ...).
248 static std::string PerlToRe2Style(const std::string& perl); 250 static std::string PerlToRe2Style(const std::string& perl);
249 251
250 // Implementation of WebRequestAction: 252 // Implementation of WebRequestAction:
251 virtual int GetStages() const OVERRIDE; 253 virtual int GetStages() const OVERRIDE;
252 virtual Type GetType() const OVERRIDE; 254 virtual Type GetType() const OVERRIDE;
253 virtual LinkedPtrEventResponseDelta CreateDelta( 255 virtual LinkedPtrEventResponseDelta CreateDelta(
254 const WebRequestRule::RequestData& request_data, 256 const WebRequestRule::RequestData& request_data,
255 const std::string& extension_id, 257 const std::string& extension_id,
256 const base::Time& extension_install_time) const OVERRIDE; 258 const base::Time& extension_install_time) const OVERRIDE;
257 259
258 private: 260 private:
259 scoped_ptr<icu::RegexPattern> from_pattern_; 261 scoped_ptr<re2::RE2> from_pattern_;
260 icu::UnicodeString to_pattern_; 262 std::string to_pattern_;
261 263
262 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectByRegExAction); 264 DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectByRegExAction);
263 }; 265 };
264 266
265 // Action that instructs to set a request header. 267 // Action that instructs to set a request header.
266 class WebRequestSetRequestHeaderAction : public WebRequestAction { 268 class WebRequestSetRequestHeaderAction : public WebRequestAction {
267 public: 269 public:
268 WebRequestSetRequestHeaderAction(const std::string& name, 270 WebRequestSetRequestHeaderAction(const std::string& name,
269 const std::string& value); 271 const std::string& value);
270 virtual ~WebRequestSetRequestHeaderAction(); 272 virtual ~WebRequestSetRequestHeaderAction();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 const base::Time& extension_install_time) const OVERRIDE; 411 const base::Time& extension_install_time) const OVERRIDE;
410 412
411 private: 413 private:
412 linked_ptr<ResponseCookieModification> response_cookie_modification_; 414 linked_ptr<ResponseCookieModification> response_cookie_modification_;
413 DISALLOW_COPY_AND_ASSIGN(WebRequestResponseCookieAction); 415 DISALLOW_COPY_AND_ASSIGN(WebRequestResponseCookieAction);
414 }; 416 };
415 417
416 } // namespace extensions 418 } // namespace extensions
417 419
418 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_ACTIO N_H_ 420 #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