summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authornsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 20:46:40 +0000
committernsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 20:46:40 +0000
commit6470ee8f59dba5eecfce4a64d7ff3930ae716095 (patch)
tree86e020619f32c56f5796a0ea20975c71607ac91f /chrome/common
parent409993dec55a874e0659acf421a87070d450a262 (diff)
downloadchromium_src-6470ee8f59dba5eecfce4a64d7ff3930ae716095.zip
chromium_src-6470ee8f59dba5eecfce4a64d7ff3930ae716095.tar.gz
chromium_src-6470ee8f59dba5eecfce4a64d7ff3930ae716095.tar.bz2
Revert dsh's change 10818
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/json_value_serializer_unittest.cc42
-rw-r--r--chrome/common/pref_service.cc50
2 files changed, 43 insertions, 49 deletions
diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc
index f09f8d3..1fc9e97 100644
--- a/chrome/common/json_value_serializer_unittest.cc
+++ b/chrome/common/json_value_serializer_unittest.cc
@@ -24,20 +24,20 @@ TEST(JSONValueSerializerTest, Roundtrip) {
DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get());
Value* null_value = NULL;
- ASSERT_TRUE(root_dict->Get(LIT16("null"), &null_value));
+ ASSERT_TRUE(root_dict->Get(L"null", &null_value));
ASSERT_TRUE(null_value);
ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL));
bool bool_value = false;
- ASSERT_TRUE(root_dict->GetBoolean(LIT16("bool"), &bool_value));
+ ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value));
ASSERT_TRUE(bool_value);
int int_value = 0;
- ASSERT_TRUE(root_dict->GetInteger(LIT16("int"), &int_value));
+ ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value));
ASSERT_EQ(42, int_value);
double real_value = 0.0;
- ASSERT_TRUE(root_dict->GetReal(LIT16("real"), &real_value));
+ ASSERT_TRUE(root_dict->GetReal(L"real", &real_value));
ASSERT_DOUBLE_EQ(3.14, real_value);
// We shouldn't be able to write using this serializer, since it was
@@ -92,7 +92,7 @@ TEST(JSONValueSerializerTest, StringEscape) {
// Test JSONWriter interface
std::string output_js;
DictionaryValue valueRoot;
- valueRoot.SetString(LIT16("all_chars"), WideToUTF16Hack(all_chars));
+ valueRoot.SetString(L"all_chars", all_chars);
JSONWriter::Write(&valueRoot, false, &output_js);
ASSERT_EQ(expected_output, output_js);
@@ -106,7 +106,7 @@ TEST(JSONValueSerializerTest, UnicodeStrings) {
// unicode string json -> escaped ascii text
DictionaryValue root;
std::wstring test(L"\x7F51\x9875");
- root.SetString(LIT16("web"), WideToUTF16Hack(test));
+ root.SetString(L"web", test);
std::string expected = "{\"web\":\"\\u7F51\\u9875\"}";
@@ -121,16 +121,16 @@ TEST(JSONValueSerializerTest, UnicodeStrings) {
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
- string16 web_value;
- ASSERT_TRUE(dict_root->GetString(LIT16("web"), &web_value));
- ASSERT_EQ(test, UTF16ToWideHack(web_value));
+ std::wstring web_value;
+ ASSERT_TRUE(dict_root->GetString(L"web", &web_value));
+ ASSERT_EQ(test, web_value);
}
TEST(JSONValueSerializerTest, HexStrings) {
// hex string json -> escaped ascii text
DictionaryValue root;
std::wstring test(L"\x01\x02");
- root.SetString(LIT16("test"), WideToUTF16Hack(test));
+ root.SetString(L"test", test);
std::string expected = "{\"test\":\"\\x01\\x02\"}";
@@ -145,9 +145,9 @@ TEST(JSONValueSerializerTest, HexStrings) {
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
- string16 test_value;
- ASSERT_TRUE(dict_root->GetString(LIT16("test"), &test_value));
- ASSERT_EQ(test, UTF16ToWideHack(test_value));
+ std::wstring test_value;
+ ASSERT_TRUE(dict_root->GetString(L"test", &test_value));
+ ASSERT_EQ(test, test_value);
// Test converting escaped regular chars
std::string escaped_chars = "{\"test\":\"\\x67\\x6f\"}";
@@ -155,8 +155,8 @@ TEST(JSONValueSerializerTest, HexStrings) {
deserial_root.reset(deserializer2.Deserialize(NULL));
ASSERT_TRUE(deserial_root.get());
dict_root = static_cast<DictionaryValue*>(deserial_root.get());
- ASSERT_TRUE(dict_root->GetString(LIT16("test"), &test_value));
- ASSERT_EQ(L"go", UTF16ToWideHack(test_value));
+ ASSERT_TRUE(dict_root->GetString(L"test", &test_value));
+ ASSERT_EQ(std::wstring(L"go"), test_value);
}
TEST(JSONValueSerializerTest, AllowTrailingComma) {
@@ -260,21 +260,21 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) {
DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get());
Value* null_value = NULL;
- ASSERT_TRUE(root_dict->Get(LIT16("null"), &null_value));
+ ASSERT_TRUE(root_dict->Get(L"null", &null_value));
ASSERT_TRUE(null_value);
ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL));
bool bool_value = false;
- ASSERT_TRUE(root_dict->GetBoolean(LIT16("bool"), &bool_value));
+ ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value));
ASSERT_TRUE(bool_value);
int int_value = 0;
- ASSERT_TRUE(root_dict->GetInteger(LIT16("int"), &int_value));
+ ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value));
ASSERT_EQ(42, int_value);
- string16 string_value;
- ASSERT_TRUE(root_dict->GetString(LIT16("string"), &string_value));
- ASSERT_EQ(L"hello", UTF16ToWideHack(string_value));
+ std::wstring string_value;
+ ASSERT_TRUE(root_dict->GetString(L"string", &string_value));
+ ASSERT_EQ(L"hello", string_value);
// Now try writing.
std::wstring written_file_path = test_dir_;
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index fd27de1..b728a87 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(WideToUTF16Hack(path), &result))
+ if (transient_->GetBoolean(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(WideToUTF16Hack(path), &result))
+ if (transient_->GetInteger(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(WideToUTF16Hack(path), &result))
+ if (transient_->GetReal(path, &result))
return result;
const Preference* pref = FindPreference(path);
@@ -339,11 +339,10 @@ double PrefService::GetReal(const wchar_t* path) const {
std::wstring PrefService::GetString(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
- string16 result16;
- if (transient_->GetString(WideToUTF16Hack(path), &result16))
- return UTF16ToWideHack(result16);
-
std::wstring result;
+ if (transient_->GetString(path, &result))
+ return result;
+
const Preference* pref = FindPreference(path);
if (!pref) {
#if defined(OS_WIN)
@@ -360,8 +359,7 @@ std::wstring PrefService::GetString(const wchar_t* path) const {
bool PrefService::HasPrefPath(const wchar_t* path) const {
Value* value = NULL;
- string16 path16 = WideToUTF16Hack(path);
- return (transient_->Get(path16, &value) || persistent_->Get(path16, &value));
+ return (transient_->Get(path, &value) || persistent_->Get(path, &value));
}
const PrefService::Preference* PrefService::FindPreference(
@@ -376,7 +374,7 @@ const DictionaryValue* PrefService::GetDictionary(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
DictionaryValue* result = NULL;
- if (transient_->GetDictionary(WideToUTF16Hack(path), &result))
+ if (transient_->GetDictionary(path, &result))
return result;
const Preference* pref = FindPreference(path);
@@ -394,7 +392,7 @@ const ListValue* PrefService::GetList(const wchar_t* path) const {
DCHECK(CalledOnValidThread());
ListValue* result = NULL;
- if (transient_->GetList(WideToUTF16Hack(path), &result))
+ if (transient_->GetList(path, &result))
return result;
const Preference* pref = FindPreference(path);
@@ -475,11 +473,10 @@ void PrefService::ClearPref(const wchar_t* path) {
return;
}
- string16 path16 = WideToUTF16Hack(path);
- transient_->Remove(path16, NULL);
+ transient_->Remove(path, NULL);
Value* value;
- bool has_old_value = persistent_->Get(path16, &value);
- persistent_->Remove(path16, NULL);
+ bool has_old_value = persistent_->Get(path, &value);
+ persistent_->Remove(path, NULL);
if (has_old_value)
FireObservers(path);
@@ -499,7 +496,7 @@ void PrefService::SetBoolean(const wchar_t* path, bool value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetBoolean(WideToUTF16Hack(path), value);
+ bool rv = persistent_->SetBoolean(path, value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -519,7 +516,7 @@ void PrefService::SetInteger(const wchar_t* path, int value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetInteger(WideToUTF16Hack(path), value);
+ bool rv = persistent_->SetInteger(path, value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -539,7 +536,7 @@ void PrefService::SetReal(const wchar_t* path, double value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetReal(WideToUTF16Hack(path), value);
+ bool rv = persistent_->SetReal(path, value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -559,8 +556,7 @@ void PrefService::SetString(const wchar_t* path, const std::wstring& value) {
}
scoped_ptr<Value> old_value(GetPrefCopy(path));
- bool rv = persistent_->SetString(WideToUTF16Hack(path),
- WideToUTF16Hack(value));
+ bool rv = persistent_->SetString(path, value);
DCHECK(rv);
FireObserversIfChanged(path, old_value.get());
@@ -580,11 +576,10 @@ DictionaryValue* PrefService::GetMutableDictionary(const wchar_t* path) {
}
DictionaryValue* dict = NULL;
- string16 path16 = WideToUTF16Hack(path);
- bool rv = persistent_->GetDictionary(path16, &dict);
+ bool rv = persistent_->GetDictionary(path, &dict);
if (!rv) {
dict = new DictionaryValue;
- rv = persistent_->Set(path16, dict);
+ rv = persistent_->Set(path, dict);
DCHECK(rv);
}
return dict;
@@ -604,11 +599,10 @@ ListValue* PrefService::GetMutableList(const wchar_t* path) {
}
ListValue* list = NULL;
- string16 path16 = WideToUTF16Hack(path);
- bool rv = persistent_->GetList(path16, &list);
+ bool rv = persistent_->GetList(path, &list);
if (!rv) {
list = new ListValue;
- rv = persistent_->Set(path16, list);
+ rv = persistent_->Set(path, list);
DCHECK(rv);
}
return list;
@@ -625,7 +619,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(WideToUTF16Hack(path), &new_value);
+ persistent_->Get(path, &new_value);
if (!old_value->Equals(new_value))
FireObservers(path);
}
@@ -678,7 +672,7 @@ const Value* PrefService::Preference::GetValue() const {
"Must register pref before getting its value";
Value* temp_value = NULL;
- if (root_pref_->Get(WideToUTF16Hack(name_), &temp_value) &&
+ if (root_pref_->Get(name_.c_str(), &temp_value) &&
temp_value->GetType() == type_) {
return temp_value;
}