blob: 6ff59184131126896b04830c68c5dfd59e29c263 [file] [log] [blame]
[email protected]716c0162013-12-13 20:36:531// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]faceb0f2012-04-12 17:07:192// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]716c0162013-12-13 20:36:535#include "components/url_matcher/url_matcher_helpers.h"
[email protected]faceb0f2012-04-12 17:07:196
avi5dd91f82015-12-25 22:30:467#include <stddef.h>
8
[email protected]faceb0f2012-04-12 17:07:199#include "base/values.h"
10
[email protected]716c0162013-12-13 20:36:5311namespace url_matcher {
[email protected]63f1a9e2012-05-09 12:51:0012namespace url_matcher_helpers {
[email protected]faceb0f2012-04-12 17:07:1913
14// Converts a ValueList |value| of strings into a vector. Returns true if
15// successful.
16bool GetAsStringVector(const base::Value* value,
17 std::vector<std::string>* out) {
Ivan Kotenkov75b1c3a2017-10-24 14:47:2418 const base::ListValue* value_as_list = nullptr;
[email protected]faceb0f2012-04-12 17:07:1919 if (!value->GetAsList(&value_as_list))
20 return false;
21
22 size_t number_types = value_as_list->GetSize();
23 for (size_t i = 0; i < number_types; ++i) {
24 std::string item;
25 if (!value_as_list->GetString(i, &item))
26 return false;
27 out->push_back(item);
28 }
29 return true;
30}
31
[email protected]63f1a9e2012-05-09 12:51:0032} // namespace url_matcher_helpers
[email protected]716c0162013-12-13 20:36:5333} // namespace url_matcher