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 "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" | |
13 | |
14 namespace net { | |
15 class URLRequest; | |
16 } | |
17 | |
18 namespace safe_browsing { | |
19 | |
20 class ClientIncidentReport_IncidentData_ScriptRequestIncident; | |
21 | |
22 // Observes network requests and reports suspicious activity. | |
23 class ScriptRequestDetector { | |
24 public: | |
25 // |incident_reporting_service| MUST outlive this class. | |
grt (UTC plus 2)
2015/02/06 23:37:47
Oops, stale comment. Sorry I missed this before.
robertshield
2015/02/09 04:36:43
Done.
| |
26 explicit ScriptRequestDetector( | |
27 scoped_ptr<IncidentReceiver> incident_receiver); | |
28 ~ScriptRequestDetector(); | |
29 | |
30 // Analyzes the |request| and triggers an incident report on suspicious | |
31 // script inclusion. | |
32 void OnResourceRequest(const net::URLRequest* request); | |
33 | |
34 protected: | |
35 // Testing hook. | |
36 void set_allow_null_profile_for_testing(bool allow_null_profile_for_testing); | |
37 | |
38 // Protected for testing. | |
39 scoped_ptr<IncidentReceiver> incident_receiver_; | |
40 | |
41 private: | |
42 void InitializeScriptSet(); | |
43 | |
44 void ReportIncidentOnUIThread( | |
45 int render_process_id, | |
46 int render_frame_id, | |
47 scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident> | |
48 incident_data); | |
49 | |
50 base::hash_set<std::string> script_set_; | |
51 bool allow_null_profile_for_testing_; | |
52 | |
53 base::WeakPtrFactory<ScriptRequestDetector> weak_ptr_factory_; | |
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 |