Index: components/subresource_filter/content/renderer/subresource_filter_agent.cc |
diff --git a/components/subresource_filter/content/renderer/subresource_filter_agent.cc b/components/subresource_filter/content/renderer/subresource_filter_agent.cc |
index 654d0247b8b0b1e99f36495e15ebc16a13ab0651..7dd1d8cffb182c4b9b1468612c9e3472910fc2ef 100644 |
--- a/components/subresource_filter/content/renderer/subresource_filter_agent.cc |
+++ b/components/subresource_filter/content/renderer/subresource_filter_agent.cc |
@@ -11,6 +11,7 @@ |
#include "components/subresource_filter/content/renderer/document_subresource_filter.h" |
#include "components/subresource_filter/content/renderer/ruleset_dealer.h" |
#include "components/subresource_filter/core/common/memory_mapped_ruleset.h" |
+#include "content/public/common/browser_side_navigation_policy.h" |
#include "content/public/renderer/render_frame.h" |
#include "ipc/ipc_message.h" |
#include "third_party/WebKit/public/web/WebDataSource.h" |
@@ -57,9 +58,11 @@ void SubresourceFilterAgent:: |
render_frame()->GetRoutingID())); |
} |
-void SubresourceFilterAgent::ActivateForProvisionalLoad( |
- ActivationState activation_state) { |
+void SubresourceFilterAgent::OnActivateForProvisionalLoad( |
+ ActivationState activation_state, |
+ const GURL& url) { |
activation_state_for_provisional_load_ = activation_state; |
+ url_for_provisional_load_ = url; |
} |
void SubresourceFilterAgent::RecordHistogramsOnLoadCommitted() { |
@@ -95,7 +98,21 @@ void SubresourceFilterAgent::OnDestruct() { |
} |
void SubresourceFilterAgent::DidStartProvisionalLoad() { |
- activation_state_for_provisional_load_ = ActivationState::DISABLED; |
+ // With PlzNavigate, DidStartProvisionalLoad and DidCommitProvisionalLoad will |
+ // both be called in response to the one commit IPC from the browser. That |
+ // means that they will come after OnActivateForProvisionalLoad. So we have to |
+ // have extra logic to check that the response to OnActivateForProvisionalLoad |
+ // isn't removed in that case. |
+ blink::WebDataSource* ds = |
+ render_frame() ? render_frame()->GetWebFrame()->provisionalDataSource() |
+ : nullptr; |
+ if (!content::IsBrowserSideNavigationEnabled() || |
+ (!ds || |
+ static_cast<GURL>(ds->request().url()) != url_for_provisional_load_)) { |
+ activation_state_for_provisional_load_ = ActivationState::DISABLED; |
+ } else { |
+ url_for_provisional_load_ = GURL(); |
+ } |
filter_for_last_committed_load_.reset(); |
} |
@@ -132,7 +149,7 @@ bool SubresourceFilterAgent::OnMessageReceived(const IPC::Message& message) { |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(SubresourceFilterAgent, message) |
IPC_MESSAGE_HANDLER(SubresourceFilterMsg_ActivateForProvisionalLoad, |
- ActivateForProvisionalLoad) |
+ OnActivateForProvisionalLoad) |
jam
2016/10/24 04:51:20
nit: changed this to match convention for IPC mess
|
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
return handled; |