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.

CEF ChromeRuntime

mike2k
Posts: 22
Joined: Wed Jan 24, 2018 2:56 pm

CEF ChromeRuntime

Post by mike2k »

Hi,

First thanks for all your hard work on this project.

I'm checking the new ChromeRuntime in TinyBrowser project on CEF 92 and I have a few question if you can enlighten me :)
It really runs OK, with extensions.

- Is it possible to have components in the browser window? like a navigation edit box and back, forward, refresh buttons ?
- how to send messages between CEF thread and the app( or other app) if there is no handle?

Hope you can help me!
Thanks again.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: CEF ChromeRuntime

Post by salvadordf »

Hi,

This is the CEF issue where the project maintainer keeps track of all the changes :
https://bitbucket.org/chromiumembedded/cef/issues/2969/support-chrome-windows-with-cef-callbacks

As you can see, it's still not marked as "resolved" and the maintainer considers it as experimental at this moment.

I still haven't tried to add a browser in that mode inside a Delphi form but I'll probably wait until it's marked as "resolved".

Adding Delphi controls into those forms is not possible at this moment because they are created by CEF.

You can create a custom thread with a custom message loop similar to the one you can see in the TCEFBrowserThread class inside the ConsoleBrowser2 demo. Then you can send messages from CEF threads to your custom thread.
mike2k
Posts: 22
Joined: Wed Jan 24, 2018 2:56 pm

Re: CEF ChromeRuntime

Post by mike2k »

Hi,

Thanks for your reply.
You can create a custom thread with a custom message loop similar to the one you can see in the TCEFBrowserThread class inside the ConsoleBrowser2 demo. Then you can send messages from CEF threads to your custom thread.
I found a workaround, I've added a FHandle to TTinyBrowser and on create:

Code: Select all

FHandle := AllocateHwnd(WndProc);
Works OK, to send/receive messages.
I still haven't tried to add a browser in that mode inside a Delphi form but I'll probably wait until it's marked as "resolved".
Pity :(, seems it will take another few months, seems that issue is started from June 2020.

Do you think it needs to make source changes or just some modification to the demo project?


Also another thing I've seen, It doesn't let me change the URL after is loaded, any idea why ?

Code: Select all

TinyBrowser.Chromium.LoadUrl('https://www.test.com');
Thanks again!
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: CEF ChromeRuntime

Post by salvadordf »

mike2k wrote: Fri Sep 17, 2021 4:32 pm Do you think it needs to make source changes or just some modification to the demo project?
I haven't checked but I wouldn't be surprised if it needs some modifications in the current components.
mike2k wrote: Fri Sep 17, 2021 4:32 pm Also another thing I've seen, It doesn't let me change the URL after is loaded, any idea why ?

Code: Select all

TinyBrowser.Chromium.LoadUrl('https://www.test.com');
TChromiumCore needs to be fixed in order to work correctly in this mode.
Thanks for reporting this issue! :D
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: CEF ChromeRuntime

Post by salvadordf »

I just uploaded the fix for the initialization issue you described and now you can call TChromium.LoadURL
mike2k
Posts: 22
Joined: Wed Jan 24, 2018 2:56 pm

Re: CEF ChromeRuntime

Post by mike2k »

salvadordf wrote: Sat Sep 18, 2021 9:02 am I just uploaded the fix for the initialization issue you described and now you can call TChromium.LoadURL
Thanks, works now!

I'll report back if I find any other anomaly :), already filled an issue with fullscreen crash:
https://bitbucket.org/chromiumembedded/cef/issues/3182/windows-fullscreen-broken-cefclient-in

I have a few questions after testing ChromeRuntime, if you can help :)
- I've added OnConsoleMessage event. it gets all the messages but they also show in dev tools console. Even if I set result to true/false. Any idea why?
- how to disable developer tools?
- TCEFWindowComponent.GetAsPanel would it help to be used with TForm?

Thanks again.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: CEF ChromeRuntime

Post by salvadordf »

