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

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: pkalinnikov review 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..079f71035808a69df24c0fb621d0233b3c31901b 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,13 +10,42 @@
#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/navigation_throttle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "net/base/net_errors.h"
namespace subresource_filter {
+namespace {
+
+// Used to forward calls to WillProcessResonse to the driver. Placeholder until
engedy 2017/04/04 11:36:53 nit: Could you please file a tracking bug and mark
Charlie Harrison 2017/04/04 15:54:01 Done. I only marked this location because basicall
engedy 2017/04/04 17:59:56 Makes sense.
+// safebrowsing refactor is finished.
+class ForwardingNavigationThrottle : public content::NavigationThrottle {
+ 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 +91,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 +144,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_)
engedy 2017/04/04 11:36:53 WDYT about moving this after the injection of the
Charlie Harrison 2017/04/04 15:54:01 Sure, done.
+ 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