Page 1 of 1
Wrong message_ type in OnDevToolsMessage
Posted: Mon Jan 11, 2021 3:09 pm
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.
Re: Wrong message_ type in OnDevToolsMessage
Posted: Mon Jan 11, 2021 3:51 pm
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
Re: Wrong message_ type in OnDevToolsMessage
Posted: Mon Jan 11, 2021 5:17 pm
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.
Re: Wrong message_ type in OnDevToolsMessage
Posted: Mon Jan 11, 2021 5:45 pm
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!

Re: Wrong message_ type in OnDevToolsMessage
Posted: Mon Jan 11, 2021 5:56 pm
by shobits1
Thank you for your hard work