| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> |
| 6 |
| 5 #include "extensions/browser/extension_function_util.h" | 7 #include "extensions/browser/extension_function_util.h" |
| 6 | 8 |
| 7 namespace extensions { | 9 namespace extensions { |
| 8 | 10 |
| 9 bool ReadOneOrMoreIntegers(base::Value* value, std::vector<int>* result) { | 11 bool ReadOneOrMoreIntegers(base::Value* value, std::vector<int>* result) { |
| 10 if (value->IsType(base::Value::TYPE_INTEGER)) { | 12 if (value->IsType(base::Value::TYPE_INTEGER)) { |
| 11 int v = -1; | 13 int v = -1; |
| 12 if (!value->GetAsInteger(&v)) | 14 if (!value->GetAsInteger(&v)) |
| 13 return false; | 15 return false; |
| 14 result->push_back(v); | 16 result->push_back(v); |
| 15 return true; | 17 return true; |
| 16 | 18 |
| 17 } else if (value->IsType(base::Value::TYPE_LIST)) { | 19 } else if (value->IsType(base::Value::TYPE_LIST)) { |
| 18 base::ListValue* values = static_cast<base::ListValue*>(value); | 20 base::ListValue* values = static_cast<base::ListValue*>(value); |
| 19 for (size_t i = 0; i < values->GetSize(); ++i) { | 21 for (size_t i = 0; i < values->GetSize(); ++i) { |
| 20 int v = -1; | 22 int v = -1; |
| 21 if (!values->GetInteger(i, &v)) | 23 if (!values->GetInteger(i, &v)) |
| 22 return false; | 24 return false; |
| 23 result->push_back(v); | 25 result->push_back(v); |
| 24 } | 26 } |
| 25 return true; | 27 return true; |
| 26 } | 28 } |
| 27 return false; | 29 return false; |
| 28 } | 30 } |
| 29 | 31 |
| 30 } // namespace extensions | 32 } // namespace extensions |
| OLD | NEW |