Update to CEF 83.4.0

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

Update to CEF 83.4.0

Post by salvadordf » Sun Jun 21, 2020 7:47 pm

Hi,

CEF4Delphi is now updated to CEF 83.4.0 which includes Chromium 83.0.4103.106.

These are the rest of the changes :
  • Added The TChromium.OnDevToolsMessage event.
  • Added The TChromium.OnDevToolsMethodResult event.
  • Added The TChromium.OnDevToolsEvent event.
  • Added The TChromium.OnDevToolsAgentAttached event.
  • Added The TChromium.OnDevToolsAgentDetached event.
  • Added The TChromium.OnDocumentAvailableInMainFrame event.
  • Added the TChromium.SendDevToolsMessage function.
  • Added the TChromium.ExecuteDevToolsMethod function.
  • Added the TChromium.AddDevToolsMessageObserver function.
  • Added the TChromium.DevToolsMsgObserver property.
  • Added the TChromium.DevToolsMsgObserverReg property.
  • Renamed The TChromium.Registration property to TChromium.MediaObserverReg.
  • Added the GlobalCEFApp.DevToolsProtocolLogFile property : Set a full path in this property to save a log with all DevTool messages.
  • Added and overloaded version of CefParseJson that uses UTF8 strings as input.
  • Added a context menu option to the JSExtension demo to switch the "offline" mode in the DevTools using TChromium.ExecuteDevToolsMethod.
  • Added more comments to the DOMVisitor demo.
  • Fixed a bug in CefCreateUrl.
As you can see, this update adds support for direct DevTools protocol messaging. Read this for more information :
https://bitbucket.org/chromiumembedded/cef/commits/fd6631bd181233d36b98e1327da84c44372add76
https://chromedevtools.github.io/devtools-protocol/

All the new TChromum events convert the JSON buffers encoded in UTF8 to an ICefValue instance automatically. They are in fact a ICefDictionaryValue instance with all the JSON information.

These are the CEF binaries :
  • 32 bits -> http://opensource.spotify.com/cefbuilds/cef_binary_83.4.0%2Bgfd6631b%2Bchromium-83.0.4103.106_windows32.tar.bz2
  • 64 bits -> http://opensource.spotify.com/cefbuilds/cef_binary_83.4.0%2Bgfd6631b%2Bchromium-83.0.4103.106_windows64.tar.bz2

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

Re: Update to CEF 83.4.0

Post by salvadordf » Sun Jun 21, 2020 7:56 pm

More details about the new DevTools events and procedures :
https://github.com/chromiumembedded/cef/blob/master/include/capi/cef_devtools_message_observer_capi.h
https://github.com/chromiumembedded/cef/blob/39aed35644dc4ae24de857aaefd2815580a260cc/include/capi/cef_browser_capi.h#L522

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

Re: Update to CEF 83.4.0

Post by salvadordf » Mon Jun 22, 2020 2:33 pm

I just uploaded a small new version of CEF4Delphi with a new TChromium.DefaultWindowInfoExStyle property.

The value of that property will be used as the ExStyle to initialize the browser window.

Some focus issues in CEF might be fixed if you set it to WS_EX_NOACTIVATE before the TChromium.CreateBrowser call but it could cause some side effects. Read these links for more information :
https://bitbucket.org/chromiumembedded/cef/issues/1856/branch-2526-cef-activates-browser-window
https://www.briskbard.com/forum/viewtopic.php?f=10&t=723

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

Re: Update to CEF 83.4.0

Post by salvadordf » Wed Jun 24, 2020 10:08 am

Other CEF developer gave this link about the DevTools protocol :
https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-clearBrowserCache

It might be possible to clear the cache and the cookies at runtime! :o

Please share the result of your experiments and I'll be glad to add them to CEF4Delphi.

Here's an example about using the new DevTools functions :
https://github.com/salvadordf/CEF4Delphi/blob/d55d7c0733d536d6f929fc5722c4ad46f64fbd0a/demos/Delphi_VCL/JavaScript/JSExtension/uJSExtension.pas#L413

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

