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

Unified Diff: extensions/renderer/script_injection_manager.cc

Issue 2465813002: Fix content script injection for cancelled loads with PlzNavigate. (Closed)
Patch Set: simpler approach Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/script_injection_manager.cc
diff --git a/extensions/renderer/script_injection_manager.cc b/extensions/renderer/script_injection_manager.cc
index 19c356f4c2b57eaca8d77d04c09092848b3bf335..3941dd44e8c6f93d3a64dc7b66dbdc910430d7b4 100644
--- a/extensions/renderer/script_injection_manager.cc
+++ b/extensions/renderer/script_injection_manager.cc
@@ -12,6 +12,7 @@
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
+#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_thread.h"
@@ -26,6 +27,7 @@
#include "extensions/renderer/scripts_run_info.h"
#include "extensions/renderer/web_ui_injection_host.h"
#include "ipc/ipc_message_macros.h"
+#include "third_party/WebKit/public/platform/WebURLError.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
@@ -77,6 +79,7 @@ class ScriptInjectionManager::RFOHelper : public content::RenderFrameObserver {
void DidFinishLoad() override;
void FrameDetached() override;
void OnDestruct() override;
+ void OnStop() override;
virtual void OnExecuteCode(const ExtensionMsg_ExecuteCode_Params& params);
virtual void OnExecuteDeclarativeScript(int tab_id,
@@ -205,6 +208,15 @@ void ScriptInjectionManager::RFOHelper::OnDestruct() {
manager_->RemoveObserver(this);
}
+void ScriptInjectionManager::RFOHelper::OnStop() {
+ // With PlzNavigate, we won't get a provisional load failed notification
+ // for 204/205/downloads since these don't notify the renderer. However the
+ // browser does fire the OnStop IPC. So use that signal instead to avoid
+ // keeping the frame in a START state indefinitely which leads to deadlocks.
+ if (content::IsBrowserSideNavigationEnabled())
+ DidFailProvisionalLoad(blink::WebURLError());
+}
+
void ScriptInjectionManager::RFOHelper::OnExecuteCode(
const ExtensionMsg_ExecuteCode_Params& params) {
manager_->HandleExecuteCode(params, render_frame());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698