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

Unified Diff: chrome/browser/download/download_danger_prompt.cc

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
« no previous file with comments | « no previous file | chrome/browser/download/download_danger_prompt_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_danger_prompt.cc
diff --git a/chrome/browser/download/download_danger_prompt.cc b/chrome/browser/download/download_danger_prompt.cc
index 4ec23bcc5304612a9b40624391a2df7e68b20c76..13d623b064bfdcc10fd524f0adcd9ecfad9ad38a 100644
--- a/chrome/browser/download/download_danger_prompt.cc
+++ b/chrome/browser/download/download_danger_prompt.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_stats.h"
+#include "chrome/browser/extensions/api/experience_sampling_private/experience_sampling.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
#include "content/public/browser/download_danger_type.h"
@@ -17,6 +18,8 @@
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
+using extensions::ExperienceSamplingEvent;
+
namespace {
// TODO(wittman): Create a native web contents modal dialog implementation of
@@ -56,6 +59,8 @@ class DownloadDangerPromptImpl : public DownloadDangerPrompt,
bool show_context_;
OnDone done_;
+ scoped_ptr<ExperienceSamplingEvent> sampling_event_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadDangerPromptImpl);
};
@@ -71,6 +76,14 @@ DownloadDangerPromptImpl::DownloadDangerPromptImpl(
DCHECK(!done_.is_null());
download_->AddObserver(this);
RecordOpenedDangerousConfirmDialog(download_->GetDangerType());
+
+ // ExperienceSampling: A malicious download warning is being shown to the
+ // user, so we start a new SamplingEvent and track it.
+ sampling_event_.reset(new ExperienceSamplingEvent(
+ ExperienceSamplingEvent::kDownloadDangerPrompt,
+ download->GetURL(),
+ download->GetReferrerUrl(),
+ download->GetBrowserContext()));
}
DownloadDangerPromptImpl::~DownloadDangerPromptImpl() {
@@ -203,14 +216,20 @@ base::string16 DownloadDangerPromptImpl::GetCancelButtonTitle() {
}
void DownloadDangerPromptImpl::OnAccepted() {
+ // ExperienceSampling: User proceeded through the warning.
+ sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed);
RunDone(ACCEPT);
}
void DownloadDangerPromptImpl::OnCanceled() {
+ // ExperienceSampling: User canceled the warning.
+ sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny);
RunDone(CANCEL);
}
void DownloadDangerPromptImpl::OnClosed() {
+ // ExperienceSampling: User canceled the warning.
+ sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny);
RunDone(DISMISS);
}
« no previous file with comments | « no previous file | chrome/browser/download/download_danger_prompt_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698