Re: Update to CEF 83.4.0

Post by salvadordf » Wed Jun 24, 2020 10:30 am

I just uploaded a new version of the CookieVisitor demo with a context menu option to delete the browser cache at runtime! :D

dilfich
Posts: 204
Joined: Thu Nov 30, 2017 1:17 am

Re: Update to CEF 83.4.0

Post by dilfich » Fri Jun 26, 2020 8:23 am

Fixed a bug in CefCreateUrl.
Check it too, but the function doesn't seem to work, the app doesn't crash, but it doesn't change the link either.

Code: Select all

   if (Pos( 'briskbard.com/images/logo.', request.Url) <> 0) then begin  
      u.scheme:= 'https';
      u.host := 'www.google.com';
      u.origin := 'https://www.google.com/';
      u.path := '/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png';
      u.query := '';
      request.Url := CefCreateUrl(u);
   end;
request.Url := CefCreateUrl(u);
Reuslt - request.Url - https://www.briskbard.com/images/logo.png

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

Re: Update to CEF 83.4.0

Post by salvadordf » Sat Jun 27, 2020 8:37 am

Where are you using that code?

CEF allows you to modify the request in some events but not in others. For example, you can't modify the request in TChromium.OnBeforeBrowse but you can modify it in TChromium.OnBeforeResourceLoad.

If you're trying to use TChromium.LoadRequest you need to first navigate to the request origin using some other mechanism (LoadURL, link click, etc).

dilfich
Posts: 204
Joined: Thu Nov 30, 2017 1:17 am

Re: Update to CEF 83.4.0

Post by dilfich » Sun Jun 28, 2020 5:58 am

In BeforeResourceLoad
On each version I did not check but on CEF 75.1.14 there are no problems with this, I did not ask how to do it, but said that it stopped working.

Demo MiniBrowser

Code: Select all

procedure TMiniBrowserFrm.Chromium1BeforeResourceLoad(Sender: TObject;
  const browser: ICefBrowser; const frame: ICefFrame;
  const request: ICefRequest; const callback: ICefRequestCallback;
  out Result: TCefReturnValue);
var
  u: TUrlParts;
begin

 if CefParseUrl(request.Url, u) then begin
   if (Pos( 'briskbard.com/images/logo.', request.Url) <> 0) then begin  // https://www.briskbard.com/index.php?lang=en
      u.scheme:= 'https';
      u.host := 'www.google.com';
      u.origin := 'https://www.google.com/';
      u.path := '/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png';
      u.query := '';
      request.Url := CefCreateUrl(u);
   end;
 end;


  Result := RV_CONTINUE;

  if Chromium1.IsSameBrowser(browser) and
     (frame <> nil) and
     frame.IsMain and
     frame.IsValid then
    InspectRequest(request);
end;
I would like to make a mistake that I am doing something wrong, but if you try it you will see that it does not work as before.

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

Re: Update to CEF 83.4.0

Post by salvadordf » Sun Jun 28, 2020 2:27 pm

TUrlParts has a "spec" field and according to the CEF documentation means "The complete URL specification".

CefParseUrl had a bug and it didn't read the "spec" value but I fixed it months ago.

The variable "u" is used to parse the URL, then some of the fields are modified and then it's reused with CefCreateUrl. In that process "spec" is never rewritten and it keeps the old URL value... and CefCreateUrl prioritizes the "spec" value to generate the new URL.

There are 3 solutions :
  • Set the "spec" value with the new complete URL.
  • Set the "spec" value to an empty string.
  • Use a different TUrlParts variable with an empty "spec" to call CefCreateUrl.

dilfich
Posts: 204
Joined: Thu Nov 30, 2017 1:17 am

Re: Update to CEF 83.4.0

Post by dilfich » Sun Jun 28, 2020 3:01 pm

Does u.spec work) I'm sorry, I didn't even check.. :?
And if not link is, possible to make it work?

Code: Select all

u.spec := 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAAC';

Post Reply