Chromium Code Reviews| Index: chrome/browser/chromeos/cros_settings.cc |
| diff --git a/chrome/browser/chromeos/cros_settings.cc b/chrome/browser/chromeos/cros_settings.cc |
| index 31e42865818a0b89e60898413561136465eb46a7..7162907fe0a1679e1cbad666d322872c1c073f01 100644 |
| --- a/chrome/browser/chromeos/cros_settings.cc |
| +++ b/chrome/browser/chromeos/cros_settings.cc |
| @@ -8,8 +8,9 @@ |
| #include "base/stl_util.h" |
| #include "base/string_util.h" |
| #include "base/values.h" |
| -#include "chrome/browser/chromeos/cros_settings_provider.h" |
| +#include "chrome/browser/chromeos/proxy_cros_settings_provider.h" |
| #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| +#include "chrome/browser/ui/webui/options/chromeos/system_settings_provider.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "content/common/content_notification_types.h" |
| #include "content/common/notification_details.h" |
| @@ -146,68 +147,87 @@ void CrosSettings::RemoveSettingsObserver(const char* path, |
| CrosSettingsProvider* CrosSettings::GetProvider( |
| const std::string& path) const { |
| for (size_t i = 0; i < providers_.size(); ++i) { |
| - if (providers_[i]->HandlesSetting(path)) { |
| + if (providers_[i]->HandlesSetting(path)) |
| return providers_[i]; |
| - } |
| } |
| return NULL; |
| } |
| -bool CrosSettings::Get(const std::string& path, Value** out_value) const { |
| +const base::Value* CrosSettings::GetPref(const std::string& path) const { |
| DCHECK(CalledOnValidThread()); |
| CrosSettingsProvider* provider; |
| provider = GetProvider(path); |
| - if (provider) { |
| - return provider->Get(path, out_value); |
| - } |
| + if (provider) |
| + return provider->Get(path); |
| + NOTREACHED() << path << " preference was not found in the signed settings."; |
| + return NULL; |
| +} |
| + |
| +bool CrosSettings::GetTrusted( |
| + const std::string& path, |
| + const base::Closure& callback) const { |
| + DCHECK(CalledOnValidThread()); |
| + CrosSettingsProvider* provider; |
| + provider = GetProvider(path); |
|
Denis Lagno
2011/10/13 13:45:25
join lines 170+171 or even 170+171+172 together?
pastarmovj
2011/10/26 15:43:19
Done here for 170+171 as well as above for 158+159
|
| + if (provider) |
| + return provider->GetTrusted(path, callback); |
| + NOTREACHED() << "CrosSettings::GetTrusted called for unknown pref : " << path; |
| return false; |
| } |
| bool CrosSettings::GetBoolean(const std::string& path, |
| bool* bool_value) const { |
| DCHECK(CalledOnValidThread()); |
| - Value* value; |
| - if (!Get(path, &value)) |
| - return false; |
| - |
| - return value->GetAsBoolean(bool_value); |
| + const base::Value* value = GetPref(path); |
| + if (value) |
| + return value->GetAsBoolean(bool_value); |
| + return false; |
| } |
| bool CrosSettings::GetInteger(const std::string& path, |
| int* out_value) const { |
| DCHECK(CalledOnValidThread()); |
| - Value* value; |
| - if (!Get(path, &value)) |
| - return false; |
| - |
| - return value->GetAsInteger(out_value); |
| + const base::Value* value = GetPref(path); |
| + if (value) |
| + return value->GetAsInteger(out_value); |
| + return false; |
| } |
| bool CrosSettings::GetDouble(const std::string& path, |
| double* out_value) const { |
| DCHECK(CalledOnValidThread()); |
| - Value* value; |
| - if (!Get(path, &value)) |
| - return false; |
| - |
| - return value->GetAsDouble(out_value); |
| + const base::Value* value = GetPref(path); |
| + if (value) |
| + return value->GetAsDouble(out_value); |
| + return false; |
| } |
| bool CrosSettings::GetString(const std::string& path, |
| std::string* out_value) const { |
| DCHECK(CalledOnValidThread()); |
| - Value* value; |
| - if (!Get(path, &value)) |
| - return false; |
| + const base::Value* value = GetPref(path); |
| + if (value) |
| + return value->GetAsString(out_value); |
| + return false; |
| +} |
| - return value->GetAsString(out_value); |
| +bool CrosSettings::GetList(const std::string& path, |
| + const base::ListValue** out_value) const { |
| + DCHECK(CalledOnValidThread()); |
| + const base::Value* value = GetPref(path); |
| + if (value) |
| + return value->GetAsList(out_value); |
| + return false; |
| } |
| CrosSettings::CrosSettings() { |
| + AddSettingsProvider(new ProxyCrosSettingsProvider()); |
| + AddSettingsProvider(new SystemSettingsProvider()); |
| + AddSettingsProvider(new UserCrosSettingsProvider()); |
| } |
| CrosSettings::~CrosSettings() { |
| - DCHECK(providers_.empty()); |
| + STLDeleteElements(&providers_); |
| STLDeleteValues(&settings_observers_); |
| } |