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

Unified Diff: components/subresource_filter/content/renderer/web_document_subresource_filter_impl.h

Issue 2697363005: Move DocumentSubresourceFilter to core/common. (Closed)
Patch Set: Address comments from engedy@. 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/renderer/web_document_subresource_filter_impl.h
diff --git a/components/subresource_filter/content/renderer/web_document_subresource_filter_impl.h b/components/subresource_filter/content/renderer/web_document_subresource_filter_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..32568bbc0eaf3129d35ec2db51f5eaabc0048c1a
--- /dev/null
+++ b/components/subresource_filter/content/renderer/web_document_subresource_filter_impl.h
@@ -0,0 +1,52 @@
+// 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_RENDERER_WEB_DOCUMENT_SUBRESOURCE_FILTER_IMPL_H_
+#define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_RENDERER_WEB_DOCUMENT_SUBRESOURCE_FILTER_IMPL_H_
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "components/subresource_filter/core/common/document_subresource_filter.h"
+#include "third_party/WebKit/public/platform/WebDocumentSubresourceFilter.h"
+
+namespace subresource_filter {
+
+class MemoryMappedRuleset;
+
+// Performs filtering of subresource loads in the scope of a given document.
+class WebDocumentSubresourceFilterImpl
+ : public blink::WebDocumentSubresourceFilter,
+ public base::SupportsWeakPtr<WebDocumentSubresourceFilterImpl> {
+ public:
+ // See DocumentSubresourceFilter description.
+ //
+ // Invokes |first_disallowed_load_callback|, if it is non-null, on the first
+ // reportDisallowedLoad() call.
+ WebDocumentSubresourceFilterImpl(
+ url::Origin document_origin,
+ ActivationState activation_state,
+ scoped_refptr<const MemoryMappedRuleset> ruleset,
+ base::OnceClosure first_disallowed_load_callback);
+
+ ~WebDocumentSubresourceFilterImpl() override;
+
+ const DocumentSubresourceFilter& filter() const { return filter_; }
+
+ // blink::WebDocumentSubresourceFilter:
+ blink::WebDocumentSubresourceFilter::LoadPolicy getLoadPolicy(
+ const blink::WebURL& resourceUrl,
+ blink::WebURLRequest::RequestContext) override;
+ void reportDisallowedLoad() override;
+
+ private:
+ DocumentSubresourceFilter filter_;
+ base::OnceClosure first_disallowed_load_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebDocumentSubresourceFilterImpl);
+};
+
+} // namespace subresource_filter
+
+#endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_RENDERER_WEB_DOCUMENT_SUBRESOURCE_FILTER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698