Chromium Code Reviews| 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..da9ae3b5159b8057f7c65bd36d4ee914d4d5a95d 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" |
|
mattm
2014/02/07 02:03:36
Can these includes just be base/prefs/pref_service
felt
2014/02/07 05:27:50
Done.
|
| #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,33 @@ 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() && |
| + !shelf_->browser()->profile()->IsOffTheRecord()) { |
| + DownloadFeedbackDialogView::DownloadReportingStatus pref_value = |
| + static_cast<DownloadFeedbackDialogView::DownloadReportingStatus>( |
| + shelf_->browser()->profile()->GetPrefs()->GetInteger( |
| + prefs::kSafeBrowsingDownloadReportingEnabled)); |
| + switch (pref_value) { |
| + case DownloadFeedbackDialogView::kDialogNotYetShown: |
| + DownloadFeedbackDialogView::Show( |
| + shelf_->get_parent()->GetNativeWindow(), |
| + shelf_->browser()->profile(), |
| + base::Bind( |
| + &DownloadItemView::PossiblySubmitDownloadToFeedbackService, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + break; |
| + |
| + case DownloadFeedbackDialogView::kDownloadReportingEnabled: |
| + case DownloadFeedbackDialogView::kDownloadReportingDisabled: |
| + PossiblySubmitDownloadToFeedbackService(pref_value); |
| + break; |
| + |
| + case DownloadFeedbackDialogView::kMaxValue: |
| + NOTREACHED(); |
| + } |
| + return; |
| + } |
| download()->Remove(); |
| } |
| @@ -890,7 +916,7 @@ void DownloadItemView::OpenDownload() { |
| UpdateAccessibleName(); |
| } |
| -bool DownloadItemView::BeginDownloadFeedback() { |
| +bool DownloadItemView::SubmitDownloadToFeedbackService() { |
| #if defined(FULL_SAFE_BROWSING) |
| SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); |
| if (!sb_service) |
| @@ -899,11 +925,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'. |
| @@ -914,6 +935,15 @@ bool DownloadItemView::BeginDownloadFeedback() { |
| #endif |
| } |
| +void DownloadItemView::PossiblySubmitDownloadToFeedbackService( |
| + DownloadFeedbackDialogView::DownloadReportingStatus status) { |
| + if (status != DownloadFeedbackDialogView::kDownloadReportingEnabled || |
| + !SubmitDownloadToFeedbackService()) { |
| + download()->Remove(); |
| + } |
| + // WARNING: 'this' is deleted at this point. Don't access 'this'. |
| +} |
| + |
| void DownloadItemView::LoadIcon() { |
| IconManager* im = g_browser_process->icon_manager(); |
| last_download_item_path_ = download()->GetTargetFilePath(); |
| @@ -1141,8 +1171,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); |