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 <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 return false; | 182 return false; |
183 } | 183 } |
184 | 184 |
185 scoped_ptr<base::ListValue> URLPatternSet::ToValue() const { | 185 scoped_ptr<base::ListValue> URLPatternSet::ToValue() const { |
186 scoped_ptr<base::ListValue> value(new base::ListValue); | 186 scoped_ptr<base::ListValue> value(new base::ListValue); |
187 for (URLPatternSet::const_iterator i = patterns_.begin(); | 187 for (URLPatternSet::const_iterator i = patterns_.begin(); |
188 i != patterns_.end(); ++i) | 188 i != patterns_.end(); ++i) |
189 value->AppendIfNotPresent(base::Value::CreateStringValue(i->GetAsString())); | 189 value->AppendIfNotPresent(new base::StringValue(i->GetAsString())); |
190 return value.Pass(); | 190 return value.Pass(); |
191 } | 191 } |
192 | 192 |
193 bool URLPatternSet::Populate(const std::vector<std::string>& patterns, | 193 bool URLPatternSet::Populate(const std::vector<std::string>& patterns, |
194 int valid_schemes, | 194 int valid_schemes, |
195 bool allow_file_access, | 195 bool allow_file_access, |
196 std::string* error) { | 196 std::string* error) { |
197 ClearPatterns(); | 197 ClearPatterns(); |
198 for (size_t i = 0; i < patterns.size(); ++i) { | 198 for (size_t i = 0; i < patterns.size(); ++i) { |
199 URLPattern pattern(valid_schemes); | 199 URLPattern pattern(valid_schemes); |
(...skipping 23 matching lines...) Expand all Loading... |
223 for (size_t i = 0; i < value.GetSize(); ++i) { | 223 for (size_t i = 0; i < value.GetSize(); ++i) { |
224 std::string item; | 224 std::string item; |
225 if (!value.GetString(i, &item)) | 225 if (!value.GetString(i, &item)) |
226 return false; | 226 return false; |
227 patterns.push_back(item); | 227 patterns.push_back(item); |
228 } | 228 } |
229 return Populate(patterns, valid_schemes, allow_file_access, error); | 229 return Populate(patterns, valid_schemes, allow_file_access, error); |
230 } | 230 } |
231 | 231 |
232 } // namespace extensions | 232 } // namespace extensions |
OLD | NEW |