Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / safe_browsing / safe_browsing_service.h
index 61e197a..c034b06 100644 (file)
@@ -17,6 +17,7 @@
 #include "base/memory/scoped_ptr.h"
 #include "base/observer_list.h"
 #include "base/sequenced_task_runner_helpers.h"
+#include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callback.h"
 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/notification_observer.h"
@@ -24,6 +25,7 @@
 
 class PrefChangeRegistrar;
 class PrefService;
+class Profile;
 struct SafeBrowsingProtocolConfig;
 class SafeBrowsingDatabaseManager;
 class SafeBrowsingPingManager;
@@ -31,6 +33,7 @@ class SafeBrowsingProtocolManager;
 class SafeBrowsingServiceFactory;
 class SafeBrowsingUIManager;
 class SafeBrowsingURLRequestContextGetter;
+class TrackedPreferenceValidationDelegate;
 
 namespace base {
 class Thread;
@@ -44,6 +47,7 @@ class URLRequestContextGetter;
 namespace safe_browsing {
 class ClientSideDetectionService;
 class DownloadProtectionService;
+class IncidentReportingService;
 }
 
 // Construction needs to happen on the main thread.
@@ -70,6 +74,12 @@ class SafeBrowsingService
   // Create an instance of the safe browsing service.
   static SafeBrowsingService* CreateSafeBrowsingService();
 
+#if defined(OS_ANDROID) && defined(FULL_SAFE_BROWSING)
+  // Return whether the user is in mobile safe browsing
+  // field trial enabled group.
+  static bool IsEnabledByFieldTrial();
+#endif
+
   // Called on the UI thread to initialize the service.
   void Initialize();
 
@@ -81,7 +91,7 @@ class SafeBrowsingService
   bool DownloadBinHashNeeded() const;
 
   // Create a protocol config struct.
-  SafeBrowsingProtocolConfig GetProtocolConfig() const;
+  virtual SafeBrowsingProtocolConfig GetProtocolConfig() const;
 
   bool enabled() const { return enabled_; }
 
@@ -109,6 +119,18 @@ class SafeBrowsingService
 
   SafeBrowsingPingManager* ping_manager() const;
 
+  // Returns a preference validation delegate that adds incidents to the
+  // incident reporting service for validation failures. Returns NULL if the
+  // service is not applicable for the given profile.
+  scoped_ptr<TrackedPreferenceValidationDelegate>
+      CreatePreferenceValidationDelegate(Profile* profile) const;
+
+  // Registers |callback| to be run after some delay following process launch.
+  // |callback| will be dropped if the service is not applicable for the
+  // process.
+  void RegisterDelayedAnalysisCallback(
+      const safe_browsing::DelayedAnalysisCallback& callback);
+
  protected:
   // Creates the safe browsing service.  Need to initialize before using.
   SafeBrowsingService();
@@ -119,6 +141,10 @@ class SafeBrowsingService
 
   virtual SafeBrowsingUIManager* CreateUIManager();
 
+  // Registers all the delayed analysis with the incident reporting service.
+  // This is where you register your process-wide, profile-independent analysis.
+  virtual void RegisterAllDelayedAnalysis();
+
  private:
   friend class SafeBrowsingServiceFactoryImpl;
   friend struct content::BrowserThread::DeleteOnThread<
@@ -211,6 +237,8 @@ class SafeBrowsingService
   // Accessed on UI thread.
   scoped_ptr<safe_browsing::DownloadProtectionService> download_service_;
 
+  scoped_ptr<safe_browsing::IncidentReportingService> incident_service_;
+
   // The UI manager handles showing interstitials.  Accessed on both UI and IO
   // thread.
   scoped_refptr<SafeBrowsingUIManager> ui_manager_;