How to inject HTML while in OnResourceRedirect?
Posted: Wed Dec 18, 2019 8:56 am
Background:
I have an OAuth login screen with a TCefWindowParent and a TChromium.
In the OnResourceRedirect event, I check if the URL we redirect to is the OAuth RedirectURI, and in that case I close my login screen by setting ModalResult to mrOK/mrCancel (depending on the parameters returned in NewURL), followed by the usual FormClose/ChromiumClose etc sequence.
This works fine, the form closes and returns with the ModalResult.
If I run this code in 'debugging mode' a memo becomes visible and I log event information to it.
In that case I do *not* set ModalResult so that the form stays open and the user can see the log. He can then click buttons to close the form, again doing the 'ModalResult thing'.
This also works.
Question:
While in the OnResourceRedirect, how can I inject some HTML code into TChromium to display a simple message like "You can now click the button to close this window"?
Thanks in advance,
Jan
I have an OAuth login screen with a TCefWindowParent and a TChromium.
In the OnResourceRedirect event, I check if the URL we redirect to is the OAuth RedirectURI, and in that case I close my login screen by setting ModalResult to mrOK/mrCancel (depending on the parameters returned in NewURL), followed by the usual FormClose/ChromiumClose etc sequence.
This works fine, the form closes and returns with the ModalResult.
If I run this code in 'debugging mode' a memo becomes visible and I log event information to it.
In that case I do *not* set ModalResult so that the form stays open and the user can see the log. He can then click buttons to close the form, again doing the 'ModalResult thing'.
This also works.
Question:
While in the OnResourceRedirect, how can I inject some HTML code into TChromium to display a simple message like "You can now click the button to close this window"?
Code: Select all
if not FDebugging then
begin
if (FAuthorizationCode = '') or (lState <> FState) then
Self.ModalResult := mrCancel
else
Self.ModalResult := mrOK;
PostMessage(Handle, WM_USER+1, 0, 0);
end
else
begin
// HERE - How to inject HTML?
//
// Loading a file from disk does not work, I would not want that anyway:
// NewURL := 'file:///' + StringReplace(fpath, '\', '/',[rfReplaceAll]);
end;
Jan