For a moment I started to think, that I know, what i'm doing, now i'm not so sure.
Long story short: Got Var Ploaded in JS, that will turn to 1 when window.onload event appears, want to check for this value turned 1 in C++, and, as it will happend - do something and turn it to 0. Attempting to do this check in win32 main loop callback function. This way I'm trying to trigger some C++ function on JS event.
Got this code inside callback WndProc:
- Code: Select all
switch(msg) {//cases, cases//}
CefRefPtr<CefBrowser> browser;
CefRefPtr<CefFrame> frame;
CefRefPtr<CefV8Context> context;
if (cf_handler.get()) {browser = cf_handler->GetBrowser();}
if (browser.get()) {frame = browser->GetMainFrame();}
if (frame.get()) {context = frame->GetV8Context();}
if (context.get()) {CefRefPtr<CefV8Value> windowobj = context->GetGlobal();
CefRefPtr<CefV8Value> GetPloaded = windowobj->GetValue("Ploaded");
int Ploaded = GetPloaded->GetIntValue();
if (Ploaded == 1 && NiceCheck == 1) {
context->GetGlobal()->SetValue("Ploaded", CefV8Value::CreateInt(0), V8_PROPERTY_ATTRIBUTE_NONE);
NiceCheck = 0;
jprint("Page is loaded - CEF");
}
}
return DefWindowProc(hWnd,msg,wParam,lParam);
jprint prints string into JS div.
This thing builds fine, but on run gives breakpoint
> Brest.exe!CefFrameCToCpp::GetV8Context() Line 324 + 0x14 bytes C++
on
cef_v8context_t* _retval = struct_->get_v8context(struct_); string in frame_ctocpp.cc
I have a bit of simmilar stuff in jprint() function:
- Code: Select all
void jprint(gchar *data) {
CefRefPtr<CefBrowser> browser;
if (cf_handler.get())
browser = cf_handler->GetBrowser();
if (browser.get()) {
CefRefPtr<CefFrame> frame = browser->GetMainFrame();
gchar *jprint = g_strdup_printf("%s%s%s", "print('", data, "');");
frame->ExecuteJavaScript(jprint,
frame->GetURL(), 0);
}
}
and jprint is triggered by button in WM_COMMAND, works fine, but if I put in this function
CefRefPtr<CefV8Context> context = frame->GetV8Context();,
just to test it, I see the same breakpoint behavior each time I push the button.
Full code, if needed: https://gist.github.com/anonymous/6d9661ffb769d21b5d6c
Sadly, wiki, and cefclient project did not helped me a lot with this =(
Hope for Your help.