1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2024-11-24 08:02:15 +02:00

CEF Views type and interface definitions

- Added some Linux and MacOS initialization (doesn't work yet)
- GlobalCEFApp.MustFreeLibrary is now FALSE by default.
- GlobalCEFApp set to nil in all demos.
- ResponseFilterBrowser now uses the critical section in Chromium1ResourceLoadComplete.
- Added overloaded TChromium.LoadURL to load a URL in a frame.
- Added url and cookiename parameters to TChromium.DeleteCookies to delete the cookies from that url and/or name.
This commit is contained in:
Salvador Díaz Fau 2018-05-24 19:15:41 +02:00
parent f68312a1a6
commit 8000e45198
52 changed files with 1231 additions and 165 deletions

View File

@ -70,4 +70,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -69,4 +69,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -76,4 +76,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -44,10 +44,13 @@ object DOMVisitorFrm: TDOMVisitorFrm
object AddressEdt: TEdit
Left = 5
Top = 5
Width = 764
Height = 21
Width = 754
Height = 20
Align = alClient
TabOrder = 0
Text = 'https://www.google.com'
ExplicitWidth = 764
ExplicitHeight = 21
end
object Panel1: TPanel
Left = 759

View File

@ -66,4 +66,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -68,4 +68,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -72,4 +72,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -72,4 +72,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -73,4 +73,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -71,4 +71,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -71,4 +71,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -137,13 +137,13 @@
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">
<DeployFile LocalName="JSExtension.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployFile LocalName="..\..\..\bin\JSExtensionWithObjectParameter.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>JSExtensionWithObjectParameter.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="JSExtension.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployClass Name="AdditionalDebugSymbols">
<Platform Name="iOSSimulator">
<Operation>1</Operation>

View File

@ -74,4 +74,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -139,13 +139,13 @@
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">
<DeployFile LocalName="JSExtension.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployFile LocalName="..\..\bin\JSRTTIExtension.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>JSRTTIExtension.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="JSExtension.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployClass Name="AdditionalDebugSymbols">
<Platform Name="iOSSimulator">
<Operation>1</Operation>

View File

@ -70,4 +70,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -70,4 +70,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -80,4 +80,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -87,5 +87,6 @@ begin
GlobalCEFApp.StartSubProcess;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -71,4 +71,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -71,4 +71,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -101,7 +101,7 @@ implementation
{$R *.dfm}
uses
uCEFv8Value, uMyV8Accessor;
uCEFv8Value, uMyV8Accessor, uCEFMiscFunctions;
// The CEF3 document describing JavaScript integration is here :
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md

View File

@ -68,4 +68,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -73,4 +73,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -62,7 +62,6 @@ begin
GlobalCEFApp.FlashEnabled := False;
GlobalCEFApp.WindowlessRenderingEnabled := True;
GlobalCEFApp.EnableHighDPISupport := True;
GlobalCEFApp.SitePerProcess := False;
if GlobalCEFApp.StartMainProcess then
begin
@ -75,4 +74,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -73,4 +73,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -69,4 +69,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -2,7 +2,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
Left = 0
Top = 0
Caption = 'Initializing browser. Please wait...'
ClientHeight = 624
ClientHeight = 710
ClientWidth = 1038
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
@ -20,7 +20,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
TextHeight = 13
object Splitter1: TSplitter
Left = 0
Top = 532
Top = 407
Width = 1038
Height = 3
Cursor = crVSplit
@ -50,7 +50,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
Margins.Right = 5
Align = alClient
TabOrder = 0
Text = 'https://www.wikipedia.org'
Text = 'https://www.briskbard.com'
ExplicitHeight = 21
end
object Panel1: TPanel
@ -88,7 +88,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
Height = 20
Align = alRight
TabOrder = 1
Text = 'index-47f5f07682.js'
Text = 'script.js'
ExplicitHeight = 21
end
end
@ -97,15 +97,15 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
Left = 0
Top = 30
Width = 1038
Height = 502
Height = 377
Align = alClient
TabOrder = 1
end
object Memo1: TMemo
Left = 0
Top = 535
Top = 410
Width = 1038
Height = 89
Height = 300
Align = alBottom
ReadOnly = True
ScrollBars = ssBoth

View File

@ -109,6 +109,7 @@ type
procedure Filter_OnFilter(Sender: TObject; data_in: Pointer; data_in_size: NativeUInt; var data_in_read: NativeUInt; data_out: Pointer; data_out_size : NativeUInt; var data_out_written: NativeUInt; var aResult : TCefResponseFilterStatus);
procedure UpdateRscEncoding(const aMimeType, aContentType : string);
function IsMyResource(const aRequest : ICefRequest) : boolean;
procedure GetResponseEncoding(const aContentType: string);
public
@ -153,41 +154,43 @@ procedure TResponseFilterBrowserFrm.Filter_OnFilter(Sender: TObject;
begin
try
try
FStreamCS.Acquire;
// This event will be called repeatedly until the input buffer has been fully read.
// When there's no more data then data_in is nil and you can show the stream contents.
FStreamCS.Acquire;
if (data_in = nil) then
begin
data_in_read := 0;
data_out_written := 0;
aResult := RESPONSE_FILTER_DONE;
if not(FRscCompleted) and (FStream.Size > 0) and
((FRscSize = -1) or (FRscSize = FStream.Size)) then
FRscCompleted := PostMessage(Handle, STREAM_COPY_COMPLETE, 0, 0);
end
else
begin
if (data_out <> nil) then
if not(FRscCompleted) and
(FStream <> nil) and
(FStream.Size > 0) and
((FRscSize = -1) or (FRscSize = FStream.Size)) then
FRscCompleted := PostMessage(Handle, STREAM_COPY_COMPLETE, 0, 0);
end
else
begin
data_out_written := min(data_in_size, data_out_size);
if (data_out <> nil) then
begin
data_out_written := min(data_in_size, data_out_size);
if (data_out_written > 0) then
Move(data_in^, data_out^, data_out_written);
end;
if (data_in_size > 0) then
data_in_read := FStream.Write(data_in^, data_in_size);
if (data_in_size > 0) then
data_in_read := FStream.Write(data_in^, data_in_size);
// Send the STREAM_COPY_COMPLETE message only if the server sent the data size in
// a Content-Length header and we can compare it with the stream size
if not(FRscCompleted) and (FRscSize <> -1) and (FRscSize = FStream.Size) then
FRscCompleted := PostMessage(Handle, STREAM_COPY_COMPLETE, 0, 0);
// Send the STREAM_COPY_COMPLETE message only if the server sent the data size in
// a Content-Length header and we can compare it with the stream size
if not(FRscCompleted) and (FRscSize <> -1) and (FRscSize = FStream.Size) then
FRscCompleted := PostMessage(Handle, STREAM_COPY_COMPLETE, 0, 0);
aResult := RESPONSE_FILTER_NEED_MORE_DATA;
end;
aResult := RESPONSE_FILTER_NEED_MORE_DATA;
end;
except
on e : exception do
begin
@ -231,7 +234,7 @@ begin
FStream := TMemoryStream.Create;
FStreamCS := TCriticalSection.Create;
FFilter := TCustomResponseFilter.Create;
FRscEncoding := TEncoding.Default;
FRscEncoding := TEncoding.Default;
FCanClose := False;
FClosing := False;
@ -260,8 +263,7 @@ begin
PostMessage(Handle, CEF_AFTERCREATED, 0, 0);
end;
procedure TResponseFilterBrowserFrm.Chromium1BeforeClose(Sender: TObject;
const browser: ICefBrowser);
procedure TResponseFilterBrowserFrm.Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
@ -294,11 +296,11 @@ procedure TResponseFilterBrowserFrm.Chromium1GetResourceResponseFilter(Sender :
out Result : ICefResponseFilter);
var
TempHeader : string;
TempLen : integer;
TempLen : integer;
begin
if (response <> nil) and IsMyResource(request) then
begin
Result := FFilter;
Result := FFilter;
TempHeader := trim(response.GetHeader('Content-Length'));
if TryStrToInt(TempHeader, TempLen) and (TempLen > 0) then
@ -306,19 +308,23 @@ begin
else
FRscSize := -1;
FRscMimeType := response.MimeType;
if (response.MimeType = 'application/json') or
(response.MimeType = 'text/json') or
(response.MimeType = 'text/javascript') or
(response.MimeType = 'application/javascript') then
begin
GetResponseEncoding(response.GetHeader('Content-Type'));
end;
UpdateRscEncoding(response.MimeType, response.GetHeader('Content-Type'));
end
else
Result := nil;
end;
procedure TResponseFilterBrowserFrm.UpdateRscEncoding(const aMimeType, aContentType : string);
begin
FRscMimeType := aMimeType;
if (aMimeType = 'application/json') or
(aMimeType = 'text/json') or
(aMimeType = 'text/javascript') or
(aMimeType = 'application/javascript') then
GetResponseEncoding(aContentType);
end;
procedure TResponseFilterBrowserFrm.Chromium1ResourceLoadComplete(Sender : TObject;
const browser : ICefBrowser;
const frame : ICefFrame;
@ -327,20 +333,21 @@ procedure TResponseFilterBrowserFrm.Chromium1ResourceLoadComplete(Sender : TObje
status : TCefUrlRequestStatus;
receivedContentLength : Int64);
begin
// In case the server didn't send a Content-Length header
// and CEF didn't send a data_in = nil in Filter_OnFilter
// we still can use this event to know when the resource is complete
if not(FRscCompleted) and IsMyResource(request) then
begin
FRscMimeType := response.MimeType;
if (response.MimeType = 'application/json')
or (response.MimeType = 'text/json')
or (response.MimeType = 'text/javascript')
or (response.MimeType = 'application/javascript')
then begin
GetResponseEncoding(response.GetHeader('Content-Type'));
end;
FRscCompleted := PostMessage(Handle, STREAM_COPY_COMPLETE, 0, 0);
try
FStreamCS.Acquire;
// In case the server didn't send a Content-Length header
// and CEF didn't send a data_in = nil in Filter_OnFilter
// we still can use this event to know when the resource is complete
if IsMyResource(request) then
begin
UpdateRscEncoding(response.MimeType, response.GetHeader('Content-Type'));
if not(FRscCompleted) then
FRscCompleted := PostMessage(Handle, STREAM_COPY_COMPLETE, 0, 0);
end;
finally
FStreamCS.Release;
end;
end;
@ -366,37 +373,34 @@ begin
FStreamCS.Acquire;
if (FStream.Size > 0) then
begin
FStream.Seek(0, soBeginning);
Memo1.Lines.Clear;
if (FRscMimeType = 'application/json') or (FRscMimeType = 'text/json') or
(FRscMimeType = 'text/javascript') or
(FRscMimeType = 'application/javascript') then
begin
SetLength(LAS, FStream.Size);
FStream.Read(LAS[Low(LAS)], FStream.Size);
if FRscEncoding = TEncoding.UTF8 then
begin
// UTF8 Here
LS := UTF8Decode(LAS);
end
else
begin
// Others encoding text
LS := string(LAS);
end;
Memo1.Lines.Add(LS);
end
else
// Image or others
Memo1.Lines.LoadFromStream(FStream);
FStream.Seek(0, soBeginning);
FStream.Clear;
FRscSize := -1;
FRscCompleted := False;
end
else
Memo1.Lines.Clear;
if (FRscMimeType = 'application/json') or
(FRscMimeType = 'text/json') or
(FRscMimeType = 'text/javascript') or
(FRscMimeType = 'application/javascript') then
begin
SetLength(LAS, FStream.Size);
FStream.Read(LAS[Low(LAS)], FStream.Size);
if (FRscEncoding = TEncoding.UTF8) then
LS := UTF8Decode(LAS) // UTF8 Here
else
LS := string(LAS); // Others encoding text
Memo1.Lines.Add(LS);
end
else
Memo1.Lines.LoadFromStream(FStream); // Image or others
FStream.Clear;
FRscSize := -1;
FRscCompleted := False;
end
else
Memo1.Lines.Clear;
finally
FStreamCS.Release;
@ -443,8 +447,7 @@ begin
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False;
end;
procedure TResponseFilterBrowserFrm.GetResponseEncoding
(const aContentType: string);
procedure TResponseFilterBrowserFrm.GetResponseEncoding(const aContentType: string);
var
LEncoding: String;
begin

View File

@ -68,4 +68,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -84,4 +84,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -54,13 +54,14 @@ begin
GlobalCEFApp := TCefApplication.Create;
// In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data.
{
GlobalCEFApp.FrameworkDirPath := 'cef';
GlobalCEFApp.ResourcesDirPath := 'cef';
GlobalCEFApp.LocalesDirPath := 'cef\locales';
GlobalCEFApp.cache := 'cef\cache';
GlobalCEFApp.cookies := 'cef\cookies';
GlobalCEFApp.UserDataPath := 'cef\User Data';
{
GlobalCEFApp.FrameworkDirPath := 'cef';
GlobalCEFApp.ResourcesDirPath := 'cef';
GlobalCEFApp.LocalesDirPath := 'cef\locales';
GlobalCEFApp.cache := 'cef\cache';
GlobalCEFApp.cookies := 'cef\cookies';
GlobalCEFApp.UserDataPath := 'cef\User Data';
}
if GlobalCEFApp.StartMainProcess then
@ -71,4 +72,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -86,4 +86,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -72,4 +72,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -47,4 +47,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -7,12 +7,17 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, uSimpleLazarusBrowser
Forms, uSimpleLazarusBrowser,
{ you can add units after this }
,uCEFApplication;
uCEFApplication;
{$R *.res}
{$IFDEF MSWINDOWS}
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
{$SetPEFlags $20}
{$ENDIF}
begin
GlobalCEFApp := TCefApplication.Create;
@ -24,6 +29,7 @@ begin
Application.Run;
end;
GlobalCEFApp.Free;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -4,13 +4,15 @@
<PathDelim Value="\"/>
<Version Value="10"/>
<BuildModes Active="Default"/>
<Units Count="30">
<Units Count="34">
<Unit0>
<Filename Value="SimpleLazarusBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="3" Y="26"/>
<UsageCount Value="33"/>
<TopLine Value="2"/>
<CursorPos X="47" Y="22"/>
<UsageCount Value="38"/>
</Unit0>
<Unit1>
<Filename Value="usimplelazarusbrowser.pas"/>
@ -19,25 +21,22 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="uSimpleLazarusBrowser"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="166"/>
<CursorPos X="53" Y="110"/>
<UsageCount Value="33"/>
<TopLine Value="56"/>
<CursorPos X="53" Y="69"/>
<UsageCount Value="38"/>
</Unit1>
<Unit2>
<Filename Value="..\..\source\uCEFChromium.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="34"/>
<CursorPos Y="49"/>
<UsageCount Value="16"/>
<Bookmarks Count="6">
<Item0 X="35" Y="771" ID="1"/>
<Item1 X="46" Y="119" ID="2"/>
<Item2 X="17" Y="843" ID="3"/>
<Item3 X="20" Y="621" ID="4"/>
<Item4 X="57" Y="3494" ID="5"/>
<Item5 X="3" Y="1079" ID="6"/>
<TopLine Value="1272"/>
<CursorPos X="61" Y="1295"/>
<UsageCount Value="17"/>
<Bookmarks Count="4">
<Item0 X="20" Y="621" ID="4"/>
<Item1 X="57" Y="3494" ID="5"/>
<Item2 X="3" Y="1079" ID="6"/>
<Item3 X="3" Y="1295" ID="2"/>
</Bookmarks>
</Unit2>
<Unit3>
@ -140,9 +139,13 @@
<Unit17>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1498"/>
<CursorPos X="50" Y="1521"/>
<UsageCount Value="11"/>
<TopLine Value="43"/>
<CursorPos Y="44"/>
<UsageCount Value="13"/>
<Bookmarks Count="2">
<Item0 X="60" Y="956" ID="1"/>
<Item1 X="9" Y="894" ID="3"/>
</Bookmarks>
</Unit17>
<Unit18>
<Filename Value="C:\lazarus\lcl\forms.pp"/>
@ -222,31 +225,48 @@
<Unit28>
<Filename Value="..\..\source\uCEFTypes.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1248"/>
<UsageCount Value="11"/>
<TopLine Value="235"/>
<CursorPos X="34" Y="252"/>
<UsageCount Value="13"/>
</Unit28>
<Unit29>
<Filename Value="..\..\source\uCEFMiscFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="106"/>
<CursorPos X="50" Y="124"/>
<TopLine Value="996"/>
<CursorPos X="67" Y="1003"/>
<UsageCount Value="10"/>
</Unit29>
<Unit30>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\inc\ctypes.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="64"/>
<UsageCount Value="10"/>
</Unit30>
<Unit31>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\inc\dynlibs.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="147"/>
<CursorPos X="35" Y="164"/>
<UsageCount Value="10"/>
</Unit31>
<Unit32>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\win\dynlibs.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="48"/>
<CursorPos X="33" Y="51"/>
<UsageCount Value="10"/>
</Unit32>
<Unit33>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\inc\systemh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="330"/>
<CursorPos X="3" Y="338"/>
<UsageCount Value="10"/>
</Unit33>
</Units>
<General>
<ActiveWindowIndexAtStart Value="-1"/>
</General>
<JumpHistory HistoryIndex="-1"/>
</ProjectSession>
<Debugging>
<BreakPoints Count="1">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="..\..\source\uCEFChromium.pas"/>
<Line Value="2233"/>
</Item1>
</BreakPoints>
</Debugging>
</CONFIG>

View File

@ -58,7 +58,6 @@ begin
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.WindowlessRenderingEnabled := True;
GlobalCEFApp.EnableHighDPISupport := True;
GlobalCEFApp.SitePerProcess := False;
if GlobalCEFApp.StartMainProcess then
begin
@ -71,4 +70,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -64,4 +64,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -92,4 +92,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -71,5 +71,6 @@ begin
GlobalCEFApp.StartSubProcess;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -70,4 +70,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -68,4 +68,5 @@ begin
end;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end.

View File

@ -91,16 +91,6 @@
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_Locale>1033</VerInfo_Locale>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
<DCC_DebugDCUs>true</DCC_DebugDCUs>
<DCC_Optimize>false</DCC_Optimize>
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
<DCC_RemoteDebug>true</DCC_RemoteDebug>
<VerInfo_Locale>3082</VerInfo_Locale>
<VerInfo_Keys>FileVersion=1.0.0.0</VerInfo_Keys>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=CEF4Delphi;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=CEF4Delphi;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName)</VerInfo_Keys>
<DCC_Description>CEF4Delphi</DCC_Description>

View File

@ -381,6 +381,7 @@ var
TempDevWidth, TempLogWidth, TempDevHeight, TempLogHeight : integer;
begin
Result := False;
if (GlobalCEFApp = nil) then exit;
if not(aUseMutex) or BeginBufferDraw then
begin

View File

@ -54,7 +54,7 @@ uses
{$IFDEF DELPHI16_UP}
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, System.UITypes,
{$ELSE}
Windows, Classes,
Windows, Classes, {$IFDEF FPC}dynlibs,{$ENDIF}
{$ENDIF}
uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar;
@ -129,7 +129,11 @@ type
FSitePerProcess : boolean;
FDisableWebSecurity : boolean;
FChromeVersionInfo : TFileVersionInfo;
{$IFDEF FPC}
FLibHandle : TLibHandle;
{$ELSE}
FLibHandle : THandle;
{$ENDIF}
FOnRegisterCustomSchemes : TOnRegisterCustomSchemesEvent;
FAppSettings : TCefSettings;
FDeviceScaleFactor : single;
@ -230,6 +234,15 @@ type
function Load_cef_string_types_h : boolean;
function Load_cef_thread_internal_h : boolean;
function Load_cef_trace_event_internal_h : boolean;
function Load_cef_browser_view_capi_h : boolean;
function Load_cef_display_capi_h : boolean;
function Load_cef_label_button_capi_h : boolean;
function Load_cef_menu_button_capi_h : boolean;
function Load_cef_panel_capi_h : boolean;
function Load_cef_scroll_view_capi_h : boolean;
function Load_cef_textfield_capi_h : boolean;
function Load_cef_window_capi_h : boolean;
function Load_cef_types_linux_h : boolean;
procedure ShutDown;
procedure FreeLibcefLibrary;
@ -467,7 +480,7 @@ begin
FProcessType := ParseProcessType;
FShutdownWaitTime := 0;
FWidevinePath := '';
FMustFreeLibrary := True;
FMustFreeLibrary := False;
FMustCreateResourceBundleHandler := False;
FMustCreateBrowserProcessHandler := True;
@ -810,7 +823,6 @@ begin
try
if not(FSingleProcess) and
(FStatus = asLoading) and
(ProcessType <> ptBrowser) and
LoadCEFlibrary then
begin
@ -891,8 +903,14 @@ begin
try
if (aApp <> nil) then
begin
{$IFDEF MSWINDOWS}
TempArgs.instance := HINSTANCE{$IFDEF FPC}(){$ENDIF};
Result := cef_execute_process(@TempArgs, aApp.Wrap, FWindowsSandboxInfo);
{$ELSE}
TempArgs.argc := argc;
TempArgs.argv := argv;
{$ENDIF}
Result := cef_execute_process(@TempArgs, aApp.Wrap, FWindowsSandboxInfo);
end;
except
on e : exception do
@ -952,7 +970,12 @@ begin
InitializeSettings(FAppSettings);
{$IFDEF MSWINDOWS}
TempArgs.instance := HINSTANCE{$IFDEF FPC}(){$ENDIF};
{$ELSE}
TempArgs.argc := argc;
TempArgs.argv := argv;
{$ENDIF}
if (cef_initialize(@TempArgs, @FAppSettings, aApp.Wrap, FWindowsSandboxInfo) <> 0) then
begin
@ -1422,7 +1445,11 @@ begin
chdir(GetModulePath);
end;
{$IFDEF MSWINDOWS}
FLibHandle := LoadLibraryEx(PChar(LibCefPath), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
{$ELSE}
FLibHandle := LoadLibrary(PChar(LibCefPath));
{$ENDIF}
if (FLibHandle = 0) then
begin
@ -1474,7 +1501,16 @@ begin
Load_cef_string_multimap_h and
Load_cef_string_types_h and
Load_cef_thread_internal_h and
Load_cef_trace_event_internal_h then
Load_cef_trace_event_internal_h and
Load_cef_browser_view_capi_h and
Load_cef_display_capi_h and
Load_cef_label_button_capi_h and
Load_cef_menu_button_capi_h and
Load_cef_panel_capi_h and
Load_cef_scroll_view_capi_h and
Load_cef_textfield_capi_h and
Load_cef_window_capi_h and
Load_cef_types_linux_h then
begin
FStatus := asLoaded;
FLibLoaded := True;
@ -2032,4 +2068,81 @@ begin
assigned(cef_trace_event_async_end);
end;
function TCefApplication.Load_cef_browser_view_capi_h : boolean;
begin
{$IFDEF FPC}Pointer({$ENDIF}cef_browser_view_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_view_create');
{$IFDEF FPC}Pointer({$ENDIF}cef_browser_view_get_for_browser{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_view_get_for_browser');
Result := assigned(cef_browser_view_create) and
assigned(cef_browser_view_get_for_browser);
end;
function TCefApplication.Load_cef_display_capi_h : boolean;
begin
{$IFDEF FPC}Pointer({$ENDIF}cef_display_get_primary{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_primary');
{$IFDEF FPC}Pointer({$ENDIF}cef_display_get_nearest_point{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_nearest_point');
{$IFDEF FPC}Pointer({$ENDIF}cef_display_get_matching_bounds{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_matching_bounds');
{$IFDEF FPC}Pointer({$ENDIF}cef_display_get_count{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_count');
{$IFDEF FPC}Pointer({$ENDIF}cef_display_get_alls{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_alls');
Result := assigned(cef_display_get_primary) and
assigned(cef_display_get_nearest_point) and
assigned(cef_display_get_matching_bounds) and
assigned(cef_display_get_count) and
assigned(cef_display_get_alls);
end;
function TCefApplication.Load_cef_label_button_capi_h : boolean;
begin
{$IFDEF FPC}Pointer({$ENDIF}cef_label_button_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_label_button_create');
Result := assigned(cef_label_button_create);
end;
function TCefApplication.Load_cef_menu_button_capi_h : boolean;
begin
{$IFDEF FPC}Pointer({$ENDIF}cef_menu_button_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_menu_button_create');
Result := assigned(cef_menu_button_create);
end;
function TCefApplication.Load_cef_panel_capi_h : boolean;
begin
{$IFDEF FPC}Pointer({$ENDIF}cef_panel_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_panel_create');
Result := assigned(cef_panel_create);
end;
function TCefApplication.Load_cef_scroll_view_capi_h : boolean;
begin
{$IFDEF FPC}Pointer({$ENDIF}cef_scroll_view_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_scroll_view_create');
Result := assigned(cef_scroll_view_create);
end;
function TCefApplication.Load_cef_textfield_capi_h : boolean;
begin
{$IFDEF FPC}Pointer({$ENDIF}cef_textfield_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_textfield_create');
Result := assigned(cef_textfield_create);
end;
function TCefApplication.Load_cef_window_capi_h : boolean;
begin
{$IFDEF FPC}Pointer({$ENDIF}cef_window_create_top_level{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_window_create_top_level');
Result := assigned(cef_window_create_top_level);
end;
function TCefApplication.Load_cef_types_linux_h : boolean;
begin
{$IFDEF LINUX}
{$IFDEF FPC}Pointer({$ENDIF}cef_get_xdisplay{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_xdisplay');
Result := assigned(cef_get_xdisplay);
{$ELSE}
Result := True;
{$ENDIF}
end;
end.

View File

@ -470,7 +470,9 @@ type
function CreateBrowser(const aBrowserParent : TWinControl = nil; const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aCookiesPath : ustring = ''; aPersistSessionCookies : boolean = False) : boolean; overload; virtual;
function CreateBrowser(aParentHandle : HWND; aParentRect : TRect; const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aCookiesPath : ustring = ''; aPersistSessionCookies : boolean = False) : boolean; overload; virtual;
procedure LoadURL(const aURL : ustring);
procedure LoadURL(const aURL : ustring; const aFrameName : ustring = ''); overload;
procedure LoadURL(const aURL : ustring; const aFrame : ICefFrame); overload;
procedure LoadURL(const aURL : ustring; const aFrameIdentifier : int64); overload;
procedure LoadString(const aString : ustring; const aURL : ustring = '');
procedure LoadRequest(const aRequest: ICefRequest);
@ -482,7 +484,7 @@ type
procedure StartDownload(const aURL : ustring);
procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer);
function DeleteCookies : boolean;
function DeleteCookies(const url : ustring = ''; const cookieName : ustring = '') : boolean;
procedure RetrieveHTML(const aFrameName : ustring = ''); overload;
procedure RetrieveHTML(const aFrame : ICefFrame); overload;
procedure RetrieveHTML(const aFrameIdentifier : int64); overload;
@ -1531,13 +1533,38 @@ begin
aSettings.accept_language_list := CefString('');
end;
procedure TChromium.LoadURL(const aURL : ustring);
// Leave aFrameName empty to load the URL in the main frame
procedure TChromium.LoadURL(const aURL : ustring; const aFrameName : ustring = '');
var
TempFrame : ICefFrame;
begin
if Initialized then
begin
TempFrame := FBrowser.MainFrame;
if (length(aFrameName) > 0) then
TempFrame := FBrowser.GetFrame(aFrameName)
else
TempFrame := FBrowser.MainFrame;
if (TempFrame <> nil) then TempFrame.LoadUrl(aURL);
end;
end;
procedure TChromium.LoadURL(const aURL : ustring; const aFrame : ICefFrame);
begin
if Initialized and (aFrame <> nil) then aFrame.LoadUrl(aURL);
end;
procedure TChromium.LoadURL(const aURL : ustring; const aFrameIdentifier : int64);
var
TempFrame : ICefFrame;
begin
if Initialized then
begin
if (aFrameIdentifier <> 0) then
TempFrame := FBrowser.GetFrameByident(aFrameIdentifier)
else
TempFrame := FBrowser.MainFrame;
if (TempFrame <> nil) then TempFrame.LoadUrl(aURL);
end;
end;
@ -1990,7 +2017,7 @@ begin
end;
end;
function TChromium.DeleteCookies : boolean;
function TChromium.DeleteCookies(const url, cookieName: ustring) : boolean;
var
TempManager : ICefCookieManager;
TempCallback : ICefDeleteCookiesCallback;
@ -2004,7 +2031,7 @@ begin
if (TempManager <> nil) then
begin
TempCallback := TCefCustomDeleteCookiesCallback.Create(self);
Result := TempManager.DeleteCookies('', '', TempCallback);
Result := TempManager.DeleteCookies(url, cookieName, TempCallback);
end;
end;
end;

View File

@ -125,6 +125,20 @@ type
ICefFindHandler = interface;
ICefCookieManager = interface;
ICefWebPluginInfo = interface;
ICefDisplay = interface;
ICefLayout = interface;
ICefBoxLayout = interface;
ICefFillLayout = interface;
ICefView = interface;
ICefBrowserView = interface;
ICefButton = interface;
ICefPanel = interface;
ICefScrollView = interface;
ICefTextfield = interface;
ICefViewDelegate = interface;
ICefWindow = interface;
ICefLabelButton = interface;
ICefMenuButton = interface;
TCefv8ValueArray = array of ICefv8Value;
TCefX509CertificateArray = array of ICefX509Certificate;
@ -2128,6 +2142,332 @@ type
procedure OnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt);
end;
// *********************************
// ************* Views *************
// *********************************
// TCefDisplay
// /include/capi/views/cef_display_capi.h (cef_display_t)
ICefDisplay = interface(ICefBaseRefCounted)
['{EC2D3606-DB4C-4894-8D38-B8F99E091965}']
function GetID : int64;
function GetDeviceScaleFactor : Single;
procedure ConvertPointToPixels(var point: TCefPoint);
procedure ConvertPointFromPixels(var point: TCefPoint);
function GetBounds : TCefRect;
function GetWorkArea : TCefRect;
function GetRotation : Integer;
end;
// TCefLayout
// /include/capi/views/cef_layout_capi.h (cef_layout_t)
ICefLayout = interface(ICefBaseRefCounted)
['{0EC7AE4B-1672-4D0B-B617-0BDA72F3C7F4}']
function AsBoxLayout : ICefBoxLayout;
function AsFillLayout : ICefFillLayout;
function IsValid : boolean;
end;
// TCefBoxLayout
// /include/capi/views/cef_box_layout_capi.h (cef_box_layout_t)
ICefBoxLayout = interface(ICefLayout)
['{E59FCCAE-A371-4C21-98D3-93D3217016AE}']
procedure SetFlexForView(const view: ICefView; flex: Integer);
procedure ClearFlexForView(const view: ICefView);
end;
// TCefFillLayout
// /include/capi/views/cef_fill_layout_capi.h (cef_fill_layout_t)
ICefFillLayout = interface(ICefLayout)
['{3DB214F2-7F27-4306-82C9-8166160422B1}']
end;
// TCefView
// /include/capi/views/cef_view_capi.h (cef_view_t)
ICefView = interface(ICefBaseRefCounted)
['{E9AF950A-F4E8-420C-BD1F-F26F4FDFA48D}']
function AsBrowserView : ICefBrowserView;
function AsButton : ICefButton;
function AsPanel : ICefPanel;
function AsScrollView : ICefScrollView;
function AsTextfield : ICefTextfield;
function GetTypeString : ustring;
function ToString(include_children: boolean): ustring;
function IsValid : boolean;
function IsAttached : boolean;
function IsSame(const that: ICefView): boolean;
function GetDelegate : ICefViewDelegate;
function GetWindow : ICefWindow;
function GetID : Integer;
procedure SetID(id: Integer);
function GetGroupID : Integer;
procedure SetGroupID(group_id: Integer);
function GetParentView : ICefView;
function GetViewForID(id: Integer): ICefView;
procedure SetBounds(const bounds: PCefRect);
function GetBounds : TCefRect;
function GetBoundsInScreen : TCefRect;
procedure SetSize(const size: PCefSize);
function GetSize : TCefSize;
procedure SetPosition(const position: PCefPoint);
function GetPosition : TCefPoint;
function GetPreferredSize : TCefSize;
procedure SizeToPreferredSize;
function GetMinimumSize : TCefSize;
function GetMaximumSize : TCefSize;
function GetHeightForWidth(width: Integer): Integer;
procedure InvalidateLayout;
procedure SetVisible(visible: boolean);
function IsVisible : boolean;
function IsDrawn : boolean;
procedure SetEnabled(enabled: boolean);
function IsEnabled : boolean;
procedure SetFocusable(focusable: boolean);
function IsFocusable : boolean;
function IsAccessibilityFocusable : boolean;
procedure RequestFocus;
procedure SetBackgroundColor(color: TCefColor);
function GetBackgroundColor : TCefColor;
function ConvertPointToScreen(point: PCefPoint): boolean;
function ConvertPointFromScreen(point: PCefPoint): boolean;
function ConvertPointToWindow(point: PCefPoint): boolean;
function ConvertPointFromWindow(point: PCefPoint): boolean;
function ConvertPointToView(const view : ICefView; point: PCefPoint): boolean;
function ConvertPointFromView(const view : ICefView; point: PCefPoint): boolean;
end;
// TCefViewDelegate
// /include/capi/views/cef_view_delegate_capi.h (cef_view_delegate_t)
ICefViewDelegate = interface(ICefBaseRefCounted)
['{5F900206-B969-4E51-B56C-0FF38D749C72}']
function GetPreferredSize(const view: ICefView): TCefSize;
function GetMinimumSize(const view: ICefView): TCefSize;
function GetMaximumSize(const view: ICefView): TCefSize;
function GetHeightForWidth(const view: ICefView; width: Integer): Integer;
procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView);
procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView);
procedure OnFocus(const view: ICefView);
procedure OnBlur(const view: ICefView);
end;
// TCefTextfield
// /include/capi/views/cef_textfield_capi.h (cef_textfield_t)
ICefTextfield = interface(ICefView)
['{B5E30155-DEA5-4CBF-BC9D-578CBCA586D9}']
procedure SetPasswordInput(password_input: boolean);
function IsPasswordInput : boolean;
procedure SetReadOnly(read_only: boolean);
function IsReadOnly : boolean;
function GetText : ustring;
procedure SetText(const text: ustring);
procedure AppendText(const text: ustring);
procedure InsertOrReplaceText(const text: ustring);
function HasSelection : boolean;
function GetSelectedText : ustring;
procedure SelectAll(reversed: boolean);
procedure ClearSelection;
function GetSelectedRange : TCefRange;
procedure SelectRange(const range: PCefRange);
function GetCursorPosition : NativeUInt;
procedure SetTextColor(color: TCefColor);
function GetTextColor : TCefColor;
procedure SetSelectionTextColor(color: TCefColor);
function GetSelectionTextColor : TCefColor;
procedure SetSelectionBackgroundColor(color: TCefColor);
function GetSelectionBackgroundColor : TCefColor;
procedure SetFontList(const font_list: ustring);
procedure ApplyTextColor(color: TCefColor; const range: PCefRange);
procedure ApplyTextStyle(style: TCefTextStyle; add: boolean; const range: PCefRange);
function IsCommandEnabled(command_id: Integer): boolean;
procedure ExecuteCommand(command_id: Integer);
procedure ClearEditHistory;
procedure SetPlaceholderText(const text: ustring);
function GgetPlaceholderText : ustring;
procedure SetPlaceholderTextColor(color: TCefColor);
procedure SetAccessibleName(const name: ustring);
end;
// TCefTextfieldDelegate
// /include/capi/views/cef_textfield_delegate_capi.h (cef_textfield_delegate_t)
ICefTextfieldDelegate = interface(ICefViewDelegate)
['{72612994-92BB-4DE9-BB38-6F49FB45F94B}']
function OnKeyEvent(const textfield: ICefTextfield; const event: PCefKeyEvent): boolean;
procedure OnAfterUserAction(const textfield: ICefTextfield);
end;
// TCefScrollView
// /include/capi/views/cef_scroll_view_capi.h (cef_scroll_view_t)
ICefScrollView = interface(ICefView)
['{55DF2883-0574-4F10-B6F5-DE4730964B5B}']
procedure SetContentView(const view: ICefView);
function GetContentView : ICefView;
function GetVisibleContentRect : TCefRect;
function HasHorizontalScrollbar : boolean;
function GetHorizontalScrollbarHeight : Integer;
function HasVerticalScrollbar : boolean;
function GetVerticalScrollbarWidth : Integer;
end;
// TCefPanel
// /include/capi/views/cef_panel_capi.h (cef_panel_t)
ICefPanel = interface(ICefView)
['{6F2F680A-3637-4438-81B8-79AD6C02252D}']
function AsWindow : ICefWindow;
function SetToFillLayout : ICefFillLayout;
function SetToBoxLayout(const settings: PCefBoxLayoutSettings): ICefBoxLayout;
function GetLayout : ICefLayout;
procedure Layout;
procedure AddChildView(const view: ICefView);
procedure AddChildViewAt(const view: ICefView; index: Integer);
procedure ReorderChildView(const view: ICefView; index: Integer);
procedure RemoveChildView(const view: ICefView);
procedure RemoveAllChildViews;
function GetChildViewCount : NativeUInt;
function GetChildViewAt(index: Integer): ICefView;
end;
// TCefPanelDelegate
// /include/capi/views/cef_panel_delegate_capi.h (cef_panel_delegate_t)
ICefPanelDelegate = interface(ICefViewDelegate)
['{305D453F-FEBA-48ED-AE33-5D978823EA96}']
end;
// TCefBrowserView
// /include/capi/views/cef_browser_view_capi.h (cef_browser_view_t)
ICefBrowserView = interface(ICefView)
['{A617EE5D-B933-4E14-9FC0-7E88E9B6C051}']
function GetBrowser : ICefBrowser;
procedure SetPreferAccelerators(prefer_accelerators: boolean);
end;
// TCefBrowserViewDelegate
// /include/capi/views/cef_browser_view_delegate_capi.h (cef_browser_view_delegate_t)
ICefBrowserViewDelegate = interface(ICefViewDelegate)
['{578A0DD4-2E7D-4061-B4DB-7C3CDC7A90C0}']
procedure OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser);
procedure OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser);
function GetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: PCefBrowserSettings; const client: ICefClient; is_devtools: boolean): ICefBrowserViewDelegate;
function OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean): boolean;
end;
// TCefButton
// /include/capi/views/cef_button_capi.h (cef_button_t)
ICefButton = interface(ICefView)
['{D3D2E8A0-9F9C-4BD8-B495-655976534281}']
function AsLabelButton : ICefLabelButton;
procedure SetState(state: TCefButtonState);
function GetState : TCefButtonState;
procedure SetInkDropEnabled(enabled: boolean);
procedure SetTooltipText(const tooltip_text: ustring);
procedure SetAccessibleName(const name: ustring);
end;
// TCefButtonDelegate
// /include/capi/views/cef_button_delegate_capi.h (cef_button_delegate_t)
ICefButtonDelegate = interface(ICefViewDelegate)
['{EA1EB5A4-DFB0-4A13-A23B-54FAF9401B39}']
procedure OnButtonPressed(const button: ICefButton);
procedure OnButtonStateChanged(const button: ICefButton);
end;
// TCefLabelButton
// /include/capi/views/cef_label_button_capi.h (cef_label_button_t)
ICefLabelButton = interface(ICefButton)
['{A99FD4F3-7EE6-4796-8BF6-EC367D51EED8}']
function GetState : ICefMenuButton;
procedure SetText(const text: ustring);
function GetText : ustring;
procedure SetImage(button_state: TCefButtonState; const image: ICefImage);
function GetImage(button_state: TCefButtonState): ICefImage;
procedure SetTextColor(for_state: TCefButtonState; color: TCefColor);
procedure SetEnabledTextColors(color: TCefColor);
procedure SetFontList(const font_list: ustring);
procedure SetHorizontalAlignment(alignment: TCefHorizontalAlignment);
procedure SetMinimumSize(const size: PCefSize);
procedure SetMaximumSize(const size: PCefSize);
end;
// TCefMenuButton
// /include/capi/views/cef_menu_button_capi.h (cef_menu_button_t)
ICefMenuButton = interface(ICefLabelButton)
['{62BFE81A-7810-400B-83C6-76D1DF133710}']
procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: PCefPoint; anchor_position: TCefMenuAnchorPosition);
procedure TriggerMenu;
end;
// TCefMenuButtonPressedLock
// /include/capi/views/cef_menu_button_delegate_capi.h (cef_menu_button_pressed_lock_t)
ICefMenuButtonPressedLock = interface(ICefBaseRefCounted)
['{71498C53-0B1D-4A05-98A0-3E589F2A1683}']
end;
// TCefMenuButtonDelegate
// /include/capi/views/cef_menu_button_delegate_capi.h (cef_menu_button_delegate_t)
ICefMenuButtonDelegate = interface(ICefButtonDelegate)
['{D0E89A75-463A-4766-8701-BD8D24B11E9F}']
procedure OnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: PCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock);
end;
// TCefWindow
// /include/capi/views/cef_window_capi.h (cef_window_t)
ICefWindow = interface(ICefPanel)
['{C450C974-BF0A-4968-A6BE-153CEAD10DA6}']
procedure Show;
procedure Hide;
procedure CenterWindow(const size: PCefSize);
procedure Close;
function IsClosed : boolean;
procedure Activate;
procedure deactivate;
function IsActive : boolean;
procedure BringToTop;
procedure SetAlwaysOnTop(on_top: boolean);
function IsAlwaysOnTop : boolean;
procedure Maximize;
procedure Minimize;
procedure Restore;
procedure SetFullscreen(fullscreen: boolean);
function IsMaximized : boolean;
function IsMinimized : boolean;
function IsFullscreen : boolean;
procedure SetTitle(const title: ustring);
function GetTitle : ustring;
procedure SetWindowIcon(const image: ICefImage);
function GetWindowIcon : ICefImage;
procedure SetWindowAppIcon(const image: ICefImage);
function GetWindowAppIcon : ICefImage;
procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: PCefPoint; anchor_position : TCefMenuAnchorPosition);
procedure CancelMenu;
function GetDisplay : ICefDisplay;
function GetClientAreaBoundsInScreen : TCefRect;
procedure SetDraggableRegions(regionsCount: NativeUInt; regions: PCefDraggableRegionArray);
function GetWindowHandle : TCefWindowHandle;
procedure SendKeyPress(key_code: Integer; event_flags: cardinal);
procedure SendMouseMove(screen_x, screen_y: Integer);
procedure SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: Integer);
procedure SetAccelerator(command_id, key_code : Integer; shift_pressed, ctrl_pressed, alt_pressed: boolean);
procedure RemoveAccelerator(command_id: Integer);
procedure RemoveAllAccelerators;
end;
// TCefWindowDelegate
// /include/capi/views/cef_window_delegate_capi.h (cef_window_delegate_t)
ICefWindowDelegate = interface(ICefPanelDelegate)
['{52D4EE2C-303B-42B6-A35F-30D03834A23F}']
procedure OnWindowCreated(const window: ICefWindow);
procedure OnWindowDestroyed(const window: ICefWindow);
function GetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean): ICefWindow;
function IsFrameless(const window: ICefWindow): boolean;
function CanResize(const window: ICefWindow): boolean;
function CanMaximize(const window: ICefWindow): boolean;
function CanMinimize(const window: ICefWindow): boolean;
function CanClose(const window: ICefWindow): boolean;
function OnAccelerator(const window: ICefWindow; command_id: Integer): boolean;
function OnKeyEvent(const window: ICefWindow; const event: PCefKeyEvent): boolean;
end;
implementation
end.

View File

@ -230,6 +230,35 @@ var
// /include/capi/cef_zip_reader_capi.h
cef_zip_reader_create : function(stream: PCefStreamReader): PCefZipReader; cdecl;
// /include/capi/views/cef_browser_view_capi.h
cef_browser_view_create : function(client: PCefClient; const url: PCefString; const settings: PCefBrowserSettings; request_context: PCefRequestContext; delegate: PCefBrowserViewDelegate): PCefBrowserView; cdecl;
cef_browser_view_get_for_browser : function(browser: PCefBrowser): PCefBrowserView; cdecl;
// /include/capi/views/cef_display_capi.h
cef_display_get_primary : function : PCefDisplay; cdecl;
cef_display_get_nearest_point : function(const point: PCefPoint; input_pixel_coords: Integer): PCefDisplay; cdecl;
cef_display_get_matching_bounds : function(const bounds: PCefRect; input_pixel_coords: Integer): PCefDisplay; cdecl;
cef_display_get_count : function : NativeUInt; cdecl;
cef_display_get_alls : procedure(var displaysCount: NativeUInt; var displays: PCefDisplay); cdecl;
// /include/capi/views/cef_label_button_capi.h
cef_label_button_create : function(delegate: PCefButtonDelegate; const text: PCefString; with_frame: Integer): PCefLabelButton; cdecl;
// /include/capi/views/cef_menu_button_capi.h
cef_menu_button_create : function(delegate: PCefMenuButtonDelegate; const text: PCefString; with_frame, with_menu_marker: Integer): PCefMenuButton; cdecl;
// /include/capi/views/cef_panel_capi.h
cef_panel_create : function(delegate: PCefPanelDelegate): PCefPanel; cdecl;
// /include/capi/views/cef_scroll_view_capi.h
cef_scroll_view_create : function(delegate: PCefViewDelegate): PCefScrollView; cdecl;
// /include/capi/views/cef_textfield_capi.h
cef_textfield_create : function(delegate: PCefTextfieldDelegate): PCefTextfield; cdecl;
// /include/capi/views/cef_window_capi.h
cef_window_create_top_level : function(delegate: PCefWindowDelegate): PCefWindow; cdecl;
// /include/internal/cef_logging_internal.h
cef_get_min_log_level : function : Integer; cdecl;
cef_get_vlog_level : function(const file_start: PAnsiChar; N: NativeInt): Integer; cdecl;
@ -307,6 +336,10 @@ var
cef_trace_event_async_step_past : procedure(const category, name: PAnsiChar; id, step: UInt64; const arg1_name: PAnsiChar; arg1_val: UInt64; copy: Integer); cdecl;
cef_trace_event_async_end : procedure(const category, name: PAnsiChar; id: UInt64; const arg1_name: PAnsiChar; arg1_val: UInt64; const arg2_name: PAnsiChar; arg2_val: UInt64; copy: Integer); cdecl;
{$IFDEF LINUX}
// /include/internal/cef_types_linux.h
cef_get_xdisplay : function : PXDisplay; cdecl;
{$ENDIF}
implementation

View File

@ -103,9 +103,23 @@ function cef_string_utf8_copy(const src: PAnsiChar; src_len: NativeUInt; output:
function cef_string_utf16_copy(const src: PChar16; src_len: NativeUInt; output: PCefStringUtf16): Integer;
function cef_string_copy(const src: PCefChar; src_len: NativeUInt; output: PCefString): Integer;
{$IFDEF MSWINDOWS}
procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : THandle; aRect : TRect; const aWindowName : ustring = '');
procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : THandle; const aWindowName : ustring = '');
procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : THandle; const aWindowName : ustring = '');
{$ENDIF}
{$IFDEF MACOS}
procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; aHidden : boolean = False; const aWindowName : ustring = '');
procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aHidden : boolean = False; const aWindowName : ustring = '');
procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aHidden : boolean = False; const aWindowName : ustring = '');
{$ENDIF}
{$IFDEF LINUX}
procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect);
procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle);
procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle);
{$ENDIF}
function TzSpecificLocalTimeToSystemTime(lpTimeZoneInformation: PTimeZoneInformation; lpLocalTime, lpUniversalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL;
function SystemTimeToTzSpecificLocalTime(lpTimeZoneInformation: PTimeZoneInformation; lpUniversalTime, lpLocalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL;
@ -410,6 +424,7 @@ begin
Result := cef_string_utf16_set(src, src_len, output, ord(True));
end;
{$IFDEF MSWINDOWS}
procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : THandle; aRect : TRect; const aWindowName : ustring);
begin
aWindowInfo.ex_style := 0;
@ -454,6 +469,84 @@ begin
aWindowInfo.windowless_rendering_enabled := ord(True);
aWindowInfo.window := 0;
end;
{$ENDIF}
{$IFDEF MACOS}
procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; aHidden : boolean; const aWindowName : ustring);
begin
aWindowInfo.window_name := CefString(aWindowName);
aWindowInfo.x := aRect.left;
aWindowInfo.y := aRect.top;
aWindowInfo.width := aRect.right - aRect.left;
aWindowInfo.height := aRect.bottom - aRect.top;
aWindowInfo.hidden := Ord(aHidden);
aWindowInfo.parent_view := aParent;
aWindowInfo.windowless_rendering_enabled := ord(False);
aWindowInfo.view := 0;
end;
procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : THandle; aHidden : boolean; const aWindowName : ustring);
begin
aWindowInfo.window_name := CefString(aWindowName);
aWindowInfo.x := integer(CW_USEDEFAULT);
aWindowInfo.y := integer(CW_USEDEFAULT);
aWindowInfo.width := integer(CW_USEDEFAULT);
aWindowInfo.height := integer(CW_USEDEFAULT);
aWindowInfo.hidden := Ord(aHidden);
aWindowInfo.parent_view := aParent;
aWindowInfo.windowless_rendering_enabled := ord(False);
aWindowInfo.view := 0;
end;
procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : THandle; aHidden : boolean; const aWindowName : ustring);
begin
aWindowInfo.window_name := CefString(aWindowName);
aWindowInfo.x := 0;
aWindowInfo.y := 0;
aWindowInfo.width := 0;
aWindowInfo.height := 0;
aWindowInfo.hidden := Ord(aHidden);
aWindowInfo.parent_view := aParent;
aWindowInfo.windowless_rendering_enabled := ord(True);
aWindowInfo.view := 0;
end;
{$ENDIF}
{$IFDEF LINUX}
procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect);
begin
aWindowInfo.x := aRect.left;
aWindowInfo.y := aRect.top;
aWindowInfo.width := aRect.right - aRect.left;
aWindowInfo.height := aRect.bottom - aRect.top;
aWindowInfo.parent_window := aParent;
aWindowInfo.windowless_rendering_enabled := ord(False);
aWindowInfo.window := 0;
end;
procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : THandle);
begin
aWindowInfo.x := integer(CW_USEDEFAULT);
aWindowInfo.y := integer(CW_USEDEFAULT);
aWindowInfo.width := integer(CW_USEDEFAULT);
aWindowInfo.height := integer(CW_USEDEFAULT);
aWindowInfo.parent_window := aParent;
aWindowInfo.windowless_rendering_enabled := ord(False);
aWindowInfo.window := 0;
end;
procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : THandle);
begin
aWindowInfo.x := 0;
aWindowInfo.y := 0;
aWindowInfo.width := 0;
aWindowInfo.height := 0;
aWindowInfo.parent_window := aParent;
aWindowInfo.windowless_rendering_enabled := ord(False);
aWindowInfo.window := 0;
end;
{$ENDIF}
function CefIsCertStatusError(Status : TCefCertStatus) : boolean;
begin

