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

Unified Diff: extensions/renderer/programmatic_script_injector.cc

Issue 2471553003: Fix content script injection not working with PlzNavigate because of different navigation timings. (Closed)
Patch Set: review comments 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 | « extensions/renderer/programmatic_script_injector.h ('k') | extensions/renderer/script_injection_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/programmatic_script_injector.cc
diff --git a/extensions/renderer/programmatic_script_injector.cc b/extensions/renderer/programmatic_script_injector.cc
index 0c40d72054e23e3694dd969eb5d3c2e897b43400..cd4a4596ca0f5ddd7d40006977e00134502d6b7a 100644
--- a/extensions/renderer/programmatic_script_injector.cc
+++ b/extensions/renderer/programmatic_script_injector.cc
@@ -26,16 +26,9 @@
namespace extensions {
ProgrammaticScriptInjector::ProgrammaticScriptInjector(
- const ExtensionMsg_ExecuteCode_Params& params,
- content::RenderFrame* render_frame)
+ const ExtensionMsg_ExecuteCode_Params& params)
: params_(new ExtensionMsg_ExecuteCode_Params(params)),
- url_(
- ScriptContext::GetDataSourceURLForFrame(render_frame->GetWebFrame())),
finished_(false) {
- if (url_.SchemeIs(url::kAboutScheme)) {
- origin_for_about_error_ =
- render_frame->GetWebFrame()->getSecurityOrigin().toString().utf8();
- }
}
ProgrammaticScriptInjector::~ProgrammaticScriptInjector() {
@@ -73,7 +66,15 @@ bool ProgrammaticScriptInjector::ShouldInjectCss(
PermissionsData::AccessType ProgrammaticScriptInjector::CanExecuteOnFrame(
const InjectionHost* injection_host,
blink::WebLocalFrame* frame,
- int tab_id) const {
+ int tab_id) {
+ // Note: we calculate url_ now and not in the constructor because with
+ // PlzNavigate we won't have the URL at that point when loads start. The
+ // browser issues the request and only when it has a response does the
+ // renderer see the provisional data source which the method below uses.
+ url_ = ScriptContext::GetDataSourceURLForFrame(frame);
+ if (url_.SchemeIs(url::kAboutScheme)) {
+ origin_for_about_error_ = frame->getSecurityOrigin().toString().utf8();
+ }
GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL(
frame, frame->document().url(), params_->match_about_blank);
if (params_->is_web_view) {
« no previous file with comments | « extensions/renderer/programmatic_script_injector.h ('k') | extensions/renderer/script_injection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698