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

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: grt feedback, switch to gmock 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..7cbc7dbf2ff7862ef66c1fc1b7a68b82a7304976
--- /dev/null
+++ b/chrome/browser/safe_browsing/incident_reporting/script_request_detector.h
@@ -0,0 +1,60 @@
+// 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:
+ // |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.
+ 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);
+
+ // Protected for testing.
+ scoped_ptr<IncidentReceiver> incident_receiver_;
+
+ private:
+ void InitializeScriptSet();
+
+ void ReportIncidentOnUIThread(
+ int render_process_id,
+ int render_frame_id,
+ scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident>
+ incident_data);
+
+ 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