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

Unified Diff: chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector.h

Issue 516663002: Introducing the OffDomainInclusionDetector to analyze resource requests for suspicious activity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: probably unecessary but harmless reset Created 6 years, 1 month 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/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..2b18d84a20c3ea4cbc20a189ff95804fca19d78c
--- /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 class AnalysisEvent {
+ 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.
+ explicit OffDomainInclusionDetector(
+ 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_

Powered by Google App Engine
This is Rietveld 408576698