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

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

Issue 19863005: Warn users about potentially unwanted downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a "Learn more" URL for unwanted downloads. Created 7 years, 5 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 discard_button_ = new views::LabelButton( 1077 discard_button_ = new views::LabelButton(
1078 this, l10n_util::GetStringUTF16(IDS_REPORT_AND_DISCARD_DOWNLOAD)); 1078 this, l10n_util::GetStringUTF16(IDS_REPORT_AND_DISCARD_DOWNLOAD));
1079 } else { 1079 } else {
1080 discard_button_ = new views::LabelButton( 1080 discard_button_ = new views::LabelButton(
1081 this, l10n_util::GetStringUTF16(IDS_DISCARD_DOWNLOAD)); 1081 this, l10n_util::GetStringUTF16(IDS_DISCARD_DOWNLOAD));
1082 } 1082 }
1083 discard_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); 1083 discard_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
1084 AddChildView(discard_button_); 1084 AddChildView(discard_button_);
1085 1085
1086 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1086 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1087 // The dangerous download label text and icon are different under 1087 switch (download()->GetDangerType()) {
1088 // different cases. 1088 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL:
1089 if (mode_ == MALICIOUS_MODE) { 1089 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
1090 warning_icon_ = rb.GetImageSkiaNamed(IDR_SAFEBROWSING_WARNING); 1090 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT:
1091 } else { 1091 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
1092 // The download file has dangerous file type (e.g.: an executable). 1092 warning_icon_ = rb.GetImageSkiaNamed(IDR_SAFEBROWSING_WARNING);
1093 warning_icon_ = rb.GetImageSkiaNamed(IDR_WARNING); 1093 break;
1094
1095 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS:
1096 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT:
1097 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED:
1098 case content::DOWNLOAD_DANGER_TYPE_MAX:
1099 NOTREACHED();
1100 // fallthrough
1101
1102 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE:
1103 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED:
1104 warning_icon_ = rb.GetImageSkiaNamed(IDR_WARNING);
1094 } 1105 }
1095 string16 dangerous_label = model_.GetWarningText(font_, kTextWidth); 1106 string16 dangerous_label = model_.GetWarningText(font_, kTextWidth);
1096 dangerous_download_label_ = new views::Label(dangerous_label); 1107 dangerous_download_label_ = new views::Label(dangerous_label);
1097 dangerous_download_label_->SetMultiLine(true); 1108 dangerous_download_label_->SetMultiLine(true);
1098 dangerous_download_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1109 dangerous_download_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1099 dangerous_download_label_->SetAutoColorReadabilityEnabled(false); 1110 dangerous_download_label_->SetAutoColorReadabilityEnabled(false);
1100 AddChildView(dangerous_download_label_); 1111 AddChildView(dangerous_download_label_);
1101 SizeLabelToMinWidth(); 1112 SizeLabelToMinWidth();
1102 UpdateDropDownButtonPosition(); 1113 UpdateDropDownButtonPosition();
1103 TooltipTextChanged(); 1114 TooltipTextChanged();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 void DownloadItemView::AnimateStateTransition(State from, State to, 1253 void DownloadItemView::AnimateStateTransition(State from, State to,
1243 ui::SlideAnimation* animation) { 1254 ui::SlideAnimation* animation) {
1244 if (from == NORMAL && to == HOT) { 1255 if (from == NORMAL && to == HOT) {
1245 animation->Show(); 1256 animation->Show();
1246 } else if (from == HOT && to == NORMAL) { 1257 } else if (from == HOT && to == NORMAL) {
1247 animation->Hide(); 1258 animation->Hide();
1248 } else if (from != to) { 1259 } else if (from != to) {
1249 animation->Reset((to == HOT) ? 1.0 : 0.0); 1260 animation->Reset((to == HOT) ? 1.0 : 0.0);
1250 } 1261 }
1251 } 1262 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service_unittest.cc ('k') | chrome/browser/ui/webui/downloads_dom_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698