I have a particular problem with handling a download link within Chromium.
The issue is not so much the download (answered here quite well: CEF4 Chromium Delphi 10.2 Tokyo - how to handle download dialogue? ) ...but this particular link is tagged with target="_blank".
Which triggers OnBeforePopup with targetDisposition=WOD_NEW_FOREGROUND_TAB However, in almost all the example code, the OnBeforePopup handler has the following code:
// For simplicity, this demo blocks all popup windows and new tabs
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
This effectively blocks that link from proceeding, thus the OnBeforeDownload event never triggers.
If I comment out the popup blocker, the default behaviour seems to be to open a new blank window, and then proceed with the download events as expected. However, the download never quite completes (it goes to 100% but never "complete"), and the new window never goes away.
My question is in two parts:
- Could I get some guidance on how to either create a new browser window that I have control over in the OnBeforePopup event?
- How to I make the download properly complete?
Note: If I paste the actual targetURL of the download file into the address bar, the download completes quite cheerfully, so I suspect the key is in the handling of the default window.
Note: I have found the CEF API documentation, it is not super informative.
Note: I'm aware TabBrowser2 handles the popup intercept, but it is far from clear what is going on, apparently calling a client window to then call the main window which in turn calls the client window again. Plus the structure I have so far does not really lend itself to that solution. The