OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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/browser/extensions/extension_setting_changes.h" |
| 6 |
| 7 #include "base/json/json_writer.h" |
| 8 |
| 9 void ExtensionSettingChanges::Builder::AppendChange( |
| 10 const std::string& key, Value* old_value, Value* new_value) { |
| 11 DictionaryValue* change = new DictionaryValue(); |
| 12 changes_.Append(change); |
| 13 |
| 14 change->SetString("key", key); |
| 15 if (old_value) { |
| 16 change->Set("oldValue", old_value); |
| 17 } |
| 18 if (new_value) { |
| 19 change->Set("newValue", new_value); |
| 20 } |
| 21 } |
| 22 |
| 23 ExtensionSettingChanges ExtensionSettingChanges::Builder::Build() { |
| 24 return ExtensionSettingChanges(&changes_); |
| 25 } |
| 26 |
| 27 ExtensionSettingChanges::ExtensionSettingChanges(ListValue* changes) |
| 28 : inner_(new Inner()) { |
| 29 inner_->changes_.Swap(changes); |
| 30 } |
| 31 |
| 32 ExtensionSettingChanges::~ExtensionSettingChanges() {} |
| 33 |
| 34 std::string ExtensionSettingChanges::ToJson() const { |
| 35 std::string changes_json; |
| 36 base::JSONWriter::Write(&inner_->changes_, false, &changes_json); |
| 37 return changes_json; |
| 38 } |
OLD | NEW |