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

Unified Diff: components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.h

Issue 2696493003: Introduce SubframeNavigationFilteringThrottle (Closed)
Patch Set: remove tests Created 3 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: components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.h
diff --git a/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.h b/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9ba823943d14f15765bbe0439a48793be82c628
--- /dev/null
+++ b/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.h
@@ -0,0 +1,55 @@
+// Copyright 2017 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 COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBFRAME_NAVIGATION_FILTERING_THROTTLE_H_
+#define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBFRAME_NAVIGATION_FILTERING_THROTTLE_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "components/subresource_filter/content/browser/async_document_subresource_filter.h"
+#include "content/public/browser/navigation_throttle.h"
+
+namespace content {
+class NavigationHandle;
+} // namespace content
+
+namespace subresource_filter {
+
+class AsyncDocumentSubresourceFilter;
+
+// NavigationThrottle responsible for filtering subframe document loads, which
+// are considered subresource loads of their parent frame, hence are subject to
+// subresource filtering using the parent frame's
+// AsyncDocumentSubresourceFilter.
+//
+// The throttle should only be instantiated for navigations occuring in
+// subframes owned by documents which already have filtering activated, and
+// therefore an associated (Async)DocumentSubresourceFilter.
+class SubframeNavigationFilteringThrottle : public content::NavigationThrottle {
+ public:
+ SubframeNavigationFilteringThrottle(
+ content::NavigationHandle* handle,
+ AsyncDocumentSubresourceFilter* parent_frame_filter);
+ ~SubframeNavigationFilteringThrottle() override;
+
+ // content::NavigationThrottle:
+ content::NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
+ content::NavigationThrottle::ThrottleCheckResult WillRedirectRequest()
+ override;
+
+ private:
+ content::NavigationThrottle::ThrottleCheckResult DeferToCalculateLoadPolicy();
+ void OnCalculatedLoadPolicy(LoadPolicy policy);
+
+ // Must outlive this class.
+ AsyncDocumentSubresourceFilter* parent_frame_filter_;
+
+ base::WeakPtrFactory<SubframeNavigationFilteringThrottle> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SubframeNavigationFilteringThrottle);
+};
+
+} // namespace subresource_filter
+
+#endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBFRAME_NAVIGATION_FILTERING_THROTTLE_H_

Powered by Google App Engine
This is Rietveld 408576698