diff options
author | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-22 03:32:07 +0000 |
---|---|---|
committer | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-22 03:32:07 +0000 |
commit | be80eae925e1bb08b0584e55cd47accceba09390 (patch) | |
tree | 2209732664ad91da73883747415c1bddb60ab25c /chrome/browser/extensions/extension_settings_storage.cc | |
parent | 15245b8b5298a41363183deba5f5e156c6d0ac74 (diff) | |
download | chromium_src-be80eae925e1bb08b0584e55cd47accceba09390.zip chromium_src-be80eae925e1bb08b0584e55cd47accceba09390.tar.gz chromium_src-be80eae925e1bb08b0584e55cd47accceba09390.tar.bz2 |
Re-commit 106660 with the crashing test disabled. Reverted in 106671.
Add onChanged events to the extension settings API, both from sync and between
split mode background pages.
BUG=97545
TEST=ExtensionSettingsStorageUnittest, ExtensionSettingsSyncUnittest, ExtensionSettingsApitest
Review URL: http://codereview.chromium.org/8177022
TBR=rsleevi@chromium.org
Review URL: http://codereview.chromium.org/8361027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_settings_storage.cc')
-rw-r--r-- | chrome/browser/extensions/extension_settings_storage.cc | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/chrome/browser/extensions/extension_settings_storage.cc b/chrome/browser/extensions/extension_settings_storage.cc index 882efe8..3259748 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() {} |