| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler_utils.h" | |
| 6 | |
| 7 namespace chromeos { | |
| 8 | |
| 9 namespace { | |
| 10 | |
| 11 template <typename StringListType> | |
| 12 bool ParseStringList(const base::Value* value, StringListType* out_value) { | |
| 13 const base::ListValue* list = NULL; | |
| 14 if (!value->GetAsList(&list)) | |
| 15 return false; | |
| 16 out_value->resize(list->GetSize()); | |
| 17 for (size_t i = 0; i < list->GetSize(); ++i) { | |
| 18 if (!list->GetString(i, &((*out_value)[i]))) | |
| 19 return false; | |
| 20 } | |
| 21 return true; | |
| 22 } | |
| 23 | |
| 24 } // namespace | |
| 25 | |
| 26 bool ParseValue(const base::Value* value, bool* out_value) { | |
| 27 return value->GetAsBoolean(out_value); | |
| 28 } | |
| 29 | |
| 30 bool ParseValue(const base::Value* value, int* out_value) { | |
| 31 return value->GetAsInteger(out_value); | |
| 32 } | |
| 33 | |
| 34 bool ParseValue(const base::Value* value, double* out_value) { | |
| 35 return value->GetAsDouble(out_value); | |
| 36 } | |
| 37 | |
| 38 bool ParseValue(const base::Value* value, std::string* out_value) { | |
| 39 return value->GetAsString(out_value); | |
| 40 } | |
| 41 | |
| 42 bool ParseValue(const base::Value* value, base::string16* out_value) { | |
| 43 return value->GetAsString(out_value); | |
| 44 } | |
| 45 | |
| 46 bool ParseValue(const base::Value* value, | |
| 47 const base::DictionaryValue** out_value) { | |
| 48 return value->GetAsDictionary(out_value); | |
| 49 } | |
| 50 | |
| 51 bool ParseValue(const base::Value* value, StringList* out_value) { | |
| 52 return ParseStringList(value, out_value); | |
| 53 } | |
| 54 | |
| 55 bool ParseValue(const base::Value* value, String16List* out_value) { | |
| 56 return ParseStringList(value, out_value); | |
| 57 } | |
| 58 | |
| 59 base::FundamentalValue MakeValue(bool v) { | |
| 60 return base::FundamentalValue(v); | |
| 61 } | |
| 62 | |
| 63 base::FundamentalValue MakeValue(int v) { | |
| 64 return base::FundamentalValue(v); | |
| 65 } | |
| 66 | |
| 67 base::FundamentalValue MakeValue(double v) { | |
| 68 return base::FundamentalValue(v); | |
| 69 } | |
| 70 | |
| 71 base::StringValue MakeValue(const std::string& v) { | |
| 72 return base::StringValue(v); | |
| 73 } | |
| 74 | |
| 75 base::StringValue MakeValue(const base::string16& v) { | |
| 76 return base::StringValue(v); | |
| 77 } | |
| 78 | |
| 79 void CallbackWrapper0(base::Callback<void()> callback, | |
| 80 const base::ListValue* args) { | |
| 81 DCHECK(args); | |
| 82 DCHECK(args->empty()); | |
| 83 callback.Run(); | |
| 84 } | |
| 85 | |
| 86 } // namespace chromeos | |
| OLD | NEW |