LoadString() ignoring string_value?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

LoadString() ignoring string_value?

Postby ScottKevill » Tue Oct 16, 2012 1:38 pm

Hopefully I'm missing something really obvious, but when I call CefFrame::LoadString(string_val, url), it seems to ignore the string_val and do the equivalent of LoadURL(url)

First I tried this below, but the "about:blank" seems to get queued after OnAfterCreate returns.
Code: Select all
Creating the browser:
    CefBrowserHost::CreateBrowser(info, handler.get(), "about:blank", settings);

OnAfterCreate:
    browser->GetMainFrame()->LoadString("<html><body>Hello World!</body></html>", "http://www.google.com");


Having read this thread, I also tried this below, but it simply loaded the about:blank page and immediately loaded Google afterwards.
Code: Select all
Creating the browser:
    CefBrowserHost::CreateBrowser(info, handler.get(), "", settings);

OnAfterCreate:
    browser->GetMainFrame()->LoadURL("about:blank");
    browser->GetMainFrame()->LoadString("<html><body>Hello World!</body></html>", "http://www.google.com");


Do I need to be creating a resource handler as well to intercept this? If so, then how does LoadString() make things simpler than LoadURL() if I need a resource handler anyway?

This is CEF 3.1180.823 with the Windows binaries.

Thanks.
ScottKevill
Techie
 
Posts: 16
Joined: Sun Oct 14, 2012 10:34 pm

Re: LoadString() ignoring string_value?

Postby nvine » Wed Oct 17, 2012 1:29 am

Actually I ran into similar problem, calling LoadString() was trying to load the URL instead of setting the string. I wanted to display a message in OnLoadError() and when I used LoadString() in OnLoadError() callback, I got the error callback again and the string wasn't set. The workaround I have now is to execute js and set the required string. Is this a bug in Cef3?
nvine
Mentor
 
Posts: 56
Joined: Tue Feb 21, 2012 11:13 pm

Re: LoadString() ignoring string_value?

Postby ScottKevill » Wed Oct 17, 2012 1:49 pm

I don't know if this affects CEF 1 as well, but I've just done a bunch of testing and the Mac OS X binaries of CEF 3 also cause this to happen. This time I made modifications to the cefclient sample to do my testing.

A whole heap of trial and error later... LoadURL("about:blank") is insufficient for LoadString() to work. Perhaps due to some kind of special case.

Anything else that triggers a request will work. eg. LoadURL(":") or LoadURL("dummy:"). This will end up calling OnLoadError, of course, but that can be ignored there.

This also works from the original CreateBrowser so that LoadURL isn't needed in OnAfterCreated.

In summary, very confusing behaviour, but this works:
Code: Select all
Creating the browser:
    CefBrowserHost::CreateBrowser(info, handler.get(), "dummy:", settings);

OnAfterCreated:
    browser->GetMainFrame()->LoadString("<html><body>Hello World!</body></html>", "http://www.google.com");
ScottKevill
Techie
 
Posts: 16
Joined: Sun Oct 14, 2012 10:34 pm

Re: LoadString() ignoring string_value?

Postby magreenblatt » Wed Oct 17, 2012 2:00 pm

We should identify why "about:blank" isn't sufficient and, if possible, fix it. Please add an issue to the CEF issue tracker.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: LoadString() ignoring string_value?

Postby ScottKevill » Wed Oct 17, 2012 11:03 pm

Done: Issue 763
ScottKevill
Techie
 
Posts: 16
Joined: Sun Oct 14, 2012 10:34 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 92 guests