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.

Update to CEF 83.4.0

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

Update to CEF 83.4.0

Post by salvadordf »

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/ ... 44372add76
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 :
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Update to CEF 83.4.0

Post by salvadordf »

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

Re: Update to CEF 83.4.0

Post by salvadordf »

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/ ... ser-window
https://www.briskbard.com/forum/viewtop ... f=10&t=723
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Update to CEF 83.4.0

Post by salvadordf »

Other CEF developer gave this link about the DevTools protocol :
https://chromedevtools.github.io/devtoo ... owserCache

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/CEF4Delph ... n.pas#L413
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Update to CEF 83.4.0

Post by salvadordf »

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: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Update to CEF 83.4.0

Post by dilfich »

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: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Update to CEF 83.4.0

Post by salvadordf »

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: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Update to CEF 83.4.0

Post by dilfich »

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: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Update to CEF 83.4.0

Post by salvadordf »

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: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Update to CEF 83.4.0

Post by dilfich »

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