OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_
H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_
H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_
H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_
H_ |
7 | 7 |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" | 12 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 class URLRequest; | 15 class URLRequest; |
16 } | 16 } |
17 | 17 |
18 namespace safe_browsing { | 18 namespace safe_browsing { |
19 | 19 |
20 class ClientIncidentReport_IncidentData_ScriptRequestIncident; | 20 class ClientIncidentReport_IncidentData_ScriptRequestIncident; |
| 21 class ClientIncidentReport_IncidentData_DomainRequestIncident; |
21 | 22 |
22 // Observes network requests and reports suspicious activity. | 23 // Observes network requests and reports suspicious activity. |
23 class ScriptRequestDetector { | 24 class ScriptRequestDetector { |
24 public: | 25 public: |
25 explicit ScriptRequestDetector( | 26 explicit ScriptRequestDetector( |
26 scoped_ptr<IncidentReceiver> incident_receiver); | 27 scoped_ptr<IncidentReceiver> incident_receiver); |
27 ~ScriptRequestDetector(); | 28 ~ScriptRequestDetector(); |
28 | 29 |
29 // Analyzes the |request| and triggers an incident report on suspicious | 30 // Analyzes the |request| and triggers an incident report on suspicious |
30 // script inclusion. | 31 // script inclusion. |
31 void OnResourceRequest(const net::URLRequest* request); | 32 void OnResourceRequest(const net::URLRequest* request); |
32 | 33 |
33 protected: | 34 protected: |
34 // Testing hook. | 35 // Testing hook. |
35 void set_allow_null_profile_for_testing(bool allow_null_profile_for_testing); | 36 void set_allow_null_profile_for_testing(bool allow_null_profile_for_testing); |
36 | 37 |
37 private: | 38 private: |
38 void InitializeScriptSet(); | 39 void InitializeHashSets(); |
39 | 40 |
40 void ReportIncidentOnUIThread( | 41 void DetectDomainRequests(const net::URLRequest* request); |
| 42 void DetectScriptRequests(const net::URLRequest* request); |
| 43 |
| 44 void ReportDomainIncidentOnUIThread( |
| 45 int render_process_id, |
| 46 int render_frame_id, |
| 47 scoped_ptr<ClientIncidentReport_IncidentData_DomainRequestIncident> |
| 48 incident_data); |
| 49 |
| 50 void ReportScriptIncidentOnUIThread( |
41 int render_process_id, | 51 int render_process_id, |
42 int render_frame_id, | 52 int render_frame_id, |
43 scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident> | 53 scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident> |
44 incident_data); | 54 incident_data); |
45 | 55 |
46 scoped_ptr<IncidentReceiver> incident_receiver_; | 56 scoped_ptr<IncidentReceiver> incident_receiver_; |
47 base::hash_set<std::string> script_set_; | 57 base::hash_set<std::string> script_set_; |
| 58 base::hash_set<std::string> domain_set_; |
48 bool allow_null_profile_for_testing_; | 59 bool allow_null_profile_for_testing_; |
49 | 60 |
50 base::WeakPtrFactory<ScriptRequestDetector> weak_ptr_factory_; | 61 base::WeakPtrFactory<ScriptRequestDetector> weak_ptr_factory_; |
51 | 62 |
52 DISALLOW_COPY_AND_ASSIGN(ScriptRequestDetector); | 63 DISALLOW_COPY_AND_ASSIGN(ScriptRequestDetector); |
53 }; | 64 }; |
54 | 65 |
55 } // namespace safe_browsing | 66 } // namespace safe_browsing |
56 | 67 |
57 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECT
OR_H_ | 68 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECT
OR_H_ |
OLD | NEW |