Chromium Code Reviews| 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..c372cd712c4acdfb38b99fd957804db59d979e9c |
| --- /dev/null |
| +++ b/components/subresource_filter/content/browser/subresource_filter_navigation_throttle.cc |
| @@ -0,0 +1,60 @@ |
| +// 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(); |
| +} |
| + |
| +SubresourceFilterNavigationThrottle::~SubresourceFilterNavigationThrottle() {} |
| + |
| +content::NavigationThrottle::ThrottleCheckResult |
| +SubresourceFilterNavigationThrottle::WillRedirectRequest() { |
| + subresource_filter::ContentSubresourceFilterDriverFactory* driver_factory = |
| + subresource_filter::ContentSubresourceFilterDriverFactory:: |
| + FromWebContents(navigation_handle()->GetWebContents()); |
| + if (driver_factory->ShouldActivateForURL(initial_url_)) { |
|
engedy
2016/06/23 22:34:18
What happens if the second (or later) URL in a red
melandory
2016/06/25 01:46:08
Redirects which has happened before SB match are r
|
| + driver_factory->AddToSocEngList(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->ShouldActivateForURL(initial_url_)) { |
|
engedy
2016/06/23 22:34:18
Is there an guaranteed ordering in which the throt
clamy
2016/06/24 12:13:38
There is no SBNavigationThrottle, but a SBResource
|
| + ContentSubresourceFilterDriver* driver = |
| + driver_factory->DriverFromFrameHost( |
| + navigation_handle()->GetRenderFrameHost()); |
| + driver->ActivateForProvisionalLoad(GetMaximumActivationState()); |
| + } |
| + |
| + return NavigationThrottle::PROCEED; |
| +} |
| + |
| +} // namespace subresource_filter |