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.

Wrong message_ type in OnDevToolsMessage

Post Reply
shobits1
Posts: 25
Joined: Wed Mar 04, 2020 9:16 pm

Wrong message_ type in OnDevToolsMessage

Post by shobits1 »

Code: Select all

ICefDevToolsMessageObserver = interface(ICefBaseRefCounted)
    ['{76E5BB2B-7F69-4BC9-94C7-B55C61CE630F}']
    procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean);
    ....
end;

Code: Select all

  // Method that will be called on receipt of a DevTools protocol message.
  // |browser| is the originating browser instance. |message| is a UTF8-encoded
  // JSON dictionary representing either a method result or an event. |message|
  // is only valid for the scope of this callback and should be copied if
  // necessary. Return true if the message was handled or false if the message
  // should be further processed and passed to the OnDevToolsMethodResult or
  // OnDevToolsEvent methods as appropriate.
  ....
  virtual bool OnDevToolsMessage(CefRefPtr<CefBrowser> browser,
                                 const void* message,
                                 size_t message_size) {
    return false;
  } 
as official cef source the message_ type in this function should be be utf8string not ICefDictionaryValue.

could you fix this , or provide an other function that return string, please.

thank you for the hard work.
User avatar
salvadordf
Posts: 4040
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Wrong message_ type in OnDevToolsMessage

Post by salvadordf »

CEF4Delphi parses the JSON string in the "message" parameter automatically.
It converts the UTF8 string to a ICefValue parameter using the CEF functions to parse JSON strings.

You can read all the values using the ICefValue and ICefDictionaryValue methods. See the MiniBrowser demo for more details.

If you need the complete JSON string you can call TCEFJson.Write
shobits1
Posts: 25
Joined: Wed Mar 04, 2020 9:16 pm

Re: Wrong message_ type in OnDevToolsMessage

Post by shobits1 »

I still believe doing it the same way as official cef is better

OnDevToolsMessage, passes json string
OnDevToolsMethodResult, passes ICefValue/ICefDictionaryValue

CefSharp also doing it the same way as official cef.

to the why, I'm asking this is because of this comment:

Code: Select all

  // JSON dictionaries can be parsed using the CefParseJSON function
  // if desired, however be aware of performance considerations when parsing
  // large messages (some of which may exceed 1MB in size).
maybe I won't run in any form of performance issue in my use case, but others might.
User avatar
salvadordf
Posts: 4040
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Wrong message_ type in OnDevToolsMessage

Post by salvadordf »

I'll try to add a new event with the raw utf8 string and convert the string only when the application uses the event with the ICefValue parameter.

Thanks! :D
shobits1
Posts: 25
Joined: Wed Mar 04, 2020 9:16 pm

Re: Wrong message_ type in OnDevToolsMessage

Post by shobits1 »

Thank you for your hard work :D
Post Reply