You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-06-12 22:07:39 +02:00
Added more comments to JSExtension
- MiniBrowser shows the name of the loaded frames. - Fixed MiniBrowser Chromium1TextResultAvailable declaration.
This commit is contained in:
@ -134,36 +134,49 @@ uses
|
|||||||
// The CEF3 document describing extensions is here :
|
// The CEF3 document describing extensions is here :
|
||||||
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
|
||||||
|
|
||||||
|
// The Chromium project document describing Chromium's architecture is here :
|
||||||
|
// http://www.chromium.org/developers/design-documents/multi-process-architecture
|
||||||
|
|
||||||
// This demo has a JavaScript extension class that is registered in the
|
// This demo has a JavaScript extension class that is registered in the
|
||||||
// GlobalCEFApp.OnWebKitInitialized event when the application is initializing.
|
// GlobalCEFApp.OnWebKitInitialized event when the application is initializing.
|
||||||
|
|
||||||
// The extension in this demo is called "myextension" and it has 2 functions called "mouseover" and "sendresulttobrowser".
|
// The extension in this demo is called "myextension" and it has 2 functions called
|
||||||
// When the JavaScript code uses those functions it executes the TTestExtensionHandler.Execute function in uTestExtensionHandler.pas
|
// "mouseover" and "sendresulttobrowser".
|
||||||
|
|
||||||
// The TTestExtensionHandler.Execute function is executed in the renderer process and it can use the
|
// When the JavaScript code uses those functions it executes the TTestExtensionHandler.Execute
|
||||||
// TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg) to send a message with the results to the browser process.
|
// function in uTestExtensionHandler.pas.
|
||||||
|
|
||||||
// TCefv8ContextRef.Current returns the v8 context for the frame that is currently executing JavaScript,
|
// When you run this demo and you select the "Set the mouseover event" menu option, the
|
||||||
// TCefv8ContextRef.Current.Browser.SendProcessMessage sends a message to the right browser even
|
// TChromium.OnContextMenuCommand event is triggered and it adds an event listener to the
|
||||||
// if you have created several browsers in one app.
|
// document's body. That listener calls one of the functions available in the registered
|
||||||
|
// extension called "myextension.mouseover".
|
||||||
|
|
||||||
|
// The TTestExtensionHandler.Execute function is executed in the renderer process and it
|
||||||
|
// can use the TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg) function
|
||||||
|
// to send a message with the results to the browser process.
|
||||||
|
|
||||||
|
// TCefv8ContextRef.Current returns the v8 context for the frame that is currently
|
||||||
|
// executing JavaScript, TCefv8ContextRef.Current.Browser.SendProcessMessage sends a message
|
||||||
|
// to the right browser even if you have created several browsers in one app.
|
||||||
|
|
||||||
// That message is received in the TChromium.OnProcessMessageReceived event.
|
// That message is received in the TChromium.OnProcessMessageReceived event.
|
||||||
// Even if you create several TChromium objects you should have no problem because each of them will have its own
|
// Even if you create several TChromium objects you should have no problem because each of
|
||||||
// TChromium.OnProcessMessageReceived event to receive the messages from the extension.
|
// them will have its own TChromium.OnProcessMessageReceived event to receive the messages
|
||||||
|
// from the extension.
|
||||||
|
|
||||||
// When run this demo and you select the "Set the mouseover event" menu option, the Chromium1ContextMenuCommand event
|
// TChromium.OnProcessMessageReceived receives that message and shows the information in
|
||||||
// is triggered and it adds an event listener to the document's body. That listener calls one of the functions
|
// the status bar.
|
||||||
// available in the registered extension called "myextension.mouseover".
|
|
||||||
|
|
||||||
// TChromium.OnProcessMessageReceived receives that message and shows the information in the status bar.
|
// If you have to debug the code executed by the extension you will need to use the
|
||||||
|
// debugging methods described in
|
||||||
// If you have to debug the code executed by the extension you will need to use the debugging methods described in
|
|
||||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||||
|
|
||||||
// Destruction steps
|
// Destruction steps
|
||||||
// =================
|
// =================
|
||||||
// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers the TChromium.OnClose event.
|
// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers
|
||||||
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
|
// the TChromium.OnClose event.
|
||||||
|
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1
|
||||||
|
// in the main thread, which triggers the TChromium.OnBeforeClose event.
|
||||||
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
||||||
|
|
||||||
procedure GlobalCEFApp_OnWebKitInitialized;
|
procedure GlobalCEFApp_OnWebKitInitialized;
|
||||||
|
@ -136,6 +136,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
|||||||
'rowser-sending'
|
'rowser-sending'
|
||||||
'https://www.w3schools.com/js/tryit.asp?filename=tryjs_win_close'
|
'https://www.w3schools.com/js/tryit.asp?filename=tryjs_win_close'
|
||||||
'https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert'
|
'https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert'
|
||||||
|
'https://www.w3schools.com/js/tryit.asp?filename=tryjs_loc_assign'
|
||||||
'https://www.w3schools.com/html/html5_video.asp'
|
'https://www.w3schools.com/html/html5_video.asp'
|
||||||
'http://www.adobe.com/software/flash/about/'
|
'http://www.adobe.com/software/flash/about/'
|
||||||
'http://isflashinstalled.com/'
|
'http://isflashinstalled.com/'
|
||||||
@ -254,6 +255,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
|||||||
OnPrefsAvailable = Chromium1PrefsAvailable
|
OnPrefsAvailable = Chromium1PrefsAvailable
|
||||||
OnResolvedHostAvailable = Chromium1ResolvedHostAvailable
|
OnResolvedHostAvailable = Chromium1ResolvedHostAvailable
|
||||||
OnRenderCompMsg = Chromium1RenderCompMsg
|
OnRenderCompMsg = Chromium1RenderCompMsg
|
||||||
|
OnLoadEnd = Chromium1LoadEnd
|
||||||
OnLoadingStateChange = Chromium1LoadingStateChange
|
OnLoadingStateChange = Chromium1LoadingStateChange
|
||||||
OnBeforeContextMenu = Chromium1BeforeContextMenu
|
OnBeforeContextMenu = Chromium1BeforeContextMenu
|
||||||
OnContextMenuCommand = Chromium1ContextMenuCommand
|
OnContextMenuCommand = Chromium1ContextMenuCommand
|
||||||
|
@ -135,7 +135,7 @@ type
|
|||||||
procedure Chromium1StatusMessage(Sender: TObject;
|
procedure Chromium1StatusMessage(Sender: TObject;
|
||||||
const browser: ICefBrowser; const value: ustring);
|
const browser: ICefBrowser; const value: ustring);
|
||||||
procedure Chromium1TextResultAvailable(Sender: TObject;
|
procedure Chromium1TextResultAvailable(Sender: TObject;
|
||||||
const aText: string);
|
const aText: ustring);
|
||||||
procedure PopupMenu1Popup(Sender: TObject);
|
procedure PopupMenu1Popup(Sender: TObject);
|
||||||
procedure DevTools1Click(Sender: TObject);
|
procedure DevTools1Click(Sender: TObject);
|
||||||
procedure Preferences1Click(Sender: TObject);
|
procedure Preferences1Click(Sender: TObject);
|
||||||
@ -195,6 +195,8 @@ type
|
|||||||
procedure Chromium1LoadingProgressChange(Sender: TObject;
|
procedure Chromium1LoadingProgressChange(Sender: TObject;
|
||||||
const browser: ICefBrowser; const progress: Double);
|
const browser: ICefBrowser; const progress: Double);
|
||||||
procedure OpenfilewithaDAT1Click(Sender: TObject);
|
procedure OpenfilewithaDAT1Click(Sender: TObject);
|
||||||
|
procedure Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser;
|
||||||
|
const frame: ICefFrame; httpStatusCode: Integer);
|
||||||
|
|
||||||
protected
|
protected
|
||||||
FResponse : TStringList;
|
FResponse : TStringList;
|
||||||
@ -598,6 +600,16 @@ begin
|
|||||||
if (TempKeyMsg.CharCode = VK_F12) then aHandled := True;
|
if (TempKeyMsg.CharCode = VK_F12) then aHandled := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMiniBrowserFrm.Chromium1LoadEnd(Sender: TObject;
|
||||||
|
const browser: ICefBrowser; const frame: ICefFrame;
|
||||||
|
httpStatusCode: Integer);
|
||||||
|
begin
|
||||||
|
if frame.IsMain then
|
||||||
|
StatusBar1.Panels[1].Text := 'main frame loaded : ' + quotedstr(frame.name)
|
||||||
|
else
|
||||||
|
StatusBar1.Panels[1].Text := 'frame loaded : ' + quotedstr(frame.name);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMiniBrowserFrm.Chromium1LoadingProgressChange(Sender: TObject;
|
procedure TMiniBrowserFrm.Chromium1LoadingProgressChange(Sender: TObject;
|
||||||
const browser: ICefBrowser; const progress: Double);
|
const browser: ICefBrowser; const progress: Double);
|
||||||
begin
|
begin
|
||||||
@ -757,7 +769,7 @@ begin
|
|||||||
if Chromium1.IsSameBrowser(browser) then ShowStatusText(value);
|
if Chromium1.IsSameBrowser(browser) then ShowStatusText(value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMiniBrowserFrm.Chromium1TextResultAvailable(Sender: TObject; const aText: string);
|
procedure TMiniBrowserFrm.Chromium1TextResultAvailable(Sender: TObject; const aText: ustring);
|
||||||
begin
|
begin
|
||||||
clipboard.AsText := aText;
|
clipboard.AsText := aText;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user