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 #include "extensions/common/url_pattern_set.h" | 5 #include "extensions/common/url_pattern_set.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 for (URLPatternSet::const_iterator j = other.patterns().begin(); | 222 for (URLPatternSet::const_iterator j = other.patterns().begin(); |
223 j != other.patterns().end(); ++j) { | 223 j != other.patterns().end(); ++j) { |
224 if (i->OverlapsWith(*j)) | 224 if (i->OverlapsWith(*j)) |
225 return true; | 225 return true; |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 return false; | 229 return false; |
230 } | 230 } |
231 | 231 |
232 scoped_ptr<base::ListValue> URLPatternSet::ToValue() const { | 232 std::unique_ptr<base::ListValue> URLPatternSet::ToValue() const { |
233 scoped_ptr<base::ListValue> value(new base::ListValue); | 233 std::unique_ptr<base::ListValue> value(new base::ListValue); |
234 for (URLPatternSet::const_iterator i = patterns_.begin(); | 234 for (URLPatternSet::const_iterator i = patterns_.begin(); |
235 i != patterns_.end(); ++i) | 235 i != patterns_.end(); ++i) |
236 value->AppendIfNotPresent(new base::StringValue(i->GetAsString())); | 236 value->AppendIfNotPresent(new base::StringValue(i->GetAsString())); |
237 return value; | 237 return value; |
238 } | 238 } |
239 | 239 |
240 bool URLPatternSet::Populate(const std::vector<std::string>& patterns, | 240 bool URLPatternSet::Populate(const std::vector<std::string>& patterns, |
241 int valid_schemes, | 241 int valid_schemes, |
242 bool allow_file_access, | 242 bool allow_file_access, |
243 std::string* error) { | 243 std::string* error) { |
(...skipping 11 matching lines...) Expand all Loading... |
255 } | 255 } |
256 if (!allow_file_access && pattern.MatchesScheme(url::kFileScheme)) { | 256 if (!allow_file_access && pattern.MatchesScheme(url::kFileScheme)) { |
257 pattern.SetValidSchemes( | 257 pattern.SetValidSchemes( |
258 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); | 258 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); |
259 } | 259 } |
260 AddPattern(pattern); | 260 AddPattern(pattern); |
261 } | 261 } |
262 return true; | 262 return true; |
263 } | 263 } |
264 | 264 |
265 scoped_ptr<std::vector<std::string> > URLPatternSet::ToStringVector() const { | 265 std::unique_ptr<std::vector<std::string>> URLPatternSet::ToStringVector() |
266 scoped_ptr<std::vector<std::string> > value(new std::vector<std::string>); | 266 const { |
| 267 std::unique_ptr<std::vector<std::string>> value(new std::vector<std::string>); |
267 for (URLPatternSet::const_iterator i = patterns_.begin(); | 268 for (URLPatternSet::const_iterator i = patterns_.begin(); |
268 i != patterns_.end(); | 269 i != patterns_.end(); |
269 ++i) { | 270 ++i) { |
270 value->push_back(i->GetAsString()); | 271 value->push_back(i->GetAsString()); |
271 } | 272 } |
272 return value; | 273 return value; |
273 } | 274 } |
274 | 275 |
275 bool URLPatternSet::Populate(const base::ListValue& value, | 276 bool URLPatternSet::Populate(const base::ListValue& value, |
276 int valid_schemes, | 277 int valid_schemes, |
277 bool allow_file_access, | 278 bool allow_file_access, |
278 std::string* error) { | 279 std::string* error) { |
279 std::vector<std::string> patterns; | 280 std::vector<std::string> patterns; |
280 for (size_t i = 0; i < value.GetSize(); ++i) { | 281 for (size_t i = 0; i < value.GetSize(); ++i) { |
281 std::string item; | 282 std::string item; |
282 if (!value.GetString(i, &item)) | 283 if (!value.GetString(i, &item)) |
283 return false; | 284 return false; |
284 patterns.push_back(item); | 285 patterns.push_back(item); |
285 } | 286 } |
286 return Populate(patterns, valid_schemes, allow_file_access, error); | 287 return Populate(patterns, valid_schemes, allow_file_access, error); |
287 } | 288 } |
288 | 289 |
289 } // namespace extensions | 290 } // namespace extensions |
OLD | NEW |