diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-16 07:13:53 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-16 07:13:53 +0000 |
commit | dc9a67601b9d8c952bf399f0309519273f82bfd5 (patch) | |
tree | b618c9da1cef3fa99718897cf523cb8768d4a273 /chrome/common | |
parent | a6dbaac4225f2fa5a170bdc657ab306390fdc439 (diff) | |
download | chromium_src-dc9a67601b9d8c952bf399f0309519273f82bfd5.zip chromium_src-dc9a67601b9d8c952bf399f0309519273f82bfd5.tar.gz chromium_src-dc9a67601b9d8c952bf399f0309519273f82bfd5.tar.bz2 |
Remove deprecated wstring Get(As)String() methods from Value, etc.
BUG=23581
TEST=builds and passes tests
Review URL: http://codereview.chromium.org/3117017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56187 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/automation_constants.cc | 10 | ||||
-rw-r--r-- | chrome/common/automation_constants.h | 10 | ||||
-rw-r--r-- | chrome/common/extensions/extension_message_bundle.cc | 15 | ||||
-rw-r--r-- | chrome/common/extensions/extension_message_bundle.h | 6 | ||||
-rw-r--r-- | chrome/common/extensions/extension_message_bundle_unittest.cc | 51 | ||||
-rw-r--r-- | chrome/common/json_value_serializer_unittest.cc | 54 | ||||
-rw-r--r-- | chrome/common/plugin_group_unittest.cc | 2 |
7 files changed, 73 insertions, 75 deletions
diff --git a/chrome/common/automation_constants.cc b/chrome/common/automation_constants.cc index 185d57b..c253871 100644 --- a/chrome/common/automation_constants.cc +++ b/chrome/common/automation_constants.cc @@ -7,9 +7,9 @@ namespace automation { // JSON value labels for proxy settings that are passed in via // AutomationMsg_SetProxyConfig. -const wchar_t kJSONProxyAutoconfig[] = L"proxy.autoconfig"; -const wchar_t kJSONProxyNoProxy[] = L"proxy.no_proxy"; -const wchar_t kJSONProxyPacUrl[] = L"proxy.pac_url"; -const wchar_t kJSONProxyBypassList[] = L"proxy.bypass_list"; -const wchar_t kJSONProxyServer[] = L"proxy.server"; +const char kJSONProxyAutoconfig[] = "proxy.autoconfig"; +const char kJSONProxyNoProxy[] = "proxy.no_proxy"; +const char kJSONProxyPacUrl[] = "proxy.pac_url"; +const char kJSONProxyBypassList[] = "proxy.bypass_list"; +const char kJSONProxyServer[] = "proxy.server"; } diff --git a/chrome/common/automation_constants.h b/chrome/common/automation_constants.h index 1b48e82..6959af7 100644 --- a/chrome/common/automation_constants.h +++ b/chrome/common/automation_constants.h @@ -10,11 +10,11 @@ namespace automation { // JSON value labels for proxy settings that are passed in via // AutomationMsg_SetProxyConfig. These are here since they are used by both // AutomationProvider and AutomationProxy. -extern const wchar_t kJSONProxyAutoconfig[]; -extern const wchar_t kJSONProxyNoProxy[]; -extern const wchar_t kJSONProxyPacUrl[]; -extern const wchar_t kJSONProxyBypassList[]; -extern const wchar_t kJSONProxyServer[]; +extern const char kJSONProxyAutoconfig[]; +extern const char kJSONProxyNoProxy[]; +extern const char kJSONProxyPacUrl[]; +extern const char kJSONProxyBypassList[]; +extern const char kJSONProxyServer[]; } #endif // CHROME_COMMON_AUTOMATION_CONSTANTS_H__ diff --git a/chrome/common/extensions/extension_message_bundle.cc b/chrome/common/extensions/extension_message_bundle.cc index 04022cd..8dd5275 100644 --- a/chrome/common/extensions/extension_message_bundle.cc +++ b/chrome/common/extensions/extension_message_bundle.cc @@ -22,9 +22,9 @@ namespace errors = extension_manifest_errors; -const wchar_t* ExtensionMessageBundle::kContentKey = L"content"; -const wchar_t* ExtensionMessageBundle::kMessageKey = L"message"; -const wchar_t* ExtensionMessageBundle::kPlaceholdersKey = L"placeholders"; +const char* ExtensionMessageBundle::kContentKey = "content"; +const char* ExtensionMessageBundle::kMessageKey = "message"; +const char* ExtensionMessageBundle::kPlaceholdersKey = "placeholders"; const char* ExtensionMessageBundle::kPlaceholderBegin = "$"; const char* ExtensionMessageBundle::kPlaceholderEnd = "$"; @@ -138,8 +138,7 @@ bool ExtensionMessageBundle::GetMessageValue(const std::string& key, } // Extract message from it. if (!name_tree->GetString(kMessageKey, value)) { - *error = StringPrintf("There is no \"%s\" element for key %s.", - WideToUTF8(kMessageKey).c_str(), + *error = StringPrintf("There is no \"%s\" element for key %s.", kMessageKey, key.c_str()); return false; } @@ -167,8 +166,7 @@ bool ExtensionMessageBundle::GetPlaceholders(const DictionaryValue& name_tree, DictionaryValue* placeholders_tree; if (!name_tree.GetDictionary(kPlaceholdersKey, &placeholders_tree)) { *error = StringPrintf("Not a valid \"%s\" element for key %s.", - WideToUTF8(kPlaceholdersKey).c_str(), - name_key.c_str()); + kPlaceholdersKey, name_key.c_str()); return false; } @@ -188,8 +186,7 @@ bool ExtensionMessageBundle::GetPlaceholders(const DictionaryValue& name_tree, std::string content; if (!placeholder->GetString(kContentKey, &content)) { *error = StringPrintf("Invalid \"%s\" element for key %s.", - WideToUTF8(kContentKey).c_str(), - name_key.c_str()); + kContentKey, name_key.c_str()); return false; } (*placeholders)[StringToLowerASCII(content_key)] = content; diff --git a/chrome/common/extensions/extension_message_bundle.h b/chrome/common/extensions/extension_message_bundle.h index 3c80356..3a49021 100644 --- a/chrome/common/extensions/extension_message_bundle.h +++ b/chrome/common/extensions/extension_message_bundle.h @@ -22,9 +22,9 @@ class ExtensionMessageBundle { typedef std::vector<linked_ptr<DictionaryValue> > CatalogVector; // JSON keys of interest for messages file. - static const wchar_t* kContentKey; - static const wchar_t* kMessageKey; - static const wchar_t* kPlaceholdersKey; + static const char* kContentKey; + static const char* kMessageKey; + static const char* kPlaceholdersKey; // Begin/end markers for placeholders and messages static const char* kPlaceholderBegin; diff --git a/chrome/common/extensions/extension_message_bundle_unittest.cc b/chrome/common/extensions/extension_message_bundle_unittest.cc index 81ae30c..dd87406 100644 --- a/chrome/common/extensions/extension_message_bundle_unittest.cc +++ b/chrome/common/extensions/extension_message_bundle_unittest.cc @@ -34,14 +34,14 @@ class ExtensionMessageBundleTest : public testing::Test { }; // Helper method for dictionary building. - void SetDictionary(const std::wstring name, + void SetDictionary(const std::string& name, DictionaryValue* subtree, DictionaryValue* target) { target->Set(name, static_cast<Value*>(subtree)); } - void CreateContentTree(const std::wstring& name, - const std::string content, + void CreateContentTree(const std::string& name, + const std::string& content, DictionaryValue* dict) { DictionaryValue* content_tree = new DictionaryValue; content_tree->SetString(ExtensionMessageBundle::kContentKey, content); @@ -50,15 +50,15 @@ class ExtensionMessageBundleTest : public testing::Test { void CreatePlaceholdersTree(DictionaryValue* dict) { DictionaryValue* placeholders_tree = new DictionaryValue; - CreateContentTree(L"a", "A", placeholders_tree); - CreateContentTree(L"b", "B", placeholders_tree); - CreateContentTree(L"c", "C", placeholders_tree); + CreateContentTree("a", "A", placeholders_tree); + CreateContentTree("b", "B", placeholders_tree); + CreateContentTree("c", "C", placeholders_tree); SetDictionary(ExtensionMessageBundle::kPlaceholdersKey, placeholders_tree, dict); } - void CreateMessageTree(const std::wstring& name, + void CreateMessageTree(const std::string& name, const std::string& message, bool create_placeholder_subtree, DictionaryValue* dict) { @@ -72,9 +72,9 @@ class ExtensionMessageBundleTest : public testing::Test { // Caller owns the memory. DictionaryValue* CreateGoodDictionary() { DictionaryValue* dict = new DictionaryValue; - CreateMessageTree(L"n1", "message1 $a$ $b$", true, dict); - CreateMessageTree(L"n2", "message2 $c$", true, dict); - CreateMessageTree(L"n3", "message3", false, dict); + CreateMessageTree("n1", "message1 $a$ $b$", true, dict); + CreateMessageTree("n2", "message2 $c$", true, dict); + CreateMessageTree("n3", "message3", false, dict); return dict; } @@ -84,35 +84,35 @@ class ExtensionMessageBundleTest : public testing::Test { // Now remove/break things. switch (what_is_bad) { case INVALID_NAME: - CreateMessageTree(L"n 5", "nevermind", false, dict); + CreateMessageTree("n 5", "nevermind", false, dict); break; case NAME_NOT_A_TREE: - dict->SetString(L"n4", "whatever"); + dict->SetString("n4", "whatever"); break; case EMPTY_NAME_TREE: { DictionaryValue* empty_tree = new DictionaryValue; - SetDictionary(L"n4", empty_tree, dict); + SetDictionary("n4", empty_tree, dict); } break; case MISSING_MESSAGE: - dict->Remove(L"n1.message", NULL); + dict->Remove("n1.message", NULL); break; case PLACEHOLDER_NOT_A_TREE: - dict->SetString(L"n1.placeholders", "whatever"); + dict->SetString("n1.placeholders", "whatever"); break; case EMPTY_PLACEHOLDER_TREE: { DictionaryValue* empty_tree = new DictionaryValue; - SetDictionary(L"n1.placeholders", empty_tree, dict); + SetDictionary("n1.placeholders", empty_tree, dict); } break; case CONTENT_MISSING: - dict->Remove(L"n1.placeholders.a.content", NULL); + dict->Remove("n1.placeholders.a.content", NULL); break; case MESSAGE_PLACEHOLDER_DOESNT_MATCH: DictionaryValue* value; - dict->Remove(L"n1.placeholders.a", NULL); - dict->GetDictionary(L"n1.placeholders", &value); - CreateContentTree(L"x", "X", value); + dict->Remove("n1.placeholders.a", NULL); + dict->GetDictionary("n1.placeholders", &value); + CreateContentTree("x", "X", value); break; } @@ -189,12 +189,12 @@ TEST_F(ExtensionMessageBundleTest, InitAppDictConsultedFirst) { DictionaryValue* app_dict = catalogs_[0].get(); // Flip placeholders in message of n1 tree. - app_dict->SetString(L"n1.message", "message1 $b$ $a$"); + app_dict->SetString("n1.message", "message1 $b$ $a$"); // Remove one message from app dict. - app_dict->Remove(L"n2", NULL); + app_dict->Remove("n2", NULL); // Replace n3 with N3. - app_dict->Remove(L"n3", NULL); - CreateMessageTree(L"N3", "message3_app_dict", false, app_dict); + app_dict->Remove("n3", NULL); + CreateMessageTree("N3", "message3_app_dict", false, app_dict); CreateMessageBundle(); @@ -258,8 +258,7 @@ TEST_F(ExtensionMessageBundleTest, ReservedMessagesOverrideDeveloperMessages) { catalogs_.push_back(linked_ptr<DictionaryValue>(CreateGoodDictionary())); DictionaryValue* dict = catalogs_[0].get(); - CreateMessageTree( - ASCIIToWide(ExtensionMessageBundle::kUILocaleKey), "x", false, dict); + CreateMessageTree(ExtensionMessageBundle::kUILocaleKey, "x", false, dict); std::string error = CreateMessageBundle(); diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc index 3f40dcc..b3f3e0d 100644 --- a/chrome/common/json_value_serializer_unittest.cc +++ b/chrome/common/json_value_serializer_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,7 +7,9 @@ #include "base/json/json_reader.h" #include "base/json/json_writer.h" #include "base/path_service.h" +#include "base/string16.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/json_value_serializer.h" @@ -24,20 +26,20 @@ TEST(JSONValueSerializerTest, Roundtrip) { DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get()); Value* null_value = NULL; - ASSERT_TRUE(root_dict->Get(L"null", &null_value)); + ASSERT_TRUE(root_dict->Get("null", &null_value)); ASSERT_TRUE(null_value); ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL)); bool bool_value = false; - ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value)); + ASSERT_TRUE(root_dict->GetBoolean("bool", &bool_value)); ASSERT_TRUE(bool_value); int int_value = 0; - ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value)); + ASSERT_TRUE(root_dict->GetInteger("int", &int_value)); ASSERT_EQ(42, int_value); double real_value = 0.0; - ASSERT_TRUE(root_dict->GetReal(L"real", &real_value)); + ASSERT_TRUE(root_dict->GetReal("real", &real_value)); ASSERT_DOUBLE_EQ(3.14, real_value); // We shouldn't be able to write using this serializer, since it was @@ -71,9 +73,9 @@ TEST(JSONValueSerializerTest, Roundtrip) { } TEST(JSONValueSerializerTest, StringEscape) { - std::wstring all_chars; + string16 all_chars; for (int i = 1; i < 256; ++i) { - all_chars += static_cast<wchar_t>(i); + all_chars += static_cast<char16>(i); } // Generated in in Firefox using the following js (with an extra backslash for // double quote): @@ -105,7 +107,7 @@ TEST(JSONValueSerializerTest, StringEscape) { // Test JSONWriter interface std::string output_js; DictionaryValue valueRoot; - valueRoot.SetString(L"all_chars", all_chars); + valueRoot.SetString("all_chars", all_chars); base::JSONWriter::Write(&valueRoot, false, &output_js); ASSERT_EQ(expected_output, output_js); @@ -118,8 +120,8 @@ TEST(JSONValueSerializerTest, StringEscape) { TEST(JSONValueSerializerTest, UnicodeStrings) { // unicode string json -> escaped ascii text DictionaryValue root; - std::wstring test(L"\x7F51\x9875"); - root.SetString(L"web", test); + string16 test(WideToUTF16(L"\x7F51\x9875")); + root.SetString("web", test); std::string expected = "{\"web\":\"\\u7F51\\u9875\"}"; @@ -134,16 +136,16 @@ TEST(JSONValueSerializerTest, UnicodeStrings) { ASSERT_TRUE(deserial_root.get()); DictionaryValue* dict_root = static_cast<DictionaryValue*>(deserial_root.get()); - std::wstring web_value; - ASSERT_TRUE(dict_root->GetString(L"web", &web_value)); + string16 web_value; + ASSERT_TRUE(dict_root->GetString("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(L"test", test); + string16 test(WideToUTF16(L"\x01\x02")); + root.SetString("test", test); std::string expected = "{\"test\":\"\\u0001\\u0002\"}"; @@ -158,8 +160,8 @@ TEST(JSONValueSerializerTest, HexStrings) { ASSERT_TRUE(deserial_root.get()); DictionaryValue* dict_root = static_cast<DictionaryValue*>(deserial_root.get()); - std::wstring test_value; - ASSERT_TRUE(dict_root->GetString(L"test", &test_value)); + string16 test_value; + ASSERT_TRUE(dict_root->GetString("test", &test_value)); ASSERT_EQ(test, test_value); // Test converting escaped regular chars @@ -168,8 +170,8 @@ TEST(JSONValueSerializerTest, HexStrings) { deserial_root.reset(deserializer2.Deserialize(NULL, NULL)); ASSERT_TRUE(deserial_root.get()); dict_root = static_cast<DictionaryValue*>(deserial_root.get()); - ASSERT_TRUE(dict_root->GetString(L"test", &test_value)); - ASSERT_EQ(std::wstring(L"go"), test_value); + ASSERT_TRUE(dict_root->GetString("test", &test_value)); + ASSERT_EQ(ASCIIToUTF16("go"), test_value); } TEST(JSONValueSerializerTest, AllowTrailingComma) { @@ -221,9 +223,9 @@ TEST(JSONValueSerializerTest, JSONReaderComments) { ASSERT_EQ(1U, list->GetSize()); Value* elt = NULL; ASSERT_TRUE(list->Get(0, &elt)); - std::wstring value; + std::string value; ASSERT_TRUE(elt && elt->GetAsString(&value)); - ASSERT_EQ(L"// ok\n /* foo */ ", value); + ASSERT_EQ("// ok\n /* foo */ ", value); // You can't nest comments. root.reset(base::JSONReader::Read("/* /* inner */ outer */ [ 1 ]", false)); @@ -275,21 +277,21 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get()); Value* null_value = NULL; - ASSERT_TRUE(root_dict->Get(L"null", &null_value)); + ASSERT_TRUE(root_dict->Get("null", &null_value)); ASSERT_TRUE(null_value); ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL)); bool bool_value = false; - ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value)); + ASSERT_TRUE(root_dict->GetBoolean("bool", &bool_value)); ASSERT_TRUE(bool_value); int int_value = 0; - ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value)); + ASSERT_TRUE(root_dict->GetInteger("int", &int_value)); ASSERT_EQ(42, int_value); - std::wstring string_value; - ASSERT_TRUE(root_dict->GetString(L"string", &string_value)); - ASSERT_EQ(L"hello", string_value); + std::string string_value; + ASSERT_TRUE(root_dict->GetString("string", &string_value)); + ASSERT_EQ("hello", string_value); // Now try writing. const FilePath written_file_path = diff --git a/chrome/common/plugin_group_unittest.cc b/chrome/common/plugin_group_unittest.cc index 879ad70..33cc8ea 100644 --- a/chrome/common/plugin_group_unittest.cc +++ b/chrome/common/plugin_group_unittest.cc @@ -151,7 +151,7 @@ TEST(PluginGroupTest, VersionExtraction) { group->AddPlugin(plugin, 0); scoped_ptr<DictionaryValue> data(group->GetDataForUI()); std::string version; - data->GetString(L"version", &version); + data->GetString("version", &version); EXPECT_EQ(versions[i][1], version); } } |