diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-29 22:10:13 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-29 22:10:13 +0000 |
commit | 1308ac961fdd5148ce95e228fe192175584a5464 (patch) | |
tree | 08f1e60a5b15a97aca4b24d1dd4e92e0dd1dc6ca /chrome/browser | |
parent | d546c48d90f0eaa592794f59e6a970b7b027db86 (diff) | |
download | chromium_src-1308ac961fdd5148ce95e228fe192175584a5464.zip chromium_src-1308ac961fdd5148ce95e228fe192175584a5464.tar.gz chromium_src-1308ac961fdd5148ce95e228fe192175584a5464.tar.bz2 |
Revert 70271 - Remove wstring from l10n_util. Part 3.
BUG=9911
TEST=no visible changes; all tests pass
Review URL: http://codereview.chromium.org/6044006
TBR=avi@chromium.org
Review URL: http://codereview.chromium.org/6051012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70281 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
27 files changed, 158 insertions, 200 deletions
diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc index 71a8f40..5f2d430 100644 --- a/chrome/browser/autocomplete/keyword_provider.cc +++ b/chrome/browser/autocomplete/keyword_provider.cc @@ -318,10 +318,9 @@ void KeywordProvider::FillInURLAndContents( if (element->url()->SupportsReplacement() && !element->IsExtensionKeyword()) { // No query input; return a generic, no-destination placeholder. - match->contents.assign(UTF16ToWideHack( - l10n_util::GetStringFUTF16(message_id, - WideToUTF16Hack(element->AdjustedShortNameForLocaleDirection()), - l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE)))); + match->contents.assign(l10n_util::GetStringF(message_id, + element->AdjustedShortNameForLocaleDirection(), + l10n_util::GetString(IDS_EMPTY_KEYWORD_VALUE))); match->contents_class.push_back( ACMatchClassification(0, ACMatchClassification::DIM)); } else { @@ -342,11 +341,10 @@ void KeywordProvider::FillInURLAndContents( *element, remaining_input, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); std::vector<size_t> content_param_offsets; - match->contents.assign(UTF16ToWideHack( - l10n_util::GetStringFUTF16(message_id, - WideToUTF16Hack(element->short_name()), - WideToUTF16Hack(remaining_input), - &content_param_offsets))); + match->contents.assign(l10n_util::GetStringF(message_id, + element->short_name(), + remaining_input, + &content_param_offsets)); if (content_param_offsets.size() == 2) { AutocompleteMatch::ClassifyLocationInString(content_param_offsets[1], remaining_input.length(), match->contents.length(), @@ -422,16 +420,15 @@ AutocompleteMatch KeywordProvider::CreateAutocompleteMatch( // Create popup entry description based on the keyword name. if (!element->IsExtensionKeyword()) { - result.description.assign(UTF16ToWideHack(l10n_util::GetStringFUTF16( - IDS_AUTOCOMPLETE_KEYWORD_DESCRIPTION, WideToUTF16Hack(keyword)))); - string16 keyword_desc( - l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_KEYWORD_DESCRIPTION)); - AutocompleteMatch::ClassifyLocationInString( - keyword_desc.find(ASCIIToUTF16("%s")), - prefix_length, - result.description.length(), - ACMatchClassification::DIM, - &result.description_class); + result.description.assign(l10n_util::GetStringF( + IDS_AUTOCOMPLETE_KEYWORD_DESCRIPTION, keyword)); + static const std::wstring kKeywordDesc( + l10n_util::GetString(IDS_AUTOCOMPLETE_KEYWORD_DESCRIPTION)); + AutocompleteMatch::ClassifyLocationInString(kKeywordDesc.find(L"%s"), + prefix_length, + result.description.length(), + ACMatchClassification::DIM, + &result.description_class); } return result; diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index ff49c8a..bd5a949 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -161,14 +161,12 @@ void SearchProvider::Start(const AutocompleteInput& input, if (default_provider) { AutocompleteMatch match; match.provider = this; - match.contents.assign(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE))); + match.contents.assign(l10n_util::GetString(IDS_EMPTY_KEYWORD_VALUE)); match.contents_class.push_back( ACMatchClassification(0, ACMatchClassification::NONE)); - match.description.assign(UTF16ToWideHack(l10n_util::GetStringFUTF16( + match.description.assign(l10n_util::GetStringF( IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, - WideToUTF16Hack( - default_provider->AdjustedShortNameForLocaleDirection())))); + default_provider->AdjustedShortNameForLocaleDirection())); match.description_class.push_back( ACMatchClassification(0, ACMatchClassification::DIM)); matches_.push_back(match); @@ -731,9 +729,9 @@ void SearchProvider::AddMatchToMap(const std::wstring& query_string, match.contents.assign(query_string); match.contents_class.push_back( ACMatchClassification(0, ACMatchClassification::NONE)); - match.description.assign(UTF16ToWideHack(l10n_util::GetStringFUTF16( + match.description.assign(l10n_util::GetStringF( IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, - WideToUTF16Hack(provider.AdjustedShortNameForLocaleDirection())))); + provider.AdjustedShortNameForLocaleDirection())); match.description_class.push_back( ACMatchClassification(0, ACMatchClassification::DIM)); } diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index b286711..ae52bac 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -65,18 +65,14 @@ std::wstring WindowCaptionFromPageTitle(std::wstring page_title) { #if defined(OS_MACOSX) || defined(OS_CHROMEOS) // On Mac or ChromeOS, we don't want to suffix the page title with // the application name. - if (page_title.empty()) { - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED)); - } + if (page_title.empty()) + return l10n_util::GetString(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); return page_title; #else if (page_title.empty()) - return UTF16ToWideHack(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); + return l10n_util::GetString(IDS_PRODUCT_NAME); - return UTF16ToWideHack( - l10n_util::GetStringFUTF16(IDS_BROWSER_WINDOW_TITLE_FORMAT, - WideToUTF16Hack(page_title))); + return l10n_util::GetStringF(IDS_BROWSER_WINDOW_TITLE_FORMAT, page_title); #endif } diff --git a/chrome/browser/custom_home_pages_table_model.cc b/chrome/browser/custom_home_pages_table_model.cc index 5ada027..f7c9a92 100644 --- a/chrome/browser/custom_home_pages_table_model.cc +++ b/chrome/browser/custom_home_pages_table_model.cc @@ -142,10 +142,9 @@ SkBitmap CustomHomePagesTableModel::GetIcon(int row) { } std::wstring CustomHomePagesTableModel::GetTooltip(int row) { - return entries_[row].title.empty() ? std::wstring() : UTF16ToWideHack( - l10n_util::GetStringFUTF16(IDS_OPTIONS_STARTUP_PAGE_TOOLTIP, - WideToUTF16Hack(entries_[row].title), - WideToUTF16Hack(FormattedURL(row)))); + return entries_[row].title.empty() ? std::wstring() : + l10n_util::GetStringF(IDS_OPTIONS_STARTUP_PAGE_TOOLTIP, + entries_[row].title, FormattedURL(row)); } void CustomHomePagesTableModel::SetObserver(TableModelObserver* observer) { diff --git a/chrome/browser/dom_ui/options/about_page_handler.cc b/chrome/browser/dom_ui/options/about_page_handler.cc index 666fb84..846c852 100644 --- a/chrome/browser/dom_ui/options/about_page_handler.cc +++ b/chrome/browser/dom_ui/options/about_page_handler.cc @@ -43,20 +43,20 @@ namespace { // These are used as placeholder text around the links in the text in the // license. -const char kBeginLink[] = "BEGIN_LINK"; -const char kEndLink[] = "END_LINK"; -const char kBeginLinkChr[] = "BEGIN_LINK_CHR"; -const char kBeginLinkOss[] = "BEGIN_LINK_OSS"; -const char kEndLinkChr[] = "END_LINK_CHR"; -const char kEndLinkOss[] = "END_LINK_OSS"; +const wchar_t kBeginLink[] = L"BEGIN_LINK"; +const wchar_t kEndLink[] = L"END_LINK"; +const wchar_t kBeginLinkChr[] = L"BEGIN_LINK_CHR"; +const wchar_t kBeginLinkOss[] = L"BEGIN_LINK_OSS"; +const wchar_t kEndLinkChr[] = L"END_LINK_CHR"; +const wchar_t kEndLinkOss[] = L"END_LINK_OSS"; #if defined(OS_CHROMEOS) -const char kBeginLinkCrosOss[] = "BEGIN_LINK_CROS_OSS"; -const char kEndLinkCrosOss[] = "END_LINK_CROS_OSS"; +const wchar_t kBeginLinkCrosOss[] = L"BEGIN_LINK_CROS_OSS"; +const wchar_t kEndLinkCrosOss[] = L"END_LINK_CROS_OSS"; #endif // Returns a substring [start, end) from |text|. -std::string StringSubRange(const std::string& text, size_t start, - size_t end) { +std::wstring StringSubRange(const std::wstring& text, size_t start, + size_t end) { DCHECK(end > start); return text.substr(start, end - start); } @@ -164,32 +164,34 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { // license - std::string text = l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_LICENSE); + std::wstring text = l10n_util::GetString(IDS_ABOUT_VERSION_LICENSE); bool chromium_url_appears_first = text.find(kBeginLinkChr) < text.find(kBeginLinkOss); size_t link1 = text.find(kBeginLink); - DCHECK(link1 != std::string::npos); + DCHECK(link1 != std::wstring::npos); size_t link1_end = text.find(kEndLink, link1); - DCHECK(link1_end != std::string::npos); + DCHECK(link1_end != std::wstring::npos); size_t link2 = text.find(kBeginLink, link1_end); - DCHECK(link2 != std::string::npos); + DCHECK(link2 != std::wstring::npos); size_t link2_end = text.find(kEndLink, link2); - DCHECK(link2_end != std::string::npos); + DCHECK(link2_end != std::wstring::npos); - localized_strings->SetString("license_content_0", text.substr(0, link1)); + localized_strings->SetString("license_content_0", + WideToUTF16Hack(text.substr(0, link1))); localized_strings->SetString("license_content_1", - StringSubRange(text, link1_end + strlen(kEndLinkOss), link2)); + WideToUTF16Hack(StringSubRange(text, link1_end + wcslen(kEndLinkOss), + link2))); localized_strings->SetString("license_content_2", - text.substr(link2_end + strlen(kEndLinkOss))); + WideToUTF16Hack(text.substr(link2_end + wcslen(kEndLinkOss)))); // The Chromium link within the main text of the dialog. localized_strings->SetString(chromium_url_appears_first ? "license_link_content_0" : "license_link_content_1", - StringSubRange(text, - text.find(kBeginLinkChr) + strlen(kBeginLinkChr), - text.find(kEndLinkChr))); + WideToUTF16Hack(StringSubRange(text, + text.find(kBeginLinkChr) + wcslen(kBeginLinkChr), + text.find(kEndLinkChr)))); localized_strings->SetString(chromium_url_appears_first ? "license_link_0" : "license_link_1", l10n_util::GetStringUTF16(IDS_CHROMIUM_PROJECT_URL)); @@ -199,28 +201,28 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { // rewritten to about:blank. localized_strings->SetString(chromium_url_appears_first ? "license_link_content_1" : "license_link_content_0", - StringSubRange(text, - text.find(kBeginLinkOss) + strlen(kBeginLinkOss), - text.find(kEndLinkOss))); + WideToUTF16Hack(StringSubRange(text, + text.find(kBeginLinkOss) + wcslen(kBeginLinkOss), + text.find(kEndLinkOss)))); localized_strings->SetString(chromium_url_appears_first ? "license_link_1" : "license_link_0", chrome::kChromeUIAboutCreditsURL); #if defined(OS_CHROMEOS) - std::string cros_text = - l10n_util::GetStringUTF8(IDS_ABOUT_CROS_VERSION_LICENSE); + std::wstring cros_text = l10n_util::GetString(IDS_ABOUT_CROS_VERSION_LICENSE); size_t cros_link = cros_text.find(kBeginLinkCrosOss); - DCHECK(cros_link != std::string::npos); + DCHECK(cros_link != std::wstring::npos); size_t cros_link_end = cros_text.find(kEndLinkCrosOss, cros_link); - DCHECK(cros_link_end != std::string::npos); + DCHECK(cros_link_end != std::wstring::npos); localized_strings->SetString("cros_license_content_0", - cros_text.substr(0, cros_link)); + WideToUTF16Hack(cros_text.substr(0, cros_link))); localized_strings->SetString("cros_license_content_1", - cros_text.substr(cros_link_end + strlen(kEndLinkCrosOss))); + WideToUTF16Hack( + cros_text.substr(cros_link_end + wcslen(kEndLinkCrosOss)))); localized_strings->SetString("cros_license_link_content_0", - StringSubRange(cros_text, cros_link + strlen(kBeginLinkCrosOss), - cros_link_end)); + WideToUTF16Hack(StringSubRange(cros_text, + cros_link + wcslen(kBeginLinkCrosOss), cros_link_end))); localized_strings->SetString("cros_license_link_0", chrome::kChromeUIAboutOSCreditsURL); #endif @@ -356,8 +358,9 @@ void AboutPageHandler::UpdateStatus( int progress = static_cast<int>(status.download_progress * 100.0); if (progress != progress_) { progress_ = progress; - message = l10n_util::GetStringFUTF16Int(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; } diff --git a/chrome/browser/extensions/extensions_startup.cc b/chrome/browser/extensions/extensions_startup.cc index c96d6ee..8e0b855 100644 --- a/chrome/browser/extensions/extensions_startup.cc +++ b/chrome/browser/extensions/extensions_startup.cc @@ -21,10 +21,9 @@ void ExtensionsStartupUtil::OnPackSuccess( const FilePath& crx_path, const FilePath& output_private_key_path) { pack_job_succeeded_ = true; - ShowPackExtensionMessage( - L"Extension Packaging Success", - UTF16ToWideHack(PackExtensionJob::StandardSuccessMessage( - crx_path, output_private_key_path))); + ShowPackExtensionMessage(L"Extension Packaging Success", + PackExtensionJob::StandardSuccessMessage( + crx_path, output_private_key_path)); } void ExtensionsStartupUtil::OnPackFailure(const std::string& error_message) { diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 3fcc861..5d3a05d 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -611,8 +611,8 @@ void ExtensionsDOMHandler::HandlePackMessage(const ListValue* args) { void ExtensionsDOMHandler::OnPackSuccess(const FilePath& crx_file, const FilePath& pem_file) { - ShowAlert(UTF16ToUTF8(PackExtensionJob::StandardSuccessMessage(crx_file, - pem_file))); + ShowAlert(WideToUTF8(PackExtensionJob::StandardSuccessMessage(crx_file, + pem_file))); ListValue results; dom_ui_->CallJavascriptFunction(L"hidePackDialog", results); diff --git a/chrome/browser/extensions/pack_extension_job.cc b/chrome/browser/extensions/pack_extension_job.cc index f4e2a03..327d7c4 100644 --- a/chrome/browser/extensions/pack_extension_job.cc +++ b/chrome/browser/extensions/pack_extension_job.cc @@ -6,7 +6,6 @@ #include "app/l10n_util.h" #include "base/message_loop.h" -#include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" #include "base/task.h" #include "chrome/browser/extensions/extension_creator.h" @@ -81,18 +80,20 @@ void PackExtensionJob::ReportFailureOnClientThread(const std::string& error) { } // static -string16 PackExtensionJob::StandardSuccessMessage(const FilePath& crx_file, - const FilePath& key_file) { - string16 crx_file_string = WideToUTF16(crx_file.ToWStringHack()); - string16 key_file_string = WideToUTF16(key_file.ToWStringHack()); - if (key_file_string.empty()) { - return l10n_util::GetStringFUTF16( +std::wstring PackExtensionJob::StandardSuccessMessage(const FilePath& crx_file, + const FilePath& key_file) +{ + // TODO(isherman): we should use string16 instead of wstring. + // See crbug.com/23581 and crbug.com/24672 + std::wstring message; + if (key_file.empty()) { + return l10n_util::GetStringF( IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_UPDATE, - crx_file_string); + crx_file.ToWStringHack()); } else { - return l10n_util::GetStringFUTF16( + return l10n_util::GetStringF( IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_NEW, - crx_file_string, - key_file_string); + crx_file.ToWStringHack(), + key_file.ToWStringHack()); } } diff --git a/chrome/browser/extensions/pack_extension_job.h b/chrome/browser/extensions/pack_extension_job.h index 6d4206d..e26687a 100644 --- a/chrome/browser/extensions/pack_extension_job.h +++ b/chrome/browser/extensions/pack_extension_job.h @@ -10,7 +10,6 @@ #include "base/file_path.h" #include "base/ref_counted.h" -#include "base/string16.h" #include "chrome/browser/browser_thread.h" @@ -42,8 +41,8 @@ class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> { void ClearClient(); // The standard packing success message. - static string16 StandardSuccessMessage(const FilePath& crx_file, - const FilePath& key_file); + static std::wstring StandardSuccessMessage(const FilePath& crx_file, + const FilePath& key_file); void set_asynchronous(bool async) { asynchronous_ = async; } diff --git a/chrome/browser/importer/importer_bridge.cc b/chrome/browser/importer/importer_bridge.cc index 588e365..f4fce91 100644 --- a/chrome/browser/importer/importer_bridge.cc +++ b/chrome/browser/importer/importer_bridge.cc @@ -117,7 +117,7 @@ void InProcessImporterBridge::NotifyEnded() { } std::wstring InProcessImporterBridge::GetLocalizedString(int message_id) { - return UTF16ToWideHack(l10n_util::GetStringUTF16(message_id)); + return l10n_util::GetString(message_id); } InProcessImporterBridge::~InProcessImporterBridge() {} diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc index 5579725..10e1101 100644 --- a/chrome/browser/importer/importer_list.cc +++ b/chrome/browser/importer/importer_list.cc @@ -51,8 +51,7 @@ void DetectSafariProfiles(std::vector<importer::ProfileInfo*>* profiles) { importer::ProfileInfo* safari = new importer::ProfileInfo(); safari->browser_type = importer::SAFARI; - safari->description = - UTF16ToWideHack(l10n_util::GetStringUTF16(IDS_IMPORT_FROM_SAFARI)); + safari->description = l10n_util::GetString(IDS_IMPORT_FROM_SAFARI); safari->source_path.clear(); safari->app_path.clear(); safari->services_supported = items; @@ -85,8 +84,7 @@ void DetectFirefoxProfiles(std::vector<importer::ProfileInfo*>* profiles) { } importer::ProfileInfo* firefox = new importer::ProfileInfo(); - firefox->description = - UTF16ToWideHack(l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX)); + firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX); firefox->browser_type = firefox_type; firefox->source_path = profile_path; #if defined(OS_WIN) @@ -107,8 +105,8 @@ void DetectGoogleToolbarProfiles( importer::ProfileInfo* google_toolbar = new importer::ProfileInfo(); google_toolbar->browser_type = importer::GOOGLE_TOOLBAR5; - google_toolbar->description = UTF16ToWideHack(l10n_util::GetStringUTF16( - IDS_IMPORT_FROM_GOOGLE_TOOLBAR)); + google_toolbar->description = l10n_util::GetString( + IDS_IMPORT_FROM_GOOGLE_TOOLBAR); google_toolbar->source_path.clear(); google_toolbar->app_path.clear(); google_toolbar->services_supported = importer::FAVORITES; diff --git a/chrome/browser/notifications/notification_exceptions_table_model.cc b/chrome/browser/notifications/notification_exceptions_table_model.cc index da40c70..a3326f9 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model.cc +++ b/chrome/browser/notifications/notification_exceptions_table_model.cc @@ -7,7 +7,6 @@ #include "app/l10n_util.h" #include "app/table_model_observer.h" #include "base/auto_reset.h" -// TODO(avi): remove when conversions not needed any more #include "base/utf_string_conversions.h" #include "chrome/common/content_settings.h" #include "chrome/common/content_settings_helper.h" @@ -82,11 +81,9 @@ std::wstring NotificationExceptionsTableModel::GetText(int row, if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { switch (entry.setting) { case CONTENT_SETTING_ALLOW: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); + return l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON); case CONTENT_SETTING_BLOCK: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); + return l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON); default: break; } diff --git a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc index 4752a80..18a998b 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc +++ b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc @@ -5,7 +5,6 @@ #include "chrome/browser/notifications/notification_exceptions_table_model.h" #include "app/l10n_util.h" -#include "base/utf_string_conversions.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/renderer_host/test/test_render_view_host.h" #include "chrome/test/testing_profile.h" @@ -76,32 +75,27 @@ TEST_F(NotificationExceptionsTableModelTest, AlphabeticalOrder) { EXPECT_EQ(L"allowed.com", model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)), + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON), model_->GetText(0, IDS_EXCEPTIONS_ACTION_HEADER)); EXPECT_EQ(L"denied.com", model_->GetText(1, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)), + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON), model_->GetText(1, IDS_EXCEPTIONS_ACTION_HEADER)); EXPECT_EQ(L"denied2.com", model_->GetText(2, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)), + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON), model_->GetText(2, IDS_EXCEPTIONS_ACTION_HEADER)); EXPECT_EQ(L"e-allowed2.com", model_->GetText(3, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)), + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON), model_->GetText(3, IDS_EXCEPTIONS_ACTION_HEADER)); EXPECT_EQ(L"f-denied3.com", model_->GetText(4, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)), + EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON), model_->GetText(4, IDS_EXCEPTIONS_ACTION_HEADER)); } diff --git a/chrome/browser/omnibox_search_hint.cc b/chrome/browser/omnibox_search_hint.cc index 4822cc8..e06931a 100644 --- a/chrome/browser/omnibox_search_hint.cc +++ b/chrome/browser/omnibox_search_hint.cc @@ -9,8 +9,6 @@ #include "base/command_line.h" #include "base/metrics/histogram.h" #include "base/task.h" -// TODO(avi): remove when conversions not needed any more -#include "base/utf_string_conversions.h" #include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/autocomplete/autocomplete_edit.h" #include "chrome/browser/autocomplete/autocomplete_edit_view.h" @@ -185,8 +183,8 @@ void OmniboxSearchHint::ShowEnteringQuery() { GetLocationBar(); AutocompleteEditView* edit_view = location_bar->location_entry(); location_bar->FocusLocation(true); - edit_view->SetUserText(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_OMNIBOX_SEARCH_HINT_OMNIBOX_TEXT))); + edit_view->SetUserText( + l10n_util::GetString(IDS_OMNIBOX_SEARCH_HINT_OMNIBOX_TEXT)); edit_view->SelectAll(false); // Entering text in the autocomplete edit view triggers the suggestion popup // that we don't want to show in this case. diff --git a/chrome/browser/plugin_exceptions_table_model.cc b/chrome/browser/plugin_exceptions_table_model.cc index 0dc7c8b..5b2a2c1 100644 --- a/chrome/browser/plugin_exceptions_table_model.cc +++ b/chrome/browser/plugin_exceptions_table_model.cc @@ -87,11 +87,9 @@ std::wstring PluginExceptionsTableModel::GetText(int row, int column_id) { case IDS_EXCEPTIONS_ACTION_HEADER: switch (entry.setting) { case CONTENT_SETTING_ALLOW: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); + return l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON); case CONTENT_SETTING_BLOCK: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); + return l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON); default: NOTREACHED(); } diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc index d34d939..fddff26 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc @@ -170,8 +170,7 @@ void CloudPrintSetupFlow::OnCloseContents(TabContents* source, } std::wstring CloudPrintSetupFlow::GetDialogTitle() const { - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_CLOUD_PRINT_SETUP_DIALOG_TITLE)); + return l10n_util::GetString(IDS_CLOUD_PRINT_SETUP_DIALOG_TITLE); } bool CloudPrintSetupFlow::IsDialogModal() const { @@ -271,11 +270,10 @@ void CloudPrintSetupFlow::ShowGaiaFailed(const GoogleServiceAuthError& error) { void CloudPrintSetupFlow::ShowSetupDone() { setup_done_ = true; - string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); - std::wstring message = - UTF16ToWideHack(l10n_util::GetStringFUTF16(IDS_CLOUD_PRINT_SETUP_DONE, - product_name, - UTF8ToUTF16(login_))); + std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME); + std::wstring message = l10n_util::GetStringF(IDS_CLOUD_PRINT_SETUP_DONE, + product_name, + UTF8ToWide(login_)); std::wstring javascript = L"cloudprint.setMessage('" + message + L"');"; ExecuteJavascriptInIFrame(kDoneIframeXPath, javascript); diff --git a/chrome/browser/remoting/remoting_setup_flow.cc b/chrome/browser/remoting/remoting_setup_flow.cc index f46fac0..05c7590 100644 --- a/chrome/browser/remoting/remoting_setup_flow.cc +++ b/chrome/browser/remoting/remoting_setup_flow.cc @@ -165,9 +165,8 @@ void RemotingSetupFlow::OnCloseContents(TabContents* source, bool* out_close_dialog) { } -std::wstring RemotingSetupFlow::GetDialogTitle() const { - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_REMOTING_SETUP_DIALOG_TITLE)); +std::wstring RemotingSetupFlow::GetDialogTitle() const { + return l10n_util::GetString(IDS_REMOTING_SETUP_DIALOG_TITLE); } bool RemotingSetupFlow::IsDialogModal() const { diff --git a/chrome/browser/remoting/setup_flow.cc b/chrome/browser/remoting/setup_flow.cc index c6756bb..fe20b8d 100644 --- a/chrome/browser/remoting/setup_flow.cc +++ b/chrome/browser/remoting/setup_flow.cc @@ -155,9 +155,8 @@ void SetupFlow::OnCloseContents(TabContents* source, bool* out_close_dialog) { } -std::wstring SetupFlow::GetDialogTitle() const { - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_REMOTING_SETUP_DIALOG_TITLE)); +std::wstring SetupFlow::GetDialogTitle() const { + return l10n_util::GetString(IDS_REMOTING_SETUP_DIALOG_TITLE); } bool SetupFlow::IsDialogModal() const { diff --git a/chrome/browser/search_engines/template_url_table_model.cc b/chrome/browser/search_engines/template_url_table_model.cc index 0acbb37..6ab7794 100644 --- a/chrome/browser/search_engines/template_url_table_model.cc +++ b/chrome/browser/search_engines/template_url_table_model.cc @@ -188,12 +188,9 @@ std::wstring TemplateURLTableModel::GetText(int row, int col_id) { // since those should always be displayed LTR. Please refer to // http://crbug.com/6726 for more information. base::i18n::AdjustStringForLocaleDirection(&url_short_name); - if (template_url_model_->GetDefaultSearchProvider() == &url) { - return UTF16ToWideHack( - l10n_util::GetStringFUTF16(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, - WideToUTF16Hack(url_short_name))); - } - return url_short_name; + return (template_url_model_->GetDefaultSearchProvider() == &url) ? + l10n_util::GetStringF(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, + url_short_name) : url_short_name; } case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { @@ -226,14 +223,14 @@ TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() { Groups groups; Group search_engine_group; - search_engine_group.title = UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR)); + search_engine_group.title = + l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR); search_engine_group.id = kMainGroupID; groups.push_back(search_engine_group); Group other_group; - other_group.title = UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR)); + other_group.title = + l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR); other_group.id = kOtherGroupID; groups.push_back(other_group); diff --git a/chrome/browser/ssl/ssl_manager.cc b/chrome/browser/ssl/ssl_manager.cc index 597d3ca..f874cc0 100644 --- a/chrome/browser/ssl/ssl_manager.cc +++ b/chrome/browser/ssl/ssl_manager.cc @@ -95,18 +95,17 @@ bool SSLManager::DeserializeSecurityInfo(const std::string& state, } // static -string16 SSLManager::GetEVCertName(const net::X509Certificate& cert) { +std::wstring SSLManager::GetEVCertName(const net::X509Certificate& cert) { // EV are required to have an organization name and country. if (cert.subject().organization_names.empty() || cert.subject().country_name.empty()) { NOTREACHED(); - return string16(); + return std::wstring(); } - return l10n_util::GetStringFUTF16( - IDS_SECURE_CONNECTION_EV, - UTF8ToUTF16(cert.subject().organization_names[0]), - UTF8ToUTF16(cert.subject().country_name)); + return l10n_util::GetStringF(IDS_SECURE_CONNECTION_EV, + UTF8ToWide(cert.subject().organization_names[0]), + UTF8ToWide(cert.subject().country_name)); } SSLManager::SSLManager(NavigationController* controller) diff --git a/chrome/browser/ssl/ssl_manager.h b/chrome/browser/ssl/ssl_manager.h index c488c35..0c61596 100644 --- a/chrome/browser/ssl/ssl_manager.h +++ b/chrome/browser/ssl/ssl_manager.h @@ -10,7 +10,6 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" -#include "base/string16.h" #include "chrome/browser/ssl/ssl_policy_backend.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" @@ -67,7 +66,7 @@ class SSLManager : public NotificationObserver { int* connection_status); // Returns "<organization_name> [<country>]". - static string16 GetEVCertName(const net::X509Certificate& cert); + static std::wstring GetEVCertName(const net::X509Certificate& cert); // Construct an SSLManager for the specified tab. // If |delegate| is NULL, SSLPolicy::GetDefaultPolicy() is used. diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc index 3d24877..a6dd5ec 100644 --- a/chrome/browser/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -390,8 +390,7 @@ void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { } std::wstring SyncSetupFlow::GetDialogTitle() const { - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_SYNC_MY_BOOKMARKS_LABEL)); + return l10n_util::GetString(IDS_SYNC_MY_BOOKMARKS_LABEL); } bool SyncSetupFlow::IsDialogModal() const { diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 786e892..b944869 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc @@ -110,8 +110,8 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) { // Check that the third entry is a tab contents resource whose title starts // starts with "Tab:". ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); - string16 prefix = l10n_util::GetStringFUTF16( - IDS_TASK_MANAGER_TAB_PREFIX, string16()); + string16 prefix = WideToUTF16Hack(l10n_util::GetStringF( + IDS_TASK_MANAGER_TAB_PREFIX, L"")); ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); // Close the tab and verify that we notice. @@ -193,8 +193,8 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) { ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(2)); ASSERT_TRUE(model()->GetResourceTabContents(2) == NULL); ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); - string16 prefix = l10n_util::GetStringFUTF16( - IDS_TASK_MANAGER_EXTENSION_PREFIX, string16()); + string16 prefix = WideToUTF16Hack(l10n_util::GetStringF( + IDS_TASK_MANAGER_EXTENSION_PREFIX, L"")); ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); // Check that the fourth entry (page.html) is of type extension and has both @@ -233,8 +233,8 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(2)); ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); - string16 prefix = l10n_util::GetStringFUTF16( - IDS_TASK_MANAGER_APP_PREFIX, string16()); + string16 prefix = WideToUTF16Hack(l10n_util::GetStringF( + IDS_TASK_MANAGER_APP_PREFIX, L"")); ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); // Unload extension to avoid crash on Windows. diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc index 151d587..40a23b2 100644 --- a/chrome/browser/task_manager/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager/task_manager_resource_providers.cc @@ -171,11 +171,12 @@ TaskManager::Resource::Type TaskManagerTabContentsResource::GetType() const { std::wstring TaskManagerTabContentsResource::GetTitle() const { // Fall back on the URL if there's no title. - string16 tab_title = tab_contents_->GetTitle(); + std::wstring tab_title(UTF16ToWideHack(tab_contents_->GetTitle())); if (tab_title.empty()) { - tab_title = UTF8ToUTF16(tab_contents_->GetURL().spec()); + tab_title = UTF8ToWide(tab_contents_->GetURL().spec()); // Force URL to be LTR. - tab_title = base::i18n::GetDisplayStringInLTRDirectionality(tab_title); + tab_title = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( + WideToUTF16(tab_title))); } else { // Since the tab_title will be concatenated with // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to @@ -195,7 +196,7 @@ std::wstring TaskManagerTabContentsResource::GetTitle() const { extensions_service->IsInstalledApp(tab_contents_->GetURL()), tab_contents_->HostsExtension(), tab_contents_->profile()->IsOffTheRecord()); - return UTF16ToWideHack(l10n_util::GetStringFUTF16(message_id, tab_title)); + return l10n_util::GetStringF(message_id, tab_title); } SkBitmap TaskManagerTabContentsResource::GetIcon() const { @@ -414,16 +415,15 @@ TaskManagerBackgroundContentsResource::~TaskManagerBackgroundContentsResource( } std::wstring TaskManagerBackgroundContentsResource::GetTitle() const { - string16 title = WideToUTF16Hack(application_name_); + std::wstring title = application_name_; if (title.empty()) { // No title (can't locate the parent app for some reason) so just display // the URL (properly forced to be LTR). - title = base::i18n::GetDisplayStringInLTRDirectionality( - UTF8ToUTF16(background_contents_->GetURL().spec())); + title = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( + UTF8ToUTF16(background_contents_->GetURL().spec()))); } - return UTF16ToWideHack( - l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title)); + return l10n_util::GetStringF(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title); } @@ -881,13 +881,12 @@ TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource( } process_handle_ = extension_host_->render_process_host()->GetHandle(); pid_ = base::GetProcId(process_handle_); - string16 extension_name = UTF8ToUTF16(GetExtension()->name()); + std::wstring extension_name(UTF8ToWide(GetExtension()->name())); DCHECK(!extension_name.empty()); int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, extension_host_->profile()->IsOffTheRecord()); - title_ = UTF16ToWideHack(l10n_util::GetStringFUTF16(message_id, - extension_name)); + title_ = l10n_util::GetStringF(message_id, extension_name); } TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { @@ -1264,8 +1263,7 @@ TaskManagerBrowserProcessResource::~TaskManagerBrowserProcessResource() { // TaskManagerResource methods: std::wstring TaskManagerBrowserProcessResource::GetTitle() const { if (title_.empty()) { - title_ = UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT)); + title_ = l10n_util::GetString(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT); } return title_; } diff --git a/chrome/browser/ui/app_modal_dialogs/message_box_handler.cc b/chrome/browser/ui/app_modal_dialogs/message_box_handler.cc index bdf7d42..a486abb 100644 --- a/chrome/browser/ui/app_modal_dialogs/message_box_handler.cc +++ b/chrome/browser/ui/app_modal_dialogs/message_box_handler.cc @@ -33,15 +33,15 @@ static std::wstring GetTitle(Profile* profile, extension = extensions_service->GetExtensionByWebExtent(frame_url); if (extension && (extension->location() == Extension::COMPONENT)) { - return UTF16ToWideHack(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); + return l10n_util::GetString(IDS_PRODUCT_NAME); } else if (extension && !extension->name().empty()) { return UTF8ToWide(extension->name()); } } if (!frame_url.has_host()) { - return UTF16ToWideHack(l10n_util::GetStringUTF16( + return l10n_util::GetString( is_alert ? IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE - : IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE)); + : IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); } // TODO(brettw) it should be easier than this to do the correct language @@ -78,16 +78,11 @@ void RunJavascriptMessageBox(Profile* profile, void RunBeforeUnloadDialog(TabContents* tab_contents, const std::wstring& message_text, IPC::Message* reply_msg) { - std::wstring full_message = message_text + L"\n\n" + UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER)); + std::wstring full_message = + message_text + L"\n\n" + + l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( - tab_contents, - UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE)), - MessageBoxFlags::kIsJavascriptConfirm, - message_text, - std::wstring(), - false, - true, - reply_msg)); + tab_contents, l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE), + MessageBoxFlags::kIsJavascriptConfirm, message_text, std::wstring(), + false, true, reply_msg)); } diff --git a/chrome/browser/ui/login/login_prompt.cc b/chrome/browser/ui/login/login_prompt.cc index 40cc66a..d653457 100644 --- a/chrome/browser/ui/login/login_prompt.cc +++ b/chrome/browser/ui/login/login_prompt.cc @@ -385,16 +385,14 @@ class LoginDialogTask : public Task { password_manager->PasswordFormsFound(v); handler_->SetPasswordManager(password_manager); - string16 host_and_port_hack16 = WideToUTF16Hack(auth_info_->host_and_port); - string16 realm_hack16 = WideToUTF16Hack(auth_info_->realm); - string16 explanation = realm_hack16.empty() ? - l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION_NO_REALM, - host_and_port_hack16) : - l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION, - host_and_port_hack16, - realm_hack16); + std::wstring explanation = auth_info_->realm.empty() ? + l10n_util::GetStringF(IDS_LOGIN_DIALOG_DESCRIPTION_NO_REALM, + auth_info_->host_and_port) : + l10n_util::GetStringF(IDS_LOGIN_DIALOG_DESCRIPTION, + auth_info_->host_and_port, + auth_info_->realm); handler_->BuildViewForPasswordManager(password_manager, - UTF16ToWideHack(explanation)); + explanation); } private: diff --git a/chrome/browser/ui/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model.cc index 98c392a..5a6a97c 100644 --- a/chrome/browser/ui/toolbar/toolbar_model.cc +++ b/chrome/browser/ui/toolbar/toolbar_model.cc @@ -117,7 +117,7 @@ std::wstring ToolbarModel::GetEVCertName() const { // the security level would be NONE. CertStore::GetInstance()->RetrieveCert( GetNavigationController()->GetActiveEntry()->ssl().cert_id(), &cert); - return UTF16ToWideHack(SSLManager::GetEVCertName(*cert)); + return SSLManager::GetEVCertName(*cert); } NavigationController* ToolbarModel::GetNavigationController() const { |