You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-12-03 21:44:45 +02:00
Fixed UTF8 string conversion in SimpleBrowser for Linux
- Removed "cmem" and "interfaces" from the TinyBrowser2 demo for Linux. - Simplified the code of the TinyBrowser2 demo for Linux. - Added the workaround for the CEF focus issue to TChromiumWindow in Linux. - Set the result type of GetChildWindowHandle to LclType.THandle in FPC for TCEFWinControl, TCEFLinkedWindowParent and TChromiumWindow.
This commit is contained in:
@@ -50,7 +50,6 @@ type
|
||||
private
|
||||
FChromium : TChromiumCore;
|
||||
|
||||
procedure Chromium_OnClose(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
|
||||
procedure Chromium_OnBeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure Chromium_OnBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean);
|
||||
procedure Chromium_OnOpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
|
||||
@@ -58,7 +57,6 @@ type
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure AfterConstruction; override;
|
||||
end;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
@@ -69,17 +67,19 @@ implementation
|
||||
// This demo is similar to the cefsimple demo in the official CEF project.
|
||||
|
||||
// It doesn't use LCL to create forms from Lazarus code.
|
||||
// It just uses CEF to create a browser window as if it was a popup browser window.
|
||||
// It just uses CEF to create a browser window as if it was a popup browser
|
||||
// window.
|
||||
|
||||
// This browser doesn't use multiple threads to handle the browser and it doesn't use an external message pump.
|
||||
// For this reason we have to call GlobalCEFApp.RunMessageLoop to let CEF handle the message loop and
|
||||
// This browser doesn't use multiple threads to handle the browser and it
|
||||
// doesn't use an external message pump. For this reason we have to call
|
||||
// GlobalCEFApp.RunMessageLoop to let CEF handle the message loop and
|
||||
// GlobalCEFApp.QuitMessageLoop when the browser has been destroyed.
|
||||
|
||||
// The destruction steps are much simpler for that reason.
|
||||
// In this demo it's only necessary to implement the TChromium.OnClose and TChromium.OnBeforeClose events.
|
||||
// The TChromium.OnClose event only sets aAction to cbaClose to continue closing the browser.
|
||||
// The TChromium.OnBeforeClose event calls GlobalCEFApp.QuitMessageLoop because the browser has been destroyed
|
||||
// and it's necessary to close the message loop.
|
||||
// In this demo it's only necessary to implement the TChromium.OnBeforeClose
|
||||
// events. The TChromium.OnBeforeClose event calls GlobalCEFApp.QuitMessageLoop
|
||||
// because the browser has been destroyed and it's necessary to close the
|
||||
// message loop.
|
||||
|
||||
uses
|
||||
uCEFApplication, uCEFConstants;
|
||||
@@ -117,47 +117,34 @@ constructor TTinyBrowser2.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FChromium := nil;
|
||||
end;
|
||||
|
||||
destructor TTinyBrowser2.Destroy;
|
||||
begin
|
||||
if (FChromium <> nil) then
|
||||
begin
|
||||
FChromium.Free;
|
||||
FChromium := nil;
|
||||
end;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTinyBrowser2.AfterConstruction;
|
||||
begin
|
||||
inherited AfterConstruction;
|
||||
|
||||
FChromium := TChromiumCore.Create(nil);
|
||||
FChromium.DefaultURL := 'https://www.google.com';
|
||||
FChromium.OnClose := Chromium_OnClose;
|
||||
FChromium.OnBeforeClose := Chromium_OnBeforeClose;
|
||||
FChromium.OnBeforePopup := Chromium_OnBeforePopup;
|
||||
FChromium.OnOpenUrlFromTab := Chromium_OnOpenUrlFromTab;
|
||||
FChromium.CreateBrowser('Tiny Browser 2');
|
||||
end;
|
||||
|
||||
procedure TTinyBrowser2.Chromium_OnClose(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
|
||||
destructor TTinyBrowser2.Destroy;
|
||||
begin
|
||||
aAction := cbaClose;
|
||||
if (FChromium <> nil) then
|
||||
FreeAndNil(FChromium);
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTinyBrowser2.Chromium_OnBeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure TTinyBrowser2.Chromium_OnBeforeClose(Sender: TObject;
|
||||
const browser: ICefBrowser);
|
||||
begin
|
||||
GlobalCEFApp.QuitMessageLoop;
|
||||
end;
|
||||
|
||||
procedure TTinyBrowser2.Chromium_OnBeforePopup(Sender: TObject; const browser: ICefBrowser;
|
||||
const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
|
||||
userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo;
|
||||
var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue;
|
||||
procedure TTinyBrowser2.Chromium_OnBeforePopup(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
|
||||
targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
|
||||
userGesture: Boolean; const popupFeatures: TCefPopupFeatures;
|
||||
var windowInfo: TCefWindowInfo; var client: ICefClient;
|
||||
var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue;
|
||||
var noJavascriptAccess: Boolean; var Result: Boolean);
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
|
||||
Reference in New Issue
Block a user