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

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

Issue 1784433003: Track CTR of uncommon download warning. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add one more test Created 4 years, 9 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/download/download_commands.cc
diff --git a/chrome/browser/download/download_commands.cc b/chrome/browser/download/download_commands.cc
index 285ee4f0939f952edfd40cdcfac815c6d09aa92c..0b6e1d740e63b071522074eba33334afedbff202 100644
--- a/chrome/browser/download/download_commands.cc
+++ b/chrome/browser/download/download_commands.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
+#include "chrome/common/safe_browsing/csd.pb.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/google/core/browser/google_util.h"
@@ -278,6 +279,35 @@ void DownloadCommands::ExecuteCommand(Command command) {
download_item_->Remove();
break;
case KEEP:
+ // Only sends uncommon download accept report if :
+ // 1. FULL_SAFE_BROWSING is enabled, and
+ // 2. Download verdict is uncommon, and
+ // 3. Download URL is not empty, and
+ // 4. User is not in incognito mode.
+#if defined(FULL_SAFE_BROWSING)
+ if (download_item_->GetDangerType() ==
+ content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT &&
+ !download_item_->GetURL().is_empty() &&
+ !download_item_->GetBrowserContext()->IsOffTheRecord()) {
+ safe_browsing::SafeBrowsingService* sb_service =
+ g_browser_process->safe_browsing_service();
+ // Compiles the uncommon download warning report.
+ safe_browsing::ClientSafeBrowsingReportRequest report;
+ report.set_type(safe_browsing::ClientSafeBrowsingReportRequest::
+ DANGEROUS_DOWNLOAD_WARNING);
+ report.set_download_verdict(
+ safe_browsing::ClientDownloadResponse::UNCOMMON);
+ report.set_url(download_item_->GetURL().spec());
+ report.set_did_proceed(true);
+ std::string serialized_report;
+ if (report.SerializeToString(&serialized_report)) {
+ sb_service->SendSerializedDownloadReport(serialized_report);
+ } else {
+ DCHECK(false)
+ << "Unable to serialize the uncommon download warning report.";
+ }
+ }
+#endif
download_item_->ValidateDangerousDownload();
break;
case LEARN_MORE_SCANNING: {

Powered by Google App Engine
This is Rietveld 408576698