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

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

Issue 2164723002: Change Dismiss button to Discard and cancel download (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove IDS_DISMISS_DOWNLOAD from generated_resources.grd Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 ExperienceSamplingEvent::kProceed); 552 ExperienceSamplingEvent::kProceed);
553 sampling_event_.reset(NULL); 553 sampling_event_.reset(NULL);
554 } 554 }
555 // This will change the state and notify us. 555 // This will change the state and notify us.
556 download()->ValidateDangerousDownload(); 556 download()->ValidateDangerousDownload();
557 return; 557 return;
558 } 558 }
559 559
560 // WARNING: all end states after this point delete |this|. 560 // WARNING: all end states after this point delete |this|.
561 DCHECK_EQ(discard_button_, sender); 561 DCHECK_EQ(discard_button_, sender);
562 if (model_.IsMalicious()) {
563 UMA_HISTOGRAM_LONG_TIMES("clickjacking.dismiss_download", warning_duration);
564 // ExperienceSampling: User chose to dismiss the dangerous download.
565 if (sampling_event_.get()) {
566 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny);
567 sampling_event_.reset(NULL);
568 }
569 shelf_->RemoveDownloadView(this);
570 return;
571 }
572 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", warning_duration); 562 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", warning_duration);
573 if (model_.ShouldAllowDownloadFeedback() && 563 if (!model_.IsMalicious() && model_.ShouldAllowDownloadFeedback() &&
574 !shelf_->browser()->profile()->IsOffTheRecord()) { 564 !shelf_->browser()->profile()->IsOffTheRecord()) {
575 if (!shelf_->browser()->profile()->GetPrefs()->HasPrefPath( 565 if (!shelf_->browser()->profile()->GetPrefs()->HasPrefPath(
576 prefs::kSafeBrowsingExtendedReportingEnabled)) { 566 prefs::kSafeBrowsingExtendedReportingEnabled)) {
577 // Show dialog, because the dialog hasn't been shown before. 567 // Show dialog, because the dialog hasn't been shown before.
578 DownloadFeedbackDialogView::Show( 568 DownloadFeedbackDialogView::Show(
579 shelf_->get_parent()->GetNativeWindow(), 569 shelf_->get_parent()->GetNativeWindow(),
580 shelf_->browser()->profile(), 570 shelf_->browser()->profile(),
581 shelf_->GetNavigator(), 571 shelf_->GetNavigator(),
582 base::Bind( 572 base::Bind(
583 &DownloadItemView::PossiblySubmitDownloadToFeedbackService, 573 &DownloadItemView::PossiblySubmitDownloadToFeedbackService,
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 download()->GetBrowserContext())); 1181 download()->GetBrowserContext()));
1192 1182
1193 body_state_ = NORMAL; 1183 body_state_ = NORMAL;
1194 drop_down_state_ = NORMAL; 1184 drop_down_state_ = NORMAL;
1195 if (mode_ == DANGEROUS_MODE) { 1185 if (mode_ == DANGEROUS_MODE) {
1196 save_button_ = new views::LabelButton( 1186 save_button_ = new views::LabelButton(
1197 this, model_.GetWarningConfirmButtonText()); 1187 this, model_.GetWarningConfirmButtonText());
1198 save_button_->SetStyle(views::Button::STYLE_BUTTON); 1188 save_button_->SetStyle(views::Button::STYLE_BUTTON);
1199 AddChildView(save_button_); 1189 AddChildView(save_button_);
1200 } 1190 }
1201 int discard_button_message = model_.IsMalicious() ?
1202 IDS_DISMISS_DOWNLOAD : IDS_DISCARD_DOWNLOAD;
1203 discard_button_ = new views::LabelButton( 1191 discard_button_ = new views::LabelButton(
1204 this, l10n_util::GetStringUTF16(discard_button_message)); 1192 this, l10n_util::GetStringUTF16(IDS_DISCARD_DOWNLOAD));
1205 discard_button_->SetStyle(views::Button::STYLE_BUTTON); 1193 discard_button_->SetStyle(views::Button::STYLE_BUTTON);
1206 AddChildView(discard_button_); 1194 AddChildView(discard_button_);
1207 1195
1208 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1196 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1209 switch (danger_type) { 1197 switch (danger_type) {
1210 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: 1198 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL:
1211 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: 1199 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
1212 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: 1200 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT:
1213 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: 1201 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
1214 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: 1202 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED:
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 animation->Reset((to == HOT) ? 1.0 : 0.0); 1353 animation->Reset((to == HOT) ? 1.0 : 0.0);
1366 } 1354 }
1367 } 1355 }
1368 1356
1369 void DownloadItemView::ProgressTimerFired() { 1357 void DownloadItemView::ProgressTimerFired() {
1370 // Only repaint for the indeterminate size case. Otherwise, we'll repaint only 1358 // Only repaint for the indeterminate size case. Otherwise, we'll repaint only
1371 // when there's an update notified via OnDownloadUpdated(). 1359 // when there's an update notified via OnDownloadUpdated().
1372 if (model_.PercentComplete() < 0) 1360 if (model_.PercentComplete() < 0)
1373 SchedulePaint(); 1361 SchedulePaint();
1374 } 1362 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698