Commit b59fa4da authored by Varun Khaneja's avatar Varun Khaneja Committed by Commit Bot

Enable uploading of downloads for extended reporting users on Mac.

Change-Id: I0fb1cf2f0a8a12ccd17f07bc764adf9654f8ff1f
Bug: 824802
Reviewed-on: https://chromium-review.googlesource.com/974441
Commit-Queue: Varun Khaneja <vakh@chromium.org>
Reviewed-by: default avatarJialiu Lin <jialiul@chromium.org>
Reviewed-by: default avatarAsanka Herath <asanka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546026}
parent 34d368d5
......@@ -10,6 +10,7 @@
#include <memory>
#include "base/time/time.h"
#include "chrome/browser/download/download_commands.h"
@class ChromeUILocalizer;
@class DownloadItemCell;
......@@ -157,6 +158,8 @@ class MenuModel;
- (IBAction)saveDownload:(id)sender;
- (IBAction)discardDownload:(id)sender;
- (IBAction)showContextMenu:(id)sender;
- (bool)submitDownloadToFeedbackService:(download::DownloadItem*)download
withCommand:(DownloadCommands::Command)command;
@end
......
......@@ -10,9 +10,12 @@
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_shelf_context_menu.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/download_protection/download_feedback_service.h"
#import "chrome/browser/themes/theme_properties.h"
#import "chrome/browser/themes/theme_service.h"
#import "chrome/browser/ui/cocoa/download/download_item_button.h"
......@@ -353,15 +356,23 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
// user did this to detect whether we're being clickjacked.
UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download",
base::Time::Now() - creationTime_);
// This will change the state and notify us.
bridge_->download_model()->download()->ValidateDangerousDownload();
DownloadItem* download = bridge_->download_model()->download();
if (![self submitDownloadToFeedbackService:download
withCommand:DownloadCommands::Command::KEEP]) {
// This will change the state and notify us.
download->ValidateDangerousDownload();
}
}
- (IBAction)discardDownload:(id)sender {
UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
base::Time::Now() - creationTime_);
DownloadItem* download = bridge_->download_model()->download();
download->Remove();
if (!
[self submitDownloadToFeedbackService:download
withCommand:DownloadCommands::Command::DISCARD])
download->Remove();
// WARNING: we are deleted at this point. Don't access 'this'.
}
......@@ -371,4 +382,29 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
[static_cast<DownloadItemButton*>(progressView_) showContextMenu];
}
- (bool)submitDownloadToFeedbackService:(download::DownloadItem*)download
withCommand:(DownloadCommands::Command)command {
safe_browsing::SafeBrowsingService* sb_service =
g_browser_process->safe_browsing_service();
if (!sb_service)
return false;
safe_browsing::DownloadProtectionService* download_protection_service =
sb_service->download_protection_service();
if (!download_protection_service)
return false;
DownloadItemModel* download_item_model = bridge_->download_model();
const Profile* profile = Profile::FromBrowserContext(
content::DownloadItemUtils::GetBrowserContext(download));
const PrefService* prefs = profile->GetPrefs();
if (!download_item_model->ShouldAllowDownloadFeedback() ||
profile->IsOffTheRecord() ||
!safe_browsing::IsExtendedReportingEnabled(*prefs))
return false;
download_protection_service->feedback_service()->BeginFeedbackForDownload(
download, command);
return true;
}
@end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment