Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: chrome/browser/ui/views/download/download_item_view.cc

Issue 8624008: Make malicious content download warning include the download filename (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Address Asanka's comment. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/download/download_item_view.h" 5 #include "chrome/browser/ui/views/download/download_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 #endif 969 #endif
970 970
971 // Elide giant extensions (this shouldn't currently be hit, but might 971 // Elide giant extensions (this shouldn't currently be hit, but might
972 // in future, should we ever notice unsafe giant extensions). 972 // in future, should we ever notice unsafe giant extensions).
973 if (extension.length() > kFileNameMaxLength / 2) 973 if (extension.length() > kFileNameMaxLength / 2)
974 ui::ElideString(extension, kFileNameMaxLength / 2, &extension); 974 ui::ElideString(extension, kFileNameMaxLength / 2, &extension);
975 975
976 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 976 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
977 // The dangerous download label text and icon are different 977 // The dangerous download label text and icon are different
978 // under different cases. 978 // under different cases.
979 string16 dangerous_label;
980 if (download_->GetDangerType() == DownloadStateInfo::DANGEROUS_URL || 979 if (download_->GetDangerType() == DownloadStateInfo::DANGEROUS_URL ||
981 download_->GetDangerType() == DownloadStateInfo::DANGEROUS_CONTENT) { 980 download_->GetDangerType() == DownloadStateInfo::DANGEROUS_CONTENT) {
982 // TODO(noelutz): add the target filename to the warning message in the
983 // case of a dangerous content warning.
984 // Safebrowsing shows the download URL or content leads to malicious file.
985 warning_icon_ = rb.GetBitmapNamed(IDR_SAFEBROWSING_WARNING); 981 warning_icon_ = rb.GetBitmapNamed(IDR_SAFEBROWSING_WARNING);
986 dangerous_label =
987 l10n_util::GetStringUTF16(IDS_PROMPT_UNSAFE_DOWNLOAD_URL);
988 } else { 982 } else {
989 // The download file has dangerous file type (e.g.: an executable).
990 DCHECK(download_->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE); 983 DCHECK(download_->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE);
991 warning_icon_ = rb.GetBitmapNamed(IDR_WARNING); 984 warning_icon_ = rb.GetBitmapNamed(IDR_WARNING);
992 if (ChromeDownloadManagerDelegate::IsExtensionDownload(download_)) { 985 }
993 dangerous_label = 986 string16 dangerous_label;
994 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); 987 if (download_->GetDangerType() == DownloadStateInfo::DANGEROUS_URL) {
995 } else { 988 // Safebrowsing shows the download URL or content leads to malicious file.
996 ui::ElideString(rootname, 989 dangerous_label = l10n_util::GetStringUTF16(
997 kFileNameMaxLength - extension.length(), 990 IDS_PROMPT_MALICIOUS_DOWNLOAD_URL);
998 &rootname); 991 } else if (download_->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE &&
999 string16 filename = rootname + ASCIIToUTF16(".") + extension; 992 ChromeDownloadManagerDelegate::IsExtensionDownload(download_)) {
1000 filename = base::i18n::GetDisplayStringInLTRDirectionality(filename); 993 dangerous_label =
1001 dangerous_label = 994 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION);
1002 l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD, filename); 995 } else {
1003 } 996 // The download file has dangerous file type (e.g.: an executable) or the
997 // file content is known to be malicious.
998 DCHECK(download_->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE ||
999 download_->GetDangerType() == DownloadStateInfo::DANGEROUS_CONTENT);
1000 ui::ElideString(rootname,
1001 kFileNameMaxLength - extension.length(),
1002 &rootname);
1003 string16 filename = rootname + ASCIIToUTF16(".") + extension;
1004 filename = base::i18n::GetDisplayStringInLTRDirectionality(filename);
1005 dangerous_label = l10n_util::GetStringFUTF16(
1006 download_->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE ?
1007 IDS_PROMPT_DANGEROUS_DOWNLOAD :
1008 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT,
1009 filename);
1004 } 1010 }
1005 1011
1006 dangerous_download_label_ = new views::Label(dangerous_label); 1012 dangerous_download_label_ = new views::Label(dangerous_label);
1007 dangerous_download_label_->SetMultiLine(true); 1013 dangerous_download_label_->SetMultiLine(true);
1008 dangerous_download_label_->SetHorizontalAlignment( 1014 dangerous_download_label_->SetHorizontalAlignment(
1009 views::Label::ALIGN_LEFT); 1015 views::Label::ALIGN_LEFT);
1010 dangerous_download_label_->SetAutoColorReadabilityEnabled(false); 1016 dangerous_download_label_->SetAutoColorReadabilityEnabled(false);
1011 AddChildView(dangerous_download_label_); 1017 AddChildView(dangerous_download_label_);
1012 SizeLabelToMinWidth(); 1018 SizeLabelToMinWidth();
1013 } 1019 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 // If the name has changed, notify assistive technology that the name 1130 // If the name has changed, notify assistive technology that the name
1125 // has changed so they can announce it immediately. 1131 // has changed so they can announce it immediately.
1126 if (new_name != accessible_name_) { 1132 if (new_name != accessible_name_) {
1127 accessible_name_ = new_name; 1133 accessible_name_ = new_name;
1128 if (GetWidget()) { 1134 if (GetWidget()) {
1129 GetWidget()->NotifyAccessibilityEvent( 1135 GetWidget()->NotifyAccessibilityEvent(
1130 this, ui::AccessibilityTypes::EVENT_NAME_CHANGED, true); 1136 this, ui::AccessibilityTypes::EVENT_NAME_CHANGED, true);
1131 } 1137 }
1132 } 1138 }
1133 } 1139 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/download/download_item_gtk.cc ('k') | chrome/browser/ui/webui/active_downloads_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698