diff options
author | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-16 17:21:13 +0000 |
---|---|---|
committer | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-16 17:21:13 +0000 |
commit | 48c70517e3bb914c4157e27fb0d70492f4f76cbe (patch) | |
tree | a4f31a59aaf2f2133dacc5440b285b9e6070ae6b /chrome | |
parent | 873043ae174de16897b9c9ff84ecd0e4f07ae516 (diff) | |
download | chromium_src-48c70517e3bb914c4157e27fb0d70492f4f76cbe.zip chromium_src-48c70517e3bb914c4157e27fb0d70492f4f76cbe.tar.gz chromium_src-48c70517e3bb914c4157e27fb0d70492f4f76cbe.tar.bz2 |
This CL fixes issue 10860 - RTL: Hebrew file names should have forced LTR
directionality in download shelf.
File names in download shelf are forced to be LTR in DownloadItemView and
through ElideFileName().
BUG=http://crbug.com/10860
TEST=1. Open chrome with Hebrew UI.
2. Right click a link and chose Save As... (4th item from the top for
non-Hebrew
speakers)
3. In the save as dialog name the file קובץ.html
4. In the download shelf the filename should display as קובץ.html (not
html.קובץ)
Review URL: http://codereview.chromium.org/131001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26359 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/views/download_item_view.cc | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc index c704b67..9f4d310 100644 --- a/chrome/browser/views/download_item_view.cc +++ b/chrome/browser/views/download_item_view.cc @@ -303,9 +303,11 @@ DownloadItemView::DownloadItemView(DownloadItem* download, ElideString(extension, kFileNameMaxLength / 2, &extension); ElideString(rootname, kFileNameMaxLength - extension.length(), &rootname); + std::wstring filename = rootname + L"." + extension; + if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + l10n_util::WrapStringWithLTRFormatting(&filename); dangerous_download_label_ = new views::Label( - l10n_util::GetStringF(IDS_PROMPT_DANGEROUS_DOWNLOAD, - rootname + L"." + extension)); + l10n_util::GetStringF(IDS_PROMPT_DANGEROUS_DOWNLOAD, filename)); dangerous_download_label_->SetMultiLine(true); dangerous_download_label_->SetHorizontalAlignment( views::Label::ALIGN_LEFT); @@ -594,15 +596,18 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) { filename = gfx::ElideFilename(download_->GetFileName(), font_, kTextWidth); } else { - std::wstring tmp_name = - l10n_util::GetStringF(IDS_DOWNLOAD_STATUS_OPENING, - download_->GetFileName().ToWStringHack()); -#if defined(OS_WIN) - FilePath filepath(tmp_name); -#else - FilePath filepath(base::SysWideToNativeMB(tmp_name)); -#endif - filename = gfx::ElideFilename(filepath, font_, kTextWidth); + // First, Calculate the download status opening string width. + std::wstring empty_string; + std::wstring status_string = + l10n_util::GetStringF(IDS_DOWNLOAD_STATUS_OPENING, empty_string); + int status_string_width = font_.GetStringWidth(status_string); + // Then, elide the file name. + std::wstring filename_string = + gfx::ElideFilename(download_->GetFileName(), font_, + kTextWidth - status_string_width); + // Last, concat the whole string. + filename = l10n_util::GetStringF(IDS_DOWNLOAD_STATUS_OPENING, + filename_string); } int mirrored_x = MirroredXWithWidthInsideView( |