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

Side by Side Diff: chrome/browser/download/download_danger_prompt.cc

Issue 1943993006: Create test fixture for SafeBrowsingService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/download/download_danger_prompt.h" 5 #include "chrome/browser/download/download_danger_prompt.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/metrics/sparse_histogram.h" 9 #include "base/metrics/sparse_histogram.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 break; 327 break;
328 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: 328 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT:
329 report.set_download_verdict(ClientDownloadResponse::UNCOMMON); 329 report.set_download_verdict(ClientDownloadResponse::UNCOMMON);
330 break; 330 break;
331 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: 331 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED:
332 report.set_download_verdict(ClientDownloadResponse::POTENTIALLY_UNWANTED); 332 report.set_download_verdict(ClientDownloadResponse::POTENTIALLY_UNWANTED);
333 break; 333 break;
334 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: 334 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
335 report.set_download_verdict(ClientDownloadResponse::DANGEROUS_HOST); 335 report.set_download_verdict(ClientDownloadResponse::DANGEROUS_HOST);
336 break; 336 break;
337 default: 337 default: // Don't send report for any other danger types.
Nathan Parker 2016/05/07 00:05:32 Does this change the behaviour? Isn't test code..
Jialiu Lin 2016/05/12 21:53:58 Oops, added a test in download_danger_prompt_brows
338 break; 338 return;
339 } 339 }
340 report.set_url(download.GetURL().spec()); 340 report.set_url(download.GetURL().spec());
341 report.set_did_proceed(did_proceed); 341 report.set_did_proceed(did_proceed);
342 342
343 std::string serialized_report; 343 std::string serialized_report;
344 if (report.SerializeToString(&serialized_report)) 344 if (report.SerializeToString(&serialized_report))
345 sb_service->SendSerializedDownloadReport(serialized_report); 345 sb_service->SendSerializedDownloadReport(serialized_report);
346 else 346 else
347 DLOG(ERROR) << "Unable to serialize the threat report."; 347 DLOG(ERROR) << "Unable to serialize the threat report.";
348 } 348 }
349 349
350 void DownloadDangerPrompt::RecordDownloadDangerPrompt( 350 void DownloadDangerPrompt::RecordDownloadDangerPrompt(
351 bool did_proceed, 351 bool did_proceed,
352 const content::DownloadItem& download) { 352 const content::DownloadItem& download) {
353 int dangerous_file_type = 353 int dangerous_file_type =
354 GetSBClientDownloadExtensionValueForUMA(download.GetTargetFilePath()); 354 GetSBClientDownloadExtensionValueForUMA(download.GetTargetFilePath());
355 content::DownloadDangerType danger_type = download.GetDangerType(); 355 content::DownloadDangerType danger_type = download.GetDangerType();
356 356
357 UMA_HISTOGRAM_SPARSE_SLOWLY( 357 UMA_HISTOGRAM_SPARSE_SLOWLY(
358 base::StringPrintf("%s.%s.Shown", kDownloadDangerPromptPrefix, 358 base::StringPrintf("%s.%s.Shown", kDownloadDangerPromptPrefix,
359 GetDangerTypeString(danger_type)), 359 GetDangerTypeString(danger_type)),
360 dangerous_file_type); 360 dangerous_file_type);
361 if (did_proceed) { 361 if (did_proceed) {
362 UMA_HISTOGRAM_SPARSE_SLOWLY( 362 UMA_HISTOGRAM_SPARSE_SLOWLY(
363 base::StringPrintf("%s.%s.Proceed", kDownloadDangerPromptPrefix, 363 base::StringPrintf("%s.%s.Proceed", kDownloadDangerPromptPrefix,
364 GetDangerTypeString(danger_type)), 364 GetDangerTypeString(danger_type)),
365 dangerous_file_type); 365 dangerous_file_type);
366 } 366 }
367 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698