[email protected] | 0b9de03 | 2014-03-15 05:47:01 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 350584cd | 2012-05-17 18:18:26 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 0b9de03 | 2014-03-15 05:47:01 | [diff] [blame] | 5 | #include "extensions/browser/extension_function_util.h" |
[email protected] | 350584cd | 2012-05-17 18:18:26 | [diff] [blame] | 6 | |
7 | namespace extensions { | ||||
8 | |||||
9 | bool ReadOneOrMoreIntegers(base::Value* value, std::vector<int>* result) { | ||||
[email protected] | 023b3d1 | 2013-12-23 18:46:49 | [diff] [blame] | 10 | if (value->IsType(base::Value::TYPE_INTEGER)) { |
[email protected] | 350584cd | 2012-05-17 18:18:26 | [diff] [blame] | 11 | int v = -1; |
12 | if (!value->GetAsInteger(&v)) | ||||
13 | return false; | ||||
14 | result->push_back(v); | ||||
15 | return true; | ||||
16 | |||||
[email protected] | 023b3d1 | 2013-12-23 18:46:49 | [diff] [blame] | 17 | } else if (value->IsType(base::Value::TYPE_LIST)) { |
[email protected] | 350584cd | 2012-05-17 18:18:26 | [diff] [blame] | 18 | base::ListValue* values = static_cast<base::ListValue*>(value); |
19 | for (size_t i = 0; i < values->GetSize(); ++i) { | ||||
20 | int v = -1; | ||||
21 | if (!values->GetInteger(i, &v)) | ||||
22 | return false; | ||||
23 | result->push_back(v); | ||||
24 | } | ||||
25 | return true; | ||||
26 | } | ||||
27 | return false; | ||||
28 | } | ||||
29 | |||||
30 | } // namespace extensions |