Chromium Code Reviews| Index: extensions/renderer/script_injection.cc |
| diff --git a/extensions/renderer/script_injection.cc b/extensions/renderer/script_injection.cc |
| index da93590c3908c00fb33421a2b3ff9f1077e04b06..d97ddc1bec665fcf8144c5f4dfd23747b9f1bc6f 100644 |
| --- a/extensions/renderer/script_injection.cc |
| +++ b/extensions/renderer/script_injection.cc |
| @@ -213,15 +213,20 @@ ScriptInjection::InjectionResult ScriptInjection::Inject( |
| DCHECK(injection_host_); |
| DCHECK(scripts_run_info); |
| DCHECK(!complete_); |
| + bool should_inject_js = injector_->ShouldInjectJs( |
| + run_location_, scripts_run_info->injected_scripts); |
| + bool should_inject_css = injector_->ShouldInjectCss( |
| + run_location_, scripts_run_info->injected_scripts); |
| - bool should_inject_js = injector_->ShouldInjectJs(run_location_); |
| - bool should_inject_css = injector_->ShouldInjectCss(run_location_); |
| - DCHECK(should_inject_js || should_inject_css); |
| + // Occurs when script is already injected. |
|
Devlin
2016/08/22 22:46:52
I'd be a little more explicit here - maybe somethi
catmullings
2016/08/24 01:13:19
That's clearer. I'll use yours.
Which crbug.com/nn
Devlin
2016/08/25 16:52:26
crbug.com/631247, which is the crash that resulted
catmullings
2016/08/27 00:23:08
Done.
|
| + if (!(should_inject_js || should_inject_css)) { |
|
Devlin
2016/08/22 22:46:52
nit: I find this a little more readable after we D
catmullings
2016/08/24 01:13:19
Done.
|
| + return INJECTION_FINISHED; |
| + } |
| if (should_inject_js) |
| - InjectJs(); |
| + InjectJs(scripts_run_info); |
| if (should_inject_css) |
| - InjectCss(); |
| + InjectCss(scripts_run_info); |
| complete_ = did_inject_js_ || !should_inject_js; |
| @@ -237,11 +242,12 @@ ScriptInjection::InjectionResult ScriptInjection::Inject( |
| return complete_ ? INJECTION_FINISHED : INJECTION_BLOCKED; |
| } |
| -void ScriptInjection::InjectJs() { |
| +void ScriptInjection::InjectJs(ScriptsRunInfo* scripts_run_info) { |
| DCHECK(!did_inject_js_); |
| blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame(); |
| std::vector<blink::WebScriptSource> sources = |
| - injector_->GetJsSources(run_location_); |
| + injector_->GetJsSources(run_location_, scripts_run_info); |
| + DCHECK(!sources.empty()); |
| bool in_main_world = injector_->ShouldExecuteInMainWorld(); |
| int world_id = in_main_world |
| ? DOMActivityLogger::kMainWorldId |
| @@ -311,9 +317,9 @@ void ScriptInjection::OnJsInjectionCompleted( |
| } |
| } |
| -void ScriptInjection::InjectCss() { |
| +void ScriptInjection::InjectCss(ScriptsRunInfo* scripts_run_info) { |
| std::vector<std::string> css_sources = |
| - injector_->GetCssSources(run_location_); |
| + injector_->GetCssSources(run_location_, scripts_run_info); |
| blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame(); |
| for (const std::string& css : css_sources) |
| web_frame->document().insertStyleSheet(blink::WebString::fromUTF8(css)); |