diff options
Diffstat (limited to 'chrome/browser')
27 files changed, 200 insertions, 158 deletions
diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc index 5f2d430..71a8f40 100644 --- a/chrome/browser/autocomplete/keyword_provider.cc +++ b/chrome/browser/autocomplete/keyword_provider.cc @@ -318,9 +318,10 @@ void KeywordProvider::FillInURLAndContents( if (element->url()->SupportsReplacement() && !element->IsExtensionKeyword()) { // No query input; return a generic, no-destination placeholder. - match->contents.assign(l10n_util::GetStringF(message_id, - element->AdjustedShortNameForLocaleDirection(), - l10n_util::GetString(IDS_EMPTY_KEYWORD_VALUE))); + match->contents.assign(UTF16ToWideHack( + l10n_util::GetStringFUTF16(message_id, + WideToUTF16Hack(element->AdjustedShortNameForLocaleDirection()), + l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE)))); match->contents_class.push_back( ACMatchClassification(0, ACMatchClassification::DIM)); } else { @@ -341,10 +342,11 @@ void KeywordProvider::FillInURLAndContents( *element, remaining_input, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); std::vector<size_t> content_param_offsets; - match->contents.assign(l10n_util::GetStringF(message_id, - element->short_name(), - remaining_input, - &content_param_offsets)); + match->contents.assign(UTF16ToWideHack( + l10n_util::GetStringFUTF16(message_id, + WideToUTF16Hack(element->short_name()), + WideToUTF16Hack(remaining_input), + &content_param_offsets))); if (content_param_offsets.size() == 2) { AutocompleteMatch::ClassifyLocationInString(content_param_offsets[1], remaining_input.length(), match->contents.length(), @@ -420,15 +422,16 @@ AutocompleteMatch KeywordProvider::CreateAutocompleteMatch( // Create popup entry description based on the keyword name. if (!element->IsExtensionKeyword()) { - 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); + 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); } return result; diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index bd5a949..ff49c8a 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -161,12 +161,14 @@ void SearchProvider::Start(const AutocompleteInput& input, if (default_provider) { AutocompleteMatch match; match.provider = this; - match.contents.assign(l10n_util::GetString(IDS_EMPTY_KEYWORD_VALUE)); + match.contents.assign(UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE))); match.contents_class.push_back( ACMatchClassification(0, ACMatchClassification::NONE)); - match.description.assign(l10n_util::GetStringF( + match.description.assign(UTF16ToWideHack(l10n_util::GetStringFUTF16( IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, - default_provider->AdjustedShortNameForLocaleDirection())); + WideToUTF16Hack( + default_provider->AdjustedShortNameForLocaleDirection())))); match.description_class.push_back( ACMatchClassification(0, ACMatchClassification::DIM)); matches_.push_back(match); @@ -729,9 +731,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(l10n_util::GetStringF( + match.description.assign(UTF16ToWideHack(l10n_util::GetStringFUTF16( IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, - provider.AdjustedShortNameForLocaleDirection())); + WideToUTF16Hack(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 ae52bac..b286711 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -65,14 +65,18 @@ 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 l10n_util::GetString(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); + if (page_title.empty()) { + return UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED)); + } return page_title; #else if (page_title.empty()) - return l10n_util::GetString(IDS_PRODUCT_NAME); + return UTF16ToWideHack(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); - return l10n_util::GetStringF(IDS_BROWSER_WINDOW_TITLE_FORMAT, page_title); + return UTF16ToWideHack( + l10n_util::GetStringFUTF16(IDS_BROWSER_WINDOW_TITLE_FORMAT, + WideToUTF16Hack(page_title))); #endif } diff --git a/chrome/browser/custom_home_pages_table_model.cc b/chrome/browser/custom_home_pages_table_model.cc index f7c9a92..5ada027 100644 --- a/chrome/browser/custom_home_pages_table_model.cc +++ b/chrome/browser/custom_home_pages_table_model.cc @@ -142,9 +142,10 @@ SkBitmap CustomHomePagesTableModel::GetIcon(int row) { } std::wstring CustomHomePagesTableModel::GetTooltip(int row) { - return entries_[row].title.empty() ? std::wstring() : - l10n_util::GetStringF(IDS_OPTIONS_STARTUP_PAGE_TOOLTIP, - entries_[row].title, FormattedURL(row)); + return entries_[row].title.empty() ? std::wstring() : UTF16ToWideHack( + l10n_util::GetStringFUTF16(IDS_OPTIONS_STARTUP_PAGE_TOOLTIP, + WideToUTF16Hack(entries_[row].title), + WideToUTF16Hack(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 846c852..666fb84 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 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"; +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"; #if defined(OS_CHROMEOS) -const wchar_t kBeginLinkCrosOss[] = L"BEGIN_LINK_CROS_OSS"; -const wchar_t kEndLinkCrosOss[] = L"END_LINK_CROS_OSS"; +const char kBeginLinkCrosOss[] = "BEGIN_LINK_CROS_OSS"; +const char kEndLinkCrosOss[] = "END_LINK_CROS_OSS"; #endif // Returns a substring [start, end) from |text|. -std::wstring StringSubRange(const std::wstring& text, size_t start, - size_t end) { +std::string StringSubRange(const std::string& text, size_t start, + size_t end) { DCHECK(end > start); return text.substr(start, end - start); } @@ -164,34 +164,32 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { // license - std::wstring text = l10n_util::GetString(IDS_ABOUT_VERSION_LICENSE); + std::string text = l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_LICENSE); bool chromium_url_appears_first = text.find(kBeginLinkChr) < text.find(kBeginLinkOss); size_t link1 = text.find(kBeginLink); - DCHECK(link1 != std::wstring::npos); + DCHECK(link1 != std::string::npos); size_t link1_end = text.find(kEndLink, link1); - DCHECK(link1_end != std::wstring::npos); + DCHECK(link1_end != std::string::npos); size_t link2 = text.find(kBeginLink, link1_end); - DCHECK(link2 != std::wstring::npos); + DCHECK(link2 != std::string::npos); size_t link2_end = text.find(kEndLink, link2); - DCHECK(link2_end != std::wstring::npos); + DCHECK(link2_end != std::string::npos); - localized_strings->SetString("license_content_0", - WideToUTF16Hack(text.substr(0, link1))); + localized_strings->SetString("license_content_0", text.substr(0, link1)); localized_strings->SetString("license_content_1", - WideToUTF16Hack(StringSubRange(text, link1_end + wcslen(kEndLinkOss), - link2))); + StringSubRange(text, link1_end + strlen(kEndLinkOss), link2)); localized_strings->SetString("license_content_2", - WideToUTF16Hack(text.substr(link2_end + wcslen(kEndLinkOss)))); + text.substr(link2_end + strlen(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", - WideToUTF16Hack(StringSubRange(text, - text.find(kBeginLinkChr) + wcslen(kBeginLinkChr), - text.find(kEndLinkChr)))); + StringSubRange(text, + text.find(kBeginLinkChr) + strlen(kBeginLinkChr), + text.find(kEndLinkChr))); localized_strings->SetString(chromium_url_appears_first ? "license_link_0" : "license_link_1", l10n_util::GetStringUTF16(IDS_CHROMIUM_PROJECT_URL)); @@ -201,28 +199,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", - WideToUTF16Hack(StringSubRange(text, - text.find(kBeginLinkOss) + wcslen(kBeginLinkOss), - text.find(kEndLinkOss)))); + StringSubRange(text, + text.find(kBeginLinkOss) + strlen(kBeginLinkOss), + text.find(kEndLinkOss))); localized_strings->SetString(chromium_url_appears_first ? "license_link_1" : "license_link_0", chrome::kChromeUIAboutCreditsURL); #if defined(OS_CHROMEOS) - std::wstring cros_text = l10n_util::GetString(IDS_ABOUT_CROS_VERSION_LICENSE); + std::string cros_text = + l10n_util::GetStringUTF8(IDS_ABOUT_CROS_VERSION_LICENSE); size_t cros_link = cros_text.find(kBeginLinkCrosOss); - DCHECK(cros_link != std::wstring::npos); + DCHECK(cros_link != std::string::npos); size_t cros_link_end = cros_text.find(kEndLinkCrosOss, cros_link); - DCHECK(cros_link_end != std::wstring::npos); + DCHECK(cros_link_end != std::string::npos); localized_strings->SetString("cros_license_content_0", - WideToUTF16Hack(cros_text.substr(0, cros_link))); + cros_text.substr(0, cros_link)); localized_strings->SetString("cros_license_content_1", - WideToUTF16Hack( - cros_text.substr(cros_link_end + wcslen(kEndLinkCrosOss)))); + cros_text.substr(cros_link_end + strlen(kEndLinkCrosOss))); localized_strings->SetString("cros_license_link_content_0", - WideToUTF16Hack(StringSubRange(cros_text, - cros_link + wcslen(kBeginLinkCrosOss), cros_link_end))); + StringSubRange(cros_text, cros_link + strlen(kBeginLinkCrosOss), + cros_link_end)); localized_strings->SetString("cros_license_link_0", chrome::kChromeUIAboutOSCreditsURL); #endif @@ -358,9 +356,8 @@ void AboutPageHandler::UpdateStatus( int progress = static_cast<int>(status.download_progress * 100.0); if (progress != progress_) { progress_ = progress; - // TODO(viettrungluu): need UTF-16 convenience form to eliminate hack. - message = WideToUTF16Hack( - l10n_util::GetStringF(IDS_UPDATE_DOWNLOADING, progress_)); + message = l10n_util::GetStringFUTF16Int(IDS_UPDATE_DOWNLOADING, + progress_); } started_ = true; } diff --git a/chrome/browser/extensions/extensions_startup.cc b/chrome/browser/extensions/extensions_startup.cc index 8e0b855..c96d6ee 100644 --- a/chrome/browser/extensions/extensions_startup.cc +++ b/chrome/browser/extensions/extensions_startup.cc @@ -21,9 +21,10 @@ void ExtensionsStartupUtil::OnPackSuccess( const FilePath& crx_path, const FilePath& output_private_key_path) { pack_job_succeeded_ = true; - ShowPackExtensionMessage(L"Extension Packaging Success", - PackExtensionJob::StandardSuccessMessage( - crx_path, output_private_key_path)); + ShowPackExtensionMessage( + L"Extension Packaging Success", + UTF16ToWideHack(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 5d3a05d..3fcc861 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(WideToUTF8(PackExtensionJob::StandardSuccessMessage(crx_file, - pem_file))); + ShowAlert(UTF16ToUTF8(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 327d7c4..f4e2a03 100644 --- a/chrome/browser/extensions/pack_extension_job.cc +++ b/chrome/browser/extensions/pack_extension_job.cc @@ -6,6 +6,7 @@ #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" @@ -80,20 +81,18 @@ void PackExtensionJob::ReportFailureOnClientThread(const std::string& error) { } // static -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( +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( IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_UPDATE, - crx_file.ToWStringHack()); + crx_file_string); } else { - return l10n_util::GetStringF( + return l10n_util::GetStringFUTF16( IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_NEW, - crx_file.ToWStringHack(), - key_file.ToWStringHack()); + crx_file_string, + key_file_string); } } diff --git a/chrome/browser/extensions/pack_extension_job.h b/chrome/browser/extensions/pack_extension_job.h index e26687a..6d4206d 100644 --- a/chrome/browser/extensions/pack_extension_job.h +++ b/chrome/browser/extensions/pack_extension_job.h @@ -10,6 +10,7 @@ #include "base/file_path.h" #include "base/ref_counted.h" +#include "base/string16.h" #include "chrome/browser/browser_thread.h" @@ -41,8 +42,8 @@ class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> { void ClearClient(); // The standard packing success message. - static std::wstring StandardSuccessMessage(const FilePath& crx_file, - const FilePath& key_file); + static string16 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 f4fce91..588e365 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 l10n_util::GetString(message_id); + return UTF16ToWideHack(l10n_util::GetStringUTF16(message_id)); } InProcessImporterBridge::~InProcessImporterBridge() {} diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc index 10e1101..5579725 100644 --- a/chrome/browser/importer/importer_list.cc +++ b/chrome/browser/importer/importer_list.cc @@ -51,7 +51,8 @@ void DetectSafariProfiles(std::vector<importer::ProfileInfo*>* profiles) { importer::ProfileInfo* safari = new importer::ProfileInfo(); safari->browser_type = importer::SAFARI; - safari->description = l10n_util::GetString(IDS_IMPORT_FROM_SAFARI); + safari->description = + UTF16ToWideHack(l10n_util::GetStringUTF16(IDS_IMPORT_FROM_SAFARI)); safari->source_path.clear(); safari->app_path.clear(); safari->services_supported = items; @@ -84,7 +85,8 @@ void DetectFirefoxProfiles(std::vector<importer::ProfileInfo*>* profiles) { } importer::ProfileInfo* firefox = new importer::ProfileInfo(); - firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX); + firefox->description = + UTF16ToWideHack(l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX)); firefox->browser_type = firefox_type; firefox->source_path = profile_path; #if defined(OS_WIN) @@ -105,8 +107,8 @@ void DetectGoogleToolbarProfiles( importer::ProfileInfo* google_toolbar = new importer::ProfileInfo(); google_toolbar->browser_type = importer::GOOGLE_TOOLBAR5; - google_toolbar->description = l10n_util::GetString( - IDS_IMPORT_FROM_GOOGLE_TOOLBAR); + google_toolbar->description = UTF16ToWideHack(l10n_util::GetStringUTF16( + 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 a3326f9..da40c70 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model.cc +++ b/chrome/browser/notifications/notification_exceptions_table_model.cc @@ -7,6 +7,7 @@ #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" @@ -81,9 +82,11 @@ std::wstring NotificationExceptionsTableModel::GetText(int row, if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { switch (entry.setting) { case CONTENT_SETTING_ALLOW: - return l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); case CONTENT_SETTING_BLOCK: - return l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(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 18a998b..4752a80 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc +++ b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc @@ -5,6 +5,7 @@ #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" @@ -75,27 +76,32 @@ TEST_F(NotificationExceptionsTableModelTest, AlphabeticalOrder) { EXPECT_EQ(L"allowed.com", model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON), + EXPECT_EQ(UTF16ToWideHack( + l10n_util::GetStringUTF16(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(l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON), + EXPECT_EQ(UTF16ToWideHack( + l10n_util::GetStringUTF16(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(l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON), + EXPECT_EQ(UTF16ToWideHack( + l10n_util::GetStringUTF16(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(l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON), + EXPECT_EQ(UTF16ToWideHack( + l10n_util::GetStringUTF16(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(l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON), + EXPECT_EQ(UTF16ToWideHack( + l10n_util::GetStringUTF16(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 e06931a..4822cc8 100644 --- a/chrome/browser/omnibox_search_hint.cc +++ b/chrome/browser/omnibox_search_hint.cc @@ -9,6 +9,8 @@ #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" @@ -183,8 +185,8 @@ void OmniboxSearchHint::ShowEnteringQuery() { GetLocationBar(); AutocompleteEditView* edit_view = location_bar->location_entry(); location_bar->FocusLocation(true); - edit_view->SetUserText( - l10n_util::GetString(IDS_OMNIBOX_SEARCH_HINT_OMNIBOX_TEXT)); + edit_view->SetUserText(UTF16ToWideHack( + l10n_util::GetStringUTF16(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 5b2a2c1..0dc7c8b 100644 --- a/chrome/browser/plugin_exceptions_table_model.cc +++ b/chrome/browser/plugin_exceptions_table_model.cc @@ -87,9 +87,11 @@ std::wstring PluginExceptionsTableModel::GetText(int row, int column_id) { case IDS_EXCEPTIONS_ACTION_HEADER: switch (entry.setting) { case CONTENT_SETTING_ALLOW: - return l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); case CONTENT_SETTING_BLOCK: - return l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(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 fddff26..d34d939 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc @@ -170,7 +170,8 @@ void CloudPrintSetupFlow::OnCloseContents(TabContents* source, } std::wstring CloudPrintSetupFlow::GetDialogTitle() const { - return l10n_util::GetString(IDS_CLOUD_PRINT_SETUP_DIALOG_TITLE); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_CLOUD_PRINT_SETUP_DIALOG_TITLE)); } bool CloudPrintSetupFlow::IsDialogModal() const { @@ -270,10 +271,11 @@ void CloudPrintSetupFlow::ShowGaiaFailed(const GoogleServiceAuthError& error) { void CloudPrintSetupFlow::ShowSetupDone() { setup_done_ = true; - 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_)); + 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 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 05c7590..f46fac0 100644 --- a/chrome/browser/remoting/remoting_setup_flow.cc +++ b/chrome/browser/remoting/remoting_setup_flow.cc @@ -165,8 +165,9 @@ void RemotingSetupFlow::OnCloseContents(TabContents* source, bool* out_close_dialog) { } -std::wstring RemotingSetupFlow::GetDialogTitle() const { - return l10n_util::GetString(IDS_REMOTING_SETUP_DIALOG_TITLE); +std::wstring RemotingSetupFlow::GetDialogTitle() const { + return UTF16ToWideHack( + l10n_util::GetStringUTF16(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 fe20b8d..c6756bb 100644 --- a/chrome/browser/remoting/setup_flow.cc +++ b/chrome/browser/remoting/setup_flow.cc @@ -155,8 +155,9 @@ void SetupFlow::OnCloseContents(TabContents* source, bool* out_close_dialog) { } -std::wstring SetupFlow::GetDialogTitle() const { - return l10n_util::GetString(IDS_REMOTING_SETUP_DIALOG_TITLE); +std::wstring SetupFlow::GetDialogTitle() const { + return UTF16ToWideHack( + l10n_util::GetStringUTF16(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 6ab7794..0acbb37 100644 --- a/chrome/browser/search_engines/template_url_table_model.cc +++ b/chrome/browser/search_engines/template_url_table_model.cc @@ -188,9 +188,12 @@ 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); - return (template_url_model_->GetDefaultSearchProvider() == &url) ? - l10n_util::GetStringF(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, - url_short_name) : 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; } case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { @@ -223,14 +226,14 @@ TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() { Groups groups; Group search_engine_group; - search_engine_group.title = - l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR); + search_engine_group.title = UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR)); search_engine_group.id = kMainGroupID; groups.push_back(search_engine_group); Group other_group; - other_group.title = - l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR); + other_group.title = UTF16ToWideHack( + l10n_util::GetStringUTF16(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 f874cc0..597d3ca 100644 --- a/chrome/browser/ssl/ssl_manager.cc +++ b/chrome/browser/ssl/ssl_manager.cc @@ -95,17 +95,18 @@ bool SSLManager::DeserializeSecurityInfo(const std::string& state, } // static -std::wstring SSLManager::GetEVCertName(const net::X509Certificate& cert) { +string16 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 std::wstring(); + return string16(); } - return l10n_util::GetStringF(IDS_SECURE_CONNECTION_EV, - UTF8ToWide(cert.subject().organization_names[0]), - UTF8ToWide(cert.subject().country_name)); + return l10n_util::GetStringFUTF16( + IDS_SECURE_CONNECTION_EV, + UTF8ToUTF16(cert.subject().organization_names[0]), + UTF8ToUTF16(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 0c61596..c488c35 100644 --- a/chrome/browser/ssl/ssl_manager.h +++ b/chrome/browser/ssl/ssl_manager.h @@ -10,6 +10,7 @@ #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" @@ -66,7 +67,7 @@ class SSLManager : public NotificationObserver { int* connection_status); // Returns "<organization_name> [<country>]". - static std::wstring GetEVCertName(const net::X509Certificate& cert); + static string16 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 a6dd5ec..3d24877 100644 --- a/chrome/browser/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -390,7 +390,8 @@ void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { } std::wstring SyncSetupFlow::GetDialogTitle() const { - return l10n_util::GetString(IDS_SYNC_MY_BOOKMARKS_LABEL); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(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 b944869..786e892 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 = WideToUTF16Hack(l10n_util::GetStringF( - IDS_TASK_MANAGER_TAB_PREFIX, L"")); + string16 prefix = l10n_util::GetStringFUTF16( + IDS_TASK_MANAGER_TAB_PREFIX, string16()); 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 = WideToUTF16Hack(l10n_util::GetStringF( - IDS_TASK_MANAGER_EXTENSION_PREFIX, L"")); + string16 prefix = l10n_util::GetStringFUTF16( + IDS_TASK_MANAGER_EXTENSION_PREFIX, string16()); 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 = WideToUTF16Hack(l10n_util::GetStringF( - IDS_TASK_MANAGER_APP_PREFIX, L"")); + string16 prefix = l10n_util::GetStringFUTF16( + IDS_TASK_MANAGER_APP_PREFIX, string16()); 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 40a23b2..151d587 100644 --- a/chrome/browser/task_manager/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager/task_manager_resource_providers.cc @@ -171,12 +171,11 @@ TaskManager::Resource::Type TaskManagerTabContentsResource::GetType() const { std::wstring TaskManagerTabContentsResource::GetTitle() const { // Fall back on the URL if there's no title. - std::wstring tab_title(UTF16ToWideHack(tab_contents_->GetTitle())); + string16 tab_title = tab_contents_->GetTitle(); if (tab_title.empty()) { - tab_title = UTF8ToWide(tab_contents_->GetURL().spec()); + tab_title = UTF8ToUTF16(tab_contents_->GetURL().spec()); // Force URL to be LTR. - tab_title = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( - WideToUTF16(tab_title))); + tab_title = base::i18n::GetDisplayStringInLTRDirectionality(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 @@ -196,7 +195,7 @@ std::wstring TaskManagerTabContentsResource::GetTitle() const { extensions_service->IsInstalledApp(tab_contents_->GetURL()), tab_contents_->HostsExtension(), tab_contents_->profile()->IsOffTheRecord()); - return l10n_util::GetStringF(message_id, tab_title); + return UTF16ToWideHack(l10n_util::GetStringFUTF16(message_id, tab_title)); } SkBitmap TaskManagerTabContentsResource::GetIcon() const { @@ -415,15 +414,16 @@ TaskManagerBackgroundContentsResource::~TaskManagerBackgroundContentsResource( } std::wstring TaskManagerBackgroundContentsResource::GetTitle() const { - std::wstring title = application_name_; + string16 title = WideToUTF16Hack(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 = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( - UTF8ToUTF16(background_contents_->GetURL().spec()))); + title = base::i18n::GetDisplayStringInLTRDirectionality( + UTF8ToUTF16(background_contents_->GetURL().spec())); } - return l10n_util::GetStringF(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title); + return UTF16ToWideHack( + l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, title)); } @@ -881,12 +881,13 @@ TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource( } process_handle_ = extension_host_->render_process_host()->GetHandle(); pid_ = base::GetProcId(process_handle_); - std::wstring extension_name(UTF8ToWide(GetExtension()->name())); + string16 extension_name = UTF8ToUTF16(GetExtension()->name()); DCHECK(!extension_name.empty()); int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, extension_host_->profile()->IsOffTheRecord()); - title_ = l10n_util::GetStringF(message_id, extension_name); + title_ = UTF16ToWideHack(l10n_util::GetStringFUTF16(message_id, + extension_name)); } TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { @@ -1263,7 +1264,8 @@ TaskManagerBrowserProcessResource::~TaskManagerBrowserProcessResource() { // TaskManagerResource methods: std::wstring TaskManagerBrowserProcessResource::GetTitle() const { if (title_.empty()) { - title_ = l10n_util::GetString(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT); + title_ = UTF16ToWideHack( + l10n_util::GetStringUTF16(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 a486abb..bdf7d42 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 l10n_util::GetString(IDS_PRODUCT_NAME); + return UTF16ToWideHack(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); } else if (extension && !extension->name().empty()) { return UTF8ToWide(extension->name()); } } if (!frame_url.has_host()) { - return l10n_util::GetString( + return UTF16ToWideHack(l10n_util::GetStringUTF16( 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,11 +78,16 @@ 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" + - l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); + std::wstring full_message = message_text + L"\n\n" + UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER)); AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( - tab_contents, l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE), - MessageBoxFlags::kIsJavascriptConfirm, message_text, std::wstring(), - false, true, reply_msg)); + tab_contents, + UTF16ToWideHack( + l10n_util::GetStringUTF16(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 d653457..40cc66a 100644 --- a/chrome/browser/ui/login/login_prompt.cc +++ b/chrome/browser/ui/login/login_prompt.cc @@ -385,14 +385,16 @@ class LoginDialogTask : public Task { password_manager->PasswordFormsFound(v); handler_->SetPasswordManager(password_manager); - 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); + 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); handler_->BuildViewForPasswordManager(password_manager, - explanation); + UTF16ToWideHack(explanation)); } private: diff --git a/chrome/browser/ui/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model.cc index 5a6a97c..98c392a 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 SSLManager::GetEVCertName(*cert); + return UTF16ToWideHack(SSLManager::GetEVCertName(*cert)); } NavigationController* ToolbarModel::GetNavigationController() const { |