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_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() {} |
OLD | NEW |