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

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..fb71b4d1331e6f7b69efa7ad402787b9f7d219ae 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 if the location is
+ // UserScript::DOCUMENT_START. It needs to be at least past
+ // UserScript::DOCUMENT_END.
Devlin 2016/11/02 00:02:57 I'm confused - how would we inject at document sta
jam 2016/11/02 00:14:43 I was trying to mean that on construction of this
+ 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