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

Unified Diff: chrome/browser/extensions/extension_settings_storage.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: sync 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_storage.cc
diff --git a/chrome/browser/extensions/extension_settings_storage.cc b/chrome/browser/extensions/extension_settings_storage.cc
index 882efe83e72268923482ae77ca8029b589eb93fc..3259748e95d012adefb3c66efd9e9cf65ff8ccc6 100644
--- a/chrome/browser/extensions/extension_settings_storage.cc
+++ b/chrome/browser/extensions/extension_settings_storage.cc
@@ -8,27 +8,57 @@
// Implementation of ExtensionSettingsStorage::Result
ExtensionSettingsStorage::Result::Result(
- DictionaryValue* settings, std::set<std::string>* changed_keys)
- : inner_(new Inner(settings, changed_keys, std::string())) {}
+ DictionaryValue* settings,
+ DictionaryValue* old_settings,
+ std::set<std::string>* changed_keys)
+ : inner_(new Inner(settings, old_settings, changed_keys, std::string())) {}
ExtensionSettingsStorage::Result::Result(const std::string& error)
- : inner_(new Inner(NULL, new std::set<std::string>(), error)) {
+ : inner_(new Inner(NULL, NULL, new std::set<std::string>(), error)) {
DCHECK(!error.empty());
}
ExtensionSettingsStorage::Result::~Result() {}
-DictionaryValue* ExtensionSettingsStorage::Result::GetSettings() const {
+const DictionaryValue* ExtensionSettingsStorage::Result::GetSettings() const {
DCHECK(!HasError());
return inner_->settings_.get();
}
-std::set<std::string>*
+const std::set<std::string>*
ExtensionSettingsStorage::Result::GetChangedKeys() const {
DCHECK(!HasError());
return inner_->changed_keys_.get();
}
+const Value* ExtensionSettingsStorage::Result::GetOldValue(
+ const std::string& key) const {
+ DCHECK(!HasError());
+ if (!inner_->changed_keys_.get()) {
+ return NULL;
+ }
+ Value* old_value = NULL;
+ if (inner_->changed_keys_->count(key)) {
+ inner_->old_settings_->GetWithoutPathExpansion(key, &old_value);
+ } else if (inner_->settings_.get()) {
+ inner_->settings_->GetWithoutPathExpansion(key, &old_value);
+ }
+ return old_value;
+}
+
+const Value* ExtensionSettingsStorage::Result::GetNewValue(
+ const std::string& key) const {
+ DCHECK(!HasError());
+ if (!inner_->changed_keys_.get()) {
+ return NULL;
+ }
+ Value* new_value = NULL;
+ if (inner_->settings_.get()) {
+ inner_->settings_->GetWithoutPathExpansion(key, &new_value);
+ }
+ return new_value;
+}
+
bool ExtensionSettingsStorage::Result::HasError() const {
return !inner_->error_.empty();
}
@@ -40,8 +70,12 @@ const std::string& ExtensionSettingsStorage::Result::GetError() const {
ExtensionSettingsStorage::Result::Inner::Inner(
DictionaryValue* settings,
+ DictionaryValue* old_settings,
std::set<std::string>* changed_keys,
const std::string& error)
- : settings_(settings), changed_keys_(changed_keys), error_(error) {}
+ : settings_(settings),
+ old_settings_(old_settings),
+ changed_keys_(changed_keys),
+ error_(error) {}
ExtensionSettingsStorage::Result::Inner::~Inner() {}
« no previous file with comments | « chrome/browser/extensions/extension_settings_storage.h ('k') | chrome/browser/extensions/extension_settings_storage_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698