| Index: chrome/browser/chromeos/cros_settings.cc
|
| diff --git a/chrome/browser/chromeos/cros_settings.cc b/chrome/browser/chromeos/cros_settings.cc
|
| index bde3c314b96288302f55f26c8a0c51515974d155..de87fbe708d9a5b6e40114e4c1dfae49fe225287 100644
|
| --- a/chrome/browser/chromeos/cros_settings.cc
|
| +++ b/chrome/browser/chromeos/cros_settings.cc
|
| @@ -8,7 +8,7 @@
|
| #include "base/stl_util.h"
|
| #include "base/string_util.h"
|
| #include "base/values.h"
|
| -#include "chrome/browser/chromeos/user_cros_settings_provider.h"
|
| +#include "chrome/browser/chromeos/device_settings_provider.h"
|
| #include "chrome/browser/ui/webui/options/chromeos/system_settings_provider.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "content/public/browser/notification_details.h"
|
| @@ -83,9 +83,9 @@ void CrosSettings::SetString(const std::string& path,
|
| void CrosSettings::AppendToList(const std::string& path,
|
| const base::Value* value) {
|
| DCHECK(CalledOnValidThread());
|
| - const base::Value* old_value = GetPref(path);
|
| + base::Value* old_value = GetPref(path);
|
| scoped_ptr<base::Value> new_value(
|
| - old_value ? old_value->DeepCopy() : new base::ListValue());
|
| + old_value ? old_value : new base::ListValue());
|
| static_cast<base::ListValue*>(new_value.get())->Append(value->DeepCopy());
|
| Set(path, *new_value);
|
| }
|
| @@ -93,9 +93,9 @@ void CrosSettings::AppendToList(const std::string& path,
|
| void CrosSettings::RemoveFromList(const std::string& path,
|
| const base::Value* value) {
|
| DCHECK(CalledOnValidThread());
|
| - const base::Value* old_value = GetPref(path);
|
| + base::Value* old_value = GetPref(path);
|
| scoped_ptr<base::Value> new_value(
|
| - old_value ? old_value->DeepCopy() : new base::ListValue());
|
| + old_value ? old_value : new base::ListValue());
|
| static_cast<base::ListValue*>(new_value.get())->Remove(*value, NULL);
|
| Set(path, *new_value);
|
| }
|
| @@ -104,9 +104,9 @@ bool CrosSettings::FindEmailInList(const std::string& path,
|
| const std::string& email) const {
|
| DCHECK(CalledOnValidThread());
|
| base::StringValue email_value(email);
|
| - const base::ListValue* value =
|
| - static_cast<const base::ListValue*>(GetPref(path));
|
| - if (value) {
|
| + scoped_ptr<base::ListValue> value(
|
| + static_cast<base::ListValue*>(GetPref(path)));
|
| + if (value.get()) {
|
| if (value->Find(email_value) != value->end())
|
| return true;
|
| std::string::size_type at_pos = email.find('@');
|
| @@ -195,7 +195,13 @@ CrosSettingsProvider* CrosSettings::GetProvider(
|
| return NULL;
|
| }
|
|
|
| -const base::Value* CrosSettings::GetPref(const std::string& path) const {
|
| +void CrosSettings::ReloadProviders() const {
|
| + for (size_t i = 0; i < providers_.size(); ++i) {
|
| + providers_[i]->Reload();
|
| + }
|
| +}
|
| +
|
| +base::Value* CrosSettings::GetPref(const std::string& path) const {
|
| DCHECK(CalledOnValidThread());
|
| CrosSettingsProvider* provider = GetProvider(path);
|
| if (provider)
|
| @@ -217,8 +223,8 @@ bool CrosSettings::GetTrusted(const std::string& path,
|
| bool CrosSettings::GetBoolean(const std::string& path,
|
| bool* bool_value) const {
|
| DCHECK(CalledOnValidThread());
|
| - const base::Value* value = GetPref(path);
|
| - if (value)
|
| + scoped_ptr<base::Value> value(GetPref(path));
|
| + if (value.get())
|
| return value->GetAsBoolean(bool_value);
|
| return false;
|
| }
|
| @@ -226,8 +232,8 @@ bool CrosSettings::GetBoolean(const std::string& path,
|
| bool CrosSettings::GetInteger(const std::string& path,
|
| int* out_value) const {
|
| DCHECK(CalledOnValidThread());
|
| - const base::Value* value = GetPref(path);
|
| - if (value)
|
| + scoped_ptr<base::Value> value(GetPref(path));
|
| + if (value.get())
|
| return value->GetAsInteger(out_value);
|
| return false;
|
| }
|
| @@ -235,8 +241,8 @@ bool CrosSettings::GetInteger(const std::string& path,
|
| bool CrosSettings::GetDouble(const std::string& path,
|
| double* out_value) const {
|
| DCHECK(CalledOnValidThread());
|
| - const base::Value* value = GetPref(path);
|
| - if (value)
|
| + scoped_ptr<base::Value> value(GetPref(path));
|
| + if (value.get())
|
| return value->GetAsDouble(out_value);
|
| return false;
|
| }
|
| @@ -244,8 +250,8 @@ bool CrosSettings::GetDouble(const std::string& path,
|
| bool CrosSettings::GetString(const std::string& path,
|
| std::string* out_value) const {
|
| DCHECK(CalledOnValidThread());
|
| - const base::Value* value = GetPref(path);
|
| - if (value)
|
| + scoped_ptr<base::Value> value(GetPref(path));
|
| + if (value.get())
|
| return value->GetAsString(out_value);
|
| return false;
|
| }
|
| @@ -253,15 +259,15 @@ bool CrosSettings::GetString(const std::string& path,
|
| bool CrosSettings::GetList(const std::string& path,
|
| const base::ListValue** out_value) const {
|
| DCHECK(CalledOnValidThread());
|
| - const base::Value* value = GetPref(path);
|
| - if (value)
|
| + scoped_ptr<base::Value> value(GetPref(path));
|
| + if (value.get())
|
| return value->GetAsList(out_value);
|
| return false;
|
| }
|
|
|
| CrosSettings::CrosSettings() {
|
| AddSettingsProvider(new SystemSettingsProvider());
|
| - AddSettingsProvider(new UserCrosSettingsProvider());
|
| + AddSettingsProvider(new DeviceSettingsProvider());
|
| }
|
|
|
| CrosSettings::~CrosSettings() {
|
|
|