Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/script_request_detector.h

Issue 845663004: Initial script request detector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
15 namespace net {
16 class URLRequest;
17 }
18
19 namespace safe_browsing {
20
21 class ClientIncidentReport_IncidentData_ScriptRequestIncident;
22
23 // Observes network requests and reports suspicious activity.
24 class ScriptRequestDetector {
25 public:
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 private:
39 void InitializeScriptSet();
40
41 void ReportIncidentOnUIThread(
42 int render_process_id,
43 int render_frame_id,
44 scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident>
45 incident_data);
46
47 scoped_ptr<IncidentReceiver> incident_receiver_;
48 base::hash_set<std::string> script_set_;
49 bool allow_null_profile_for_testing_;
50
51 base::WeakPtrFactory<ScriptRequestDetector> weak_ptr_factory_;
52
53 DISALLOW_COPY_AND_ASSIGN(ScriptRequestDetector);
54 };
55
56 } // namespace safe_browsing
57
58 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECT OR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698