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

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

Issue 1436273002: Send safe browsing ThreatDetails to track download CTR when user tries to recover blocked downloads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scoped_refptr Created 5 years, 1 month 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/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) {
Lei Zhang 2015/11/24 18:55:27 This should be always true, right?
Jialiu Lin 2015/11/25 23:43:20 Yes, you're right. This check is not necessary. Th
+ 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.";
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698