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.
OnWebKitInitialized isn't fired
Re: OnWebKitInitialized isn't fired
I saw that I can set a Dictionary in the Argument list of ICefProcessMessage, but I couldn't figure out how to create a ICefDictionaryValue object. Because I need to transfere the whole TDictionary to the sub-processe.
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: OnWebKitInitialized isn't fired
The TChromium.UpdateProxyPrefs function creates a ICefDictionaryValue to set the proxy settings.
Re: OnWebKitInitialized isn't fired
Is there an other way to save a normal TDictionary to the ArgumentList?
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: OnWebKitInitialized isn't fired
I've never tried this but you could try to save the TDictionary into an stream and then send it in binary form.
If it's not too big you can use the ArgumentList.SetBinary with a ICefBinaryValue. Use the TCefBinaryValueRef.New class function to create the ICefBinaryValue.
However, if the binary data is bigger than a few kilobytes you might need to do this :
http://www.magpcss.org/ceforum/viewtopi ... =6&t=10590
Remember that you can compress the binary stream :
https://stackoverflow.com/questions/143 ... ve-to-file
If it's not too big you can use the ArgumentList.SetBinary with a ICefBinaryValue. Use the TCefBinaryValueRef.New class function to create the ICefBinaryValue.
However, if the binary data is bigger than a few kilobytes you might need to do this :
http://www.magpcss.org/ceforum/viewtopi ... =6&t=10590
Remember that you can compress the binary stream :
https://stackoverflow.com/questions/143 ... ve-to-file
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: OnWebKitInitialized isn't fired
Hi,
I added an example of binary parameters in process messages to the JSEval demo.
To test it, right click when the homepage is fully loaded and click on "Send JPEG image...".
Select a small jpg file and you will get the results in a new form : the image size and the encoded data.
Read the code comments for all the details.
I added an example of binary parameters in process messages to the JSEval demo.
To test it, right click when the homepage is fully loaded and click on "Send JPEG image...".
Select a small jpg file and you will get the results in a new form : the image size and the encoded data.
Read the code comments for all the details.
Re: OnWebKitInitialized isn't fired
After a while, I finally found time to come back here.
I saw that you put the TFileStream into a TBytes Buffer. But I haven't found a way to do this with a TDictionary. Currently I have this (not working) code. I'va added comments to explain the errors.
FCallbackClasses ist a TDictionary.
I saw that you put the TFileStream into a TBytes Buffer. But I haven't found a way to do this with a TDictionary. Currently I have this (not working) code. I'va added comments to explain the errors.
FCallbackClasses ist a TDictionary.
Code: Select all
// Send Message
ProcMsg := TCefProcessMessageRef.New(MESSAGE_ID);
ProcMsg.ArgumentList.SetString(0, MSG_Callback_change);
ProcMsg.ArgumentList.SetBinary(1, TCefBinaryValueRef.New(@Instance.FCallbackClasses, Instance.FCallbackClasses.InstanceSize));
ProcMsg.ArgumentList.SetInt(2, Instance.FCallbackClasses.InstanceSize);
browser.SendProcessMessage(PID_RENDERER, ProcMsg);
Code: Select all
// Reveive Message
procedure TCtmCefBridge.ProcessHandler_OnProcessMessageReceivedEvent(const pBrowser : ICefBrowser;
uSourceProcess : TCefProcessId;
const pMessage : ICefProcessMessage);
var
binValue: ICefBinaryValue;
binSize: NativeUInt;
tmpPointer: Pointer;
tmpDict: ^TDictionary<TChromium,TValue>;
begin
CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_INFO, 'OnProcessMessageReceivedEvent Begin');
if (pMessage = nil) or (pMessage.ArgumentList = nil) then exit;
ShowMessage(IntToStr(GetCurrentProcessId));
if (pMessage.Name = MESSAGE_ID) and (pMessage.ArgumentList.GetString(0) = MSG_Callback_change) then
begin
// GetDictionary and set FCallbackClasses
binValue := pMessage.ArgumentList.GetBinary(1);
binSize := pMessage.ArgumentList.GetInt(2);
//binSize := binValue.GetData(tmpPointer, binSize, 0); // This way causes an error when assigning the pointer to FCallbackClasses
tmpPointer := binValue.Wrap; // This way causes an error later when trying to acces FCallbackClasses
tmpDict := tmpPointer;
FCallbackClasses := tmpDict^;
end;
CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_INFO, 'OnProcessMessageReceivedEvent End');
end;
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: OnWebKitInitialized isn't fired
Hi,
I used streams because it's a generic solution to pass all kind of data.
Searching in google for "delphi tdictionary to stream" I found this web page that may help you to save your TDictionary into a Stream :
https://stackoverflow.com/questions/143 ... ve-to-file
I used streams because it's a generic solution to pass all kind of data.
Searching in google for "delphi tdictionary to stream" I found this web page that may help you to save your TDictionary into a Stream :
https://stackoverflow.com/questions/143 ... ve-to-file
Re: OnWebKitInitialized isn't fired
I think that the biggest problem is the generic TValue that I store in the TDictionary, but I'm trying to handle it and I'm going to post my solution, if I find one.