| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "extensions/common/value_builder.h" | 5 #include "extensions/common/value_builder.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace extensions { |
| 10 | 10 |
| 11 // DictionaryBuilder | 11 // DictionaryBuilder |
| 12 | 12 |
| 13 DictionaryBuilder::DictionaryBuilder() : dict_(new base::DictionaryValue) {} | 13 DictionaryBuilder::DictionaryBuilder() : dict_(new base::DictionaryValue) {} |
| 14 | 14 |
| 15 DictionaryBuilder::DictionaryBuilder(const base::DictionaryValue& init) | 15 DictionaryBuilder::DictionaryBuilder(const base::DictionaryValue& init) |
| 16 : dict_(init.DeepCopy()) {} | 16 : dict_(init.DeepCopy()) {} |
| 17 | 17 |
| 18 DictionaryBuilder::~DictionaryBuilder() {} | 18 DictionaryBuilder::~DictionaryBuilder() {} |
| 19 | 19 |
| 20 std::string DictionaryBuilder::ToJSON() const { | 20 std::string DictionaryBuilder::ToJSON() const { |
| 21 std::string json; | 21 std::string json; |
| 22 base::JSONWriter::WriteWithOptions( | 22 base::JSONWriter::WriteWithOptions( |
| 23 dict_.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); | 23 *dict_, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); |
| 24 return json; | 24 return json; |
| 25 } | 25 } |
| 26 | 26 |
| 27 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, | 27 DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, |
| 28 int in_value) { | 28 int in_value) { |
| 29 dict_->SetWithoutPathExpansion(path, new base::FundamentalValue(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, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 list_->Append(in_value.Build().release()); | 102 list_->Append(in_value.Build().release()); |
| 103 return *this; | 103 return *this; |
| 104 } | 104 } |
| 105 | 105 |
| 106 ListBuilder& ListBuilder::AppendBoolean(bool in_value) { | 106 ListBuilder& ListBuilder::AppendBoolean(bool in_value) { |
| 107 list_->Append(new base::FundamentalValue(in_value)); | 107 list_->Append(new base::FundamentalValue(in_value)); |
| 108 return *this; | 108 return *this; |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace extensions | 111 } // namespace extensions |
| OLD | NEW |