Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / safe_browsing / incident_reporting / incident_reporting_service.h
index d180288..b824b36 100644 (file)
 #include "base/threading/thread_checker.h"
 #include "base/time/time.h"
 #include "base/timer/timer.h"
+#include "chrome/browser/safe_browsing/download_protection_service.h"
 #include "chrome/browser/safe_browsing/incident_reporting/add_incident_callback.h"
 #include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callback.h"
 #include "chrome/browser/safe_browsing/incident_reporting/delayed_callback_runner.h"
+#include "chrome/browser/safe_browsing/incident_reporting/download_metadata_manager.h"
 #include "chrome/browser/safe_browsing/incident_reporting/incident_report_uploader.h"
 #include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h"
 #include "content/public/browser/notification_observer.h"
@@ -36,6 +38,7 @@ class TaskRunner;
 }
 
 namespace content {
+class DownloadManager;
 class NotificationDetails;
 class NotificationSource;
 }
@@ -46,6 +49,7 @@ class URLRequestContextGetter;
 
 namespace safe_browsing {
 
+class ClientDownloadRequest;
 class ClientIncidentReport;
 class ClientIncidentReport_DownloadDetails;
 class ClientIncidentReport_EnvironmentData;
@@ -71,7 +75,7 @@ class IncidentReportingService : public content::NotificationObserver {
 
   // All incident collection, data collection, and uploads in progress are
   // dropped at destruction.
-  virtual ~IncidentReportingService();
+  ~IncidentReportingService() override;
 
   // Returns a callback by which external components can add an incident to the
   // service on behalf of |profile|. The callback may outlive the service, but
@@ -90,6 +94,10 @@ class IncidentReportingService : public content::NotificationObserver {
   // Registers |callback| to be run after some delay following process launch.
   void RegisterDelayedAnalysisCallback(const DelayedAnalysisCallback& callback);
 
+  // Adds |download_manager| to the set monitored for client download request
+  // storage.
+  void AddDownloadManager(content::DownloadManager* download_manager);
+
  protected:
   // A pointer to a function that populates a protobuf with environment data.
   typedef void (*CollectEnvironmentDataFn)(
@@ -232,10 +240,14 @@ class IncidentReportingService : public content::NotificationObserver {
                             IncidentReportUploader::Result result,
                             scoped_ptr<ClientIncidentResponse> response);
 
+  // DownloadProtectionService::ClientDownloadRequestCallback implementation.
+  void OnClientDownloadRequest(content::DownloadItem* download,
+                               const ClientDownloadRequest* request);
+
   // content::NotificationObserver methods.
-  virtual void Observe(int type,
-                       const content::NotificationSource& source,
-                       const content::NotificationDetails& details) OVERRIDE;
+  void Observe(int type,
+               const content::NotificationSource& source,
+               const content::NotificationDetails& details) override;
 
   base::ThreadChecker thread_checker_;
 
@@ -260,6 +272,11 @@ class IncidentReportingService : public content::NotificationObserver {
   // Registrar for observing profile lifecycle notifications.
   content::NotificationRegistrar notification_registrar_;
 
+  // A subscription for ClientDownloadRequests, used to persist them for later
+  // use.
+  DownloadProtectionService::ClientDownloadRequestSubscription
+      client_download_request_subscription_;
+
   // True when the asynchronous environment collection task has been fired off
   // but has not yet completed.
   bool environment_collection_pending_;
@@ -296,6 +313,8 @@ class IncidentReportingService : public content::NotificationObserver {
   // Callbacks registered for performing delayed analysis.
   DelayedCallbackRunner delayed_analysis_callbacks_;
 
+  DownloadMetadataManager download_metadata_manager_;
+
   // The collection of uploads in progress.
   ScopedVector<UploadContext> uploads_;