OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/value_builder.h" | 5 #include "chrome/common/extensions/value_builder.h" |
6 | 6 |
7 using base::DictionaryValue; | 7 using base::DictionaryValue; |
8 using base::ListValue; | 8 using base::ListValue; |
9 | 9 |
10 namespace extensions { | 10 namespace extensions { |
11 | 11 |
12 // DictionaryBuilder | 12 // DictionaryBuilder |
13 | 13 |
14 DictionaryBuilder::DictionaryBuilder() : dict_(new DictionaryValue) {} | 14 DictionaryBuilder::DictionaryBuilder() : dict_(new DictionaryValue) {} |
15 | 15 |
16 DictionaryBuilder::DictionaryBuilder(const DictionaryValue& init) | 16 DictionaryBuilder::DictionaryBuilder(const DictionaryValue& init) |
17 : dict_(init.DeepCopy()) {} | 17 : dict_(init.DeepCopy()) {} |
18 | 18 |
19 DictionaryBuilder::~DictionaryBuilder() {} | 19 DictionaryBuilder::~DictionaryBuilder() {} |
20 | 20 |
21 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, | 21 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, |
22 int in_value) { | 22 int in_value) { |
23 dict_->SetWithoutPathExpansion(path, Value::CreateIntegerValue(in_value)); | 23 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(in_value)); |
24 return *this; | 24 return *this; |
25 } | 25 } |
26 | 26 |
27 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, | 27 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, |
28 double in_value) { | 28 double in_value) { |
29 dict_->SetWithoutPathExpansion(path, Value::CreateDoubleValue(in_value)); | 29 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(in_value)); |
30 return *this; | 30 return *this; |
31 } | 31 } |
32 | 32 |
33 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, | 33 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, |
34 const std::string& in_value) { | 34 const std::string& in_value) { |
35 dict_->SetWithoutPathExpansion(path, Value::CreateStringValue(in_value)); | 35 dict_->SetWithoutPathExpansion(path, new base::StringValue(in_value)); |
36 return *this; | 36 return *this; |
37 } | 37 } |
38 | 38 |
39 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, | 39 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, |
40 const string16& in_value) { | 40 const string16& in_value) { |
41 dict_->SetWithoutPathExpansion(path, Value::CreateStringValue(in_value)); | 41 dict_->SetWithoutPathExpansion(path, new base::StringValue(in_value)); |
42 return *this; | 42 return *this; |
43 } | 43 } |
44 | 44 |
45 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, | 45 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, |
46 DictionaryBuilder& in_value) { | 46 DictionaryBuilder& in_value) { |
47 dict_->SetWithoutPathExpansion(path, in_value.Build().release()); | 47 dict_->SetWithoutPathExpansion(path, in_value.Build().release()); |
48 return *this; | 48 return *this; |
49 } | 49 } |
50 | 50 |
51 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, | 51 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, |
52 ListBuilder& in_value) { | 52 ListBuilder& in_value) { |
53 dict_->SetWithoutPathExpansion(path, in_value.Build().release()); | 53 dict_->SetWithoutPathExpansion(path, in_value.Build().release()); |
54 return *this; | 54 return *this; |
55 } | 55 } |
56 | 56 |
57 DictionaryBuilder& DictionaryBuilder::SetBoolean( | 57 DictionaryBuilder& DictionaryBuilder::SetBoolean( |
58 const std::string& path, bool in_value) { | 58 const std::string& path, bool in_value) { |
59 dict_->SetWithoutPathExpansion(path, Value::CreateBooleanValue(in_value)); | 59 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(in_value)); |
60 return *this; | 60 return *this; |
61 } | 61 } |
62 | 62 |
63 // ListBuilder | 63 // ListBuilder |
64 | 64 |
65 ListBuilder::ListBuilder() : list_(new ListValue) {} | 65 ListBuilder::ListBuilder() : list_(new ListValue) {} |
66 ListBuilder::ListBuilder(const ListValue& init) : list_(init.DeepCopy()) {} | 66 ListBuilder::ListBuilder(const ListValue& init) : list_(init.DeepCopy()) {} |
67 ListBuilder::~ListBuilder() {} | 67 ListBuilder::~ListBuilder() {} |
68 | 68 |
69 ListBuilder& ListBuilder::Append(int in_value) { | 69 ListBuilder& ListBuilder::Append(int in_value) { |
70 list_->Append(Value::CreateIntegerValue(in_value)); | 70 list_->Append(new base::FundamentalValue(in_value)); |
71 return *this; | 71 return *this; |
72 } | 72 } |
73 | 73 |
74 ListBuilder& ListBuilder::Append(double in_value) { | 74 ListBuilder& ListBuilder::Append(double in_value) { |
75 list_->Append(Value::CreateDoubleValue(in_value)); | 75 list_->Append(new base::FundamentalValue(in_value)); |
76 return *this; | 76 return *this; |
77 } | 77 } |
78 | 78 |
79 ListBuilder& ListBuilder::Append(const std::string& in_value) { | 79 ListBuilder& ListBuilder::Append(const std::string& in_value) { |
80 list_->Append(Value::CreateStringValue(in_value)); | 80 list_->Append(new base::StringValue(in_value)); |
81 return *this; | 81 return *this; |
82 } | 82 } |
83 | 83 |
84 ListBuilder& ListBuilder::Append(const string16& in_value) { | 84 ListBuilder& ListBuilder::Append(const string16& in_value) { |
85 list_->Append(Value::CreateStringValue(in_value)); | 85 list_->Append(new base::StringValue(in_value)); |
86 return *this; | 86 return *this; |
87 } | 87 } |
88 | 88 |
89 ListBuilder& ListBuilder::Append(DictionaryBuilder& in_value) { | 89 ListBuilder& ListBuilder::Append(DictionaryBuilder& in_value) { |
90 list_->Append(in_value.Build().release()); | 90 list_->Append(in_value.Build().release()); |
91 return *this; | 91 return *this; |
92 } | 92 } |
93 | 93 |
94 ListBuilder& ListBuilder::Append(ListBuilder& in_value) { | 94 ListBuilder& ListBuilder::Append(ListBuilder& in_value) { |
95 list_->Append(in_value.Build().release()); | 95 list_->Append(in_value.Build().release()); |
96 return *this; | 96 return *this; |
97 } | 97 } |
98 | 98 |
99 ListBuilder& ListBuilder::AppendBoolean(bool in_value) { | 99 ListBuilder& ListBuilder::AppendBoolean(bool in_value) { |
100 list_->Append(Value::CreateBooleanValue(in_value)); | 100 list_->Append(new base::FundamentalValue(in_value)); |
101 return *this; | 101 return *this; |
102 } | 102 } |
103 | 103 |
104 } // namespace extensions | 104 } // namespace extensions |
OLD | NEW |