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

Unified Diff: components/subresource_filter/content/browser/subresource_filter_navigation_throttle.cc

Issue 2060313002: Navigation throttle for the Safe Browsing Subresource Filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pre-tab-activation
Patch Set: comments Created 4 years, 6 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/subresource_filter_navigation_throttle.cc
diff --git a/components/subresource_filter/content/browser/subresource_filter_navigation_throttle.cc b/components/subresource_filter/content/browser/subresource_filter_navigation_throttle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4d44ab9e25303adec5388768b8f7f49e76415ab0
--- /dev/null
+++ b/components/subresource_filter/content/browser/subresource_filter_navigation_throttle.cc
@@ -0,0 +1,61 @@
+// Copyright 2016 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.
+
+#include "components/subresource_filter/content/browser/subresource_filter_navigation_throttle.h"
+
+#include "components/subresource_filter/content/browser/content_subresource_filter_driver.h"
+#include "components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h"
+#include "components/subresource_filter/core/browser/subresource_filter_features.h"
+#include "components/subresource_filter/core/common/activation_state.h"
+#include "content/public/browser/navigation_handle.h"
+
+namespace subresource_filter {
+
+// static
+std::unique_ptr<content::NavigationThrottle>
+SubresourceFilterNavigationThrottle::Create(content::NavigationHandle* handle) {
+ return std::unique_ptr<content::NavigationThrottle>(
+ new SubresourceFilterNavigationThrottle(handle));
+}
+
+SubresourceFilterNavigationThrottle::SubresourceFilterNavigationThrottle(
+ content::NavigationHandle* handle)
+ : content::NavigationThrottle(handle) {
+ initial_url_ = navigation_handle()->GetURL();
nasko 2016/06/28 22:12:36 Why not put this in the initializer list?
melandory 2016/07/01 07:10:49 No good reason at all.
+}
+
+SubresourceFilterNavigationThrottle::~SubresourceFilterNavigationThrottle() {}
+
+content::NavigationThrottle::ThrottleCheckResult
+SubresourceFilterNavigationThrottle::WillRedirectRequest() {
+ subresource_filter::ContentSubresourceFilterDriverFactory* driver_factory =
nasko 2016/06/28 22:12:36 You are already in the subresource_filter namespac
melandory 2016/07/01 07:10:49 Done.
+ subresource_filter::ContentSubresourceFilterDriverFactory::
+ FromWebContents(navigation_handle()->GetWebContents());
+ if (driver_factory->ShouldActivateForURL(initial_url_)) {
+ driver_factory->AddOriginOfURLToActivationSet(
+ navigation_handle()->GetURL());
+ }
+
+ return NavigationThrottle::PROCEED;
+}
+
+content::NavigationThrottle::ThrottleCheckResult
+SubresourceFilterNavigationThrottle::WillProcessResponse() {
+ if (!navigation_handle()->GetURL().SchemeIsHTTPOrHTTPS())
+ return NavigationThrottle::PROCEED;
+
+ subresource_filter::ContentSubresourceFilterDriverFactory* driver_factory =
+ subresource_filter::ContentSubresourceFilterDriverFactory::
+ FromWebContents(navigation_handle()->GetWebContents());
+ if (driver_factory && driver_factory->ShouldActivateForURL(initial_url_)) {
+ ContentSubresourceFilterDriver* driver =
+ driver_factory->DriverFromFrameHost(
+ navigation_handle()->GetRenderFrameHost());
+ driver->ActivateForProvisionalLoad(GetMaximumActivationState());
+ }
+
+ return NavigationThrottle::PROCEED;
+}
+
+} // namespace subresource_filter

Powered by Google App Engine
This is Rietveld 408576698