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

Unified Diff: chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc

Issue 663023007: Include high-fidelity metadata about a download in incident reports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: added DCHECK Created 6 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/safe_browsing/incident_reporting/incident_reporting_service.cc
diff --git a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc
index 30e5beb801cd139b7fad3f114dcead603725e136..ae74bb5e4fb5570f6ae0d53f8bd131ec4057f638 100644
--- a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc
@@ -249,8 +249,9 @@ IncidentReportingService::UploadContext::~UploadContext() {
IncidentReportingService::IncidentReportingService(
SafeBrowsingService* safe_browsing_service,
const scoped_refptr<net::URLRequestContextGetter>& request_context_getter)
- : database_manager_(safe_browsing_service ?
- safe_browsing_service->database_manager() : NULL),
+ : database_manager_(safe_browsing_service
+ ? safe_browsing_service->database_manager()
+ : NULL),
url_request_context_getter_(request_context_getter),
collect_environment_data_fn_(&CollectEnvironmentData),
environment_collection_task_runner_(
@@ -268,6 +269,7 @@ IncidentReportingService::IncidentReportingService(
content::BrowserThread::GetBlockingPool()
->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)),
+ download_metadata_manager_(content::BrowserThread::GetBlockingPool()),
receiver_weak_ptr_factory_(this),
weak_ptr_factory_(this) {
notification_registrar_.Add(this,
@@ -276,6 +278,16 @@ IncidentReportingService::IncidentReportingService(
notification_registrar_.Add(this,
chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllSources());
+ DownloadProtectionService* download_protection_service =
+ (safe_browsing_service ?
+ safe_browsing_service->download_protection_service() :
+ NULL);
+ if (download_protection_service) {
+ client_download_request_subscription_ =
+ download_protection_service->RegisterClientDownloadRequestCallback(
+ base::Bind(&IncidentReportingService::OnClientDownloadRequest,
+ base::Unretained(this)));
+ }
}
IncidentReportingService::~IncidentReportingService() {
@@ -333,13 +345,19 @@ void IncidentReportingService::RegisterDelayedAnalysisCallback(
delayed_analysis_callbacks_.Start();
}
+void IncidentReportingService::AddDownloadManager(
+ content::DownloadManager* download_manager) {
+ download_metadata_manager_.AddDownloadManager(download_manager);
+}
+
IncidentReportingService::IncidentReportingService(
SafeBrowsingService* safe_browsing_service,
const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
base::TimeDelta delayed_task_interval,
const scoped_refptr<base::TaskRunner>& delayed_task_runner)
- : database_manager_(safe_browsing_service ?
- safe_browsing_service->database_manager() : NULL),
+ : database_manager_(safe_browsing_service
+ ? safe_browsing_service->database_manager()
+ : NULL),
url_request_context_getter_(request_context_getter),
collect_environment_data_fn_(&CollectEnvironmentData),
environment_collection_task_runner_(
@@ -353,6 +371,7 @@ IncidentReportingService::IncidentReportingService(
this,
&IncidentReportingService::OnCollationTimeout),
delayed_analysis_callbacks_(delayed_task_interval, delayed_task_runner),
+ download_metadata_manager_(content::BrowserThread::GetBlockingPool()),
receiver_weak_ptr_factory_(this),
weak_ptr_factory_(this) {
notification_registrar_.Add(this,
@@ -427,7 +446,10 @@ void IncidentReportingService::OnProfileAdded(Profile* profile) {
scoped_ptr<LastDownloadFinder> IncidentReportingService::CreateDownloadFinder(
const LastDownloadFinder::LastDownloadCallback& callback) {
- return LastDownloadFinder::Create(callback).Pass();
+ return LastDownloadFinder::Create(
+ base::Bind(&DownloadMetadataManager::GetDownloadDetails,
+ base::Unretained(&download_metadata_manager_)),
+ callback).Pass();
}
scoped_ptr<IncidentReportUploader> IncidentReportingService::StartReportUpload(
@@ -945,6 +967,13 @@ void IncidentReportingService::OnReportUploadResult(
// else retry?
}
+void IncidentReportingService::OnClientDownloadRequest(
+ content::DownloadItem* download,
+ const ClientDownloadRequest* request) {
+ if (!download->GetBrowserContext()->IsOffTheRecord())
+ download_metadata_manager_.SetRequest(download, request);
+}
+
void IncidentReportingService::Observe(
int type,
const content::NotificationSource& source,

Powered by Google App Engine
This is Rietveld 408576698