Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/common/extensions/value_builder.cc

Issue 48643003: Moved extension and value builder code to extensions component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/common/extensions/value_builder.h"
6
7 namespace extensions {
8
9 // DictionaryBuilder
10
11 DictionaryBuilder::DictionaryBuilder() : dict_(new base::DictionaryValue) {}
12
13 DictionaryBuilder::DictionaryBuilder(const base::DictionaryValue& init)
14 : dict_(init.DeepCopy()) {}
15
16 DictionaryBuilder::~DictionaryBuilder() {}
17
18 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
19 int in_value) {
20 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(in_value));
21 return *this;
22 }
23
24 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
25 double in_value) {
26 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(in_value));
27 return *this;
28 }
29
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;
34 }
35
36 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
37 const string16& in_value) {
38 dict_->SetWithoutPathExpansion(path, new base::StringValue(in_value));
39 return *this;
40 }
41
42 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
43 DictionaryBuilder& in_value) {
44 dict_->SetWithoutPathExpansion(path, in_value.Build().release());
45 return *this;
46 }
47
48 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
49 ListBuilder& in_value) {
50 dict_->SetWithoutPathExpansion(path, in_value.Build().release());
51 return *this;
52 }
53
54 DictionaryBuilder& DictionaryBuilder::SetBoolean(
55 const std::string& path, bool in_value) {
56 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(in_value));
57 return *this;
58 }
59
60 // ListBuilder
61
62 ListBuilder::ListBuilder() : list_(new base::ListValue) {}
63 ListBuilder::ListBuilder(const base::ListValue& init) : list_(init.DeepCopy()) {
64 }
65 ListBuilder::~ListBuilder() {}
66
67 ListBuilder& ListBuilder::Append(int in_value) {
68 list_->Append(new base::FundamentalValue(in_value));
69 return *this;
70 }
71
72 ListBuilder& ListBuilder::Append(double in_value) {
73 list_->Append(new base::FundamentalValue(in_value));
74 return *this;
75 }
76
77 ListBuilder& ListBuilder::Append(const std::string& in_value) {
78 list_->Append(new base::StringValue(in_value));
79 return *this;
80 }
81
82 ListBuilder& ListBuilder::Append(const string16& in_value) {
83 list_->Append(new base::StringValue(in_value));
84 return *this;
85 }
86
87 ListBuilder& ListBuilder::Append(DictionaryBuilder& in_value) {
88 list_->Append(in_value.Build().release());
89 return *this;
90 }
91
92 ListBuilder& ListBuilder::Append(ListBuilder& in_value) {
93 list_->Append(in_value.Build().release());
94 return *this;
95 }
96
97 ListBuilder& ListBuilder::AppendBoolean(bool in_value) {
98 list_->Append(new base::FundamentalValue(in_value));
99 return *this;
100 }
101
102 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/value_builder.h ('k') | chrome/renderer/chrome_content_renderer_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698