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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_settings_observer.h"
6
7 #include "base/json/json_writer.h"
8
9 ExtensionSettingsObserver::ChangeList::ChangeList() {}
10
11 ExtensionSettingsObserver::ChangeList::~ChangeList() {}
12
13 void ExtensionSettingsObserver::ChangeList::AppendChange(
14 const std::string& key, Value* old_value, Value* new_value) {
15 DictionaryValue* change = new DictionaryValue();
16 change->Set("key", Value::CreateStringValue(key));
17 if (old_value) {
18 change->Set("oldValue", old_value);
19 }
20 if (new_value) {
21 change->Set("newValue", new_value);
22 }
23 changes_.Append(change);
24 }
25
26 std::string ExtensionSettingsObserver::ChangeList::GetEventJson() const {
27 std::string event_json;
28 base::JSONWriter::Write(&changes_, false, &event_json);
29 // Event JSON is a list of arguments to the onChanged callback, a singleton
30 // list of a list of changes.
31 return std::string("[") + event_json + "]";
32 }
33
34 ExtensionSettingsObserver::~ExtensionSettingsObserver() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698