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

Unified Diff: chrome/browser/extensions/extension_setting_changes.cc

Issue 8177022: Add onChanged events to the extension settings API, both from sync and between (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: changes return string Created 9 years, 2 months 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 side-by-side diff with in-line comments
Download patch
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_;
+}

Powered by Google App Engine
This is Rietveld 408576698