Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

The question about TabbedBrowser2

Post Reply
Alexeich
Posts: 24
Joined: Fri May 29, 2020 12:15 pm

The question about TabbedBrowser2

Post by Alexeich »

Hello. Could you please clarify to me the next problem:
In TabbedBrowser2 in the OnBeforePopup you calls FHiddenTab.CreateClientHandler and then PostMessage(CEF_CREATENEXTTAB) to show the tab and create another one hidden tab. But as we know postmessage doesn't works momentally and it's easily possible one more OnBeforePopup event before another one hidden tab will be created in the main thread.
So the CreateClientHandler will be called again for the FHiddenTab and old data will be lost. And then it will be perfomed twice the CEF_CREATENEXTTAB handler. So we would get two new similar tabs... Where am I mistaking?
User avatar
salvadordf
Posts: 4580
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: The question about TabbedBrowser2

Post by salvadordf »

If the application allows all new tabs and popup windows, even the ones that weren't generated by a user action, then you might lose some of them using this method.

In that case you can increase the number of hidden tabs and popup windows.

However, modern browsers block any attempt to create multiple tabs or popup windows. Try this :
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open6
Alexeich
Posts: 24
Joined: Fri May 29, 2020 12:15 pm

Re: The question about TabbedBrowser2

Post by Alexeich »

But several tabs might be opened at the same moment from different pages opened in the browser, especially when there're lot of them...
It would be nice if after a new tab created in the main thread (using postmessage to the main thread from the OnBeforePopup) there would be the way to postmessage back to the chromium thread to call CreateClientHandler there for each new tab?
User avatar
salvadordf
Posts: 4580
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: The question about TabbedBrowser2

Post by salvadordf »

You can also use an "external message pump" for the browser.

Several demos use that mode to execute all events in the main application thread, like the ExternalPumpBrowser demo.

In that case the TChromium.OnBeforePopup event is executed in the main application thread too and you can safely create your tab or popup window inside that event, without messages and hidden tabs or child windows.
Alexeich
Posts: 24
Joined: Fri May 29, 2020 12:15 pm

Re: The question about TabbedBrowser2

Post by Alexeich »

Thank you for your answers.
Post Reply