Index: chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector.h |
diff --git a/chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector.h b/chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..52cf129d59e1b9b96c9368c42e3c6a97a55f32e7 |
--- /dev/null |
+++ b/chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector.h |
@@ -0,0 +1,54 @@ |
+// Copyright 2014 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_OFF_DOMAIN_INCLUSION_DETECTOR_H_ |
+#define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_OFF_DOMAIN_INCLUSION_DETECTOR_H_ |
+ |
+#include "base/callback.h" |
+#include "base/macros.h" |
+#include "content/public/common/resource_type.h" |
+ |
+namespace net { |
+class URLRequest; |
+} |
+ |
+namespace safe_browsing { |
+ |
+// Observes network requests and reports suspicious activity. |
+class OffDomainInclusionDetector { |
+ public: |
+ enum AnalysisEvent { |
mattm
2014/11/14 04:16:00
Use enum class?
gab
2014/11/14 19:48:36
Done.
|
+ NO_EVENT, |
+ EMPTY_MAIN_FRAME_URL, |
+ INVALID_MAIN_FRAME_URL, |
+ OFF_DOMAIN_INCLUSION_DETECTED, |
+ }; |
+ |
+ // TODO(gab): Hook the OffDomainInclusionDetector to the |
+ // IncidentReportingService and use an AddIncidentCallback instead of this |
+ // custom callback type. |
+ typedef base::Callback<void(AnalysisEvent event)> ReportAnalysisEventCallback; |
+ |
+ OffDomainInclusionDetector(); |
+ |
+ // Constructs an OffDomainInclusionDetector with a ReportAnalysisEventCallback |
+ // to get feedback from detection events, used only in tests. |
+ OffDomainInclusionDetector( |
mattm
2014/11/14 04:16:00
explicit
gab
2014/11/14 19:48:36
Done.
|
+ const ReportAnalysisEventCallback& report_analysis_event_callback); |
+ |
+ ~OffDomainInclusionDetector(); |
+ |
+ // Analyzes the |request| and reports via UMA if an AnalysisEvent is triggered |
+ // (and via |report_analysis_event_callback_| if it is set). |
+ void OnResourceRequest(const net::URLRequest* request); |
+ |
+ private: |
+ const ReportAnalysisEventCallback report_analysis_event_callback_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(OffDomainInclusionDetector); |
+}; |
+ |
+} // namespace safe_browsing |
+ |
+#endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_OFF_DOMAIN_INCLUSION_DETECTOR_H_ |