summaryrefslogtreecommitdiffstats
path: root/chrome/common/pref_service.cc
diff options
context:
space:
mode:
authordsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 21:49:53 +0000
committerdsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 21:49:53 +0000
commit3a79b3cc8393d54d72c8c7e14615fe64d86fd039 (patch)
tree2730ef27672c8f9c9e1b6ef3f443434ac98bfd4f /chrome/common/pref_service.cc
parent1c9e90e17741f9c34f4cbe7f3e68a8300ed24e08 (diff)
downloadchromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.zip
chromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.tar.gz
chromium_src-3a79b3cc8393d54d72c8c7e14615fe64d86fd039.tar.bz2
Port DictionaryValue to use string16 instead of wstring.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=10818 Review URL: http://codereview.chromium.org/31014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10833 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/pref_service.cc')
-rw-r--r--chrome/common/pref_service.cc50
1 files changed, 28 insertions, 22 deletions
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index b728a87..fd27de1 100644
--- a/chrome/common/pref_service.cc
+++ b/chrome/common/pref_service.cc
@@ -289,7 +289,7 @@ bool PrefService::GetBoolean(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
bool result = false;
- if (transient_->GetBoolean(path, &result))
+ if (transient_->GetBoolean(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -306,7 +306,7 @@ int PrefService::GetInteger(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
int result = 0;
- if (transient_->GetInteger(path, &result))
+ if (transient_->GetInteger(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -323,7 +323,7 @@ double PrefService::GetReal(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
double result = 0.0;
- if (transient_->GetReal(path, &result))
+ if (transient_->GetReal(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -339,10 +339,11 @@ double PrefService::GetReal(const wchar_t* path) const {
std::wstring PrefService::GetString(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
- std::wstring result;
- if (transient_->GetString(path, &result))
- return result;
+ string16 result16;
+ if (transient_->GetString(WideToUTF16Hack(path), &result16))
+ return UTF16ToWideHack(result16);
+ std::wstring result;
const Preference* pref = FindPreference(path);
if (!pref) {
#if defined(OS_WIN)
@@ -359,7 +360,8 @@ std::wstring PrefService::GetString(const wchar_t* path) const {
bool PrefService::HasPrefPath(const wchar_t* path) const {
Value* value = NULL;
- return (transient_->Get(path, &value) || persistent_->Get(path, &value));
+ string16 path16 = WideToUTF16Hack(path);
+ return (transient_->Get(path16, &value) || persistent_->Get(path16, &value));
}
const PrefService::Preference* PrefService::FindPreference(
@@ -374,7 +376,7 @@ const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
DictionaryValue* result = NULL;
- if (transient_->GetDictionary(path, &result))
+ if (transient_->GetDictionary(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -392,7 +394,7 @@ const ListValue* PrefService::GetList(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
ListValue* result = NULL;
- if (transient_->GetList(path, &result))
+ if (transient_->GetList(WideToUTF16Hack(path), &result))
return result;
const Preference* pref = FindPreference(path);
@@ -473,10 +475,11 @@ void PrefService::ClearPref(const wchar_t* path) {
return;
}
- transient_->Remove(path, NULL);
+ string16 path16 = WideToUTF16Hack(path);
+ transient_->Remove(path16, NULL);
Value* value;
- bool has_old_value = persistent_->Get(path, &value);
- persistent_->Remove(path, NULL);
+ bool has_old_value = persistent_->Get(path16, &value);
+ persistent_->Remove(path16, NULL);
if (has_old_value)
FireObservers(path);
@@ -496,7 +499,7 @@ void PrefService::SetBoolean(const wchar_t* path, bool value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetBoolean(path, value);
+ bool rv = persistent_->SetBoolean(WideToUTF16Hack(path), value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -516,7 +519,7 @@ void PrefService::SetInteger(const wchar_t* path, int value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetInteger(path, value);
+ bool rv = persistent_->SetInteger(WideToUTF16Hack(path), value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -536,7 +539,7 @@ void PrefService::SetReal(const wchar_t* path, double value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetReal(path, value);
+ bool rv = persistent_->SetReal(WideToUTF16Hack(path), value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -556,7 +559,8 @@ void PrefService::SetString(const wchar_t* path, const std::wstring& value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetString(path, value);
+ bool rv = persistent_->SetString(WideToUTF16Hack(path),
+ WideToUTF16Hack(value));
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -576,10 +580,11 @@ DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) {
}
DictionaryValue* dict = NULL;
- bool rv = persistent_->GetDictionary(path, &dict);
+ string16 path16 = WideToUTF16Hack(path);
+ bool rv = persistent_->GetDictionary(path16, &dict);
if (!rv) {
dict = new DictionaryValue;
- rv = persistent_->Set(path, dict);
+ rv = persistent_->Set(path16, dict);
DCHECK(rv);
}
return dict;
@@ -599,10 +604,11 @@ ListValue* PrefService::GetMutableList(const wchar_t* path) {
}
ListValue* list = NULL;
- bool rv = persistent_->GetList(path, &list);
+ string16 path16 = WideToUTF16Hack(path);
+ bool rv = persistent_->GetList(path16, &list);
if (!rv) {
list = new ListValue;
- rv = persistent_->Set(path, list);
+ rv = persistent_->Set(path16, list);
DCHECK(rv);
}
return list;
@@ -619,7 +625,7 @@ Value* PrefService::GetPrefCopy(const wchar_t* path) {
void PrefService::FireObserversIfChanged(const wchar_t* path,
const Value* old_value) {
Value* new_value = NULL;
- persistent_->Get(path, &new_value);
+ persistent_->Get(WideToUTF16Hack(path), &new_value);
if (!old_value->Equals(new_value))
FireObservers(path);
}
@@ -672,7 +678,7 @@ const Value* PrefService::Preference::GetValue() const {
"Must register pref before getting its value";
Value* temp_value = NULL;
- if (root_pref_->Get(name_.c_str(), &temp_value) &&
+ if (root_pref_->Get(WideToUTF16Hack(name_), &temp_value) &&
temp_value->GetType() == type_) {
return temp_value;
}