| Index: chrome/browser/ui/cocoa/download/download_item_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/download/download_item_controller.mm b/chrome/browser/ui/cocoa/download/download_item_controller.mm
|
| index aa896e5c66d60e697de2316a03d5bf6587cbbad3..dce472acfc08e359e47087e9c5d1f7f147c4e5e7 100644
|
| --- a/chrome/browser/ui/cocoa/download/download_item_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/download/download_item_controller.mm
|
| @@ -41,10 +41,6 @@ namespace {
|
| // rules so all platforms can get inline in the future.
|
| const int kTextWidth = 140; // Pixels
|
|
|
| -// The maximum number of characters we show in a file name when displaying the
|
| -// dangerous download message.
|
| -const int kFileNameMaxLength = 20;
|
| -
|
| // The maximum width in pixels for the file name tooltip.
|
| const int kToolTipMaxWidth = 900;
|
|
|
| @@ -165,7 +161,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
|
| DCHECK_EQ(bridge_->download_model(), downloadModel);
|
|
|
| // Handle dangerous downloads.
|
| - if (downloadModel->download()->GetSafetyState() == DownloadItem::DANGEROUS) {
|
| + if (downloadModel->IsDangerous()) {
|
| [self setState:kDangerous];
|
|
|
| ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| @@ -173,59 +169,22 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
|
| NSString* confirmButtonTitle;
|
| NSImage* alertIcon;
|
|
|
| - // The dangerous download label, button text and icon are different under
|
| - // different cases.
|
| - if (downloadModel->download()->GetDangerType() ==
|
| - content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL) {
|
| - // TODO(noelutz): add support for malicious content.
|
| - // Safebrowsing shows the download URL leads to malicious file.
|
| + dangerousWarning =
|
| + base::SysUTF16ToNSString(downloadModel->GetWarningText(
|
| + gfx::Font(), kTextWidth));
|
| + if (downloadModel->IsMalicious()) {
|
| alertIcon = rb.GetNativeImageNamed(IDR_SAFEBROWSING_WARNING);
|
| - dangerousWarning = l10n_util::GetNSStringWithFixup(
|
| - IDS_PROMPT_MALICIOUS_DOWNLOAD_URL);
|
| confirmButtonTitle = l10n_util::GetNSStringWithFixup(
|
| IDS_CONFIRM_DOWNLOAD);
|
| } else {
|
| - // It's a dangerous file type (e.g.: an executable).
|
| - DCHECK_EQ(downloadModel->download()->GetDangerType(),
|
| - content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE);
|
| alertIcon = rb.GetNativeImageNamed(IDR_WARNING);
|
| if (ChromeDownloadManagerDelegate::IsExtensionDownload(
|
| downloadModel->download())) {
|
| - dangerousWarning = l10n_util::GetNSStringWithFixup(
|
| - IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION);
|
| confirmButtonTitle = l10n_util::GetNSStringWithFixup(
|
| IDS_CONTINUE_EXTENSION_DOWNLOAD);
|
| } else {
|
| - // This basic fixup copies Windows DownloadItemView::DownloadItemView().
|
| -
|
| - // Extract the file extension (if any).
|
| - FilePath filename(downloadModel->download()->GetTargetName());
|
| - FilePath::StringType extension = filename.Extension();
|
| -
|
| - // Remove leading '.' from the extension
|
| - if (extension.length() > 0)
|
| - extension = extension.substr(1);
|
| -
|
| - // Elide giant extensions.
|
| - if (extension.length() > kFileNameMaxLength / 2) {
|
| - string16 utf16_extension;
|
| - ui::ElideString(UTF8ToUTF16(extension), kFileNameMaxLength / 2,
|
| - &utf16_extension);
|
| - extension = UTF16ToUTF8(utf16_extension);
|
| - }
|
| -
|
| - // Rebuild the filename.extension.
|
| - string16 rootname = UTF8ToUTF16(filename.RemoveExtension().value());
|
| - ui::ElideString(rootname, kFileNameMaxLength - extension.length(),
|
| - &rootname);
|
| - std::string new_filename = UTF16ToUTF8(rootname);
|
| - if (extension.length())
|
| - new_filename += std::string(".") + extension;
|
| -
|
| - dangerousWarning = l10n_util::GetNSStringFWithFixup(
|
| - IDS_PROMPT_DANGEROUS_DOWNLOAD, UTF8ToUTF16(new_filename));
|
| - confirmButtonTitle =
|
| - l10n_util::GetNSStringWithFixup(IDS_CONFIRM_DOWNLOAD);
|
| + confirmButtonTitle =
|
| + l10n_util::GetNSStringWithFixup(IDS_CONFIRM_DOWNLOAD);
|
| }
|
| }
|
| DCHECK(alertIcon);
|
|
|