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..ee6869e44ef239340f1c6801e4f16f6279090290 |
--- /dev/null |
+++ b/chrome/browser/safe_browsing/incident_reporting/script_request_detector.h |
@@ -0,0 +1,61 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
grt (UTC plus 2)
2015/01/28 14:49:05
So this is the new year? I don't feel any differen
robertshield
2015/01/28 22:20:32
I find your assumption that I too am bound to the
|
+// 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/callback.h" |
grt (UTC plus 2)
2015/01/28 14:49:05
unused?
robertshield
2015/01/28 22:20:32
Done.
|
+#include "base/containers/hash_tables.h" |
+#include "base/macros.h" |
+#include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.h" |
+#include "chrome/common/safe_browsing/csd.pb.h" |
grt (UTC plus 2)
2015/01/28 14:49:05
replace this with a forward decl of ClientIncident
robertshield
2015/01/28 22:20:33
Done.
|
+#include "content/public/common/resource_type.h" |
grt (UTC plus 2)
2015/01/28 14:49:05
unused?
robertshield
2015/01/28 22:20:33
Done.
|
+ |
+namespace net { |
+class URLRequest; |
+} |
+ |
+namespace safe_browsing { |
+ |
+// Observes network requests and reports suspicious activity. |
+class ScriptRequestDetector { |
+ public: |
+ // |incident_reporting_service| MUST outlive this class. |
+ explicit ScriptRequestDetector( |
+ IncidentReportingService* incident_reporting_service); |
grt (UTC plus 2)
2015/01/28 14:49:05
Passing in a ptr to the service defeats the whole
robertshield
2015/01/28 22:20:33
Agreed, at the same time with the current API this
grt (UTC plus 2)
2015/01/30 16:15:23
The more I think about it, the less comfortable I
robertshield
2015/02/01 04:25:57
Sure, happy to merge either way, let me know.
grt (UTC plus 2)
2015/02/02 18:45:22
The latest work-in-progress is out for review here
robertshield
2015/02/06 02:47:47
Rebased on top of the latest hotness.
|
+ virtual ~ScriptRequestDetector(); |
+ |
+ // Analyzes the |request| and triggers an incident report on suspicious |
+ // script inclusion. |
+ void OnResourceRequest(const net::URLRequest* request); |
+ |
+ // Add a custom script hash. Used only for testing. |
+ void AddScriptHashForTesting(const std::string& raw_hash); |
grt (UTC plus 2)
2015/01/28 14:49:05
unused
robertshield
2015/01/28 22:20:32
Done.
grt (UTC plus 2)
2015/01/30 16:15:23
Hard to kill, it seems.
robertshield
2015/02/01 04:26:00
Huh, I stabbed it repeatedly this time.
|
+ |
+ // Add a custom script hash. Used only for testing. |
+ bool ContainsScriptHashForTesting(const std::string& raw_hash); |
grt (UTC plus 2)
2015/01/28 14:49:05
unused
robertshield
2015/01/28 22:20:33
Done.
grt (UTC plus 2)
2015/01/30 16:15:23
I don't think this word means what you think it me
robertshield
2015/02/01 04:25:57
It would seem I fell victim to one of the classic
|
+ |
+ protected: |
+ // Testing hook. |
+ virtual bool AllowNullProfileForTesting(); |
grt (UTC plus 2)
2015/01/28 14:49:05
interesting. gab@ chose to do GetProfileForRenderP
robertshield
2015/01/28 22:20:32
Interesting, I don't believe one is better than th
grt (UTC plus 2)
2015/01/30 16:15:23
How do you feel about getting rid of virtual dispa
robertshield
2015/02/01 04:25:59
Equally ok. I am chronically unopinionated about s
|
+ |
+ private: |
+ void InitializeScriptSet(); |
+ |
+ void ReportIncidentOnUIThread( |
+ int render_process_id, |
+ scoped_ptr<ClientIncidentReport_IncidentData_ScriptRequestIncident> |
+ incident_data); |
+ |
+ IncidentReportingService* incident_reporting_service_; |
+ base::hash_set<std::string> script_set_; |
+ |
+ 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_ |