| Index: chrome/browser/ui/cocoa/download/download_item_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/download/download_item_controller.mm b/chrome/browser/ui/cocoa/download/download_item_controller.mm
|
| index 430ecbc3fd7b1a4b0b5f3c85bdb6fa187f9b25df..8f6f2e2e8561dbafa78c16c61802df79803fa056 100644
|
| --- a/chrome/browser/ui/cocoa/download/download_item_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/download/download_item_controller.mm
|
| @@ -14,6 +14,7 @@
|
| #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/extensions/api/experience_sampling_private/experience_sampling.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"
|
| @@ -35,9 +36,14 @@
|
| #include "ui/gfx/image/image.h"
|
|
|
| using content::DownloadItem;
|
| +using extensions::ExperienceSamplingEvent;
|
|
|
| namespace {
|
|
|
| +// Constants for Experience Sampling.
|
| +const char kEventNameMalicious[] = "download_warning_malicious";
|
| +const char kEventNameDangerous[] = "download_warning_dangerous";
|
| +
|
| // NOTE: Mac currently doesn't use this like Windows does. Mac uses this to
|
| // control the min size on the dangerous download text. TVL sent a query off to
|
| // UX to fully spec all the the behaviors of download items and truncations
|
| @@ -117,6 +123,8 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
|
| }
|
|
|
| - (void)dealloc {
|
| + if (sampling_event_.get())
|
| + sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny);
|
| [[NSNotificationCenter defaultCenter] removeObserver:self];
|
| [progressView_ setController:nil];
|
| [[self view] removeFromSuperview];
|
| @@ -144,6 +152,17 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
|
|
|
| [self setState:kDangerous];
|
|
|
| + // ExperienceSampling: Dangerous or malicious download warning is being shown
|
| + // to the user, so we start a new SamplingEvent and track it.
|
| + std::string event_name = downloadModel->MightBeMalicious() ?
|
| + kEventNameMalicious
|
| + : kEventNameDangerous;
|
| + sampling_event_.reset(new ExperienceSamplingEvent(
|
| + event_name,
|
| + downloadModel->download()->GetURL(),
|
| + downloadModel->download()->GetReferrerUrl(),
|
| + downloadModel->download()->GetBrowserContext()));
|
| +
|
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| NSImage* alertIcon;
|
|
|
| @@ -320,6 +339,11 @@ 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_);
|
| + // ExperienceSampling: User chose to proceed with dangerous download.
|
| + if (sampling_event_.get()) {
|
| + sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed);
|
| + sampling_event_.reset(NULL);
|
| + }
|
| // This will change the state and notify us.
|
| bridge_->download_model()->download()->ValidateDangerousDownload();
|
| }
|
| @@ -333,6 +357,11 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
|
| }
|
|
|
| - (IBAction)dismissMaliciousDownload:(id)sender {
|
| + // ExperienceSampling: User dismissed the dangerous download.
|
| + if (sampling_event_.get()) {
|
| + sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny);
|
| + sampling_event_.reset(NULL);
|
| + }
|
| [self remove];
|
| // WARNING: we are deleted at this point.
|
| }
|
|
|