Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
make sure DidiCreateDocumentElement runs if a new render frame is not…
Browse files Browse the repository at this point in the history
… created
  • Loading branch information
bridiver committed May 18, 2016
1 parent 3426a25 commit 22312fc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions atom/renderer/extensions/atom_extensions_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@

namespace {

void DidCreateDocumentElement(blink::WebLocalFrame* frame) {
void DidCreateDocumentElement(content::RenderFrame* render_frame) {
v8::Isolate* isolate = blink::mainThreadIsolate();
v8::HandleScope handle_scope(isolate);

v8::Local<v8::Context> context = frame->mainWorldScriptContext();
v8::Local<v8::Context> context =
render_frame->GetWebFrame()->mainWorldScriptContext();
v8::Context::Scope context_scope(context);

auto script_context =
Expand All @@ -43,6 +44,12 @@ void DidCreateDocumentElement(blink::WebLocalFrame* frame) {
extensions::Feature::Context::WEB_PAGE_CONTEXT)
script_context->module_system()
->CallModuleMethod("ipc", "didCreateDocumentElement");

// reschedule the callback because a new render frame
// is not always created when navigating
extensions::ExtensionFrameHelper::Get(render_frame)
->ScheduleAtDocumentStart(base::Bind(DidCreateDocumentElement,
render_frame));
}

} // namespace
Expand Down Expand Up @@ -107,7 +114,7 @@ void AtomExtensionsRendererClient::RenderFrameCreated(
extension_dispatcher_->OnRenderFrameCreated(render_frame);
ExtensionFrameHelper::Get(render_frame)
->ScheduleAtDocumentStart(base::Bind(DidCreateDocumentElement,
render_frame->GetWebFrame()));
render_frame));
}

void AtomExtensionsRendererClient::RenderViewCreated(
Expand Down

1 comment on commit 22312fc

@bridiver
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.