View File

@ -54,6 +54,7 @@ uses
{$IFDEF DELPHI16_UP}
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Math;
{$ELSE}
{$IFDEF FPC}{$IFDEF LINUX}xlib,{$ENDIF}{$ENDIF}
Windows, Math;
{$ENDIF}
@ -204,11 +205,53 @@ type
PCefX509CertPrincipal = ^TCefX509CertPrincipal;
PCefX509Certificate = ^TCefX509Certificate;
PPCefX509Certificate = ^PCefX509Certificate;
PCefDisplay = ^TCefDisplay;
PCefLayout = ^TCefLayout;
PCefBoxLayout = ^TCefBoxLayout;
PCefFillLayout = ^TCefFillLayout;
PCefView = ^TCefView;
PCefViewDelegate = ^TCefViewDelegate;
PCefTextfield = ^TCefTextfield;
PCefTextfieldDelegate = ^TCefTextfieldDelegate;
PCefScrollView = ^TCefScrollView;
PCefPanel = ^TCefPanel;
PCefPanelDelegate = ^TCefPanelDelegate;
PCefBrowserView = ^TCefBrowserView;
PCefBrowserViewDelegate = ^TCefBrowserViewDelegate;
PCefButton = ^TCefButton;
PCefButtonDelegate = ^TCefButtonDelegate;
PCefLabelButton = ^TCefLabelButton;
PCefMenuButton = ^TCefMenuButton;
PCefMenuButtonPressedLock = ^TCefMenuButtonPressedLock;
PCefMenuButtonDelegate = ^TCefMenuButtonDelegate;
PCefWindow = ^TCefWindow;
PCefWindowDelegate = ^TCefWindowDelegate;
PCefBoxLayoutSettings = ^TCefBoxLayoutSettings;
{$IFDEF LINUX}
PXEvent = Pointer;
TXDisplay = record end;
PXDisplay = ^TXDisplay;
{$ENDIF}
{$IFDEF MSWINDOWS}
TCefWindowHandle = HWND; // /include/internal/cef_types_win.h (cef_window_handle_t)
TCefCursorHandle = HCURSOR; // /include/internal/cef_types_win.h (cef_cursor_handle_t)
TCefEventHandle = PMsg; // /include/internal/cef_types_win.h (cef_event_handle_t)
{$ENDIF}
{$IFDEF MACOS}
TCefWindowHandle = Pointer; // /include/internal/cef_types_win.h (cef_window_handle_t)
TCefCursorHandle = Pointer; // /include/internal/cef_types_win.h (cef_cursor_handle_t)
TCefEventHandle = Pointer; // /include/internal/cef_types_win.h (cef_event_handle_t)
{$ENDIF}
{$IFDEF LINUX}
TCefWindowHandle = cardinal; // /include/internal/cef_types_win.h (cef_window_handle_t)
TCefCursorHandle = cardinal; // /include/internal/cef_types_win.h (cef_cursor_handle_t)
TCefEventHandle = PXEvent; // /include/internal/cef_types_win.h (cef_event_handle_t)
{$ENDIF}
TCefWindowHandle = HWND; // /include/internal/cef_types_win.h (cef_window_handle_t)
TCefCursorHandle = HCURSOR; // /include/internal/cef_types_win.h (cef_cursor_handle_t)
TCefEventHandle = PMsg; // /include/internal/cef_types_win.h (cef_event_handle_t)
TCefPlatformThreadId = DWORD; // /include/internal/cef_thread_internal.h (cef_platform_thread_id_t)
TCefPlatformThreadHandle = DWORD; // /include/internal/cef_thread_internal.h (cef_platform_thread_handle_t)
TCefTransitionType = Cardinal; // /include/internal/cef_types.h (cef_transition_type_t)
@ -325,7 +368,12 @@ type
// /include/internal/cef_types_win.h (cef_main_args_t)
TCefMainArgs = record
{$IFDEF MSWINDOWS}
instance : HINST;
{$ELSE}
argc : Integer;
argv : PPChar;
{$ENDIF}
end;
// /include/internal/cef_types.h (cef_rect_t)
@ -965,6 +1013,7 @@ type
// /include/internal/cef_types_win.h (cef_window_info_t)
TCefWindowInfo = record
{$IFDEF MSWINDOWS}
ex_style : DWORD;
window_name : TCefString;
style : DWORD;
@ -976,6 +1025,27 @@ type
menu : HMENU;
windowless_rendering_enabled : Integer;
window : TCefWindowHandle;
{$ENDIF}
{$IFDEF MACOS}
window_name : TCefString;
x : Integer;
y : Integer;
width : Integer;
height : Integer;
hidden : Integer;
parent_view : TCefWindowHandle;
windowless_rendering_enabled : Integer;
view : TCefWindowHandle;
{$ENDIF}
{$IFDEF LINUX}
x : uint32;
y : uint32;
width : uint32;
height : uint32;
parent_window : TCefWindowHandle;
windowless_rendering_enabled : Integer;
window : TCefWindowHandle;
{$ENDIF}
end;
// /include/internal/cef_types.h (cef_draggable_region_t)
@ -2587,6 +2657,312 @@ type
on_web_socket_message : procedure(self: PCefServerHandler; server: PCefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); stdcall;
end;
// *********************************
// ************* Views *************
// *********************************
// /include/capi/views/cef_display_capi.h (cef_display_t)
TCefDisplay = record
base : TCefBaseRefCounted;
get_id : function(self: PCefDisplay): int64; stdcall;
get_device_scale_factor : function(self: PCefDisplay): Single; stdcall;
convert_point_to_pixels : procedure(self: PCefDisplay; point: PCefPoint); stdcall;
convert_point_from_pixels : procedure(self: PCefDisplay; point: PCefPoint); stdcall;
get_bounds : function(self: PCefDisplay): TCefRect; stdcall;
get_work_area : function(self: PCefDisplay): TCefRect; stdcall;
get_rotation : function(self: PCefDisplay): Integer; stdcall;
end;
// /include/capi/views/cef_layout_capi.h (cef_layout_t)
TCefLayout = record
base : TCefBaseRefCounted;
as_box_layout : function(self: PCefLayout): PCefBoxLayout; stdcall;
as_fill_layout : function(self: PCefLayout): PCefFillLayout; stdcall;
is_valid : function(self: PCefLayout): Integer; stdcall;
end;
// /include/capi/views/cef_box_layout_capi.h (cef_box_layout_t)
TCefBoxLayout = record
base : TCefLayout;
set_flex_for_view : procedure(self: PCefBoxLayout; view: PCefView; flex: Integer); stdcall;
clear_flex_for_view : procedure(self: PCefBoxLayout; view: PCefView); stdcall;
end;
// /include/capi/views/cef_fill_layout_capi.h (cef_fill_layout_t)
TCefFillLayout = record
base : TCefLayout;
end;
// /include/capi/views/cef_view_capi.h (cef_view_t)
TCefView = record
base : TCefBaseRefCounted;
as_browser_view : function(self: PCefView): PCefBrowserView; stdcall;
as_button : function(self: PCefView): PCefButton; stdcall;
as_panel : function(self: PCefView): PCefPanel; stdcall;
as_scroll_view : function(self: PCefView): PCefScrollView; stdcall;
as_textfield : function(self: PCefView): PCefTextfield; stdcall;
get_type_string : function(self: PCefView): PCefStringUserFree; stdcall;
to_string : function(self: PCefView; include_children: Integer): PCefStringUserFree; stdcall;
is_valid : function(self: PCefView): Integer; stdcall;
is_attached : function(self: PCefView): Integer; stdcall;
is_same : function(self, that: PCefView): Integer; stdcall;
get_delegate : function(self: PCefView): PCefViewDelegate; stdcall;
get_window : function(self: PCefView): PCefWindow; stdcall;
get_id : function(self: PCefView): Integer; stdcall;
set_id : procedure(self: PCefView; id: Integer); stdcall;
get_group_id : function(self: PCefView): Integer; stdcall;
set_group_id : procedure(self: PCefView; group_id: Integer); stdcall;
get_parent_view : function(self: PCefView): PCefView; stdcall;
get_view_for_id : function(self: PCefView; id: Integer): PCefView; stdcall;
set_bounds : procedure(self: PCefView; const bounds: PCefRect); stdcall;
get_bounds : function(self: PCefView): TCefRect; stdcall;
get_bounds_in_screen : function(self: PCefView): TCefRect; stdcall;
set_size : procedure(self: PCefView; const size: PCefSize); stdcall;
get_size : function(self: PCefView): TCefSize; stdcall;
set_position : procedure(self: PCefView; const position: PCefPoint); stdcall;
get_position : function(self: PCefView): TCefPoint; stdcall;
get_preferred_size : function(self: PCefView): TCefSize; stdcall;
size_to_preferred_size : procedure(self: PCefView); stdcall;
get_minimum_size : function(self: PCefView): TCefSize; stdcall;
get_maximum_size : function(self: PCefView): TCefSize; stdcall;
get_height_for_width : function(self: PCefView; width: Integer): Integer; stdcall;
invalidate_layout : procedure(self: PCefView); stdcall;
set_visible : procedure(self: PCefView; visible: Integer); stdcall;
is_visible : function(self: PCefView): Integer; stdcall;
is_drawn : function(self: PCefView): Integer; stdcall;
set_enabled : procedure(self: PCefView; enabled: Integer); stdcall;
is_enabled : function(self: PCefView): Integer; stdcall;
set_focusable : procedure(self: PCefView; focusable: Integer); stdcall;
is_focusable : function(self: PCefView): Integer; stdcall;
is_accessibility_focusable : function(self: PCefView): Integer; stdcall;
request_focus : procedure(self: PCefView); stdcall;
set_background_color : procedure(self: PCefView; color: TCefColor); stdcall;
get_background_color : function(self: PCefView): TCefColor; stdcall;
convert_point_to_screen : function(self: PCefView; point: PCefPoint): Integer; stdcall;
convert_point_from_screen : function(self: PCefView; point: PCefPoint): Integer; stdcall;
convert_point_to_window : function(self: PCefView; point: PCefPoint): Integer; stdcall;
convert_point_from_window : function(self: PCefView; point: PCefPoint): Integer; stdcall;
convert_point_to_view : function(self, view: PCefView; point: PCefPoint): Integer; stdcall;
convert_point_from_view : function(self, view: PCefView; point: PCefPoint): Integer; stdcall;
end;
// /include/capi/views/cef_view_delegate_capi.h (cef_view_delegate_t)
TCefViewDelegate = record
base : TCefBaseRefCounted;
get_preferred_size : function(self: PCefViewDelegate; view: PCefView): TCefSize; stdcall;
get_minimum_size : function(self: PCefViewDelegate; view: PCefView): TCefSize; stdcall;
get_maximum_size : function(self: PCefViewDelegate; view: PCefView): TCefSize; stdcall;
get_height_for_width : function(self: PCefViewDelegate; view: PCefView; width: Integer): Integer; stdcall;
on_parent_view_changed : procedure(self: PCefViewDelegate; view: PCefView; added: Integer; parent: PCefView); stdcall;
on_child_view_changed : procedure(self: PCefViewDelegate; view: PCefView; added: Integer; child: PCefView); stdcall;
on_focus : procedure(self: PCefViewDelegate; view: PCefView); stdcall;
on_blur : procedure(self: PCefViewDelegate; view: PCefView); stdcall;
end;
// /include/capi/views/cef_textfield_capi.h (cef_textfield_t)
TCefTextfield = record
base : TCefView;
set_password_input : procedure(self: PCefTextfield; password_input: Integer); stdcall;
is_password_input : function(self: PCefTextfield): Integer; stdcall;
set_read_only : procedure(self: PCefTextfield; read_only: Integer); stdcall;
is_read_only : function(self: PCefTextfield): Integer; stdcall;
get_text : function(self: PCefTextfield): PCefStringUserFree; stdcall;
set_text : procedure(self: PCefTextfield; const text: PCefString); stdcall;
append_text : procedure(self: PCefTextfield; const text: PCefString); stdcall;
insert_or_replace_text : procedure(self: PCefTextfield; const text: PCefString); stdcall;
has_selection : function(self: PCefTextfield): Integer; stdcall;
get_selected_text : function(self: PCefTextfield): PCefStringUserFree; stdcall;
select_all : procedure(self: PCefTextfield; reversed: Integer); stdcall;
clear_selection : procedure(self: PCefTextfield); stdcall;
get_selected_range : function(self: PCefTextfield): TCefRange; stdcall;
select_range : procedure(self: PCefTextfield; const range: PCefRange); stdcall;
get_cursor_position : function(self: PCefTextfield): NativeUInt; stdcall;
set_text_color : procedure(self: PCefTextfield; color: TCefColor); stdcall;
get_text_color : function(self: PCefTextfield): TCefColor; stdcall;
set_selection_text_color : procedure(self: PCefTextfield; color: TCefColor); stdcall;
get_selection_text_color : function(self: PCefTextfield): TCefColor; stdcall;
set_selection_background_color : procedure(self: PCefTextfield; color: TCefColor); stdcall;
get_selection_background_color : function(self: PCefTextfield): TCefColor; stdcall;
set_font_list : procedure(self: PCefTextfield; const font_list: PCefString); stdcall;
apply_text_color : procedure(self: PCefTextfield; color: TCefColor; const range: PCefRange); stdcall;
apply_text_style : procedure(self: PCefTextfield; style: TCefTextStyle; add: Integer; const range: PCefRange); stdcall;
is_command_enabled : function(self: PCefTextfield; command_id: Integer): Integer; stdcall;
execute_command : procedure(self: PCefTextfield; command_id: Integer); stdcall;
clear_edit_history : procedure(self: PCefTextfield); stdcall;
set_placeholder_text : procedure(self: PCefTextfield; const text: PCefString); stdcall;
get_placeholder_text : function(self: PCefTextfield): PCefStringUserFree; stdcall;
set_placeholder_text_color : procedure(self: PCefTextfield; color: TCefColor); stdcall;
set_accessible_name : procedure(self: PCefTextfield; const name: PCefString); stdcall;
end;
// /include/capi/views/cef_textfield_delegate_capi.h (cef_textfield_delegate_t)
TCefTextfieldDelegate = record
base : TCefViewDelegate;
on_key_event : function(self: PCefTextfieldDelegate; textfield: PCefTextfield; const event: PCefKeyEvent): Integer; stdcall;
on_after_user_action : procedure(self: PCefTextfieldDelegate; textfield: PCefTextfield); stdcall;
end;
// /include/capi/views/cef_scroll_view_capi.h (cef_scroll_view_t)
TCefScrollView = record
base : TCefView;
set_content_view : procedure(self: PCefScrollView; view: PCefView); stdcall;
get_content_view : function(self: PCefScrollView): PCefView; stdcall;
get_visible_content_rect : function(self: PCefScrollView): TCefRect; stdcall;
has_horizontal_scrollbar : function(self: PCefScrollView): Integer; stdcall;
get_horizontal_scrollbar_height : function(self: PCefScrollView): Integer; stdcall;
has_vertical_scrollbar : function(self: PCefScrollView): Integer; stdcall;
get_vertical_scrollbar_width : function(self: PCefScrollView): Integer; stdcall;
end;
// /include/capi/views/cef_panel_capi.h (cef_panel_t)
TCefPanel = record
base : TCefView;
as_window : function(self: PCefPanel): PCefWindow; stdcall;
set_to_fill_layout : function(self: PCefPanel): PCefFillLayout; stdcall;
set_to_box_layout : function(self: PCefPanel; const settings: PCefBoxLayoutSettings): PCefBoxLayout; stdcall;
get_layout : function(self: PCefPanel): PCefLayout; stdcall;
layout : procedure(self: PCefPanel); stdcall;
add_child_view : procedure(self: PCefPanel; view: PCefView); stdcall;
add_child_view_at : procedure(self: PCefPanel; view: PCefView; index: Integer); stdcall;
reorder_child_view : procedure(self: PCefPanel; view: PCefView; index: Integer); stdcall;
remove_child_view : procedure(self: PCefPanel; view: PCefView); stdcall;
remove_all_child_views : procedure(self: PCefPanel); stdcall;
get_child_view_count : function(self: PCefPanel): NativeUInt; stdcall;
get_child_view_at : function(self: PCefPanel; index: Integer): PCefView; stdcall;
end;
// /include/capi/views/cef_panel_delegate_capi.h (cef_panel_delegate_t)
TCefPanelDelegate = record
base : TCefViewDelegate;
end;
// /include/capi/views/cef_browser_view_capi.h (cef_browser_view_t)
TCefBrowserView = record
base : TCefView;
get_browser : function(self: PCefBrowserView): PCefBrowser; stdcall;
set_prefer_accelerators : procedure(self: PCefBrowserView; prefer_accelerators: Integer); stdcall;
end;
// /include/capi/views/cef_browser_view_delegate_capi.h (cef_browser_view_delegate_t)
TCefBrowserViewDelegate = record
base : TCefViewDelegate;
on_browser_created : procedure(self: PCefBrowserViewDelegate; browser_view: PCefBrowserView; browser: PCefBrowser); stdcall;
on_browser_destroyed : procedure(self: PCefBrowserViewDelegate; browser_view: PCefBrowserView; browser: PCefBrowser); stdcall;
get_delegate_for_popup_browser_view : function(self: PCefBrowserViewDelegate; browser_view: PCefBrowserView; const settings: PCefBrowserSettings; client: PCefClient; is_devtools: Integer): PCefBrowserViewDelegate; stdcall;
on_popup_browser_view_created : function(self: PCefBrowserViewDelegate; browser_view, popup_browser_view: PCefBrowserView; is_devtools: Integer): Integer; stdcall;
end;
// /include/capi/views/cef_button_capi.h (cef_button_t)
TCefButton = record
base : TCefView;
as_label_button : function(self: PCefButton): PCefLabelButton; stdcall;
set_state : procedure(self: PCefButton; state: TCefButtonState); stdcall;
get_state : function(self: PCefButton): TCefButtonState; stdcall;
set_ink_drop_enabled : procedure(self: PCefButton; enabled: Integer); stdcall;
set_tooltip_text : procedure(self: PCefButton; const tooltip_text: PCefString); stdcall;
set_accessible_name : procedure(self: PCefButton; const name: PCefString); stdcall;
end;
// /include/capi/views/cef_button_delegate_capi.h (cef_button_delegate_t)
TCefButtonDelegate = record
base : TCefViewDelegate;
on_button_pressed : procedure(self: PCefButtonDelegate; button: PCefButton); stdcall;
on_button_state_changed : procedure(self: PCefButtonDelegate; button: PCefButton); stdcall;
end;
// /include/capi/views/cef_label_button_capi.h (cef_label_button_t)
TCefLabelButton = record
base : TCefButton;
get_state : function(self: PCefLabelButton): PCefMenuButton; stdcall;
set_text : procedure(self: PCefLabelButton; const text: PCefString); stdcall;
get_text : function(self: PCefLabelButton): PCefStringUserFree; stdcall;
set_image : procedure(self: PCefLabelButton; button_state: TCefButtonState; image: PCefImage); stdcall;
get_image : function(self: PCefLabelButton; button_state: TCefButtonState): PCefImage; stdcall;
set_text_color : procedure(self: PCefLabelButton; for_state: TCefButtonState; color: TCefColor); stdcall;
set_enabled_text_colors : procedure(self: PCefLabelButton; color: TCefColor); stdcall;
set_font_list : procedure(self: PCefLabelButton; const font_list: PCefString); stdcall;
set_horizontal_alignment : procedure(self: PCefLabelButton; alignment: TCefHorizontalAlignment); stdcall;
set_minimum_size : procedure(self: PCefLabelButton; const size: PCefSize); stdcall;
set_maximum_size : procedure(self: PCefLabelButton; const size: PCefSize); stdcall;
end;
// /include/capi/views/cef_menu_button_capi.h (cef_menu_button_t)
TCefMenuButton = record
base : TCefLabelButton;
show_menu : procedure(self: PCefMenuButton; menu_model: PCefMenuModel; const screen_point: PCefPoint; anchor_position: TCefMenuAnchorPosition); stdcall;
trigger_menu : procedure(self: PCefMenuButton); stdcall;
end;
// /include/capi/views/cef_menu_button_delegate_capi.h (cef_menu_button_pressed_lock_t)
TCefMenuButtonPressedLock = record
base : TCefBaseRefCounted;
end;
// /include/capi/views/cef_menu_button_delegate_capi.h (cef_menu_button_delegate_t)
TCefMenuButtonDelegate = record
base : TCefButtonDelegate;
on_menu_button_pressed : procedure(self: PCefMenuButtonDelegate; menu_button: PCefMenuButton; const screen_point: PCefPoint; button_pressed_lock: PCefMenuButtonPressedLock); stdcall;
end;
// /include/capi/views/cef_window_capi.h (cef_window_t)
TCefWindow = record
base : TCefPanel;
show : procedure(self: PCefWindow); stdcall;
hide : procedure(self: PCefWindow); stdcall;
center_window : procedure(self: PCefWindow; const size: PCefSize); stdcall;
close : procedure(self: PCefWindow); stdcall;
is_closed : function(self: PCefWindow): Integer; stdcall;
activate : procedure(self: PCefWindow); stdcall;
deactivate : procedure(self: PCefWindow); stdcall;
is_active : function(self: PCefWindow): Integer; stdcall;
bring_to_top : procedure(self: PCefWindow); stdcall;
set_always_on_top : procedure(self: PCefWindow; on_top: Integer); stdcall;
is_always_on_top : function(self: PCefWindow): Integer; stdcall;
maximize : procedure(self: PCefWindow); stdcall;
minimize : procedure(self: PCefWindow); stdcall;
restore : procedure(self: PCefWindow); stdcall;
set_fullscreen : procedure(self: PCefWindow; fullscreen: Integer); stdcall;
is_maximized : function(self: PCefWindow): Integer; stdcall;
is_minimized : function(self: PCefWindow): Integer; stdcall;
is_fullscreen : function(self: PCefWindow): Integer; stdcall;
set_title : procedure(self: PCefWindow; const title: PCefString); stdcall;
get_title : function(self: PCefWindow): PCefStringUserFree; stdcall;
set_window_icon : procedure(self: PCefWindow; image: PCefImage); stdcall;
get_window_icon : function(self: PCefWindow): PCefImage; stdcall;
set_window_app_icon : procedure(self: PCefWindow; image: PCefImage); stdcall;
get_window_app_icon : function(self: PCefWindow): PCefImage; stdcall;
show_menu : procedure(self: PCefWindow; menu_model: PCefMenuModel; const screen_point: PCefPoint; anchor_position : TCefMenuAnchorPosition); stdcall;
cancel_menu : procedure(self: PCefWindow); stdcall;
get_display : function(self: PCefWindow): PCefDisplay; stdcall;
get_client_area_bounds_in_screen : function(self: PCefWindow): TCefRect; stdcall;
set_draggable_regions : procedure(self: PCefWindow; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); stdcall;
get_window_handle : function(self: PCefWindow): TCefWindowHandle; stdcall;
send_key_press : procedure(self: PCefWindow; key_code: Integer; event_flags: cardinal); stdcall;
send_mouse_move : procedure(self: PCefWindow; screen_x, screen_y: Integer); stdcall;
send_mouse_events : procedure(self: PCefWindow; button: TCefMouseButtonType; mouse_down, mouse_up: Integer); stdcall;
set_accelerator : procedure(self: PCefWindow; command_id, key_code, shift_pressed, ctrl_pressed, alt_pressed: Integer); stdcall;
remove_accelerator : procedure(self: PCefWindow; command_id: Integer); stdcall;
remove_all_accelerators : procedure(self: PCefWindow); stdcall;
end;
// /include/capi/views/cef_window_delegate_capi.h (cef_window_delegate_t)
TCefWindowDelegate = record
base : TCefPanelDelegate;
on_window_created : procedure(self: PCefWindowDelegate; window: PCefWindow); stdcall;
on_window_destroyed : procedure(self: PCefWindowDelegate; window: PCefWindow); stdcall;
get_parent_window : function(self: PCefWindowDelegate; window: PCefWindow; is_menu, can_activate_menu: PInteger): PCefWindow; stdcall;
is_frameless : function(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall;
can_resize : function(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall;
can_maximize : function(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall;
can_minimize : function(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall;
can_close : function(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall;
on_accelerator : function(self: PCefWindowDelegate; window: PCefWindow; command_id: Integer): Integer; stdcall;
on_key_event : function(self: PCefWindowDelegate; window: PCefWindow; const event: PCefKeyEvent): Integer; stdcall;
end;
implementation
end.

View File

@ -387,6 +387,7 @@ var
TempWidth, TempHeight : integer;
begin
Result := False;
if (GlobalCEFApp = nil) then exit;
if not(aUseMutex) or BeginBufferDraw then
begin

View File

@ -443,7 +443,9 @@ type
function CreateBrowser(aParentHandle : HWND; aParentRect : TRect; const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aCookiesPath : ustring = ''; aPersistSessionCookies : boolean = False) : boolean; overload; virtual;
{$ENDIF}
procedure LoadURL(const aURL : ustring);
procedure LoadURL(const aURL : ustring; const aFrameName : ustring = ''); overload;
procedure LoadURL(const aURL : ustring; const aFrame : ICefFrame); overload;
procedure LoadURL(const aURL : ustring; const aFrameIdentifier : int64); overload;
procedure LoadString(const aString : ustring; const aURL : ustring = '');
procedure LoadRequest(const aRequest: ICefRequest);
@ -455,7 +457,7 @@ type
procedure StartDownload(const aURL : ustring);
procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer);
function DeleteCookies : boolean;
function DeleteCookies(const url : ustring = ''; const cookieName : ustring = '') : boolean;
procedure RetrieveHTML(const aFrameName : ustring = ''); overload;
procedure RetrieveHTML(const aFrame : ICefFrame); overload;
procedure RetrieveHTML(const aFrameIdentifier : int64); overload;
@ -1365,13 +1367,38 @@ begin
aSettings.accept_language_list := CefString('');
end;
procedure TFMXChromium.LoadURL(const aURL : ustring);
// Leave aFrameName empty to load the URL in the main frame
procedure TFMXChromium.LoadURL(const aURL : ustring; const aFrameName : ustring = '');
var
TempFrame : ICefFrame;
begin
if Initialized then
begin
TempFrame := FBrowser.MainFrame;
if (length(aFrameName) > 0) then
TempFrame := FBrowser.GetFrame(aFrameName)
else
TempFrame := FBrowser.MainFrame;
if (TempFrame <> nil) then TempFrame.LoadUrl(aURL);
end;
end;
procedure TFMXChromium.LoadURL(const aURL : ustring; const aFrame : ICefFrame);
begin
if Initialized and (aFrame <> nil) then aFrame.LoadUrl(aURL);
end;
procedure TFMXChromium.LoadURL(const aURL : ustring; const aFrameIdentifier : int64);
var
TempFrame : ICefFrame;
begin
if Initialized then
begin
if (aFrameIdentifier <> 0) then
TempFrame := FBrowser.GetFrameByident(aFrameIdentifier)
else
TempFrame := FBrowser.MainFrame;
if (TempFrame <> nil) then TempFrame.LoadUrl(aURL);
end;
end;
@ -1824,7 +1851,7 @@ begin
end;
end;
function TFMXChromium.DeleteCookies : boolean;
function TFMXChromium.DeleteCookies(const url, cookieName: ustring) : boolean;
var
TempManager : ICefCookieManager;
TempCallback : ICefDeleteCookiesCallback;
@ -1838,7 +1865,7 @@ begin
if (TempManager <> nil) then
begin
TempCallback := TCefCustomDeleteCookiesCallback.Create(self);
Result := TempManager.DeleteCookies('', '', TempCallback);
Result := TempManager.DeleteCookies(url, cookieName, TempCallback);
end;
end;
end;