diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-28 23:29:42 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-28 23:29:42 +0000 |
commit | 42197a2a59f7d74ab299dce1be5c7831c3bf49b0 (patch) | |
tree | bbeac88b36d834a55f0f01eb85326dc012e0f1fa /chrome/browser | |
parent | f61ba8cfb9b5ef812c131de7860433cd832a60ff (diff) | |
download | chromium_src-42197a2a59f7d74ab299dce1be5c7831c3bf49b0.zip chromium_src-42197a2a59f7d74ab299dce1be5c7831c3bf49b0.tar.gz chromium_src-42197a2a59f7d74ab299dce1be5c7831c3bf49b0.tar.bz2 |
Remove wstring from l10n_util. Part 2.
BUG=9911
TEST=no visible changes; all tests pass
Review URL: http://codereview.chromium.org/5959008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70242 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
24 files changed, 291 insertions, 264 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 6bb8ad2..dfbc3a6 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -958,18 +958,19 @@ void AutocompleteController::AddHistoryContentsShortcut() { if (history_contents_provider_->db_match_count() == history_contents_provider_->kMaxMatchCount) { // History contents searcher has maxed out. - match.contents = l10n_util::GetStringF(IDS_OMNIBOX_RECENT_HISTORY_MANY, - input_.text(), - &keyword_offset); + match.contents = UTF16ToWideHack( + l10n_util::GetStringFUTF16(IDS_OMNIBOX_RECENT_HISTORY_MANY, + WideToUTF16Hack(input_.text()), + &keyword_offset)); } else { // We can report exact matches when there aren't too many. std::vector<size_t> content_param_offsets; - match.contents = l10n_util::GetStringF( + match.contents = UTF16ToWideHack(l10n_util::GetStringFUTF16( IDS_OMNIBOX_RECENT_HISTORY, - UTF16ToWide(base::FormatNumber(history_contents_provider_-> - db_match_count())), - input_.text(), - &content_param_offsets); + base::FormatNumber(history_contents_provider_-> + db_match_count()), + WideToUTF16Hack(input_.text()), + &content_param_offsets)); // content_param_offsets is ordered based on supplied params, we expect // that the second one contains the query (first is the number). diff --git a/chrome/browser/content_exceptions_table_model.cc b/chrome/browser/content_exceptions_table_model.cc index ee92157..dad02b9 100644 --- a/chrome/browser/content_exceptions_table_model.cc +++ b/chrome/browser/content_exceptions_table_model.cc @@ -110,13 +110,17 @@ std::wstring ContentExceptionsTableModel::GetText(int row, int column_id) { case IDS_EXCEPTIONS_ACTION_HEADER: switch (entry.second) { 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)); case CONTENT_SETTING_ASK: - return l10n_util::GetString(IDS_EXCEPTIONS_ASK_BUTTON); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON)); case CONTENT_SETTING_SESSION_ONLY: - return l10n_util::GetString(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON)); default: NOTREACHED(); } diff --git a/chrome/browser/download/download_item_model.cc b/chrome/browser/download/download_item_model.cc index 48c75ad..68c1861 100644 --- a/chrome/browser/download/download_item_model.cc +++ b/chrome/browser/download/download_item_model.cc @@ -27,7 +27,7 @@ void DownloadItemModel::CancelTask() { download_->Cancel(true /* update history service */); } -std::wstring DownloadItemModel::GetStatusText() { +string16 DownloadItemModel::GetStatusText() { int64 size = download_->received_bytes(); int64 total = download_->total_bytes(); @@ -89,7 +89,7 @@ std::wstring DownloadItemModel::GetStatusText() { NOTREACHED(); } - return UTF16ToWideHack(status_text); + return status_text; } // ----------------------------------------------------------------------------- @@ -104,23 +104,23 @@ void SavePageModel::CancelTask() { save_->Cancel(true); } -std::wstring SavePageModel::GetStatusText() { +string16 SavePageModel::GetStatusText() { int64 size = download_->received_bytes(); int64 total_size = download_->total_bytes(); - std::wstring status_text; + string16 status_text; switch (download_->state()) { case DownloadItem::IN_PROGRESS: - status_text = l10n_util::GetStringF( + status_text = l10n_util::GetStringFUTF16( IDS_SAVE_PAGE_PROGRESS, - UTF16ToWide(base::FormatNumber(size)), - UTF16ToWide(base::FormatNumber(total_size))); + base::FormatNumber(size), + base::FormatNumber(total_size)); break; case DownloadItem::COMPLETE: - status_text = l10n_util::GetString(IDS_SAVE_PAGE_STATUS_COMPLETED); + status_text = l10n_util::GetStringUTF16(IDS_SAVE_PAGE_STATUS_COMPLETED); break; case DownloadItem::CANCELLED: - status_text = l10n_util::GetString(IDS_SAVE_PAGE_STATUS_CANCELED); + status_text = l10n_util::GetStringUTF16(IDS_SAVE_PAGE_STATUS_CANCELED); break; case DownloadItem::REMOVING: break; diff --git a/chrome/browser/download/download_item_model.h b/chrome/browser/download/download_item_model.h index f399489..d8327d3 100644 --- a/chrome/browser/download/download_item_model.h +++ b/chrome/browser/download/download_item_model.h @@ -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. @@ -9,6 +9,7 @@ #include <string> #include "base/basictypes.h" +#include "base/string16.h" class DownloadItem; class SavePackage; @@ -25,7 +26,7 @@ class BaseDownloadItemModel { virtual void CancelTask() = 0; // Get the status text to display. - virtual std::wstring GetStatusText() = 0; + virtual string16 GetStatusText() = 0; DownloadItem* download() { return download_; } @@ -45,7 +46,7 @@ class DownloadItemModel : public BaseDownloadItemModel { virtual void CancelTask(); // Get downloading status text. - virtual std::wstring GetStatusText(); + virtual string16 GetStatusText(); private: DISALLOW_COPY_AND_ASSIGN(DownloadItemModel); @@ -63,7 +64,7 @@ class SavePageModel : public BaseDownloadItemModel { virtual void CancelTask(); // Get page saving status text. - virtual std::wstring GetStatusText(); + virtual string16 GetStatusText(); private: // Saving page management. diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index c7babd3..1854d11 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -186,12 +186,14 @@ void GenerateFileName(const GURL& url, const std::string& referrer_charset, const std::string& mime_type, FilePath* generated_name) { - std::wstring default_name = - l10n_util::GetString(IDS_DEFAULT_DOWNLOAD_FILENAME); #if defined(OS_WIN) - FilePath default_file_path(default_name); + FilePath default_file_path( + l10n_util::GetStringUTF16(IDS_DEFAULT_DOWNLOAD_FILENAME)); #elif defined(OS_POSIX) - FilePath default_file_path(base::SysWideToNativeMB(default_name)); + std::string default_file = + l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); + FilePath default_file_path( + base::SysWideToNativeMB(base::SysUTF8ToWide(default_file))); #endif *generated_name = net::GetSuggestedFilename(GURL(url), @@ -511,7 +513,7 @@ DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) { } file_value->SetString("progress_status_text", - WideToUTF16Hack(GetProgressStatusText(download))); + GetProgressStatusText(download)); file_value->SetInteger("percent", static_cast<int>(download->PercentComplete())); @@ -533,13 +535,12 @@ DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) { return file_value; } -std::wstring GetProgressStatusText(DownloadItem* download) { +string16 GetProgressStatusText(DownloadItem* download) { int64 total = download->total_bytes(); int64 size = download->received_bytes(); DataUnits amount_units = GetByteDisplayUnits(size); - std::wstring received_size = UTF16ToWideHack(FormatBytes(size, amount_units, - true)); - std::wstring amount = received_size; + string16 received_size = FormatBytes(size, amount_units, true); + string16 amount = received_size; // Adjust both strings for the locale direction since we don't yet know which // string we'll end up using for constructing the final progress string. @@ -547,21 +548,19 @@ std::wstring GetProgressStatusText(DownloadItem* download) { if (total) { amount_units = GetByteDisplayUnits(total); - std::wstring total_text = - UTF16ToWideHack(FormatBytes(total, amount_units, true)); + string16 total_text = FormatBytes(total, amount_units, true); base::i18n::AdjustStringForLocaleDirection(&total_text); base::i18n::AdjustStringForLocaleDirection(&received_size); - amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, - received_size, - total_text); + amount = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, + received_size, + total_text); } else { amount.assign(received_size); } int64 current_speed = download->CurrentSpeed(); amount_units = GetByteDisplayUnits(current_speed); - std::wstring speed_text = UTF16ToWideHack(FormatSpeed(current_speed, - amount_units, true)); + string16 speed_text = FormatSpeed(current_speed, amount_units, true); base::i18n::AdjustStringForLocaleDirection(&speed_text); base::TimeDelta remaining; @@ -573,11 +572,11 @@ std::wstring GetProgressStatusText(DownloadItem* download) { if (time_remaining.empty()) { base::i18n::AdjustStringForLocaleDirection(&amount); - return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS_TIME_UNKNOWN, - speed_text, amount); + return l10n_util::GetStringFUTF16( + IDS_DOWNLOAD_TAB_PROGRESS_STATUS_TIME_UNKNOWN, speed_text, amount); } - return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS, speed_text, - amount, UTF16ToWideHack(time_remaining)); + return l10n_util::GetStringFUTF16(IDS_DOWNLOAD_TAB_PROGRESS_STATUS, + speed_text, amount, time_remaining); } #if !defined(OS_MACOSX) diff --git a/chrome/browser/download/download_util.h b/chrome/browser/download/download_util.h index 0a0bd90..c1013a3 100644 --- a/chrome/browser/download/download_util.h +++ b/chrome/browser/download/download_util.h @@ -12,6 +12,7 @@ #include "base/basictypes.h" #include "base/file_path.h" +#include "base/string16.h" #include "gfx/native_widget_types.h" #if defined(TOOLKIT_VIEWS) @@ -157,7 +158,7 @@ void DragDownload(const DownloadItem* download, DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id); // Get the localized status text for an in-progress download. -std::wstring GetProgressStatusText(DownloadItem* download); +string16 GetProgressStatusText(DownloadItem* download); // Update the application icon to indicate overall download progress. // |download_count| is the number of downloads currently in progress. If diff --git a/chrome/browser/geolocation/geolocation_exceptions_table_model.cc b/chrome/browser/geolocation/geolocation_exceptions_table_model.cc index 7095e53..731ac3f7 100644 --- a/chrome/browser/geolocation/geolocation_exceptions_table_model.cc +++ b/chrome/browser/geolocation/geolocation_exceptions_table_model.cc @@ -152,24 +152,29 @@ std::wstring GeolocationExceptionsTableModel::GetText(int row, // origin "embedded on any other site", so this row will never appear. If // we add the ability to add/edit exceptions, we'll need to decide when to // display this and how "removing" it will function. - return indent + - l10n_util::GetString(IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ANY_OTHER); + return indent + UTF16ToWideHack(l10n_util::GetStringUTF16( + IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ANY_OTHER)); } - return indent + l10n_util::GetStringF( + return indent + UTF16ToWideHack(l10n_util::GetStringFUTF16( IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST, - content_settings_helper::OriginToWString(entry.embedding_origin)); + WideToUTF16Hack( + content_settings_helper::OriginToWString(entry.embedding_origin)))); } 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)); case CONTENT_SETTING_ASK: - return l10n_util::GetString(IDS_EXCEPTIONS_ASK_BUTTON); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON)); case CONTENT_SETTING_DEFAULT: - return l10n_util::GetString(IDS_EXCEPTIONS_NOT_SET_BUTTON); + return UTF16ToWideHack( + l10n_util::GetStringUTF16(IDS_EXCEPTIONS_NOT_SET_BUTTON)); default: break; } diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc index 69f0484..84cfd63 100644 --- a/chrome/browser/gtk/download_item_gtk.cc +++ b/chrome/browser/gtk/download_item_gtk.cc @@ -401,10 +401,9 @@ void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) { return; } - std::wstring status_text = download_model_->GetStatusText(); - status_text_ = WideToUTF8(status_text); + status_text_ = UTF16ToUTF8(download_model_->GetStatusText()); // Remove the status text label. - if (status_text.empty()) { + if (status_text_.empty()) { gtk_widget_destroy(status_label_); return; } diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index d683d97..11dcfd8 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -58,13 +58,13 @@ static const char* const kLearnMoreMalwareUrl = static const char* const kLearnMorePhishingUrl = "http://www.google.com/support/bin/answer.py?answer=106318"; -static const wchar_t* const kSbDiagnosticHtml = - L"<a href=\"\" onclick=\"sendCommand('showDiagnostic'); return false;\" " - L"onmousedown=\"return false;\">%ls</a>"; +static const char* const kSbDiagnosticHtml = + "<a href=\"\" onclick=\"sendCommand('showDiagnostic'); return false;\" " + "onmousedown=\"return false;\">%s</a>"; -static const wchar_t* const kPLinkHtml = - L"<a href=\"\" onclick=\"sendCommand('proceed'); return false;\" " - L"onmousedown=\"return false;\">%ls</a>"; +static const char* const kPLinkHtml = + "<a href=\"\" onclick=\"sendCommand('proceed'); return false;\" " + "onmousedown=\"return false;\">%s</a>"; // The commands returned by the page when the user performs an action. static const char* const kShowDiagnosticCommand = "showDiagnostic"; @@ -175,16 +175,16 @@ std::string SafeBrowsingBlockingPage::GetHTMLContents() { void SafeBrowsingBlockingPage::PopulateStringDictionary( DictionaryValue* strings, - const std::wstring& title, - const std::wstring& headline, - const std::wstring& description1, - const std::wstring& description2, - const std::wstring& description3) { - strings->SetString("title", WideToUTF16Hack(title)); - strings->SetString("headLine", WideToUTF16Hack(headline)); - strings->SetString("description1", WideToUTF16Hack(description1)); - strings->SetString("description2", WideToUTF16Hack(description2)); - strings->SetString("description3", WideToUTF16Hack(description3)); + const string16& title, + const string16& headline, + const string16& description1, + const string16& description2, + const string16& description3) { + strings->SetString("title", title); + strings->SetString("headLine", headline); + strings->SetString("description1", description1); + strings->SetString("description2", description2); + strings->SetString("description3", description3); } void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( @@ -228,31 +228,34 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( PopulateStringDictionary( strings, // Use the malware headline, it is the scariest one. - l10n_util::GetString(IDS_SAFE_BROWSING_MULTI_THREAT_TITLE), - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_HEADLINE), - l10n_util::GetStringF(IDS_SAFE_BROWSING_MULTI_THREAT_DESCRIPTION1, - UTF8ToWide(tab()->GetURL().host())), - l10n_util::GetString(IDS_SAFE_BROWSING_MULTI_THREAT_DESCRIPTION2), - L""); + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MULTI_THREAT_TITLE), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE), + l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MULTI_THREAT_DESCRIPTION1, + UTF8ToUTF16(tab()->GetURL().host())), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MULTI_THREAT_DESCRIPTION2), + string16()); } else if (malware) { // Just malware. PopulateStringDictionary( strings, - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_TITLE), - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_HEADLINE), - l10n_util::GetStringF(IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION1, - UTF8ToWide(tab()->GetURL().host())), - l10n_util::GetString(IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION2), - l10n_util::GetString(IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION3)); + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_TITLE), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE), + l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION1, + UTF8ToUTF16(tab()->GetURL().host())), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION2), + l10n_util::GetStringUTF16( + IDS_SAFE_BROWSING_MULTI_MALWARE_DESCRIPTION3)); } else { // Just phishing. PopulateStringDictionary( strings, - l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_TITLE), - l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_HEADLINE), - l10n_util::GetStringF(IDS_SAFE_BROWSING_MULTI_PHISHING_DESCRIPTION1, - UTF8ToWide(tab()->GetURL().host())), - L"", L""); + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_TITLE), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_HEADLINE), + l10n_util::GetStringFUTF16( + IDS_SAFE_BROWSING_MULTI_PHISHING_DESCRIPTION1, + UTF8ToUTF16(tab()->GetURL().host())), + string16(), + string16()); } strings->SetString("confirm_text", @@ -268,41 +271,45 @@ void SafeBrowsingBlockingPage::PopulateMultipleThreatStringDictionary( void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( DictionaryValue* strings) { - std::wstring diagnostic_link = StringPrintf(kSbDiagnosticHtml, - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str()); + std::string diagnostic_link = StringPrintf(kSbDiagnosticHtml, + l10n_util::GetStringUTF8( + IDS_SAFE_BROWSING_MALWARE_DIAGNOSTIC_PAGE).c_str()); strings->SetString("badURL", url().host()); // Check to see if we're blocking the main page, or a sub-resource on the // main page. - std::wstring description1, description3, description5; + string16 description1, description3, description5; if (is_main_frame_) { - description1 = l10n_util::GetStringF(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION1, - UTF8ToWide(url().host())); + description1 = l10n_util::GetStringFUTF16( + IDS_SAFE_BROWSING_MALWARE_DESCRIPTION1, UTF8ToUTF16(url().host())); } else { - description1 = l10n_util::GetStringF(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION4, - UTF8ToWide(tab()->GetURL().host()), - UTF8ToWide(url().host())); + description1 = l10n_util::GetStringFUTF16( + IDS_SAFE_BROWSING_MALWARE_DESCRIPTION4, + UTF8ToUTF16(tab()->GetURL().host()), + UTF8ToUTF16(url().host())); } - std::wstring proceed_link = StringPrintf(kPLinkHtml, - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK).c_str()); - description3 = l10n_util::GetStringF(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3, - proceed_link); + std::string proceed_link = StringPrintf(kPLinkHtml, + l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK).c_str()); + description3 = + l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION3, + UTF8ToUTF16(proceed_link)); PopulateStringDictionary( strings, - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_TITLE), - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_HEADLINE), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_TITLE), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_HEADLINE), description1, - l10n_util::GetString(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION2), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION2), description3); - description5 = l10n_util::GetStringF(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION5, - UTF8ToWide(url().host()), - UTF8ToWide(url().host()), - diagnostic_link); + description5 = + l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_DESCRIPTION5, + UTF8ToUTF16(url().host()), + UTF8ToUTF16(url().host()), + UTF8ToUTF16(diagnostic_link)); - strings->SetString("description5", WideToUTF16Hack(description5)); + strings->SetString("description5", description5); strings->SetString("back_button", l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); @@ -313,20 +320,19 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary( DictionaryValue* strings) { - std::wstring proceed_link = StringPrintf( - kPLinkHtml, - l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_PROCEED_LINK).c_str()); - std::wstring description3 = l10n_util::GetStringF( + std::string proceed_link = StringPrintf(kPLinkHtml, l10n_util::GetStringUTF8( + IDS_SAFE_BROWSING_PHISHING_PROCEED_LINK).c_str()); + string16 description3 = l10n_util::GetStringFUTF16( IDS_SAFE_BROWSING_PHISHING_DESCRIPTION3, - proceed_link); + UTF8ToUTF16(proceed_link)); PopulateStringDictionary( strings, - l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_TITLE), - l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_HEADLINE), - l10n_util::GetStringF(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION1, - UTF8ToWide(url().host())), - l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION2), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_TITLE), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_HEADLINE), + l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION1, + UTF8ToUTF16(url().host())), + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION2), description3); strings->SetString("back_button", diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h index cfe2358..e06b23b 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h @@ -96,11 +96,11 @@ class SafeBrowsingBlockingPage : public InterstitialPage { // A helper method used by the Populate methods above used to populate common // fields. void PopulateStringDictionary(DictionaryValue* strings, - const std::wstring& title, - const std::wstring& headline, - const std::wstring& description1, - const std::wstring& description2, - const std::wstring& description3); + const string16& title, + const string16& headline, + const string16& description1, + const string16& description2, + const string16& description3); // Records a user action for this interstitial, using the form // SBInterstitial[Phishing|Malware|Multiple][Show|Proceed|DontProceed]. diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc index b2bf6a1..ebec519 100644 --- a/chrome/browser/ssl/ssl_blocking_page.cc +++ b/chrome/browser/ssl/ssl_blocking_page.cc @@ -68,8 +68,8 @@ std::string SSLBlockingPage::GetHTMLContents() { // Let's build the html error page. DictionaryValue strings; SSLErrorInfo error_info = delegate_->GetSSLErrorInfo(handler_); - strings.SetString("headLine", WideToUTF16Hack(error_info.title())); - strings.SetString("description", WideToUTF16Hack(error_info.details())); + strings.SetString("headLine", error_info.title()); + strings.SetString("description", error_info.details()); strings.SetString("moreInfoTitle", l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); @@ -158,14 +158,14 @@ void SSLBlockingPage::NotifyAllowCertificate() { // static void SSLBlockingPage::SetExtraInfo( DictionaryValue* strings, - const std::vector<std::wstring>& extra_info) { + const std::vector<string16>& extra_info) { DCHECK(extra_info.size() < 5); // We allow 5 paragraphs max. const char* keys[5] = { "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" }; int i; for (i = 0; i < static_cast<int>(extra_info.size()); i++) { - strings->SetString(keys[i], WideToUTF16Hack(extra_info[i])); + strings->SetString(keys[i], extra_info[i]); } for (; i < 5; i++) { strings->SetString(keys[i], ""); diff --git a/chrome/browser/ssl/ssl_blocking_page.h b/chrome/browser/ssl/ssl_blocking_page.h index 0e76152..9b6584d 100644 --- a/chrome/browser/ssl/ssl_blocking_page.h +++ b/chrome/browser/ssl/ssl_blocking_page.h @@ -7,7 +7,9 @@ #pragma once #include <string> +#include <vector> +#include "base/string16.h" #include "chrome/browser/ssl/ssl_error_info.h" #include "chrome/browser/tab_contents/interstitial_page.h" @@ -53,7 +55,7 @@ class SSLBlockingPage : public InterstitialPage { // ssl_error.html files. // Note: there can be up to 5 strings in |extra_info|. static void SetExtraInfo(DictionaryValue* strings, - const std::vector<std::wstring>& extra_info); + const std::vector<string16>& extra_info); protected: // InterstitialPage implementation. diff --git a/chrome/browser/ssl/ssl_error_info.cc b/chrome/browser/ssl/ssl_error_info.cc index b10e212..6769d88 100644 --- a/chrome/browser/ssl/ssl_error_info.cc +++ b/chrome/browser/ssl/ssl_error_info.cc @@ -15,10 +15,10 @@ #include "net/base/net_errors.h" #include "net/base/ssl_info.h" -SSLErrorInfo::SSLErrorInfo(const std::wstring& title, - const std::wstring& details, - const std::wstring& short_description, - const std::vector<std::wstring>& extra_info) +SSLErrorInfo::SSLErrorInfo(const string16& title, + const string16& details, + const string16& short_description, + const std::vector<string16>& extra_info) : title_(title), details_(details), short_description_(short_description), @@ -29,11 +29,12 @@ SSLErrorInfo::SSLErrorInfo(const std::wstring& title, SSLErrorInfo SSLErrorInfo::CreateError(ErrorType error_type, net::X509Certificate* cert, const GURL& request_url) { - std::wstring title, details, short_description; - std::vector<std::wstring> extra_info; + string16 title, details, short_description; + std::vector<string16> extra_info; switch (error_type) { case CERT_COMMON_NAME_INVALID: { - title = l10n_util::GetString(IDS_CERT_ERROR_COMMON_NAME_INVALID_TITLE); + title = + l10n_util::GetStringUTF16(IDS_CERT_ERROR_COMMON_NAME_INVALID_TITLE); // If the certificate contains multiple DNS names, we choose the most // representative one -- either the DNS name that's also in the subject // field, or the first one. If this heuristic turns out to be @@ -51,135 +52,138 @@ SSLErrorInfo SSLErrorInfo::CreateError(ErrorType error_type, if (i == dns_names.size()) i = 0; details = - l10n_util::GetStringF(IDS_CERT_ERROR_COMMON_NAME_INVALID_DETAILS, - UTF8ToWide(request_url.host()), - UTF8ToWide(dns_names[i]), - UTF8ToWide(request_url.host())); - short_description = - l10n_util::GetString(IDS_CERT_ERROR_COMMON_NAME_INVALID_DESCRIPTION); + l10n_util::GetStringFUTF16(IDS_CERT_ERROR_COMMON_NAME_INVALID_DETAILS, + UTF8ToUTF16(request_url.host()), + UTF8ToUTF16(dns_names[i]), + UTF8ToUTF16(request_url.host())); + short_description = l10n_util::GetStringUTF16( + IDS_CERT_ERROR_COMMON_NAME_INVALID_DESCRIPTION); extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_1)); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_1)); extra_info.push_back( - l10n_util::GetStringF( + l10n_util::GetStringFUTF16( IDS_CERT_ERROR_COMMON_NAME_INVALID_EXTRA_INFO_2, - UTF8ToWide(cert->subject().common_name), - UTF8ToWide(request_url.host()))); + UTF8ToUTF16(cert->subject().common_name), + UTF8ToUTF16(request_url.host()))); break; } case CERT_DATE_INVALID: extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_1)); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_1)); if (cert->HasExpired()) { - title = l10n_util::GetString(IDS_CERT_ERROR_EXPIRED_TITLE); - details = l10n_util::GetStringF(IDS_CERT_ERROR_EXPIRED_DETAILS, - UTF8ToWide(request_url.host()), - UTF8ToWide(request_url.host())); + title = l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXPIRED_TITLE); + details = l10n_util::GetStringFUTF16(IDS_CERT_ERROR_EXPIRED_DETAILS, + UTF8ToUTF16(request_url.host()), + UTF8ToUTF16(request_url.host())); short_description = - l10n_util::GetString(IDS_CERT_ERROR_EXPIRED_DESCRIPTION); - extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_EXPIRED_DETAILS_EXTRA_INFO_2)); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXPIRED_DESCRIPTION); + extra_info.push_back(l10n_util::GetStringUTF16( + IDS_CERT_ERROR_EXPIRED_DETAILS_EXTRA_INFO_2)); } else { // Then it must be not yet valid. We don't check that it is not yet // valid as there is still a very unlikely chance that the cert might // have become valid since the error occurred. - title = l10n_util::GetString(IDS_CERT_ERROR_NOT_YET_VALID_TITLE); - details = l10n_util::GetStringF(IDS_CERT_ERROR_NOT_YET_VALID_DETAILS, - UTF8ToWide(request_url.host()), - UTF8ToWide(request_url.host())); + title = l10n_util::GetStringUTF16(IDS_CERT_ERROR_NOT_YET_VALID_TITLE); + details = l10n_util::GetStringFUTF16( + IDS_CERT_ERROR_NOT_YET_VALID_DETAILS, + UTF8ToUTF16(request_url.host()), + UTF8ToUTF16(request_url.host())); short_description = - l10n_util::GetString(IDS_CERT_ERROR_NOT_YET_VALID_DESCRIPTION); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_NOT_YET_VALID_DESCRIPTION); extra_info.push_back( - l10n_util::GetString( + l10n_util::GetStringUTF16( IDS_CERT_ERROR_NOT_YET_VALID_DETAILS_EXTRA_INFO_2)); } break; case CERT_AUTHORITY_INVALID: - title = l10n_util::GetString(IDS_CERT_ERROR_AUTHORITY_INVALID_TITLE); - details = l10n_util::GetStringF(IDS_CERT_ERROR_AUTHORITY_INVALID_DETAILS, - UTF8ToWide(request_url.host())); - short_description = - l10n_util::GetString(IDS_CERT_ERROR_AUTHORITY_INVALID_DESCRIPTION); - extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_1)); - extra_info.push_back( - l10n_util::GetStringF(IDS_CERT_ERROR_AUTHORITY_INVALID_EXTRA_INFO_2, - UTF8ToWide(request_url.host()), - UTF8ToWide(request_url.host()))); + title = l10n_util::GetStringUTF16(IDS_CERT_ERROR_AUTHORITY_INVALID_TITLE); + details = l10n_util::GetStringFUTF16( + IDS_CERT_ERROR_AUTHORITY_INVALID_DETAILS, + UTF8ToUTF16(request_url.host())); + short_description = l10n_util::GetStringUTF16( + IDS_CERT_ERROR_AUTHORITY_INVALID_DESCRIPTION); extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_AUTHORITY_INVALID_EXTRA_INFO_3)); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_1)); + extra_info.push_back(l10n_util::GetStringFUTF16( + IDS_CERT_ERROR_AUTHORITY_INVALID_EXTRA_INFO_2, + UTF8ToUTF16(request_url.host()), + UTF8ToUTF16(request_url.host()))); + extra_info.push_back(l10n_util::GetStringUTF16( + IDS_CERT_ERROR_AUTHORITY_INVALID_EXTRA_INFO_3)); break; case CERT_CONTAINS_ERRORS: - title = l10n_util::GetString(IDS_CERT_ERROR_CONTAINS_ERRORS_TITLE); - details = l10n_util::GetStringF(IDS_CERT_ERROR_CONTAINS_ERRORS_DETAILS, - UTF8ToWide(request_url.host())); + title = l10n_util::GetStringUTF16(IDS_CERT_ERROR_CONTAINS_ERRORS_TITLE); + details = l10n_util::GetStringFUTF16( + IDS_CERT_ERROR_CONTAINS_ERRORS_DETAILS, + UTF8ToUTF16(request_url.host())); short_description = - l10n_util::GetString(IDS_CERT_ERROR_CONTAINS_ERRORS_DESCRIPTION); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_CONTAINS_ERRORS_DESCRIPTION); extra_info.push_back( - l10n_util::GetStringF(IDS_CERT_ERROR_EXTRA_INFO_1, - UTF8ToWide(request_url.host()))); - extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_CONTAINS_ERRORS_EXTRA_INFO_2)); + l10n_util::GetStringFUTF16(IDS_CERT_ERROR_EXTRA_INFO_1, + UTF8ToUTF16(request_url.host()))); + extra_info.push_back(l10n_util::GetStringUTF16( + IDS_CERT_ERROR_CONTAINS_ERRORS_EXTRA_INFO_2)); break; case CERT_NO_REVOCATION_MECHANISM: - title = - l10n_util::GetString(IDS_CERT_ERROR_NO_REVOCATION_MECHANISM_TITLE); - details = - l10n_util::GetString(IDS_CERT_ERROR_NO_REVOCATION_MECHANISM_DETAILS); - short_description = l10n_util::GetString( + title = l10n_util::GetStringUTF16( + IDS_CERT_ERROR_NO_REVOCATION_MECHANISM_TITLE); + details = l10n_util::GetStringUTF16( + IDS_CERT_ERROR_NO_REVOCATION_MECHANISM_DETAILS); + short_description = l10n_util::GetStringUTF16( IDS_CERT_ERROR_NO_REVOCATION_MECHANISM_DESCRIPTION); break; case CERT_UNABLE_TO_CHECK_REVOCATION: - title = - l10n_util::GetString(IDS_CERT_ERROR_UNABLE_TO_CHECK_REVOCATION_TITLE); - details = l10n_util::GetString( + title = l10n_util::GetStringUTF16( + IDS_CERT_ERROR_UNABLE_TO_CHECK_REVOCATION_TITLE); + details = l10n_util::GetStringUTF16( IDS_CERT_ERROR_UNABLE_TO_CHECK_REVOCATION_DETAILS); - short_description = l10n_util::GetString( + short_description = l10n_util::GetStringUTF16( IDS_CERT_ERROR_UNABLE_TO_CHECK_REVOCATION_DESCRIPTION); break; case CERT_REVOKED: - title = l10n_util::GetString(IDS_CERT_ERROR_REVOKED_CERT_TITLE); - details = l10n_util::GetStringF(IDS_CERT_ERROR_REVOKED_CERT_DETAILS, - UTF8ToWide(request_url.host())); + title = l10n_util::GetStringUTF16(IDS_CERT_ERROR_REVOKED_CERT_TITLE); + details = l10n_util::GetStringFUTF16(IDS_CERT_ERROR_REVOKED_CERT_DETAILS, + UTF8ToUTF16(request_url.host())); short_description = - l10n_util::GetString(IDS_CERT_ERROR_REVOKED_CERT_DESCRIPTION); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_REVOKED_CERT_DESCRIPTION); extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_1)); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_1)); extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_REVOKED_CERT_EXTRA_INFO_2)); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_REVOKED_CERT_EXTRA_INFO_2)); break; case CERT_INVALID: - title = l10n_util::GetString(IDS_CERT_ERROR_INVALID_CERT_TITLE); - details = l10n_util::GetString(IDS_CERT_ERROR_INVALID_CERT_DETAILS); + title = l10n_util::GetStringUTF16(IDS_CERT_ERROR_INVALID_CERT_TITLE); + details = l10n_util::GetStringUTF16(IDS_CERT_ERROR_INVALID_CERT_DETAILS); short_description = - l10n_util::GetString(IDS_CERT_ERROR_INVALID_CERT_DESCRIPTION); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_INVALID_CERT_DESCRIPTION); break; case CERT_WEAK_SIGNATURE_ALGORITHM: - title = - l10n_util::GetString(IDS_CERT_ERROR_WEAK_SIGNATURE_ALGORITHM_TITLE); - details = l10n_util::GetStringF( + title = l10n_util::GetStringUTF16( + IDS_CERT_ERROR_WEAK_SIGNATURE_ALGORITHM_TITLE); + details = l10n_util::GetStringFUTF16( IDS_CERT_ERROR_WEAK_SIGNATURE_ALGORITHM_DETAILS, - UTF8ToWide(request_url.host())); - short_description = l10n_util::GetString( + UTF8ToUTF16(request_url.host())); + short_description = l10n_util::GetStringUTF16( IDS_CERT_ERROR_WEAK_SIGNATURE_ALGORITHM_DESCRIPTION); extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_1)); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_1)); extra_info.push_back( - l10n_util::GetString( + l10n_util::GetStringUTF16( IDS_CERT_ERROR_WEAK_SIGNATURE_ALGORITHM_EXTRA_INFO_2)); break; case CERT_NOT_IN_DNS: - title = l10n_util::GetString(IDS_CERT_ERROR_NOT_IN_DNS_TITLE); - details = l10n_util::GetString(IDS_CERT_ERROR_NOT_IN_DNS_DETAILS); - short_description = l10n_util::GetString( + title = l10n_util::GetStringUTF16(IDS_CERT_ERROR_NOT_IN_DNS_TITLE); + details = l10n_util::GetStringUTF16(IDS_CERT_ERROR_NOT_IN_DNS_DETAILS); + short_description = l10n_util::GetStringUTF16( IDS_CERT_ERROR_NOT_IN_DNS_DESCRIPTION); extra_info.push_back( - l10n_util::GetString(IDS_CERT_ERROR_NOT_IN_DNS_EXTRA_INFO)); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_NOT_IN_DNS_EXTRA_INFO)); break; case UNKNOWN: - title = l10n_util::GetString(IDS_CERT_ERROR_UNKNOWN_ERROR_TITLE); - details = l10n_util::GetString(IDS_CERT_ERROR_UNKNOWN_ERROR_DETAILS); + title = l10n_util::GetStringUTF16(IDS_CERT_ERROR_UNKNOWN_ERROR_TITLE); + details = l10n_util::GetStringUTF16(IDS_CERT_ERROR_UNKNOWN_ERROR_DETAILS); short_description = - l10n_util::GetString(IDS_CERT_ERROR_UNKNOWN_ERROR_DESCRIPTION); + l10n_util::GetStringUTF16(IDS_CERT_ERROR_UNKNOWN_ERROR_DESCRIPTION); break; default: NOTREACHED(); diff --git a/chrome/browser/ssl/ssl_error_info.h b/chrome/browser/ssl/ssl_error_info.h index 225ccf6..ca87a0b4 100644 --- a/chrome/browser/ssl/ssl_error_info.h +++ b/chrome/browser/ssl/ssl_error_info.h @@ -9,6 +9,7 @@ #include <string> #include <vector> +#include "base/string16.h" #include "net/base/x509_certificate.h" class GURL; @@ -51,32 +52,32 @@ class SSLErrorInfo { std::vector<SSLErrorInfo>* errors); // A title describing the error, usually to be used with the details below. - const std::wstring& title() const { return title_; } + const string16& title() const { return title_; } // A description of the error. - const std::wstring& details() const { return details_; } + const string16& details() const { return details_; } // A short message describing the error (1 line). - const std::wstring& short_description() const { return short_description_; } + const string16& short_description() const { return short_description_; } // A lengthy explanation of what the error is. Each entry in the returned // vector is a paragraph. - const std::vector<std::wstring>& extra_information() const { + const std::vector<string16>& extra_information() const { return extra_information_; } private: - SSLErrorInfo(const std::wstring& title, - const std::wstring& details, - const std::wstring& short_description, - const std::vector<std::wstring>& extra_info); - - std::wstring title_; - std::wstring details_; - std::wstring short_description_; + SSLErrorInfo(const string16& title, + const string16& details, + const string16& short_description, + const std::vector<string16>& extra_info); + + string16 title_; + string16 details_; + string16 short_description_; // Extra-informations contains paragraphs of text explaining in details what // the error is and what the risks are. - std::vector<std::wstring> extra_information_; + std::vector<string16> extra_information_; }; #endif // CHROME_BROWSER_SSL_SSL_ERROR_INFO_H_ diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 3dba1a8..65e24e2 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -719,40 +719,41 @@ bool TabContents::ShouldDisplayFavIcon() { return true; } -std::wstring TabContents::GetStatusText() const { +string16 TabContents::GetStatusText() const { if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE) - return std::wstring(); + return string16(); switch (load_state_) { case net::LOAD_STATE_WAITING_FOR_CACHE: - return l10n_util::GetString(IDS_LOAD_STATE_WAITING_FOR_CACHE); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_WAITING_FOR_CACHE); case net::LOAD_STATE_ESTABLISHING_PROXY_TUNNEL: - return l10n_util::GetString(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); + return + l10n_util::GetStringUTF16(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); case net::LOAD_STATE_RESOLVING_PROXY_FOR_URL: - return l10n_util::GetString(IDS_LOAD_STATE_RESOLVING_PROXY_FOR_URL); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_PROXY_FOR_URL); case net::LOAD_STATE_RESOLVING_HOST: - return l10n_util::GetString(IDS_LOAD_STATE_RESOLVING_HOST); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_HOST); case net::LOAD_STATE_CONNECTING: - return l10n_util::GetString(IDS_LOAD_STATE_CONNECTING); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_CONNECTING); case net::LOAD_STATE_SSL_HANDSHAKE: - return l10n_util::GetString(IDS_LOAD_STATE_SSL_HANDSHAKE); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SSL_HANDSHAKE); case net::LOAD_STATE_SENDING_REQUEST: if (upload_size_) - return l10n_util::GetStringF( + return l10n_util::GetStringFUTF16Int( IDS_LOAD_STATE_SENDING_REQUEST_WITH_PROGRESS, static_cast<int>((100 * upload_position_) / upload_size_)); else - return l10n_util::GetString(IDS_LOAD_STATE_SENDING_REQUEST); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SENDING_REQUEST); case net::LOAD_STATE_WAITING_FOR_RESPONSE: - return l10n_util::GetStringF(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, - load_state_host_); + return l10n_util::GetStringFUTF16(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, + load_state_host_); // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE case net::LOAD_STATE_IDLE: case net::LOAD_STATE_READING_RESPONSE: break; } - return std::wstring(); + return string16(); } void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { @@ -3076,8 +3077,8 @@ void TabContents::LoadStateChanged(const GURL& url, std::wstring languages = UTF8ToWide(profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); std::string host = url.host(); - load_state_host_ = - net::IDNToUnicode(host.c_str(), host.size(), languages, NULL); + load_state_host_ = WideToUTF16Hack( + net::IDNToUnicode(host.c_str(), host.size(), languages, NULL)); if (load_state_ == net::LOAD_STATE_READING_RESPONSE) SetNotWaitingForResponse(); if (is_loading()) diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 3352200..a791cc1 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -14,6 +14,7 @@ #include "base/basictypes.h" #include "base/gtest_prod_util.h" #include "base/scoped_ptr.h" +#include "base/string16.h" #include "chrome/browser/dom_ui/dom_ui_factory.h" #include "chrome/browser/download/save_package.h" #include "chrome/browser/extensions/image_loading_tracker.h" @@ -260,7 +261,7 @@ class TabContents : public PageNavigator, virtual bool ShouldDisplayFavIcon(); // Returns a human-readable description the tab's loading state. - virtual std::wstring GetStatusText() const; + virtual string16 GetStatusText() const; // Add and remove observers for page navigation notifications. Adding or // removing multiple times has no effect. The order in which notifications @@ -1179,7 +1180,7 @@ class TabContents : public PageNavigator, // The current load state and the URL associated with it. net::LoadState load_state_; - std::wstring load_state_host_; + string16 load_state_host_; // Upload progress, for displaying in the status bar. // Set to zero when there is no significant upload happening. uint64 upload_size_; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index d2d831e..52a3b96 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2664,8 +2664,7 @@ void Browser::TabSelectedAt(TabContentsWrapper* old_contents, status_bubble->Hide(); // Show the loading state (if any). - status_bubble->SetStatus(WideToUTF16Hack( - GetSelectedTabContents()->GetStatusText())); + status_bubble->SetStatus(GetSelectedTabContents()->GetStatusText()); } if (HasFindBarController()) { @@ -2831,8 +2830,7 @@ void Browser::LoadingStateChanged(TabContents* source) { if (source == selected_contents) { UpdateReloadStopState(source->is_loading(), false); if (GetStatusBubble()) { - GetStatusBubble()->SetStatus(WideToUTF16( - GetSelectedTabContents()->GetStatusText())); + GetStatusBubble()->SetStatus(GetSelectedTabContents()->GetStatusText()); } if (!source->is_loading() && @@ -3787,7 +3785,7 @@ void Browser::ProcessPendingUIUpdates() { // Updating the URL happens synchronously in ScheduleUIUpdate. if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) - GetStatusBubble()->SetStatus(WideToUTF16(contents->GetStatusText())); + GetStatusBubble()->SetStatus(contents->GetStatusText()); if (flags & (TabContents::INVALIDATE_TAB | TabContents::INVALIDATE_TITLE)) { diff --git a/chrome/browser/ui/cocoa/download/download_item_cell.mm b/chrome/browser/ui/cocoa/download/download_item_cell.mm index b83d6f5..d2a8335 100644 --- a/chrome/browser/ui/cocoa/download/download_item_cell.mm +++ b/chrome/browser/ui/cocoa/download/download_item_cell.mm @@ -237,14 +237,14 @@ NSGradient* BackgroundTheme::GetNSGradient(int id) const { // Set the name of the download. downloadPath_ = downloadModel->download()->GetFileNameToReportUser(); - std::wstring statusText = downloadModel->GetStatusText(); + string16 statusText = downloadModel->GetStatusText(); if (statusText.empty()) { // Remove the status text label. [self hideSecondaryTitle]; isStatusTextVisible_ = NO; } else { // Set status text. - NSString* statusString = base::SysWideToNSString(statusText); + NSString* statusString = base::SysUTF16ToNSString(statusText); [self setSecondaryTitle:statusString]; isStatusTextVisible_ = YES; } diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm index 1598cad..845835a 100644 --- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm +++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm @@ -6,6 +6,7 @@ #include "app/resource_bundle.h" #include "base/scoped_nsobject.h" +#include "base/utf_string_conversions.h" #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" @@ -133,7 +134,7 @@ TEST_F(AutocompleteTextFieldCellTest, DISABLED_FocusedDisplay) { KeywordHintDecoration keyword_hint_decoration([view_ font]); keyword_hint_decoration.SetVisible(true); - keyword_hint_decoration.SetKeyword(std::wstring(L"google"), false); + keyword_hint_decoration.SetKeyword(ASCIIToUTF16("google"), false); [cell addRightDecoration:&keyword_hint_decoration]; EXPECT_NE(keyword_hint_decoration.GetWidthForSpace(kVeryWide), LocationBarDecoration::kOmittedWidth); diff --git a/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h b/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h index 3b8c607..da8c42b 100644 --- a/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h +++ b/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h @@ -11,6 +11,7 @@ #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" #import "base/scoped_nsobject.h" +#include "base/string16.h" // Draws the keyword hint, "Press [tab] to search <site>". @@ -21,7 +22,7 @@ class KeywordHintDecoration : public LocationBarDecoration { // Calculates the message to display and where to place the [tab] // image. - void SetKeyword(const std::wstring& keyword, bool is_extension_keyword); + void SetKeyword(const string16& keyword, bool is_extension_keyword); // Implement |LocationBarDecoration|. virtual void DrawInFrame(NSRect frame, NSView* control_view); diff --git a/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm b/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm index 0b080319..767092b 100644 --- a/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm +++ b/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.mm @@ -34,10 +34,10 @@ const CGFloat kHintAvailableRatio = 2.0 / 3.0; // Helper to convert |s| to an |NSString|, trimming whitespace at // ends. -NSString* TrimAndConvert(const std::wstring& s) { - std::wstring output; +NSString* TrimAndConvert(const string16& s) { + string16 output; TrimWhitespace(s, TRIM_ALL, &output); - return base::SysWideToNSString(output); + return base::SysUTF16ToNSString(output); } } // namespace @@ -65,7 +65,7 @@ NSImage* KeywordHintDecoration::GetHintImage() { return hint_image_; } -void KeywordHintDecoration::SetKeyword(const std::wstring& short_name, +void KeywordHintDecoration::SetKeyword(const string16& short_name, bool is_extension_keyword) { // KEYWORD_HINT is a message like "Press [tab] to search <site>". // [tab] is a parameter to be replaced by an image. "<site>" is @@ -73,10 +73,10 @@ void KeywordHintDecoration::SetKeyword(const std::wstring& short_name, std::vector<size_t> content_param_offsets; int message_id = is_extension_keyword ? IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; - const std::wstring keyword_hint( - l10n_util::GetStringF(message_id, - std::wstring(), short_name, - &content_param_offsets)); + const string16 keyword_hint( + l10n_util::GetStringFUTF16(message_id, + string16(), short_name, + &content_param_offsets)); // Should always be 2 offsets, see the comment in // location_bar_view.cc after IDS_OMNIBOX_KEYWORD_HINT fetch. diff --git a/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration_unittest.mm b/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration_unittest.mm index bfcf454..12ac5d8 100644 --- a/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration_unittest.mm +++ b/chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration_unittest.mm @@ -6,6 +6,7 @@ #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" +#include "base/utf_string_conversions.h" #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" #include "testing/gtest/include/gtest/gtest.h" @@ -22,7 +23,7 @@ class KeywordHintDecorationTest : public CocoaTest { TEST_F(KeywordHintDecorationTest, GetWidthForSpace) { decoration_.SetVisible(true); - decoration_.SetKeyword(std::wstring(L"Google"), false); + decoration_.SetKeyword(ASCIIToUTF16("google"), false); const CGFloat kVeryWide = 1000.0; const CGFloat kFairlyWide = 100.0; // Estimate for full hint space. diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm index d433822..32002e6 100644 --- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm +++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm @@ -680,7 +680,8 @@ void LocationBarViewMac::Layout() { std::wstring label(toolbar_model_->GetEVCertName()); ev_bubble_decoration_->SetFullLabel(base::SysWideToNSString(label)); } else if (!keyword.empty() && is_keyword_hint) { - keyword_hint_decoration_->SetKeyword(short_name, is_extension_keyword); + keyword_hint_decoration_->SetKeyword(WideToUTF16Hack(short_name), + is_extension_keyword); keyword_hint_decoration_->SetVisible(true); } diff --git a/chrome/browser/ui/views/download_item_view.cc b/chrome/browser/ui/views/download_item_view.cc index f6d022d..3ebdf44 100644 --- a/chrome/browser/ui/views/download_item_view.cc +++ b/chrome/browser/ui/views/download_item_view.cc @@ -353,7 +353,7 @@ void DownloadItemView::OnDownloadUpdated(DownloadItem* download) { ClearDangerousMode(); } - std::wstring status_text = model_->GetStatusText(); + string16 status_text = model_->GetStatusText(); switch (download_->state()) { case DownloadItem::IN_PROGRESS: download_->is_paused() ? StopDownloadProgress() : StartDownloadProgress(); @@ -384,7 +384,7 @@ void DownloadItemView::OnDownloadUpdated(DownloadItem* download) { NOTREACHED(); } - status_text_ = status_text; + status_text_ = UTF16ToWideHack(status_text); UpdateAccessibleName(); // We use the parent's (DownloadShelfView's) SchedulePaint, since there |