Chromium Code Reviews| 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..2e8eb72f071f4b2512889ca20274efccc1ab6cf6 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,8 +18,13 @@ |
| #include "grit/generated_resources.h" |
| #include "ui/base/l10n/l10n_util.h" |
| +using extensions::ExperienceSamplingEvent; |
| + |
| namespace { |
| +// Constants for the Experience Sampling instrumentation. |
|
felt
2014/08/11 21:57:27
Constant
Chris Thompson
2014/08/11 22:00:50
Done.
|
| +const char kEventName[] = "download_danger_prompt"; |
| + |
| // TODO(wittman): Create a native web contents modal dialog implementation of |
| // this dialog for non-Views platforms, to support bold formatting of the |
| // message lead. |
| @@ -56,6 +62,8 @@ class DownloadDangerPromptImpl : public DownloadDangerPrompt, |
| bool show_context_; |
| OnDone done_; |
| + scoped_ptr<ExperienceSamplingEvent> sampling_event_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(DownloadDangerPromptImpl); |
| }; |
| @@ -71,6 +79,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( |
| + kEventName, |
| + download->GetURL(), |
| + download->GetReferrerUrl(), |
| + download->GetBrowserContext())); |
| } |
| DownloadDangerPromptImpl::~DownloadDangerPromptImpl() { |
| @@ -203,14 +219,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); |
| } |