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

Unified Diff: chrome/browser/ui/views/download/download_item_view.cc

Issue 147593002: Implement new dangerous download reporting dialog for UNCOMMON_DOWNLOAD, in Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/download/download_item_view.cc
diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc
index 65f6495f0b3f12fd4d7b9f051b7fa4f7844a8ecb..cc38fb24ee7534e12e68835c0b9bf8f273b419fc 100644
--- a/chrome/browser/ui/views/download/download_item_view.cc
+++ b/chrome/browser/ui/views/download/download_item_view.cc
@@ -22,10 +22,12 @@
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_stats.h"
#include "chrome/browser/download/drag_download_item.h"
+#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/safe_browsing/download_feedback_service.h"
#include "chrome/browser/safe_browsing/download_protection_service.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/themes/theme_properties.h"
+#include "chrome/browser/ui/views/download/download_feedback_dialog_view.h"
#include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h"
#include "chrome/browser/ui/views/download/download_shelf_view.h"
#include "content/public/browser/download_danger_type.h"
@@ -550,9 +552,34 @@ void DownloadItemView::ButtonPressed(views::Button* sender,
shelf_->RemoveDownloadView(this);
return;
}
- if (model_.ShouldAllowDownloadFeedback() && BeginDownloadFeedback())
- return;
UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", warning_duration);
+ if (model_.ShouldAllowDownloadFeedback()) {
+ const int pref_value = shelf_->browser()->profile()->GetPrefs()->GetInteger(
+ prefs::kSafeBrowsingDownloadReportingEnabled);
+ switch (static_cast<DownloadFeedbackDialogView::Response>(pref_value)) {
+ case DownloadFeedbackDialogView::kNeverShown: {
Peter Kasting 2014/02/04 21:56:33 Nit: {} not necessary on any of these cases.
felt 2014/02/04 23:37:22 Done, but doesn't the style guide say either with
Peter Kasting 2014/02/05 00:07:36 Yes, either way is acceptable by the style guide.
+ DownloadFeedbackDialogView::Show(
+ shelf_->GetParentWindowView()->GetNativeWindow(),
+ shelf_->browser()->profile(),
+ base::Bind(&DownloadItemView::BeginDownloadFeedbackWrapper,
+ weak_ptr_factory_.GetWeakPtr()));
+ break;
+ }
+ case DownloadFeedbackDialogView::kUserEnabled: {
+ BeginDownloadFeedbackWrapper(true);
+ break;
+ }
+ case DownloadFeedbackDialogView::kUserDisabled: {
+ BeginDownloadFeedbackWrapper(false);
+ break;
+ }
+ case DownloadFeedbackDialogView::kMaxValue:
Peter Kasting 2014/02/04 21:56:33 Having this value buys you nothing over just havin
felt 2014/02/04 23:37:22 Switching to just "default", but I need kMaxValue
Peter Kasting 2014/02/05 00:07:36 In that case, I would eliminate "default" and only
felt 2014/02/05 02:08:53 Done.
+ default: {
+ NOTREACHED();
+ }
+ }
+ return;
+ }
download()->Remove();
}
@@ -890,6 +917,13 @@ void DownloadItemView::OpenDownload() {
UpdateAccessibleName();
}
+void DownloadItemView::BeginDownloadFeedbackWrapper(bool user_enabled) {
Peter Kasting 2014/02/04 21:56:33 Nit: If you make the argument to this be the enum
felt 2014/02/05 02:08:53 Done.
+ if (user_enabled && BeginDownloadFeedback())
+ return;
+ download()->Remove();
+ // WARNING: 'this' is deleted at this point. Don't access 'this'.
Peter Kasting 2014/02/04 21:56:33 Nit: Shorter: if (!user_enabled || !BeginDownlo
felt 2014/02/04 23:37:22 Done.
+}
+
bool DownloadItemView::BeginDownloadFeedback() {
#if defined(FULL_SAFE_BROWSING)
SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service();
@@ -899,11 +933,6 @@ bool DownloadItemView::BeginDownloadFeedback() {
sb_service->download_protection_service();
if (!download_protection_service)
return false;
- base::TimeDelta warning_duration = base::TimeDelta();
- if (!time_download_warning_shown_.is_null())
- warning_duration = base::Time::Now() - time_download_warning_shown_;
- UMA_HISTOGRAM_LONG_TIMES("clickjacking.report_and_discard_download",
- warning_duration);
download_protection_service->feedback_service()->BeginFeedbackForDownload(
download());
// WARNING: we are deleted at this point. Don't access 'this'.
@@ -1141,8 +1170,6 @@ void DownloadItemView::ShowWarningDialog() {
}
int discard_button_message = model_.IsMalicious() ?
IDS_DISMISS_DOWNLOAD : IDS_DISCARD_DOWNLOAD;
- if (!model_.IsMalicious() && model_.ShouldAllowDownloadFeedback())
- discard_button_message = IDS_REPORT_AND_DISCARD_DOWNLOAD;
discard_button_ = new views::LabelButton(
this, l10n_util::GetStringUTF16(discard_button_message));
discard_button_->SetStyle(views::Button::STYLE_BUTTON);

Powered by Google App Engine
This is Rietveld 408576698