diff options
Diffstat (limited to 'extensions/renderer/script_injection_manager.cc')
-rw-r--r-- | extensions/renderer/script_injection_manager.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/extensions/renderer/script_injection_manager.cc b/extensions/renderer/script_injection_manager.cc index aa0f5d3..0e234d0 100644 --- a/extensions/renderer/script_injection_manager.cc +++ b/extensions/renderer/script_injection_manager.cc @@ -88,6 +88,8 @@ class ScriptInjectionManager::RFOHelper : public content::RenderFrameObserver { // document_idle. void RunIdle(); + void StartInjectScripts(UserScript::RunLocation run_location); + // Indicate that the frame is no longer valid because it is starting // a new load or closing. void InvalidateAndResetFrame(); @@ -136,7 +138,10 @@ void ScriptInjectionManager::RFOHelper::DidCreateNewDocument() { } void ScriptInjectionManager::RFOHelper::DidCreateDocumentElement() { - manager_->StartInjectScripts(render_frame(), UserScript::DOCUMENT_START); + ExtensionFrameHelper::Get(render_frame()) + ->ScheduleAtDocumentStart( + base::Bind(&ScriptInjectionManager::RFOHelper::StartInjectScripts, + weak_factory_.GetWeakPtr(), UserScript::DOCUMENT_START)); } void ScriptInjectionManager::RFOHelper::DidFailProvisionalLoad( @@ -162,7 +167,11 @@ void ScriptInjectionManager::RFOHelper::DidFailProvisionalLoad( void ScriptInjectionManager::RFOHelper::DidFinishDocumentLoad() { DCHECK(content::RenderThread::Get()); - manager_->StartInjectScripts(render_frame(), UserScript::DOCUMENT_END); + ExtensionFrameHelper::Get(render_frame()) + ->ScheduleAtDocumentEnd( + base::Bind(&ScriptInjectionManager::RFOHelper::StartInjectScripts, + weak_factory_.GetWeakPtr(), UserScript::DOCUMENT_END)); + // We try to run idle in two places: here and DidFinishLoad. // DidFinishDocumentLoad() corresponds to completing the document's load, // whereas DidFinishLoad corresponds to completing the document and all @@ -231,6 +240,11 @@ void ScriptInjectionManager::RFOHelper::RunIdle() { } } +void ScriptInjectionManager::RFOHelper::StartInjectScripts( + UserScript::RunLocation run_location) { + manager_->StartInjectScripts(render_frame(), run_location); +} + void ScriptInjectionManager::RFOHelper::InvalidateAndResetFrame() { // Invalidate any pending idle injections, and reset the frame inject on idle. weak_factory_.InvalidateWeakPtrs(); |