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 std::string changes_json; | |
akalin
2011/10/17 17:37:38
should probably clear changes_ (i.e., pass a point
not at google - send to devlin
2011/10/17 23:05:44
Done.
| |
25 base::JSONWriter::Write(&changes_, false, &changes_json); | |
26 return ExtensionSettingChanges(changes_json); | |
27 } | |
28 | |
29 ExtensionSettingChanges::ExtensionSettingChanges(const std::string& changes) | |
30 : inner_(new Inner(changes)) {} | |
31 | |
32 ExtensionSettingChanges::~ExtensionSettingChanges() {} | |
33 | |
34 std::string ExtensionSettingChanges::ToJson() const { | |
35 return inner_->changes_; | |
36 } | |
OLD | NEW |