Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/extension_function_util.h" | |
| 6 | |
| 7 bool ExtensionFuncUtil::ReadOneOrMoreIntegers(base::Value* value, | |
|
Matt Perry
2012/05/08 01:00:34
nit: just make the function global. classes of sta
nasko
2012/05/08 16:39:50
Done.
| |
| 8 std::vector<int>* result) { | |
| 9 if (value->IsType(Value::TYPE_INTEGER)) { | |
| 10 int v = -1; | |
| 11 if (!value->GetAsInteger(&v)) | |
| 12 return false; | |
| 13 result->push_back(v); | |
| 14 return true; | |
| 15 | |
| 16 } else if (value->IsType(Value::TYPE_LIST)) { | |
| 17 base::ListValue* values = static_cast<base::ListValue*>(value); | |
| 18 for (size_t i = 0; i < values->GetSize(); ++i) { | |
| 19 int v = -1; | |
| 20 if (!values->GetInteger(i, &v)) | |
| 21 return false; | |
| 22 result->push_back(v); | |
| 23 } | |
| 24 return true; | |
| 25 } | |
| 26 return false; | |
| 27 } | |
| OLD | NEW |