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

Side by Side Diff: extensions/browser/api/declarative_webrequest/webrequest_action.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 #include "extensions/browser/api/declarative_webrequest/webrequest_action.h" 5 #include "extensions/browser/api/declarative_webrequest/webrequest_action.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 "EUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="; 46 "EUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==";
47 const char kEmptyDocumentUrl[] = "data:text/html,"; 47 const char kEmptyDocumentUrl[] = "data:text/html,";
48 48
49 #define INPUT_FORMAT_VALIDATE(test) do { \ 49 #define INPUT_FORMAT_VALIDATE(test) do { \
50 if (!(test)) { \ 50 if (!(test)) { \
51 *bad_message = true; \ 51 *bad_message = true; \
52 return scoped_refptr<const WebRequestAction>(NULL); \ 52 return scoped_refptr<const WebRequestAction>(NULL); \
53 } \ 53 } \
54 } while (0) 54 } while (0)
55 55
56 scoped_ptr<helpers::RequestCookie> ParseRequestCookie( 56 std::unique_ptr<helpers::RequestCookie> ParseRequestCookie(
57 const base::DictionaryValue* dict) { 57 const base::DictionaryValue* dict) {
58 scoped_ptr<helpers::RequestCookie> result(new helpers::RequestCookie); 58 std::unique_ptr<helpers::RequestCookie> result(new helpers::RequestCookie);
59 std::string tmp; 59 std::string tmp;
60 if (dict->GetString(keys::kNameKey, &tmp)) 60 if (dict->GetString(keys::kNameKey, &tmp))
61 result->name.reset(new std::string(tmp)); 61 result->name.reset(new std::string(tmp));
62 if (dict->GetString(keys::kValueKey, &tmp)) 62 if (dict->GetString(keys::kValueKey, &tmp))
63 result->value.reset(new std::string(tmp)); 63 result->value.reset(new std::string(tmp));
64 return result; 64 return result;
65 } 65 }
66 66
67 void ParseResponseCookieImpl(const base::DictionaryValue* dict, 67 void ParseResponseCookieImpl(const base::DictionaryValue* dict,
68 helpers::ResponseCookie* cookie) { 68 helpers::ResponseCookie* cookie) {
(...skipping 11 matching lines...) Expand all
80 if (dict->GetString(keys::kDomainKey, &string_tmp)) 80 if (dict->GetString(keys::kDomainKey, &string_tmp))
81 cookie->domain.reset(new std::string(string_tmp)); 81 cookie->domain.reset(new std::string(string_tmp));
82 if (dict->GetString(keys::kPathKey, &string_tmp)) 82 if (dict->GetString(keys::kPathKey, &string_tmp))
83 cookie->path.reset(new std::string(string_tmp)); 83 cookie->path.reset(new std::string(string_tmp));
84 if (dict->GetBoolean(keys::kSecureKey, &bool_tmp)) 84 if (dict->GetBoolean(keys::kSecureKey, &bool_tmp))
85 cookie->secure.reset(new bool(bool_tmp)); 85 cookie->secure.reset(new bool(bool_tmp));
86 if (dict->GetBoolean(keys::kHttpOnlyKey, &bool_tmp)) 86 if (dict->GetBoolean(keys::kHttpOnlyKey, &bool_tmp))
87 cookie->http_only.reset(new bool(bool_tmp)); 87 cookie->http_only.reset(new bool(bool_tmp));
88 } 88 }
89 89
90 scoped_ptr<helpers::ResponseCookie> ParseResponseCookie( 90 std::unique_ptr<helpers::ResponseCookie> ParseResponseCookie(
91 const base::DictionaryValue* dict) { 91 const base::DictionaryValue* dict) {
92 scoped_ptr<helpers::ResponseCookie> result(new helpers::ResponseCookie); 92 std::unique_ptr<helpers::ResponseCookie> result(new helpers::ResponseCookie);
93 ParseResponseCookieImpl(dict, result.get()); 93 ParseResponseCookieImpl(dict, result.get());
94 return result; 94 return result;
95 } 95 }
96 96
97 scoped_ptr<helpers::FilterResponseCookie> ParseFilterResponseCookie( 97 std::unique_ptr<helpers::FilterResponseCookie> ParseFilterResponseCookie(
98 const base::DictionaryValue* dict) { 98 const base::DictionaryValue* dict) {
99 scoped_ptr<helpers::FilterResponseCookie> result( 99 std::unique_ptr<helpers::FilterResponseCookie> result(
100 new helpers::FilterResponseCookie); 100 new helpers::FilterResponseCookie);
101 ParseResponseCookieImpl(dict, result.get()); 101 ParseResponseCookieImpl(dict, result.get());
102 102
103 int int_tmp = 0; 103 int int_tmp = 0;
104 bool bool_tmp = false; 104 bool bool_tmp = false;
105 if (dict->GetInteger(keys::kAgeUpperBoundKey, &int_tmp)) 105 if (dict->GetInteger(keys::kAgeUpperBoundKey, &int_tmp))
106 result->age_upper_bound.reset(new int(int_tmp)); 106 result->age_upper_bound.reset(new int(int_tmp));
107 if (dict->GetInteger(keys::kAgeLowerBoundKey, &int_tmp)) 107 if (dict->GetInteger(keys::kAgeLowerBoundKey, &int_tmp))
108 result->age_lower_bound.reset(new int(int_tmp)); 108 result->age_lower_bound.reset(new int(int_tmp));
109 if (dict->GetBoolean(keys::kSessionCookieKey, &bool_tmp)) 109 if (dict->GetBoolean(keys::kSessionCookieKey, &bool_tmp))
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 CHECK(value->GetAsDictionary(&dict)); 146 CHECK(value->GetAsDictionary(&dict));
147 std::string from; 147 std::string from;
148 std::string to; 148 std::string to;
149 INPUT_FORMAT_VALIDATE(dict->GetString(keys::kFromKey, &from)); 149 INPUT_FORMAT_VALIDATE(dict->GetString(keys::kFromKey, &from));
150 INPUT_FORMAT_VALIDATE(dict->GetString(keys::kToKey, &to)); 150 INPUT_FORMAT_VALIDATE(dict->GetString(keys::kToKey, &to));
151 151
152 to = WebRequestRedirectByRegExAction::PerlToRe2Style(to); 152 to = WebRequestRedirectByRegExAction::PerlToRe2Style(to);
153 153
154 RE2::Options options; 154 RE2::Options options;
155 options.set_case_sensitive(false); 155 options.set_case_sensitive(false);
156 scoped_ptr<RE2> from_pattern(new RE2(from, options)); 156 std::unique_ptr<RE2> from_pattern(new RE2(from, options));
157 157
158 if (!from_pattern->ok()) { 158 if (!from_pattern->ok()) {
159 *error = "Invalid pattern '" + from + "' -> '" + to + "'"; 159 *error = "Invalid pattern '" + from + "' -> '" + to + "'";
160 return scoped_refptr<const WebRequestAction>(NULL); 160 return scoped_refptr<const WebRequestAction>(NULL);
161 } 161 }
162 return scoped_refptr<const WebRequestAction>( 162 return scoped_refptr<const WebRequestAction>(
163 new WebRequestRedirectByRegExAction(std::move(from_pattern), to)); 163 new WebRequestRedirectByRegExAction(std::move(from_pattern), to));
164 } 164 }
165 165
166 scoped_refptr<const WebRequestAction> CreateSetRequestHeaderAction( 166 scoped_refptr<const WebRequestAction> CreateSetRequestHeaderAction(
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 new helpers::EventResponseDelta(extension_id, extension_install_time)); 688 new helpers::EventResponseDelta(extension_id, extension_install_time));
689 result->new_url = GURL(kEmptyDocumentUrl); 689 result->new_url = GURL(kEmptyDocumentUrl);
690 return result; 690 return result;
691 } 691 }
692 692
693 // 693 //
694 // WebRequestRedirectByRegExAction 694 // WebRequestRedirectByRegExAction
695 // 695 //
696 696
697 WebRequestRedirectByRegExAction::WebRequestRedirectByRegExAction( 697 WebRequestRedirectByRegExAction::WebRequestRedirectByRegExAction(
698 scoped_ptr<RE2> from_pattern, 698 std::unique_ptr<RE2> from_pattern,
699 const std::string& to_pattern) 699 const std::string& to_pattern)
700 : WebRequestAction(ON_BEFORE_REQUEST | ON_HEADERS_RECEIVED, 700 : WebRequestAction(ON_BEFORE_REQUEST | ON_HEADERS_RECEIVED,
701 ACTION_REDIRECT_BY_REGEX_DOCUMENT, 701 ACTION_REDIRECT_BY_REGEX_DOCUMENT,
702 std::numeric_limits<int>::min(), 702 std::numeric_limits<int>::min(),
703 STRATEGY_DEFAULT), 703 STRATEGY_DEFAULT),
704 from_pattern_(std::move(from_pattern)), 704 from_pattern_(std::move(from_pattern)),
705 to_pattern_(to_pattern.data(), to_pattern.size()) {} 705 to_pattern_(to_pattern.data(), to_pattern.size()) {}
706 706
707 WebRequestRedirectByRegExAction::~WebRequestRedirectByRegExAction() {} 707 WebRequestRedirectByRegExAction::~WebRequestRedirectByRegExAction() {}
708 708
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 const base::Time& extension_install_time) const { 1158 const base::Time& extension_install_time) const {
1159 CHECK(request_data.stage & stages()); 1159 CHECK(request_data.stage & stages());
1160 LinkedPtrEventResponseDelta result( 1160 LinkedPtrEventResponseDelta result(
1161 new extension_web_request_api_helpers::EventResponseDelta( 1161 new extension_web_request_api_helpers::EventResponseDelta(
1162 extension_id, extension_install_time)); 1162 extension_id, extension_install_time));
1163 result->messages_to_extension.insert(message_); 1163 result->messages_to_extension.insert(message_);
1164 return result; 1164 return result;
1165 } 1165 }
1166 1166
1167 } // namespace extensions 1167 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698