diff --git a/demos/Delphi_VCL/DOMVisitor/DOMVisitor.dproj b/demos/Delphi_VCL/DOMVisitor/DOMVisitor.dproj index 28c6962c..7abec96b 100644 --- a/demos/Delphi_VCL/DOMVisitor/DOMVisitor.dproj +++ b/demos/Delphi_VCL/DOMVisitor/DOMVisitor.dproj @@ -1,7 +1,7 @@  {3B58D3C2-1F7F-4146-A307-5F778CD7C586} - 19.3 + 19.4 VCL DOMVisitor.dpr True @@ -1287,17 +1287,17 @@ 1 - - - - - - + - + + + + + + True diff --git a/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.dfm b/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.dfm index bfa148ca..881159ff 100644 --- a/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.dfm +++ b/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.dfm @@ -15,7 +15,6 @@ object DOMVisitorFrm: TDOMVisitorFrm OnCreate = FormCreate OnDestroy = FormDestroy OnShow = FormShow - PixelsPerInch = 96 TextHeight = 13 object CEFWindowParent1: TCEFWindowParent Left = 0 diff --git a/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.pas b/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.pas index 2ecf4865..acef1edf 100644 --- a/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.pas +++ b/demos/Delphi_VCL/DOMVisitor/uDOMVisitor.pas @@ -79,6 +79,7 @@ const RETRIEVEDOM_MSGNAME_FULL = 'retrievedomfull'; FRAMEIDS_MSGNAME = 'getframeids'; CONSOLE_MSG_PREAMBLE = 'DOMVISITOR'; + FILLUSERNAME_MSGNAME = 'fillusername'; NODE_ID = 'keywords'; @@ -414,6 +415,27 @@ begin end; end; +procedure GlobalCEFApp_OnFocusedNodeChanged(const browser : ICefBrowser; + const frame : ICefFrame; + const node : ICefDomNode); +var + TempMsg : ICefProcessMessage; +begin + // If the user focuses the username box then we send a message to the main + // process to fill it with a username value. + if (frame <> nil) and + frame.IsValid and + (node <> nil) and + (CompareText(node.ElementTagName, 'input') = 0) and + (CompareText(node.GetElementAttribute('id'), 'username') = 0) then + try + TempMsg := TCefProcessMessageRef.New(FILLUSERNAME_MSGNAME); + frame.SendProcessMessage(PID_BROWSER, TempMsg); + finally + TempMsg := nil; + end; +end; + procedure GlobalCEFApp_OnProcessMessageReceived(const browser : ICefBrowser; const frame : ICefFrame; sourceProcess : TCefProcessId; @@ -460,6 +482,7 @@ procedure CreateGlobalCEFApp; begin GlobalCEFApp := TCefApplication.Create; GlobalCEFApp.OnProcessMessageReceived := GlobalCEFApp_OnProcessMessageReceived; + GlobalCEFApp.OnFocusedNodeChanged := GlobalCEFApp_OnFocusedNodeChanged; // Enabling the debug log file for then DOM visitor demo. // This adds lots of warnings to the console, specially if you run this inside VirtualBox. @@ -738,7 +761,10 @@ begin Clipboard.AsText := message.ArgumentList.GetString(0); StatusText := 'Frame IDs copied to the clipboard in the render process.'; Result := True; - end; + end + else + if (message.Name = FILLUSERNAME_MSGNAME) and (frame <> nil) and frame.IsValid then + frame.ExecuteJavaScript('document.getElementById("username").value = "myusername";', 'about:blank', 0); if Result then PostMessage(Handle, MINIBROWSER_SHOWSTATUSTEXT, 0, 0); diff --git a/demos/Lazarus_Windows/DOMVisitor/DOMVisitor.lpi b/demos/Lazarus_Windows/DOMVisitor/DOMVisitor.lpi index 825a40e1..38067839 100644 --- a/demos/Lazarus_Windows/DOMVisitor/DOMVisitor.lpi +++ b/demos/Lazarus_Windows/DOMVisitor/DOMVisitor.lpi @@ -1,7 +1,7 @@ - + @@ -9,9 +9,9 @@ + - <UseAppBundle Value="False"/> <ResourceType Value="res"/> @@ -25,7 +25,6 @@ </PublishOptions> <RunParams> <FormatVersion Value="2"/> - <Modes Count="0"/> </RunParams> <RequiredPackages Count="2"> <Item1> diff --git a/demos/Lazarus_Windows/DOMVisitor/uDOMVisitor.pas b/demos/Lazarus_Windows/DOMVisitor/uDOMVisitor.pas index e36d5f01..33d50ca7 100644 --- a/demos/Lazarus_Windows/DOMVisitor/uDOMVisitor.pas +++ b/demos/Lazarus_Windows/DOMVisitor/uDOMVisitor.pas @@ -73,7 +73,8 @@ const RETRIEVEDOM_MSGNAME_PARTIAL = 'retrievedompartial'; RETRIEVEDOM_MSGNAME_FULL = 'retrievedomfull'; FRAMEIDS_MSGNAME = 'getframeids'; - CONSOLE_MSG_PREAMBLE = 'DOMVISITOR'; + CONSOLE_MSG_PREAMBLE = 'DOMVISITOR'; + FILLUSERNAME_MSGNAME = 'fillusername'; NODE_ID = 'keywords'; @@ -400,6 +401,27 @@ begin end; end; +procedure GlobalCEFApp_OnFocusedNodeChanged(const browser : ICefBrowser; + const frame : ICefFrame; + const node : ICefDomNode); +var + TempMsg : ICefProcessMessage; +begin + // If the user focuses the username box then we send a message to the main + // process to fill it with a username value. + if (frame <> nil) and + frame.IsValid and + (node <> nil) and + (CompareText(node.ElementTagName, 'input') = 0) and + (CompareText(node.GetElementAttribute('id'), 'username') = 0) then + try + TempMsg := TCefProcessMessageRef.New(FILLUSERNAME_MSGNAME); + frame.SendProcessMessage(PID_BROWSER, TempMsg); + finally + TempMsg := nil; + end; +end; + procedure GlobalCEFApp_OnProcessMessageReceived(const browser : ICefBrowser; const frame : ICefFrame; sourceProcess : TCefProcessId; @@ -445,7 +467,8 @@ end; procedure CreateGlobalCEFApp; begin GlobalCEFApp := TCefApplication.Create; - GlobalCEFApp.OnProcessMessageReceived := GlobalCEFApp_OnProcessMessageReceived; + GlobalCEFApp.OnProcessMessageReceived := GlobalCEFApp_OnProcessMessageReceived; + GlobalCEFApp.OnFocusedNodeChanged := GlobalCEFApp_OnFocusedNodeChanged; // Enabling the debug log file for then DOM visitor demo. // This adds lots of warnings to the console, specially if you run this inside VirtualBox. @@ -721,7 +744,10 @@ begin Clipboard.AsText := message.ArgumentList.GetString(0); StatusText := 'Frame IDs copied to the clipboard in the render process.'; Result := True; - end; + end + else + if (message.Name = FILLUSERNAME_MSGNAME) and (frame <> nil) and frame.IsValid then + frame.ExecuteJavaScript('document.getElementById("username").value = "myusername";', 'about:blank', 0); if Result then PostMessage(Handle, MINIBROWSER_SHOWSTATUSTEXT, 0, 0); diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 44188cba..cc69d549 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,7 +2,7 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 386, + "InternalVersion" : 387, "Name" : "cef4delphi_lazarus.lpk", "Version" : "100.0.23.0" }