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

Unified 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: Use GetLastCommittedURL instead of going through the SiteInstance on the RFH 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 side-by-side diff with in-line comments
Download patch
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..f5e31f0654bb4c54683cb3947c4656985195e05f
--- /dev/null
+++ b/chrome/browser/safe_browsing/incident_reporting/script_request_detector.h
@@ -0,0 +1,57 @@
+// 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 "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
+
+namespace net {
+class URLRequest;
+}
+
+namespace safe_browsing {
+
+class ClientIncidentReport_IncidentData_ScriptRequestIncident;
+
+// Observes network requests and reports suspicious activity.
+class ScriptRequestDetector {
+ public:
+ explicit ScriptRequestDetector(
+ scoped_ptr<IncidentReceiver> incident_receiver);
+ ~ScriptRequestDetector();
+
+ // Analyzes the |request| and triggers an incident report on suspicious
+ // script inclusion.
+ void OnResourceRequest(const net::URLRequest* request);
+
+ protected:
+ // Testing hook.
+ void set_allow_null_profile_for_testing(bool allow_null_profile_for_testing);
+
+ private:
+ void InitializeScriptSet();
+
+ void ReportIncidentOnUIThread(
+ int render_process_id,
+ int render_frame_id,
+ scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident>
+ incident_data);
+
+ scoped_ptr<IncidentReceiver> incident_receiver_;
+ base::hash_set<std::string> script_set_;
+ bool allow_null_profile_for_testing_;
+
+ base::WeakPtrFactory<ScriptRequestDetector> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScriptRequestDetector);
+};
+
+} // namespace safe_browsing
+
+#endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_SCRIPT_REQUEST_DETECTOR_H_

Powered by Google App Engine
This is Rietveld 408576698