Chromium Code Reviews| Index: chrome/browser/extensions/extension_setting_changes.cc |
| diff --git a/chrome/browser/extensions/extension_setting_changes.cc b/chrome/browser/extensions/extension_setting_changes.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..091b448e3546762212dc00786044a98ee4b61c6d |
| --- /dev/null |
| +++ b/chrome/browser/extensions/extension_setting_changes.cc |
| @@ -0,0 +1,36 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/extension_setting_changes.h" |
| + |
| +#include "base/json/json_writer.h" |
| + |
| +void ExtensionSettingChanges::Builder::AppendChange( |
| + const std::string& key, Value* old_value, Value* new_value) { |
| + DictionaryValue* change = new DictionaryValue(); |
| + changes_.Append(change); |
| + |
| + change->SetString("key", key); |
| + if (old_value) { |
| + change->Set("oldValue", old_value); |
| + } |
| + if (new_value) { |
| + change->Set("newValue", new_value); |
| + } |
| +} |
| + |
| +ExtensionSettingChanges ExtensionSettingChanges::Builder::Build() { |
| + 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.
|
| + base::JSONWriter::Write(&changes_, false, &changes_json); |
| + return ExtensionSettingChanges(changes_json); |
| +} |
| + |
| +ExtensionSettingChanges::ExtensionSettingChanges(const std::string& changes) |
| + : inner_(new Inner(changes)) {} |
| + |
| +ExtensionSettingChanges::~ExtensionSettingChanges() {} |
| + |
| +std::string ExtensionSettingChanges::ToJson() const { |
| + return inner_->changes_; |
| +} |