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

Unified Diff: chrome/browser/chromeos/settings/cros_settings.cc

Issue 10832035: Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 4 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/chromeos/settings/cros_settings.cc
diff --git a/chrome/browser/chromeos/settings/cros_settings.cc b/chrome/browser/chromeos/settings/cros_settings.cc
index a0622b4a228030c7372f4791f7c4d4b4e6f8a00d..f0592f34f29d683388ed031ab0554baa8477da3f 100644
--- a/chrome/browser/chromeos/settings/cros_settings.cc
+++ b/chrome/browser/chromeos/settings/cros_settings.cc
@@ -11,7 +11,7 @@
#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/chromeos/settings/device_settings_provider.h"
-#include "chrome/browser/chromeos/settings/signed_settings_helper.h"
+#include "chrome/browser/chromeos/settings/device_settings_service.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
#include "chrome/browser/chromeos/settings/system_settings_provider.h"
#include "chrome/common/chrome_notification_types.h"
@@ -35,22 +35,6 @@ bool CrosSettings::IsCrosSettings(const std::string& path) {
return StartsWithASCII(path, kCrosSettingsPrefix, true);
}
-void CrosSettings::FireObservers(const std::string& path) {
- DCHECK(CalledOnValidThread());
- SettingsObserverMap::iterator observer_iterator =
- settings_observers_.find(path);
- if (observer_iterator == settings_observers_.end())
- return;
-
- NotificationObserverList::Iterator it(*(observer_iterator->second));
- content::NotificationObserver* observer;
- while ((observer = it.GetNext()) != NULL) {
- observer->Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED,
- content::Source<CrosSettings>(this),
- content::Details<const std::string>(&path));
- }
-}
-
void CrosSettings::Set(const std::string& path, const base::Value& in_value) {
DCHECK(CalledOnValidThread());
CrosSettingsProvider* provider;
@@ -59,6 +43,27 @@ void CrosSettings::Set(const std::string& path, const base::Value& in_value) {
provider->Set(path, in_value);
}
+const base::Value* CrosSettings::GetPref(const std::string& path) const {
+ DCHECK(CalledOnValidThread());
+ CrosSettingsProvider* provider = GetProvider(path);
+ if (provider)
+ return provider->Get(path);
+ NOTREACHED() << path << " preference was not found in the signed settings.";
+ return NULL;
+}
+
+CrosSettingsProvider::TrustedStatus CrosSettings::PrepareTrustedValues(
+ const base::Closure& callback) const {
+ DCHECK(CalledOnValidThread());
+ for (size_t i = 0; i < providers_.size(); ++i) {
+ CrosSettingsProvider::TrustedStatus status =
+ providers_[i]->PrepareTrustedValues(callback);
+ if (status != CrosSettingsProvider::TRUSTED)
+ return status;
+ }
+ return CrosSettingsProvider::TRUSTED;
+}
+
void CrosSettings::SetBoolean(const std::string& path, bool in_value) {
DCHECK(CalledOnValidThread());
base::FundamentalValue value(in_value);
@@ -104,6 +109,51 @@ void CrosSettings::RemoveFromList(const std::string& path,
Set(path, *new_value);
}
+bool CrosSettings::GetBoolean(const std::string& path,
+ bool* bool_value) const {
+ DCHECK(CalledOnValidThread());
+ 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());
+ 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());
+ 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());
+ const base::Value* value = GetPref(path);
+ if (value)
+ return value->GetAsString(out_value);
+ return false;
+}
+
+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;
+}
+
bool CrosSettings::FindEmailInList(const std::string& path,
const std::string& email) const {
DCHECK(CalledOnValidThread());
@@ -220,77 +270,6 @@ CrosSettingsProvider* CrosSettings::GetProvider(
return NULL;
}
-void CrosSettings::ReloadProviders() {
- for (size_t i = 0; i < providers_.size(); ++i)
- providers_[i]->Reload();
-}
-
-const base::Value* CrosSettings::GetPref(const std::string& path) const {
- DCHECK(CalledOnValidThread());
- CrosSettingsProvider* provider = GetProvider(path);
- if (provider)
- return provider->Get(path);
- NOTREACHED() << path << " preference was not found in the signed settings.";
- return NULL;
-}
-
-CrosSettingsProvider::TrustedStatus CrosSettings::PrepareTrustedValues(
- const base::Closure& callback) const {
- DCHECK(CalledOnValidThread());
- for (size_t i = 0; i < providers_.size(); ++i) {
- CrosSettingsProvider::TrustedStatus status =
- providers_[i]->PrepareTrustedValues(callback);
- if (status != CrosSettingsProvider::TRUSTED)
- return status;
- }
- return CrosSettingsProvider::TRUSTED;
-}
-
-bool CrosSettings::GetBoolean(const std::string& path,
- bool* bool_value) const {
- DCHECK(CalledOnValidThread());
- 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());
- 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());
- 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());
- const base::Value* value = GetPref(path);
- if (value)
- return value->GetAsString(out_value);
- return false;
-}
-
-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() {
CrosSettingsProvider::NotifyObserversCallback notify_cb(
base::Bind(&CrosSettings::FireObservers,
@@ -301,7 +280,7 @@ CrosSettings::CrosSettings() {
AddSettingsProvider(new StubCrosSettingsProvider(notify_cb));
} else {
AddSettingsProvider(
- new DeviceSettingsProvider(notify_cb, SignedSettingsHelper::Get()));
+ new DeviceSettingsProvider(notify_cb, DeviceSettingsService::Get()));
}
// System settings are not mocked currently.
AddSettingsProvider(new SystemSettingsProvider(notify_cb));
@@ -312,4 +291,20 @@ CrosSettings::~CrosSettings() {
STLDeleteValues(&settings_observers_);
}
+void CrosSettings::FireObservers(const std::string& path) {
+ DCHECK(CalledOnValidThread());
+ SettingsObserverMap::iterator observer_iterator =
+ settings_observers_.find(path);
+ if (observer_iterator == settings_observers_.end())
+ return;
+
+ NotificationObserverList::Iterator it(*(observer_iterator->second));
+ content::NotificationObserver* observer;
+ while ((observer = it.GetNext()) != NULL) {
+ observer->Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED,
+ content::Source<CrosSettings>(this),
+ content::Details<const std::string>(&path));
+ }
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698