Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_ H_ | |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_ H_ | |
| 7 | |
| 8 #include "base/containers/hash_tables.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h" | |
|
grt (UTC plus 2)
2015/01/30 16:15:24
can you forward decl IncidentReportingService inst
robertshield
2015/02/01 04:26:03
Done.
robertshield
2015/02/01 04:26:03
Done.
| |
| 11 | |
| 12 namespace net { | |
| 13 class URLRequest; | |
| 14 } | |
| 15 | |
| 16 namespace safe_browsing { | |
| 17 | |
| 18 class ClientIncidentReport_IncidentData_ScriptRequestIncident; | |
| 19 | |
| 20 // Observes network requests and reports suspicious activity. | |
| 21 class ScriptRequestDetector { | |
| 22 public: | |
| 23 // |incident_reporting_service| MUST outlive this class. | |
| 24 explicit ScriptRequestDetector( | |
| 25 IncidentReportingService* incident_reporting_service); | |
| 26 virtual ~ScriptRequestDetector(); | |
| 27 | |
| 28 // Analyzes the |request| and triggers an incident report on suspicious | |
| 29 // script inclusion. | |
| 30 void OnResourceRequest(const net::URLRequest* request); | |
| 31 | |
| 32 // Add a custom script hash. Used only for testing. | |
| 33 void AddScriptHashForTesting(const std::string& raw_hash); | |
| 34 | |
| 35 // Add a custom script hash. Used only for testing. | |
| 36 bool ContainsScriptHashForTesting(const std::string& raw_hash); | |
| 37 | |
| 38 protected: | |
| 39 // Testing hook. | |
| 40 virtual bool AllowNullProfileForTesting(); | |
| 41 | |
| 42 private: | |
| 43 void InitializeScriptSet(); | |
| 44 | |
| 45 void ReportIncidentOnUIThread( | |
| 46 int render_process_id, | |
| 47 scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident> | |
| 48 incident_data); | |
| 49 | |
| 50 IncidentReportingService* incident_reporting_service_; | |
| 51 base::hash_set<std::string> script_set_; | |
| 52 | |
| 53 base::WeakPtrFactory<ScriptRequestDetector> weak_ptr_factory_; | |
|
grt (UTC plus 2)
2015/01/30 16:15:24
#include "base/memory/weak_ptr.h"
| |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(ScriptRequestDetector); | |
| 56 }; | |
| 57 | |
| 58 } // namespace safe_browsing | |
| 59 | |
| 60 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECT OR_H_ | |
| OLD | NEW |