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

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

Issue 8091002: PART2: Make SignedSettings use proper Value types instead of string all around the place. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the nits and rebased on ToT (which now has PART1 in). Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/chromeos/cros_settings.h ('k') | chrome/browser/chromeos/cros_settings_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros_settings.cc
diff --git a/chrome/browser/chromeos/cros_settings.cc b/chrome/browser/chromeos/cros_settings.cc
index 16f70a2a79bab6d2c0b0017bc8eca5c40493583c..bde3c314b96288302f55f26c8a0c51515974d155 100644
--- a/chrome/browser/chromeos/cros_settings.cc
+++ b/chrome/browser/chromeos/cros_settings.cc
@@ -46,7 +46,7 @@ void CrosSettings::FireObservers(const char* path) {
}
}
-void CrosSettings::Set(const std::string& path, Value* in_value) {
+void CrosSettings::Set(const std::string& path, const base::Value& in_value) {
DCHECK(CalledOnValidThread());
CrosSettingsProvider* provider;
provider = GetProvider(path);
@@ -57,23 +57,66 @@ void CrosSettings::Set(const std::string& path, Value* in_value) {
void CrosSettings::SetBoolean(const std::string& path, bool in_value) {
DCHECK(CalledOnValidThread());
- Set(path, Value::CreateBooleanValue(in_value));
+ base::FundamentalValue value(in_value);
+ Set(path, value);
}
void CrosSettings::SetInteger(const std::string& path, int in_value) {
DCHECK(CalledOnValidThread());
- Set(path, Value::CreateIntegerValue(in_value));
+ base::FundamentalValue value(in_value);
+ Set(path, value);
}
void CrosSettings::SetDouble(const std::string& path, double in_value) {
DCHECK(CalledOnValidThread());
- Set(path, Value::CreateDoubleValue(in_value));
+ base::FundamentalValue value(in_value);
+ Set(path, value);
}
void CrosSettings::SetString(const std::string& path,
const std::string& in_value) {
DCHECK(CalledOnValidThread());
- Set(path, Value::CreateStringValue(in_value));
+ base::StringValue value(in_value);
+ Set(path, value);
+}
+
+void CrosSettings::AppendToList(const std::string& path,
+ const base::Value* value) {
+ DCHECK(CalledOnValidThread());
+ const base::Value* old_value = GetPref(path);
+ scoped_ptr<base::Value> new_value(
+ old_value ? old_value->DeepCopy() : new base::ListValue());
+ static_cast<base::ListValue*>(new_value.get())->Append(value->DeepCopy());
+ Set(path, *new_value);
+}
+
+void CrosSettings::RemoveFromList(const std::string& path,
+ const base::Value* value) {
+ DCHECK(CalledOnValidThread());
+ const base::Value* old_value = GetPref(path);
+ scoped_ptr<base::Value> new_value(
+ old_value ? old_value->DeepCopy() : new base::ListValue());
+ static_cast<base::ListValue*>(new_value.get())->Remove(*value, NULL);
+ Set(path, *new_value);
+}
+
+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) {
+ if (value->Find(email_value) != value->end())
+ return true;
+ std::string::size_type at_pos = email.find('@');
+ if (at_pos != std::string::npos) {
+ base::StringValue wildcarded_value(
+ std::string("*").append(email.substr(at_pos)));
+ return value->Find(wildcarded_value) != value->end();
+ }
+ }
+ return false;
}
bool CrosSettings::AddSettingsProvider(CrosSettingsProvider* provider) {
« no previous file with comments | « chrome/browser/chromeos/cros_settings.h ('k') | chrome/browser/chromeos/cros_settings_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698