1 // Copyright 2013 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 "extensions/common/value_builder.h"
11 DictionaryBuilder::DictionaryBuilder() : dict_(new base::DictionaryValue
) {}
13 DictionaryBuilder::DictionaryBuilder(const base::DictionaryValue
& init
)
14 : dict_(init
.DeepCopy()) {}
16 DictionaryBuilder::~DictionaryBuilder() {}
18 DictionaryBuilder
& DictionaryBuilder::Set(const std::string
& path
,
20 dict_
->SetWithoutPathExpansion(path
, new base::FundamentalValue(in_value
));
24 DictionaryBuilder
& DictionaryBuilder::Set(const std::string
& path
,
26 dict_
->SetWithoutPathExpansion(path
, new base::FundamentalValue(in_value
));
30 DictionaryBuilder
& DictionaryBuilder::Set(const std::string
& path
,
31 const std::string
& in_value
) {
32 dict_
->SetWithoutPathExpansion(path
, new base::StringValue(in_value
));
36 DictionaryBuilder
& DictionaryBuilder::Set(const std::string
& path
,
37 const base::string16
& in_value
) {
38 dict_
->SetWithoutPathExpansion(path
, new base::StringValue(in_value
));
42 DictionaryBuilder
& DictionaryBuilder::Set(const std::string
& path
,
43 DictionaryBuilder
& in_value
) {
44 dict_
->SetWithoutPathExpansion(path
, in_value
.Build().release());
48 DictionaryBuilder
& DictionaryBuilder::Set(const std::string
& path
,
49 ListBuilder
& in_value
) {
50 dict_
->SetWithoutPathExpansion(path
, in_value
.Build().release());
54 DictionaryBuilder
& DictionaryBuilder::SetBoolean(
55 const std::string
& path
, bool in_value
) {
56 dict_
->SetWithoutPathExpansion(path
, new base::FundamentalValue(in_value
));
62 ListBuilder::ListBuilder() : list_(new base::ListValue
) {}
63 ListBuilder::ListBuilder(const base::ListValue
& init
) : list_(init
.DeepCopy()) {
65 ListBuilder::~ListBuilder() {}
67 ListBuilder
& ListBuilder::Append(int in_value
) {
68 list_
->Append(new base::FundamentalValue(in_value
));
72 ListBuilder
& ListBuilder::Append(double in_value
) {
73 list_
->Append(new base::FundamentalValue(in_value
));
77 ListBuilder
& ListBuilder::Append(const std::string
& in_value
) {
78 list_
->Append(new base::StringValue(in_value
));
82 ListBuilder
& ListBuilder::Append(const base::string16
& in_value
) {
83 list_
->Append(new base::StringValue(in_value
));
87 ListBuilder
& ListBuilder::Append(DictionaryBuilder
& in_value
) {
88 list_
->Append(in_value
.Build().release());
92 ListBuilder
& ListBuilder::Append(ListBuilder
& in_value
) {
93 list_
->Append(in_value
.Build().release());
97 ListBuilder
& ListBuilder::AppendBoolean(bool in_value
) {
98 list_
->Append(new base::FundamentalValue(in_value
));
102 } // namespace extensions