Reputation: 51
today i'm working with Chromium Embedded Framework 3.
I have everything set up, compiled and executed. Everything works fine.
Now I want to read the page source after everything is rendered and JavaScript is executed. I would also like to get the buffer from the offscreen rendering.
My basic application structure is:
App implements CefApp, CefBrowserProcessHandler and CefRenderProcessHandler
Handler implements CefClient, CefDisplayHandler, CefLifeSpanHandler, CefLoadHandler and CefRenderHandler
Visitor implements CefStringVisitor
In App::OnContextInitialized() i'm executing
CreateBrowser(window_info, handler.get(), "http://www.google.com/", browser_settings, NULL);
while
window_info.SetAsWindowless(NULL, true);
Now is App::OnContextCreated() only called if i run CEF3 in single-mode with
main_settings.single_process = true;
otherwise it's never called. In App::OnContextCreated() im doing
browser->GetMainFrame()->GetSource(new Visitor());
to get the page source and it works, but the method is called multiple times and seems not to executing JavaScript at this point.
My question is now what's the best point to read the page source AFTER everything is rendered and JavaScript is executed ?
Also Handler::OnPaint() is never called while Handler::GetViewRect() is.
regards
Norwido
Upvotes: 3
Views: 6097
Reputation: 20675
OnContextCreated runs in the Renderer process, that's probably why it works only in single process mode. You should call GetSource in CefLoadHandler::OnLoadEnd or OnLoadingStateChange that run in the Browser process.
Not implementing all the necessary callbacks in CefRenderHandler may be the cause of the OnPaint callback not being called. Read the doc comments in the header files.
Upvotes: 1