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.
5 #include "components/login/base_screen_handler_utils.h"
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
))
16 out_value
->resize(list
->GetSize());
17 for (size_t i
= 0; i
< list
->GetSize(); ++i
) {
18 if (!list
->GetString(i
, &((*out_value
)[i
])))
26 bool ParseValue(const base::Value
* value
, bool* out_value
) {
27 return value
->GetAsBoolean(out_value
);
30 bool ParseValue(const base::Value
* value
, int* out_value
) {
31 return value
->GetAsInteger(out_value
);
34 bool ParseValue(const base::Value
* value
, double* out_value
) {
35 return value
->GetAsDouble(out_value
);
38 bool ParseValue(const base::Value
* value
, std::string
* out_value
) {
39 return value
->GetAsString(out_value
);
42 bool ParseValue(const base::Value
* value
, base::string16
* out_value
) {
43 return value
->GetAsString(out_value
);
46 bool ParseValue(const base::Value
* value
,
47 const base::DictionaryValue
** out_value
) {
48 return value
->GetAsDictionary(out_value
);
51 bool ParseValue(const base::Value
* value
, StringList
* out_value
) {
52 return ParseStringList(value
, out_value
);
55 bool ParseValue(const base::Value
* value
, String16List
* out_value
) {
56 return ParseStringList(value
, out_value
);
59 base::FundamentalValue
MakeValue(bool v
) {
60 return base::FundamentalValue(v
);
63 base::FundamentalValue
MakeValue(int v
) {
64 return base::FundamentalValue(v
);
67 base::FundamentalValue
MakeValue(double v
) {
68 return base::FundamentalValue(v
);
71 base::StringValue
MakeValue(const std::string
& v
) {
72 return base::StringValue(v
);
75 base::StringValue
MakeValue(const base::string16
& v
) {
76 return base::StringValue(v
);