Introduce AndroidMetricsProvider class.
[chromium-blink-merge.git] / extensions / common / value_builder.cc
blob0b257454327360e231bc312cd2ec4aa276a72640
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"
7 namespace extensions {
9 // DictionaryBuilder
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,
19 int in_value) {
20 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(in_value));
21 return *this;
24 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
25 double in_value) {
26 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(in_value));
27 return *this;
30 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
31 const std::string& in_value) {
32 dict_->SetWithoutPathExpansion(path, new base::StringValue(in_value));
33 return *this;
36 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
37 const base::string16& in_value) {
38 dict_->SetWithoutPathExpansion(path, new base::StringValue(in_value));
39 return *this;
42 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
43 DictionaryBuilder& in_value) {
44 dict_->SetWithoutPathExpansion(path, in_value.Build().release());
45 return *this;
48 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
49 ListBuilder& in_value) {
50 dict_->SetWithoutPathExpansion(path, in_value.Build().release());
51 return *this;
54 DictionaryBuilder& DictionaryBuilder::SetBoolean(
55 const std::string& path, bool in_value) {
56 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(in_value));
57 return *this;
60 // ListBuilder
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));
69 return *this;
72 ListBuilder& ListBuilder::Append(double in_value) {
73 list_->Append(new base::FundamentalValue(in_value));
74 return *this;
77 ListBuilder& ListBuilder::Append(const std::string& in_value) {
78 list_->Append(new base::StringValue(in_value));
79 return *this;
82 ListBuilder& ListBuilder::Append(const base::string16& in_value) {
83 list_->Append(new base::StringValue(in_value));
84 return *this;
87 ListBuilder& ListBuilder::Append(DictionaryBuilder& in_value) {
88 list_->Append(in_value.Build().release());
89 return *this;
92 ListBuilder& ListBuilder::Append(ListBuilder& in_value) {
93 list_->Append(in_value.Build().release());
94 return *this;
97 ListBuilder& ListBuilder::AppendBoolean(bool in_value) {
98 list_->Append(new base::FundamentalValue(in_value));
99 return *this;
102 } // namespace extensions