mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-02-02 10:25:26 +02:00
Added more comments to JSExtension
- MiniBrowser shows the name of the loaded frames. - Fixed MiniBrowser Chromium1TextResultAvailable declaration.
This commit is contained in:
parent
5f82e1ace3
commit
55aa9965df
@ -134,36 +134,49 @@ uses
|
||||
// The CEF3 document describing extensions is here :
|
||||
// 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
|
||||
// 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".
|
||||
// When the JavaScript code uses those functions it executes the TTestExtensionHandler.Execute function in uTestExtensionHandler.pas
|
||||
// The extension in this demo is called "myextension" and it has 2 functions called
|
||||
// "mouseover" and "sendresulttobrowser".
|
||||
|
||||
// The TTestExtensionHandler.Execute function is executed in the renderer process and it can use the
|
||||
// TCefv8ContextRef.Current.Browser.SendProcessMessage(PID_BROWSER, msg) to send a message with the results to the browser process.
|
||||
// When the JavaScript code uses those functions it executes the TTestExtensionHandler.Execute
|
||||
// function in uTestExtensionHandler.pas.
|
||||
|
||||
// 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.
|
||||
// When you run this demo and you select the "Set the mouseover event" menu option, the
|
||||
// TChromium.OnContextMenuCommand event is triggered and it adds an event listener to the
|
||||
// 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.
|
||||
// Even if you create several TChromium objects you should have no problem because each of them will have its own
|
||||
// TChromium.OnProcessMessageReceived event to receive the messages from the extension.
|
||||
// Even if you create several TChromium objects you should have no problem because each of
|
||||
// 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
|
||||
// is triggered and it adds an event listener to the document's body. That listener calls one of the functions
|
||||
// available in the registered extension called "myextension.mouseover".
|
||||
// TChromium.OnProcessMessageReceived receives that message and shows the information in
|
||||
// the status bar.
|
||||
|
||||
// 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
|
||||
|
||||
// Destruction steps
|
||||
// =================
|
||||
// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers 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.
|
||||
// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers
|
||||
// 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.
|
||||
|
||||
procedure GlobalCEFApp_OnWebKitInitialized;
|
||||
|
@ -136,6 +136,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
||||
'rowser-sending'
|
||||
'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_loc_assign'
|
||||
'https://www.w3schools.com/html/html5_video.asp'
|
||||
'http://www.adobe.com/software/flash/about/'
|
||||
'http://isflashinstalled.com/'
|
||||
@ -254,6 +255,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
||||
OnPrefsAvailable = Chromium1PrefsAvailable
|
||||
OnResolvedHostAvailable = Chromium1ResolvedHostAvailable
|
||||
OnRenderCompMsg = Chromium1RenderCompMsg
|
||||
OnLoadEnd = Chromium1LoadEnd
|
||||
OnLoadingStateChange = Chromium1LoadingStateChange
|
||||
OnBeforeContextMenu = Chromium1BeforeContextMenu
|
||||
OnContextMenuCommand = Chromium1ContextMenuCommand
|
||||
|
@ -135,7 +135,7 @@ type
|
||||
procedure Chromium1StatusMessage(Sender: TObject;
|
||||
const browser: ICefBrowser; const value: ustring);
|
||||
procedure Chromium1TextResultAvailable(Sender: TObject;
|
||||
const aText: string);
|
||||
const aText: ustring);
|
||||
procedure PopupMenu1Popup(Sender: TObject);
|
||||
procedure DevTools1Click(Sender: TObject);
|
||||
procedure Preferences1Click(Sender: TObject);
|
||||
@ -195,6 +195,8 @@ type
|
||||
procedure Chromium1LoadingProgressChange(Sender: TObject;
|
||||
const browser: ICefBrowser; const progress: Double);
|
||||
procedure OpenfilewithaDAT1Click(Sender: TObject);
|
||||
procedure Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser;
|
||||
const frame: ICefFrame; httpStatusCode: Integer);
|
||||
|
||||
protected
|
||||
FResponse : TStringList;
|
||||
@ -598,6 +600,16 @@ begin
|
||||
if (TempKeyMsg.CharCode = VK_F12) then aHandled := True;
|
||||
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;
|
||||
const browser: ICefBrowser; const progress: Double);
|
||||
begin
|
||||
@ -757,7 +769,7 @@ begin
|
||||
if Chromium1.IsSameBrowser(browser) then ShowStatusText(value);
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Chromium1TextResultAvailable(Sender: TObject; const aText: string);
|
||||
procedure TMiniBrowserFrm.Chromium1TextResultAvailable(Sender: TObject; const aText: ustring);
|
||||
begin
|
||||
clipboard.AsText := aText;
|
||||
end;
|
||||
|
Loading…
x
Reference in New Issue
Block a user