Chromium Code Reviews| Index: chrome/browser/safe_browsing/incident_reporting/script_request_detector.h |
| diff --git a/chrome/browser/safe_browsing/incident_reporting/script_request_detector.h b/chrome/browser/safe_browsing/incident_reporting/script_request_detector.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ac91f28e0463d6dbf3ceaea39c320ba88b20060f |
| --- /dev/null |
| +++ b/chrome/browser/safe_browsing/incident_reporting/script_request_detector.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_H_ |
| +#define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_H_ |
| + |
| +#include "base/containers/hash_tables.h" |
| +#include "base/macros.h" |
| +#include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.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.
|
| + |
| +namespace net { |
| +class URLRequest; |
| +} |
| + |
| +namespace safe_browsing { |
| + |
| +class ClientIncidentReport_IncidentData_ScriptRequestIncident; |
| + |
| +// Observes network requests and reports suspicious activity. |
| +class ScriptRequestDetector { |
| + public: |
| + // |incident_reporting_service| MUST outlive this class. |
| + explicit ScriptRequestDetector( |
| + IncidentReportingService* incident_reporting_service); |
| + virtual ~ScriptRequestDetector(); |
| + |
| + // Analyzes the |request| and triggers an incident report on suspicious |
| + // script inclusion. |
| + void OnResourceRequest(const net::URLRequest* request); |
| + |
| + // Add a custom script hash. Used only for testing. |
| + void AddScriptHashForTesting(const std::string& raw_hash); |
| + |
| + // Add a custom script hash. Used only for testing. |
| + bool ContainsScriptHashForTesting(const std::string& raw_hash); |
| + |
| + protected: |
| + // Testing hook. |
| + virtual bool AllowNullProfileForTesting(); |
| + |
| + private: |
| + void InitializeScriptSet(); |
| + |
| + void ReportIncidentOnUIThread( |
| + int render_process_id, |
| + scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident> |
| + incident_data); |
| + |
| + IncidentReportingService* incident_reporting_service_; |
| + base::hash_set<std::string> script_set_; |
| + |
| + base::WeakPtrFactory<ScriptRequestDetector> weak_ptr_factory_; |
|
grt (UTC plus 2)
2015/01/30 16:15:24
#include "base/memory/weak_ptr.h"
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScriptRequestDetector); |
| +}; |
| + |
| +} // namespace safe_browsing |
| + |
| +#endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_H_ |