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

Unified Diff: chrome/browser/extensions/extension_settings_observer.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: . 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_settings_observer.cc
diff --git a/chrome/browser/extensions/extension_settings_observer.cc b/chrome/browser/extensions/extension_settings_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ff8d2238348ec684152f419f93ff8b7aa50ff129
--- /dev/null
+++ b/chrome/browser/extensions/extension_settings_observer.cc
@@ -0,0 +1,34 @@
+// 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_settings_observer.h"
+
+#include "base/json/json_writer.h"
+
+ExtensionSettingsObserver::ChangeList::ChangeList() {}
+
+ExtensionSettingsObserver::ChangeList::~ChangeList() {}
+
+void ExtensionSettingsObserver::ChangeList::AppendChange(
+ const std::string& key, Value* old_value, Value* new_value) {
+ DictionaryValue* change = new DictionaryValue();
+ change->Set("key", Value::CreateStringValue(key));
+ if (old_value) {
+ change->Set("oldValue", old_value);
+ }
+ if (new_value) {
+ change->Set("newValue", new_value);
+ }
+ changes_.Append(change);
+}
+
+std::string ExtensionSettingsObserver::ChangeList::GetEventJson() const {
+ std::string event_json;
+ base::JSONWriter::Write(&changes_, false, &event_json);
+ // Event JSON is a list of arguments to the onChanged callback, a singleton
+ // list of a list of changes.
+ return std::string("[") + event_json + "]";
+}
+
+ExtensionSettingsObserver::~ExtensionSettingsObserver() {}

Powered by Google App Engine
This is Rietveld 408576698