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

Unified Diff: extensions/renderer/script_injection.cc

Issue 2134613002: Stop injection when injections are invalidated Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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: extensions/renderer/script_injection.cc
diff --git a/extensions/renderer/script_injection.cc b/extensions/renderer/script_injection.cc
index da93590c3908c00fb33421a2b3ff9f1077e04b06..cc1a63233ada6dae326790a55dfc45686057c80a 100644
--- a/extensions/renderer/script_injection.cc
+++ b/extensions/renderer/script_injection.cc
@@ -153,7 +153,7 @@ ScriptInjection::InjectionResult ScriptInjection::TryToInject(
if (!injection_host_) {
NotifyWillNotInject(ScriptInjector::EXTENSION_REMOVED);
- return INJECTION_FINISHED; // We're done.
+ return INJECTION_CANCELED; // We're done.
}
blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame();
@@ -172,6 +172,8 @@ ScriptInjection::InjectionResult ScriptInjection::TryToInject(
// notify it upon completion.
if (result == INJECTION_BLOCKED)
async_completion_callback_ = async_completion_callback;
+ else if (result == INJECTION_CANCELED)
+ NotifyWillNotInject(ScriptInjector::EXTENSION_REMOVED);
return result;
}
@@ -218,8 +220,11 @@ ScriptInjection::InjectionResult ScriptInjection::Inject(
bool should_inject_css = injector_->ShouldInjectCss(run_location_);
DCHECK(should_inject_js || should_inject_css);
- if (should_inject_js)
+ if (should_inject_js) {
InjectJs();
+ if (!injection_host_)
Devlin 2016/07/08 20:51:09 A comment explaining why/how this could happen wou
robwu 2016/07/09 05:22:02 Done.
+ return INJECTION_CANCELED;
+ }
if (should_inject_css)
InjectCss();
@@ -274,7 +279,7 @@ void ScriptInjection::InjectJs() {
callback.release());
}
- if (injection_host_->id().type() == HostID::EXTENSIONS)
+ if (injection_host_ && injection_host_->id().type() == HostID::EXTENSIONS)
UMA_HISTOGRAM_TIMES("Extensions.InjectScriptTime", exec_timer.Elapsed());
}

Powered by Google App Engine
This is Rietveld 408576698