CefClient + tab support

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.

CefClient + tab support

Postby Peter » Tue Mar 24, 2020 4:44 am

Hello all!

I am trying to modify the included CefClient example to support tabs, and getting a bit confused about how to do this in the best way. (I'm also using a rather outdated version of CEF for compatibility reasons, but that's a different problem)

For example, I see that ClientHandler has a field named "browser_count_", so it looks like it can support multiple browsers - but then, it works with only a single BrowserWindow, that can also know only about a single browser instance... :?

Can I get any advice on how to use CEF for multiple tabs? Is it even supposed to be used that way? I've got a feeling that somebody spent a lot of time to optimize out all the tab-related code, and here I am trying to add it back :roll:
Peter
Techie
 
Posts: 38
Joined: Thu Mar 05, 2020 9:41 am

Re: CefClient + tab support

Postby magreenblatt » Tue Mar 24, 2020 9:56 am

CEF can create multiple browser windows. Your application can parent those browser windows to tabs. This is not demonstrated by cefclient so you will need to implement the native code for tab handling yourself.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefClient + tab support

Postby Peter » Tue Mar 24, 2020 11:38 am

By "browser windows", do you mean BrowserWindows, or should I make multiple RootWindows?
Peter
Techie
 
Posts: 38
Joined: Thu Mar 05, 2020 9:41 am

Re: CefClient + tab support

Postby magreenblatt » Tue Mar 24, 2020 11:56 am

I mean CefBrowser/CefBrowserHost, which is then parented to a native window.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefClient + tab support

Postby Peter » Tue Mar 24, 2020 12:27 pm

Hmm I see...
By the way, is there a way to save/restore a browser state, in case I'd want restore a closed tab?
Peter
Techie
 
Posts: 38
Joined: Thu Mar 05, 2020 9:41 am

Re: CefClient + tab support

Postby magreenblatt » Tue Mar 24, 2020 12:33 pm

What do you consider "browser state"?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefClient + tab support

Postby Peter » Tue Mar 24, 2020 12:56 pm

Actually, at this point I'd be happy to have at least the back-forward URL history - currently I know only how to access the current URL via GetMainFrame()->GetUrl(is this the correct way btw?)
Peter
Techie
 
Posts: 38
Joined: Thu Mar 05, 2020 9:41 am

Re: CefClient + tab support

Postby magreenblatt » Tue Mar 24, 2020 1:07 pm

You can retrieve the back/forward state using CefBrowserHost::GetNavigationEntries but there is not currently a way to restore that information after restart.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefClient + tab support

Postby Peter » Wed Mar 25, 2020 4:47 am

Is there a way to retrieve the page scroll position as well?

Shame there isn't a way to restore NavigationEntries - I probably can imagine a workaround, but surely there must be a proper way to do this in the actual browsers, because session managers exist...
Peter
Techie
 
Posts: 38
Joined: Thu Mar 05, 2020 9:41 am

Re: CefClient + tab support

Postby magreenblatt » Wed Mar 25, 2020 9:32 am

You can retrieve the page scroll position by injecting JavaScript. See https://bitbucket.org/chromiumembedded/ ... gration.md
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 67 guests