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

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

Issue 2762403002: Wire up the ThrottleManager using the existing page activation logic (Closed)
Patch Set: small tweaks Created 3 years, 9 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/content_subresource_filter_throttle_manager.cc
diff --git a/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.cc b/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.cc
index 1f701be98ac04039ab52dbf69e2dda0401ceda6d..b8531ab1a7a30cee23f44206ba417f633a485af1 100644
--- a/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.cc
+++ b/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.cc
@@ -10,6 +10,7 @@
#include "components/subresource_filter/content/browser/activation_state_computing_navigation_throttle.h"
#include "components/subresource_filter/content/browser/async_document_subresource_filter.h"
#include "components/subresource_filter/content/browser/subframe_navigation_filtering_throttle.h"
+#include "components/subresource_filter/content/common/subresource_filter_messages.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
@@ -17,6 +18,33 @@
namespace subresource_filter {
+namespace {
+
+// Used to forward calls to WillProcessResonse to the driver. Placeholder until
+// safebrowsing refactor is finished.
+class ForwardingNavigationThrottle : public content::NavigationThrottle {
pkalinnikov 2017/04/03 13:40:08 nit: #include "content/public/browser/navigation_t
Charlie Harrison 2017/04/03 15:33:31 Done.
+ public:
+ ForwardingNavigationThrottle(
+ content::NavigationHandle* handle,
+ ContentSubresourceFilterThrottleManager::Delegate* delegate)
+ : content::NavigationThrottle(handle), delegate_(delegate) {}
+ ~ForwardingNavigationThrottle() override {}
+
+ // content::NavigationThrottle:
+ content::NavigationThrottle::ThrottleCheckResult WillProcessResponse()
+ override {
+ delegate_->WillProcessResponse(navigation_handle());
+ return content::NavigationThrottle::PROCEED;
+ }
+
+ private:
+ ContentSubresourceFilterThrottleManager::Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(ForwardingNavigationThrottle);
+};
+
+} // namespace
+
bool ContentSubresourceFilterThrottleManager::Delegate::
ShouldSuppressActivation(content::NavigationHandle* navigation_handle) {
return false;
@@ -62,17 +90,22 @@ void ContentSubresourceFilterThrottleManager::ReadyToCommitNavigation(
if (throttle == ongoing_activation_throttles_.end())
return;
+ // A filter with DISABLED activation indicates a corrupted ruleset.
AsyncDocumentSubresourceFilter* filter = throttle->second->filter();
if (!filter || navigation_handle->GetNetErrorCode() != net::OK ||
+ filter->activation_state().activation_level ==
+ ActivationLevel::DISABLED ||
delegate_->ShouldSuppressActivation(navigation_handle)) {
return;
}
- DCHECK_NE(ActivationLevel::DISABLED,
- filter->activation_state().activation_level);
-
throttle->second->WillSendActivationToRenderer();
- // TODO(csharrison): Send an IPC to the renderer.
+
+ content::RenderFrameHost* frame_host =
+ navigation_handle->GetRenderFrameHost();
+ frame_host->Send(new SubresourceFilterMsg_ActivateForNextCommittedLoad(
+ frame_host->GetRoutingID(), filter->activation_state().activation_level,
+ filter->activation_state().measure_performance));
}
void ContentSubresourceFilterThrottleManager::DidFinishNavigation(
@@ -110,10 +143,28 @@ void ContentSubresourceFilterThrottleManager::DidFinishNavigation(
DestroyRulesetHandleIfNoLongerUsed();
}
+bool ContentSubresourceFilterThrottleManager::OnMessageReceived(
+ const IPC::Message& message,
+ content::RenderFrameHost* render_frame_host) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ContentSubresourceFilterThrottleManager, message)
+ IPC_MESSAGE_HANDLER(SubresourceFilterHostMsg_DidDisallowFirstSubresource,
+ MaybeCallFirstDisallowedLoad)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
void ContentSubresourceFilterThrottleManager::MaybeAppendNavigationThrottles(
content::NavigationHandle* navigation_handle,
std::vector<std::unique_ptr<content::NavigationThrottle>>* throttles) {
DCHECK(!navigation_handle->IsSameDocument());
+ if (!dealer_handle_)
+ return;
+ if (navigation_handle->IsInMainFrame()) {
+ throttles->push_back(base::MakeUnique<ForwardingNavigationThrottle>(
+ navigation_handle, delegate_));
+ }
if (auto filtering_throttle =
MaybeCreateSubframeNavigationFilteringThrottle(navigation_handle)) {
throttles->push_back(std::move(filtering_throttle));

Powered by Google App Engine
This is Rietveld 408576698