| 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" |
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "extensions/common/error_utils.h" | 15 #include "extensions/common/error_utils.h" |
| 15 #include "extensions/common/url_pattern.h" | 16 #include "extensions/common/url_pattern.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 #include "url/origin.h" | 18 #include "url/origin.h" |
| 18 #include "url/url_constants.h" | 19 #include "url/url_constants.h" |
| 19 | 20 |
| 20 namespace extensions { | 21 namespace extensions { |
| 21 | 22 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 227 } |
| 227 } | 228 } |
| 228 | 229 |
| 229 return false; | 230 return false; |
| 230 } | 231 } |
| 231 | 232 |
| 232 std::unique_ptr<base::ListValue> URLPatternSet::ToValue() const { | 233 std::unique_ptr<base::ListValue> URLPatternSet::ToValue() const { |
| 233 std::unique_ptr<base::ListValue> value(new base::ListValue); | 234 std::unique_ptr<base::ListValue> value(new base::ListValue); |
| 234 for (URLPatternSet::const_iterator i = patterns_.begin(); | 235 for (URLPatternSet::const_iterator i = patterns_.begin(); |
| 235 i != patterns_.end(); ++i) | 236 i != patterns_.end(); ++i) |
| 236 value->AppendIfNotPresent(new base::StringValue(i->GetAsString())); | 237 value->AppendIfNotPresent( |
| 238 base::MakeUnique<base::StringValue>(i->GetAsString())); |
| 237 return value; | 239 return value; |
| 238 } | 240 } |
| 239 | 241 |
| 240 bool URLPatternSet::Populate(const std::vector<std::string>& patterns, | 242 bool URLPatternSet::Populate(const std::vector<std::string>& patterns, |
| 241 int valid_schemes, | 243 int valid_schemes, |
| 242 bool allow_file_access, | 244 bool allow_file_access, |
| 243 std::string* error) { | 245 std::string* error) { |
| 244 ClearPatterns(); | 246 ClearPatterns(); |
| 245 for (size_t i = 0; i < patterns.size(); ++i) { | 247 for (size_t i = 0; i < patterns.size(); ++i) { |
| 246 URLPattern pattern(valid_schemes); | 248 URLPattern pattern(valid_schemes); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 for (size_t i = 0; i < value.GetSize(); ++i) { | 283 for (size_t i = 0; i < value.GetSize(); ++i) { |
| 282 std::string item; | 284 std::string item; |
| 283 if (!value.GetString(i, &item)) | 285 if (!value.GetString(i, &item)) |
| 284 return false; | 286 return false; |
| 285 patterns.push_back(item); | 287 patterns.push_back(item); |
| 286 } | 288 } |
| 287 return Populate(patterns, valid_schemes, allow_file_access, error); | 289 return Populate(patterns, valid_schemes, allow_file_access, error); |
| 288 } | 290 } |
| 289 | 291 |
| 290 } // namespace extensions | 292 } // namespace extensions |
| OLD | NEW |