OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/url_matcher/url_matcher_helpers.h" | 5 #include "components/url_matcher/url_matcher_helpers.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include "base/values.h" | 9 #include "base/values.h" |
8 | 10 |
9 namespace url_matcher { | 11 namespace url_matcher { |
10 namespace url_matcher_helpers { | 12 namespace url_matcher_helpers { |
11 | 13 |
12 // Converts a ValueList |value| of strings into a vector. Returns true if | 14 // Converts a ValueList |value| of strings into a vector. Returns true if |
13 // successful. | 15 // successful. |
14 bool GetAsStringVector(const base::Value* value, | 16 bool GetAsStringVector(const base::Value* value, |
15 std::vector<std::string>* out) { | 17 std::vector<std::string>* out) { |
16 const base::ListValue* value_as_list = 0; | 18 const base::ListValue* value_as_list = 0; |
17 if (!value->GetAsList(&value_as_list)) | 19 if (!value->GetAsList(&value_as_list)) |
18 return false; | 20 return false; |
19 | 21 |
20 size_t number_types = value_as_list->GetSize(); | 22 size_t number_types = value_as_list->GetSize(); |
21 for (size_t i = 0; i < number_types; ++i) { | 23 for (size_t i = 0; i < number_types; ++i) { |
22 std::string item; | 24 std::string item; |
23 if (!value_as_list->GetString(i, &item)) | 25 if (!value_as_list->GetString(i, &item)) |
24 return false; | 26 return false; |
25 out->push_back(item); | 27 out->push_back(item); |
26 } | 28 } |
27 return true; | 29 return true; |
28 } | 30 } |
29 | 31 |
30 } // namespace url_matcher_helpers | 32 } // namespace url_matcher_helpers |
31 } // namespace url_matcher | 33 } // namespace url_matcher |
OLD | NEW |