mike2k wrote: Sat Sep 18, 2021 11:54 am I have a few questions after testing ChromeRuntime, if you can help :)
- I've added OnConsoleMessage event. it gets all the messages but they also show in dev tools console. Even if I set result to true/false. Any idea why?
I put a breakpoint in that event and the True (1) result is returned correctly to CEF.

I also tried several old CEF versions with the DOMVisitor demo because it uses the "console trick" to send information by calling "console.log" in JS and all of them had the same issue.

I went back to CEF 85 but we should modify cefclient and test this issue there because this could be a CEF issue.
mike2k wrote: Sat Sep 18, 2021 11:54 am - how to disable developer tools?
I haven't tested this but try removing the "Inspect" context menu option and intercept the F12 key press.
Use TChromium.OnBeforeContextMenu and TChromium.OnPreKeyEvent
mike2k wrote: Sat Sep 18, 2021 11:54 am - TCEFWindowComponent.GetAsPanel would it help to be used with TForm?
I'm afraid I have limited experience with the Views framework and I don't know if that could help. I would need to investigate.
mike2k
Posts: 22
Joined: Wed Jan 24, 2018 2:56 pm

Re: CEF ChromeRuntime

Post by mike2k »

I went back to CEF 85 but we should modify cefclient and test this issue there because this could be a CEF issue.
Unfortunately I can't help on this, I don't know much C language. But seems to be a CEF issue.
Use TChromium.OnBeforeContextMenu and TChromium.OnPreKeyEvent
Thanks for the PreKey tip, I was already working on this.
I thought you know some flag to disable developer tools, but seems there isn't.

Btw, found another possible bug with CEFWindowComponent OnKeyEvent, it's not triggered at all (only if find box is in focus (CTRL+F), it triggers)
With ChromeRuntime false, it's triggered correctly.

Also, I came across another issue.
I want to prevent the user to open any new window, because they have Chromium design.
So there are 2 possible solutions, either I catch somehow all new windows and block them or open them as plain browser window.

Chromium OnBeforePopup is not triggered when user presses SHIFT or CTRL key and clicks on a link (link opens in new window)
EDIT: Just tried Chromium RenderCompMsg to catch mouse down, but it's not even triggered.

Any help is welcomed :)

Thanks
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: CEF ChromeRuntime

Post by salvadordf »

mike2k wrote: Sat Sep 18, 2021 4:51 pm Btw, found another possible bug with CEFWindowComponent OnKeyEvent, it's not triggered at all (only if find box is in focus (CTRL+F), it triggers)
With ChromeRuntime false, it's triggered correctly.
If that event is triggered sometimes then the handler is implemented correctly. It's CEF/Chromium the one who decides when it's triggered.
Chrome runtime is not fully implemented in CEF and this could be just an unfinished feature.
mike2k wrote: Sat Sep 18, 2021 4:51 pm Also, I came across another issue.
I want to prevent the user to open any new window, because they have Chromium design.
So there are 2 possible solutions, either I catch somehow all new windows and block them or open them as plain browser window.
Chromium OnBeforePopup is not triggered when user presses SHIFT or CTRL key and clicks on a link (link opens in new window)
EDIT: Just tried Chromium RenderCompMsg to catch mouse down, but it's not even triggered.
Use the TChromium.OnOpenUrlFromTab and TChromium.OnBeforePopup events like this :
https://github.com/salvadordf/CEF4Delphi/blob/fe3d171c5b9ce0c1c4a8a7ea4aff8ab8dc4a7a1e/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.pas#L187
mike2k
Posts: 22
Joined: Wed Jan 24, 2018 2:56 pm

Re: CEF ChromeRuntime

Post by mike2k »

Use the TChromium.OnOpenUrlFromTab and TChromium.OnBeforePopup events like this :
https://github.com/salvadordf/CEF4Delphi/blob/fe3d171c5b9ce0c1c4a8a7ea4aff8ab8dc4a7a1e/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.pas#L187
Perfect, OpenURLFromTab does the job! Thanks!

When user click on a link and ALT is pressed the page is downloaded.
I've tried OnDownloadUpdated and OnBeforeDownload, which are not triggered. Any events I can check to block this?
Post Reply