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.
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_H_
8 #include "base/containers/hash_tables.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
18 namespace safe_browsing
{
20 class ClientIncidentReport_IncidentData_ScriptRequestIncident
;
22 // Observes network requests and reports suspicious activity.
23 class ScriptRequestDetector
{
25 explicit ScriptRequestDetector(
26 scoped_ptr
<IncidentReceiver
> incident_receiver
);
27 ~ScriptRequestDetector();
29 // Analyzes the |request| and triggers an incident report on suspicious
31 void OnResourceRequest(const net::URLRequest
* request
);
35 void set_allow_null_profile_for_testing(bool allow_null_profile_for_testing
);
38 void InitializeScriptSet();
40 void ReportIncidentOnUIThread(
41 int render_process_id
,
43 scoped_ptr
<ClientIncidentReport_IncidentData_ScriptRequestIncident
>
46 scoped_ptr
<IncidentReceiver
> incident_receiver_
;
47 base::hash_set
<std::string
> script_set_
;
48 bool allow_null_profile_for_testing_
;
50 base::WeakPtrFactory
<ScriptRequestDetector
> weak_ptr_factory_
;
52 DISALLOW_COPY_AND_ASSIGN(ScriptRequestDetector
);
55 } // namespace safe_browsing
57 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_H_