diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/dom_ui/about_page_handler.cc | 89 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_i18n_api.cc | 9 | ||||
-rw-r--r-- | chrome/browser/pref_service.cc | 10 | ||||
-rw-r--r-- | chrome/browser/pref_value_store_unittest.cc | 13 | ||||
-rw-r--r-- | chrome/renderer/dom_ui_bindings.cc | 6 |
5 files changed, 68 insertions, 59 deletions
diff --git a/chrome/browser/dom_ui/about_page_handler.cc b/chrome/browser/dom_ui/about_page_handler.cc index 1246f31..dfb992d 100644 --- a/chrome/browser/dom_ui/about_page_handler.cc +++ b/chrome/browser/dom_ui/about_page_handler.cc @@ -11,6 +11,7 @@ #include "base/command_line.h" #include "base/file_version_info.h" #include "base/i18n/time_formatting.h" +#include "base/string16.h" #include "base/string_number_conversions.h" #include "base/time.h" #include "base/utf_string_conversions.h" @@ -138,21 +139,21 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); DCHECK(version_info.get() != NULL); - std::wstring browser_version = version_info->file_version(); + string16 browser_version = WideToUTF16Hack(version_info->file_version()); string16 version_modifier = platform_util::GetVersionStringModifier(); if (version_modifier.length()) { - browser_version += L" "; - browser_version += UTF16ToWide(version_modifier); + browser_version += ASCIIToUTF16(" "); + browser_version += version_modifier; } #if !defined(GOOGLE_CHROME_BUILD) - browser_version += L" ("; - browser_version += version_info->last_change(); - browser_version += L")"; + browser_version += ASCIIToUTF16(" ("); + browser_version += WideToUTF16Hack(version_info->last_change()); + browser_version += ASCIIToUTF16(")"); #endif - localized_strings->SetString(L"browser_version", browser_version); + localized_strings->SetString("browser_version", browser_version); // license @@ -170,62 +171,68 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { size_t link2_end = text.find(kEndLink, link2); DCHECK(link1_end != std::wstring::npos); - localized_strings->SetString(L"license_content_0", text.substr(0, link1)); - localized_strings->SetString(L"license_content_1", StringSubRange(text, - link1_end + wcslen(kEndLinkOss), link2)); - localized_strings->SetString(L"license_content_2", - text.substr(link2_end + wcslen(kEndLinkOss))); + localized_strings->SetString("license_content_0", + WideToUTF16Hack(text.substr(0, link1))); + localized_strings->SetString("license_content_1", + WideToUTF16Hack(StringSubRange(text, link1_end + wcslen(kEndLinkOss), + link2))); + localized_strings->SetString("license_content_2", + WideToUTF16Hack(text.substr(link2_end + wcslen(kEndLinkOss)))); // The Chromium link within the main text of the dialog. localized_strings->SetString(chromium_url_appears_first ? - L"license_link_content_0" : L"license_link_content_1", - StringSubRange(text, text.find(kBeginLinkChr) + wcslen(kBeginLinkChr), - text.find(kEndLinkChr))); + "license_link_content_0" : "license_link_content_1", + WideToUTF16Hack(StringSubRange(text, + text.find(kBeginLinkChr) + wcslen(kBeginLinkChr), + text.find(kEndLinkChr)))); localized_strings->SetString(chromium_url_appears_first ? - L"license_link_0" : L"license_link_1", - l10n_util::GetString(IDS_CHROMIUM_PROJECT_URL)); + "license_link_0" : "license_link_1", + l10n_util::GetStringUTF16(IDS_CHROMIUM_PROJECT_URL)); // The Open Source link within the main text of the dialog. localized_strings->SetString(chromium_url_appears_first ? - L"license_link_content_1" : L"license_link_content_0", - StringSubRange(text, text.find(kBeginLinkOss) + wcslen(kBeginLinkOss), - text.find(kEndLinkOss))); + "license_link_content_1" : "license_link_content_0", + WideToUTF16Hack(StringSubRange(text, + text.find(kBeginLinkOss) + wcslen(kBeginLinkOss), + text.find(kEndLinkOss)))); localized_strings->SetString(chromium_url_appears_first ? - L"license_link_1" : L"license_link_0", chrome::kAboutCreditsURL); + "license_link_1" : "license_link_0", chrome::kAboutCreditsURL); // webkit - localized_strings->SetString(L"webkit_version", + localized_strings->SetString("webkit_version", webkit_glue::GetWebKitVersion()); // javascript #if defined(CHROME_V8) - localized_strings->SetString(L"js_engine", "V8"); - localized_strings->SetString(L"js_engine_version", v8::V8::GetVersion()); + localized_strings->SetString("js_engine", "V8"); + localized_strings->SetString("js_engine_version", v8::V8::GetVersion()); #else - localized_strings->SetString(L"js_engine", "JavaScriptCore"); - localized_strings->SetString(L"js_engine_version", + localized_strings->SetString("js_engine", "JavaScriptCore"); + localized_strings->SetString("js_engine_version", webkit_glue::GetWebKitVersion()); #endif // user agent - localized_strings->SetString(L"user_agent_info", + localized_strings->SetString("user_agent_info", webkit_glue::GetUserAgent(GURL())); // command line #if defined(OS_WIN) - localized_strings->SetString(L"command_line_info", - CommandLine::ForCurrentProcess()->command_line_string()); + localized_strings->SetString("command_line_info", + WideToUTF16(CommandLine::ForCurrentProcess()->command_line_string())); #elif defined(OS_POSIX) + // TODO(viettrungluu): something horrible might happen if there are non-UTF-8 + // arguments (since |SetString()| requires Unicode). std::string command_line = ""; typedef std::vector<std::string> ArgvList; const ArgvList& argv = CommandLine::ForCurrentProcess()->argv(); for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++) command_line += " " + *iter; - localized_strings->SetString(L"command_line_info", command_line); + localized_strings->SetString("command_line_info", command_line); #endif } @@ -262,24 +269,24 @@ void AboutPageHandler::CheckNow(const Value* value) { void AboutPageHandler::UpdateStatus( const chromeos::UpdateLibrary::Status& status) { - std::wstring message; + string16 message; std::string image = "up-to-date"; bool enabled = false; switch (status.status) { case chromeos::UPDATE_STATUS_IDLE: if (!sticky_) { - message = l10n_util::GetStringF(IDS_UPGRADE_ALREADY_UP_TO_DATE, - l10n_util::GetString(IDS_PRODUCT_OS_NAME)); + message = l10n_util::GetStringFUTF16(IDS_UPGRADE_ALREADY_UP_TO_DATE, + l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME)); enabled = true; } break; case chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE: - message = l10n_util::GetString(IDS_UPGRADE_CHECK_STARTED); + message = l10n_util::GetStringUTF16(IDS_UPGRADE_CHECK_STARTED); sticky_ = false; break; case chromeos::UPDATE_STATUS_UPDATE_AVAILABLE: - message = l10n_util::GetString(IDS_UPDATE_AVAILABLE); + message = l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE); started_ = true; break; case chromeos::UPDATE_STATUS_DOWNLOADING: @@ -287,21 +294,23 @@ void AboutPageHandler::UpdateStatus( int progress = static_cast<int>(status.download_progress * 100.0); if (progress != progress_) { progress_ = progress; - message = l10n_util::GetStringF(IDS_UPDATE_DOWNLOADING, progress_); + // TODO(viettrungluu): need UTF-16 convenience form to eliminate hack. + message = WideToUTF16Hack( + l10n_util::GetStringF(IDS_UPDATE_DOWNLOADING, progress_)); } started_ = true; } break; case chromeos::UPDATE_STATUS_VERIFYING: - message = l10n_util::GetString(IDS_UPDATE_VERIFYING); + message = l10n_util::GetStringUTF16(IDS_UPDATE_VERIFYING); started_ = true; break; case chromeos::UPDATE_STATUS_FINALIZING: - message = l10n_util::GetString(IDS_UPDATE_FINALIZING); + message = l10n_util::GetStringUTF16(IDS_UPDATE_FINALIZING); started_ = true; break; case chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT: - message = l10n_util::GetString(IDS_UPDATE_COMPLETED); + message = l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED); image = "available"; sticky_ = true; break; @@ -312,7 +321,7 @@ void AboutPageHandler::UpdateStatus( // The error is only displayed if we were able to determine an // update was available. if (started_) { - message = l10n_util::GetString(IDS_UPDATE_ERROR); + message = l10n_util::GetStringUTF16(IDS_UPDATE_ERROR); image = "fail"; enabled = true; sticky_ = true; diff --git a/chrome/browser/extensions/extension_i18n_api.cc b/chrome/browser/extensions/extension_i18n_api.cc index 146e62a..f48eee7 100644 --- a/chrome/browser/extensions/extension_i18n_api.cc +++ b/chrome/browser/extensions/extension_i18n_api.cc @@ -13,8 +13,8 @@ static const char kEmptyAcceptLanguagesError[] = "accept-languages is empty."; bool GetAcceptLanguagesFunction::RunImpl() { - std::wstring acceptLanguages = - UTF8ToWide(profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); + string16 acceptLanguages = + UTF8ToUTF16(profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); // Currently, there are 2 ways to set browser's accept-languages: through UI // or directly modify the preference file. The accept-languages set through // UI is guranteed to be valid, and the accept-languages string returned from @@ -32,19 +32,18 @@ bool GetAcceptLanguagesFunction::RunImpl() { } size_t begin = 0; size_t end; - std::wstring acceptLang; while (1) { end = acceptLanguages.find(',', begin); if (end > begin) { // Guard against a malformed value with multiple "," in a row. - acceptLang = acceptLanguages.substr(begin, end - begin); + string16 acceptLang = acceptLanguages.substr(begin, end - begin); static_cast<ListValue*>(result_.get())-> Append(Value::CreateStringValue(acceptLang)); } begin = end + 1; // 'begin >= acceptLanguages.length()' to guard against a value // ending with ','. - if (end == std::wstring::npos || begin >= acceptLanguages.length()) + if (end == string16::npos || begin >= acceptLanguages.length()) break; } if (static_cast<ListValue*>(result_.get())->GetSize() == 0) { diff --git a/chrome/browser/pref_service.cc b/chrome/browser/pref_service.cc index 96964e9..4535528 100644 --- a/chrome/browser/pref_service.cc +++ b/chrome/browser/pref_service.cc @@ -32,26 +32,26 @@ namespace { // the string value in the locale dll. Because we control the values in a // locale dll, this should always return a Value of the appropriate type. Value* CreateLocaleDefaultValue(Value::ValueType type, int message_id) { - std::wstring resource_string = l10n_util::GetString(message_id); + std::string resource_string = l10n_util::GetStringUTF8(message_id); DCHECK(!resource_string.empty()); switch (type) { case Value::TYPE_BOOLEAN: { - if (L"true" == resource_string) + if ("true" == resource_string) return Value::CreateBooleanValue(true); - if (L"false" == resource_string) + if ("false" == resource_string) return Value::CreateBooleanValue(false); break; } case Value::TYPE_INTEGER: { int val; - base::StringToInt(WideToUTF8(resource_string), &val); + base::StringToInt(resource_string, &val); return Value::CreateIntegerValue(val); } case Value::TYPE_REAL: { double val; - base::StringToDouble(WideToUTF8(resource_string), &val); + base::StringToDouble(resource_string, &val); return Value::CreateRealValue(val); } diff --git a/chrome/browser/pref_value_store_unittest.cc b/chrome/browser/pref_value_store_unittest.cc index 42033fb..0effd04 100644 --- a/chrome/browser/pref_value_store_unittest.cc +++ b/chrome/browser/pref_value_store_unittest.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. #include "base/scoped_ptr.h" -#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/chrome_thread.h" @@ -158,9 +157,9 @@ class PrefValueStoreTest : public testing::Test { DictionaryValue* CreateSampleDictValue() { DictionaryValue* sample_dict = new DictionaryValue(); - sample_dict->SetBoolean(L"issample", true); - sample_dict->SetInteger(L"value", 4); - sample_dict->SetString(L"descr", L"Sample Test Dictionary"); + sample_dict->SetBoolean("issample", true); + sample_dict->SetInteger("value", 4); + sample_dict->SetString("descr", "Sample Test Dictionary"); return sample_dict; } @@ -304,7 +303,7 @@ TEST_F(PrefValueStoreTest, SetUserPrefValue) { // Test that enforced values can not be set. ASSERT_TRUE(pref_value_store_->PrefValueInManagedStore(prefs::kHomepage)); // The Ownership is tranfered to |PrefValueStore|. - new_value = Value::CreateStringValue(L"http://www.youtube.com"); + new_value = Value::CreateStringValue("http://www.youtube.com"); pref_value_store_->SetUserPrefValue(prefs::kHomepage, new_value); ASSERT_TRUE(pref_value_store_->GetValue(prefs::kHomepage, &actual_value)); @@ -491,7 +490,7 @@ TEST_F(PrefValueStoreTest, TestRefreshPolicyPrefsCompletion) { // the test class are removed by the DummyStore scoped_ptr<DummyPrefStore> new_managed_store(new DummyPrefStore()); DictionaryValue* dict = new DictionaryValue(); - dict->SetString(L"homepage", L"some other changed homepage"); + dict->SetString("homepage", "some other changed homepage"); new_managed_store->set_prefs(dict); MockPolicyRefreshCallback callback; EXPECT_CALL(callback, DoCallback(expected_differing_paths_)).Times(1); @@ -516,7 +515,7 @@ TEST_F(PrefValueStoreTest, TestRefreshPolicyPrefsCompletion) { // Test properties that are added to the recommended store. scoped_ptr<DummyPrefStore> new_recommended_store(new DummyPrefStore()); dict = new DictionaryValue(); - dict->SetString(L"homepage", L"some other changed homepage 2"); + dict->SetString("homepage", "some other changed homepage 2"); new_recommended_store->set_prefs(dict); expected_differing_paths_.clear(); expected_differing_paths_.push_back(std::string("homepage")); diff --git a/chrome/renderer/dom_ui_bindings.cc b/chrome/renderer/dom_ui_bindings.cc index 229cb29..d5fb7c5 100644 --- a/chrome/renderer/dom_ui_bindings.cc +++ b/chrome/renderer/dom_ui_bindings.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. @@ -6,6 +6,7 @@ #include "base/json/json_writer.h" #include "base/stl_util-inl.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/common/render_messages.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" @@ -40,7 +41,8 @@ void DOMUIBindings::send(const CppArgumentList& args, CppVariant* result) { std::vector<std::wstring> strings = args[1].ToStringVector(); ListValue value; for (size_t i = 0; i < strings.size(); ++i) { - value.Append(Value::CreateStringValue(strings[i])); + // TODO(viettrungluu): remove conversion and utf_string_conversions.h + value.Append(Value::CreateStringValue(WideToUTF16Hack(strings[i]))); } base::JSONWriter::Write(&value, /* pretty_print= */ false, &content); } |