diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 16:36:16 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 16:36:16 +0000 |
commit | 5bc6e985df15af4f5fce0ae109a847db400960d3 (patch) | |
tree | 6a76f85d596f27144afb410832792531f3f9342a | |
parent | e4ce5f12d132e6a56c73cd42a5bb4e6aaea9a4e1 (diff) | |
download | chromium_src-5bc6e985df15af4f5fce0ae109a847db400960d3.zip chromium_src-5bc6e985df15af4f5fce0ae109a847db400960d3.tar.gz chromium_src-5bc6e985df15af4f5fce0ae109a847db400960d3.tar.bz2 |
Change CorsSettings::Get's assumption of who owns the returned value.
This is because most of the settings providers and
CoreChromeOSOptionsHandler::NotifySettingsChanged assumes the caller
would own the returned value.
BUG=none.
TEST=none.
Review URL: http://codereview.chromium.org/3382008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59665 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/cros_settings.h | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros_settings_provider_user.cc | 8 | ||||
-rw-r--r-- | chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/cros_settings.h b/chrome/browser/chromeos/cros_settings.h index e53caee..596b093 100644 --- a/chrome/browser/chromeos/cros_settings.h +++ b/chrome/browser/chromeos/cros_settings.h @@ -39,7 +39,7 @@ class CrosSettings : public NonThreadSafe { void FireObservers(const char* path); // Gets settings value of given |path| to |out_value|. - // Note that |out_value| is still owned by this class. + // Note that the caller owns |out_value| returned. bool Get(const std::string& path, Value** out_value) const; // Convenience forms of Set(). These methods will replace any existing diff --git a/chrome/browser/chromeos/cros_settings_provider_user.cc b/chrome/browser/chromeos/cros_settings_provider_user.cc index a22915c..1a53c4d 100644 --- a/chrome/browser/chromeos/cros_settings_provider_user.cc +++ b/chrome/browser/chromeos/cros_settings_provider_user.cc @@ -55,7 +55,13 @@ void UserCrosSettingsProvider::Set(const std::string& path, Value* in_value) { bool UserCrosSettingsProvider::Get(const std::string& path, Value** out_value) const { - return dict_->Get(path, out_value); + Value* value = NULL; + if (dict_->Get(path, &value) && value) { + *out_value = value->DeepCopy(); + return true; + } + + return false; } bool UserCrosSettingsProvider::HandlesSetting(const std::string& path) { diff --git a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc index 3d564ee..d76e33d 100644 --- a/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc +++ b/chrome/browser/chromeos/dom_ui/core_chromeos_options_handler.cc @@ -22,7 +22,7 @@ Value* CoreChromeOSOptionsHandler::FetchPref(const std::string& pref_name) { Value* pref_value = NULL; CrosSettings::Get()->Get(pref_name, &pref_value); - return pref_value ? pref_value->DeepCopy() : Value::CreateNullValue(); + return pref_value ? pref_value : Value::CreateNullValue(); } void CoreChromeOSOptionsHandler::ObservePref(const std::string& pref_name) { |