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

Side by Side Diff: extensions/common/matcher/url_matcher_factory.cc

Issue 16866009: Rewrite scoped_ptr<T>(NULL) to use the default ctor in extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « no previous file | extensions/common/matcher/url_matcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/matcher/url_matcher_factory.h" 5 #include "extensions/common/matcher/url_matcher_factory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 218
219 // static 219 // static
220 scoped_ptr<URLMatcherSchemeFilter> URLMatcherFactory::CreateURLMatcherScheme( 220 scoped_ptr<URLMatcherSchemeFilter> URLMatcherFactory::CreateURLMatcherScheme(
221 const base::Value* value, 221 const base::Value* value,
222 std::string* error) { 222 std::string* error) {
223 std::vector<std::string> schemas; 223 std::vector<std::string> schemas;
224 if (!helpers::GetAsStringVector(value, &schemas)) { 224 if (!helpers::GetAsStringVector(value, &schemas)) {
225 *error = ErrorUtils::FormatErrorMessage(kVectorOfStringsExpected, 225 *error = ErrorUtils::FormatErrorMessage(kVectorOfStringsExpected,
226 keys::kSchemesKey); 226 keys::kSchemesKey);
227 return scoped_ptr<URLMatcherSchemeFilter>(NULL); 227 return scoped_ptr<URLMatcherSchemeFilter>();
228 } 228 }
229 for (std::vector<std::string>::const_iterator it = schemas.begin(); 229 for (std::vector<std::string>::const_iterator it = schemas.begin();
230 it != schemas.end(); ++it) { 230 it != schemas.end(); ++it) {
231 if (ContainsUpperCase(*it)) { 231 if (ContainsUpperCase(*it)) {
232 *error = ErrorUtils::FormatErrorMessage(kLowerCaseExpected, 232 *error = ErrorUtils::FormatErrorMessage(kLowerCaseExpected,
233 "Scheme"); 233 "Scheme");
234 return scoped_ptr<URLMatcherSchemeFilter>(NULL); 234 return scoped_ptr<URLMatcherSchemeFilter>();
235 } 235 }
236 } 236 }
237 return scoped_ptr<URLMatcherSchemeFilter>( 237 return scoped_ptr<URLMatcherSchemeFilter>(
238 new URLMatcherSchemeFilter(schemas)); 238 new URLMatcherSchemeFilter(schemas));
239 } 239 }
240 240
241 // static 241 // static
242 scoped_ptr<URLMatcherPortFilter> URLMatcherFactory::CreateURLMatcherPorts( 242 scoped_ptr<URLMatcherPortFilter> URLMatcherFactory::CreateURLMatcherPorts(
243 const base::Value* value, 243 const base::Value* value,
244 std::string* error) { 244 std::string* error) {
245 std::vector<URLMatcherPortFilter::Range> ranges; 245 std::vector<URLMatcherPortFilter::Range> ranges;
246 const base::ListValue* value_list = NULL; 246 const base::ListValue* value_list = NULL;
247 if (!value->GetAsList(&value_list)) { 247 if (!value->GetAsList(&value_list)) {
248 *error = kInvalidPortRanges; 248 *error = kInvalidPortRanges;
249 return scoped_ptr<URLMatcherPortFilter>(NULL); 249 return scoped_ptr<URLMatcherPortFilter>();
250 } 250 }
251 251
252 for (ListValue::const_iterator i = value_list->begin(); 252 for (ListValue::const_iterator i = value_list->begin();
253 i != value_list->end(); ++i) { 253 i != value_list->end(); ++i) {
254 Value* entry = *i; 254 Value* entry = *i;
255 int port = 0; 255 int port = 0;
256 base::ListValue* range = NULL; 256 base::ListValue* range = NULL;
257 if (entry->GetAsInteger(&port)) { 257 if (entry->GetAsInteger(&port)) {
258 ranges.push_back(URLMatcherPortFilter::CreateRange(port)); 258 ranges.push_back(URLMatcherPortFilter::CreateRange(port));
259 } else if (entry->GetAsList(&range)) { 259 } else if (entry->GetAsList(&range)) {
260 int from = 0, to = 0; 260 int from = 0, to = 0;
261 if (range->GetSize() != 2u || 261 if (range->GetSize() != 2u ||
262 !range->GetInteger(0, &from) || 262 !range->GetInteger(0, &from) ||
263 !range->GetInteger(1, &to)) { 263 !range->GetInteger(1, &to)) {
264 *error = kInvalidPortRanges; 264 *error = kInvalidPortRanges;
265 return scoped_ptr<URLMatcherPortFilter>(NULL); 265 return scoped_ptr<URLMatcherPortFilter>();
266 } 266 }
267 ranges.push_back(URLMatcherPortFilter::CreateRange(from, to)); 267 ranges.push_back(URLMatcherPortFilter::CreateRange(from, to));
268 } else { 268 } else {
269 *error = kInvalidPortRanges; 269 *error = kInvalidPortRanges;
270 return scoped_ptr<URLMatcherPortFilter>(NULL); 270 return scoped_ptr<URLMatcherPortFilter>();
271 } 271 }
272 } 272 }
273 273
274 return scoped_ptr<URLMatcherPortFilter>(new URLMatcherPortFilter(ranges)); 274 return scoped_ptr<URLMatcherPortFilter>(new URLMatcherPortFilter(ranges));
275 } 275 }
276 276
277 } // namespace extensions 277 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/common/matcher/url_matcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698