| 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 f581e42b6408ba8d18ccab4cf71b672b937b6a56..b44ecfb2b5acf0fe40521e7f918ca4ab648df209 100644
|
| --- a/chrome/browser/download/download_danger_prompt.cc
|
| +++ b/chrome/browser/download/download_danger_prompt.cc
|
| @@ -6,19 +6,24 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/browser/browser_process.h"
|
| #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/safe_browsing/safe_browsing_service.h"
|
| #include "chrome/browser/ui/tab_modal_confirm_dialog.h"
|
| #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
|
| +#include "chrome/common/safe_browsing/csd.pb.h"
|
| #include "chrome/grit/chromium_strings.h"
|
| #include "chrome/grit/generated_resources.h"
|
| +#include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/download_danger_type.h"
|
| #include "content/public/browser/download_item.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
|
|
| using extensions::ExperienceSamplingEvent;
|
| +using safe_browsing::ClientSafeBrowsingReportRequest;
|
|
|
| namespace {
|
|
|
| @@ -240,6 +245,11 @@ void DownloadDangerPromptImpl::RunDone(Action action) {
|
| OnDone done = done_;
|
| done_.Reset();
|
| if (download_ != NULL) {
|
| + if (!download_->GetURL().is_empty() &&
|
| + !download_->GetBrowserContext()->IsOffTheRecord()) {
|
| + SendSafeBrowsingDownloadRecoveryReport(
|
| + action == DownloadDangerPrompt::ACCEPT, download_->GetURL());
|
| + }
|
| download_->RemoveObserver(this);
|
| download_ = NULL;
|
| }
|
| @@ -263,3 +273,23 @@ DownloadDangerPrompt* DownloadDangerPrompt::Create(
|
| return prompt;
|
| }
|
| #endif
|
| +
|
| +void DownloadDangerPrompt::SendSafeBrowsingDownloadRecoveryReport(
|
| + bool did_proceed,
|
| + const GURL& url) {
|
| + safe_browsing::SafeBrowsingService* sb_service =
|
| + g_browser_process->safe_browsing_service();
|
| + if (sb_service) {
|
| + ClientSafeBrowsingReportRequest report;
|
| + report.set_type(
|
| + ClientSafeBrowsingReportRequest::MALICIOUS_DOWNLOAD_RECOVERY);
|
| + report.set_url(url.spec());
|
| + report.set_did_proceed(did_proceed);
|
| +
|
| + std::string serialized_report;
|
| + if (report.SerializeToString(&serialized_report))
|
| + sb_service->SendDownloadRecoveryReport(serialized_report);
|
| + else
|
| + DLOG(ERROR) << "Unable to serialize the threat report.";
|
| + }
|
| +}
|
|
|