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

Unified Diff: chrome/browser/ui/cocoa/download/download_item_controller.mm

Issue 402293002: Experience sampling instrumentation for dangerous downloads warnings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sampling-api
Patch Set: Add default actions for tests Created 6 years, 4 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/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..3d4a8e611a93040cb7c3565e149832d6f9445de8 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,6 +36,7 @@
#include "ui/gfx/image/image.h"
using content::DownloadItem;
+using extensions::ExperienceSamplingEvent;
namespace {
@@ -117,6 +119,8 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
}
- (void)dealloc {
+ if (sampling_event_.get())
+ sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kIgnore);
[[NSNotificationCenter defaultCenter] removeObserver:self];
[progressView_ setController:nil];
[[self view] removeFromSuperview];
@@ -144,6 +148,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()
+ ? ExperienceSamplingEvent::kMaliciousDownload
+ : ExperienceSamplingEvent::kDangerousDownload;
+ 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 +335,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 +353,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.
}

Powered by Google App Engine
This is Rietveld 408576698