You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-06-12 22:07:39 +02:00
Added TChromium.GetNavigationEntries and TChromium.OnNavigationVisitorResultAvailable
- MiniBrowser demo : Added a context menu option to get the navigation entries.
This commit is contained in:
@ -260,6 +260,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
|||||||
OnPdfPrintFinished = Chromium1PdfPrintFinished
|
OnPdfPrintFinished = Chromium1PdfPrintFinished
|
||||||
OnPrefsAvailable = Chromium1PrefsAvailable
|
OnPrefsAvailable = Chromium1PrefsAvailable
|
||||||
OnResolvedHostAvailable = Chromium1ResolvedHostAvailable
|
OnResolvedHostAvailable = Chromium1ResolvedHostAvailable
|
||||||
|
OnNavigationVisitorResultAvailable = Chromium1NavigationVisitorResultAvailable
|
||||||
OnRenderCompMsg = Chromium1RenderCompMsg
|
OnRenderCompMsg = Chromium1RenderCompMsg
|
||||||
OnLoadEnd = Chromium1LoadEnd
|
OnLoadEnd = Chromium1LoadEnd
|
||||||
OnLoadError = Chromium1LoadError
|
OnLoadError = Chromium1LoadError
|
||||||
|
@ -63,6 +63,7 @@ const
|
|||||||
MINIBROWSER_SAVEPREFERENCES = WM_APP + $107;
|
MINIBROWSER_SAVEPREFERENCES = WM_APP + $107;
|
||||||
MINIBROWSER_COPYALLTEXT = WM_APP + $108;
|
MINIBROWSER_COPYALLTEXT = WM_APP + $108;
|
||||||
MINIBROWSER_TAKESNAPSHOT = WM_APP + $109;
|
MINIBROWSER_TAKESNAPSHOT = WM_APP + $109;
|
||||||
|
MINIBROWSER_SHOWNAVIGATION = WM_APP + $10A;
|
||||||
|
|
||||||
MINIBROWSER_HOMEPAGE = 'https://www.google.com';
|
MINIBROWSER_HOMEPAGE = 'https://www.google.com';
|
||||||
|
|
||||||
@ -77,6 +78,7 @@ const
|
|||||||
MINIBROWSER_CONTEXTMENU_SAVEPREFERENCES = MENU_ID_USER_FIRST + 9;
|
MINIBROWSER_CONTEXTMENU_SAVEPREFERENCES = MENU_ID_USER_FIRST + 9;
|
||||||
MINIBROWSER_CONTEXTMENU_COPYALLTEXT = MENU_ID_USER_FIRST + 10;
|
MINIBROWSER_CONTEXTMENU_COPYALLTEXT = MENU_ID_USER_FIRST + 10;
|
||||||
MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT = MENU_ID_USER_FIRST + 11;
|
MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT = MENU_ID_USER_FIRST + 11;
|
||||||
|
MINIBROWSER_CONTEXTMENU_GETNAVIGATION = MENU_ID_USER_FIRST + 12;
|
||||||
|
|
||||||
type
|
type
|
||||||
TMiniBrowserFrm = class(TForm)
|
TMiniBrowserFrm = class(TForm)
|
||||||
@ -208,10 +210,14 @@ type
|
|||||||
const browser: ICefBrowser; certError: Integer;
|
const browser: ICefBrowser; certError: Integer;
|
||||||
const requestUrl: ustring; const sslInfo: ICefSslInfo;
|
const requestUrl: ustring; const sslInfo: ICefSslInfo;
|
||||||
const callback: ICefRequestCallback; out Result: Boolean);
|
const callback: ICefRequestCallback; out Result: Boolean);
|
||||||
|
procedure Chromium1NavigationVisitorResultAvailable(
|
||||||
|
const entry: ICefNavigationEntry; current: Boolean; index, total: Integer;
|
||||||
|
var aResult: Boolean);
|
||||||
|
|
||||||
protected
|
protected
|
||||||
FResponse : TStringList;
|
FResponse : TStringList;
|
||||||
FRequest : TStringList;
|
FRequest : TStringList;
|
||||||
|
FNavigation : TStringList;
|
||||||
// Variables to control when can we destroy the form safely
|
// Variables to control when can we destroy the form safely
|
||||||
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
|
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
|
||||||
FClosing : boolean; // Set to True in the CloseQuery event.
|
FClosing : boolean; // Set to True in the CloseQuery event.
|
||||||
@ -237,6 +243,7 @@ type
|
|||||||
procedure CopyFramesIDsMsg(var aMessage : TMessage); message MINIBROWSER_COPYFRAMEIDS;
|
procedure CopyFramesIDsMsg(var aMessage : TMessage); message MINIBROWSER_COPYFRAMEIDS;
|
||||||
procedure CopyFramesNamesMsg(var aMessage : TMessage); message MINIBROWSER_COPYFRAMENAMES;
|
procedure CopyFramesNamesMsg(var aMessage : TMessage); message MINIBROWSER_COPYFRAMENAMES;
|
||||||
procedure ShowResponseMsg(var aMessage : TMessage); message MINIBROWSER_SHOWRESPONSE;
|
procedure ShowResponseMsg(var aMessage : TMessage); message MINIBROWSER_SHOWRESPONSE;
|
||||||
|
procedure ShowNavigationMsg(var aMessage : TMessage); message MINIBROWSER_SHOWNAVIGATION;
|
||||||
procedure SavePreferencesMsg(var aMessage : TMessage); message MINIBROWSER_SAVEPREFERENCES;
|
procedure SavePreferencesMsg(var aMessage : TMessage); message MINIBROWSER_SAVEPREFERENCES;
|
||||||
procedure TakeSnapshotMsg(var aMessage : TMessage); message MINIBROWSER_TAKESNAPSHOT;
|
procedure TakeSnapshotMsg(var aMessage : TMessage); message MINIBROWSER_TAKESNAPSHOT;
|
||||||
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
|
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
|
||||||
@ -329,6 +336,7 @@ begin
|
|||||||
|
|
||||||
model.AddSeparator;
|
model.AddSeparator;
|
||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT, 'Take snapshot...');
|
model.AddItem(MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT, 'Take snapshot...');
|
||||||
|
model.AddItem(MINIBROWSER_CONTEXTMENU_GETNAVIGATION, 'Get navigation entries');
|
||||||
model.AddSeparator;
|
model.AddSeparator;
|
||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_COPYALLTEXT, 'Copy displayed text to clipboard');
|
model.AddItem(MINIBROWSER_CONTEXTMENU_COPYALLTEXT, 'Copy displayed text to clipboard');
|
||||||
model.AddItem(MINIBROWSER_CONTEXTMENU_COPYHTML, 'Copy HTML to clipboard');
|
model.AddItem(MINIBROWSER_CONTEXTMENU_COPYHTML, 'Copy HTML to clipboard');
|
||||||
@ -475,6 +483,12 @@ begin
|
|||||||
MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT :
|
MINIBROWSER_CONTEXTMENU_TAKESNAPSHOT :
|
||||||
PostMessage(Handle, MINIBROWSER_TAKESNAPSHOT, 0, 0);
|
PostMessage(Handle, MINIBROWSER_TAKESNAPSHOT, 0, 0);
|
||||||
|
|
||||||
|
MINIBROWSER_CONTEXTMENU_GETNAVIGATION :
|
||||||
|
begin
|
||||||
|
FNavigation.Clear;
|
||||||
|
Chromium1.GetNavigationEntries(False);
|
||||||
|
end;
|
||||||
|
|
||||||
MINIBROWSER_CONTEXTMENU_JSWRITEDOC :
|
MINIBROWSER_CONTEXTMENU_JSWRITEDOC :
|
||||||
if (browser <> nil) and (browser.MainFrame <> nil) then
|
if (browser <> nil) and (browser.MainFrame <> nil) then
|
||||||
browser.MainFrame.ExecuteJavaScript(
|
browser.MainFrame.ExecuteJavaScript(
|
||||||
@ -677,6 +691,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMiniBrowserFrm.Chromium1NavigationVisitorResultAvailable(
|
||||||
|
const entry: ICefNavigationEntry; current: Boolean; index, total: Integer;
|
||||||
|
var aResult: Boolean);
|
||||||
|
begin
|
||||||
|
if (entry <> nil) and entry.IsValid then FNavigation.Add(entry.Url);
|
||||||
|
|
||||||
|
if (index < pred(total)) then
|
||||||
|
aResult := True
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
aResult := False;
|
||||||
|
PostMessage(Handle, MINIBROWSER_SHOWNAVIGATION, 0, 0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMiniBrowserFrm.Chromium1PdfPrintFinished(Sender: TObject; aResultOK: Boolean);
|
procedure TMiniBrowserFrm.Chromium1PdfPrintFinished(Sender: TObject; aResultOK: Boolean);
|
||||||
begin
|
begin
|
||||||
if aResultOK then
|
if aResultOK then
|
||||||
@ -844,10 +873,11 @@ end;
|
|||||||
|
|
||||||
procedure TMiniBrowserFrm.FormCreate(Sender: TObject);
|
procedure TMiniBrowserFrm.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FCanClose := False;
|
FCanClose := False;
|
||||||
FClosing := False;
|
FClosing := False;
|
||||||
FResponse := TStringList.Create;
|
FResponse := TStringList.Create;
|
||||||
FRequest := TStringList.Create;
|
FRequest := TStringList.Create;
|
||||||
|
FNavigation := TStringList.Create;
|
||||||
Chromium1.DefaultURL := MINIBROWSER_HOMEPAGE;
|
Chromium1.DefaultURL := MINIBROWSER_HOMEPAGE;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -855,6 +885,7 @@ procedure TMiniBrowserFrm.FormDestroy(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
FResponse.Free;
|
FResponse.Free;
|
||||||
FRequest.Free;
|
FRequest.Free;
|
||||||
|
FNavigation.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMiniBrowserFrm.FormShow(Sender: TObject);
|
procedure TMiniBrowserFrm.FormShow(Sender: TObject);
|
||||||
@ -1099,6 +1130,13 @@ begin
|
|||||||
SimpleTextViewerFrm.ShowModal;
|
SimpleTextViewerFrm.ShowModal;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMiniBrowserFrm.ShowNavigationMsg(var aMessage : TMessage);
|
||||||
|
begin
|
||||||
|
SimpleTextViewerFrm.Memo1.Lines.Clear;
|
||||||
|
SimpleTextViewerFrm.Memo1.Lines.AddStrings(FNavigation);
|
||||||
|
SimpleTextViewerFrm.ShowModal;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMiniBrowserFrm.SavePreferencesMsg(var aMessage : TMessage);
|
procedure TMiniBrowserFrm.SavePreferencesMsg(var aMessage : TMessage);
|
||||||
begin
|
begin
|
||||||
SaveDialog1.DefaultExt := 'txt';
|
SaveDialog1.DefaultExt := 'txt';
|
||||||
|
@ -228,15 +228,16 @@ type
|
|||||||
FOnFindResult : TOnFindResult;
|
FOnFindResult : TOnFindResult;
|
||||||
|
|
||||||
// Custom
|
// Custom
|
||||||
FOnTextResultAvailable : TOnTextResultAvailableEvent;
|
FOnTextResultAvailable : TOnTextResultAvailableEvent;
|
||||||
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
|
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
|
||||||
FOnPrefsAvailable : TOnPrefsAvailableEvent;
|
FOnPrefsAvailable : TOnPrefsAvailableEvent;
|
||||||
FOnCookiesDeleted : TOnCookiesDeletedEvent;
|
FOnCookiesDeleted : TOnCookiesDeletedEvent;
|
||||||
FOnResolvedHostAvailable : TOnResolvedIPsAvailableEvent;
|
FOnResolvedHostAvailable : TOnResolvedIPsAvailableEvent;
|
||||||
|
FOnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent;
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
FOnBrowserCompMsg : TOnCompMsgEvent;
|
FOnBrowserCompMsg : TOnCompMsgEvent;
|
||||||
FOnWidgetCompMsg : TOnCompMsgEvent;
|
FOnWidgetCompMsg : TOnCompMsgEvent;
|
||||||
FOnRenderCompMsg : TOnCompMsgEvent;
|
FOnRenderCompMsg : TOnCompMsgEvent;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
function GetIsLoading : boolean;
|
function GetIsLoading : boolean;
|
||||||
@ -468,6 +469,7 @@ type
|
|||||||
procedure doUpdateOwnPreferences; virtual;
|
procedure doUpdateOwnPreferences; virtual;
|
||||||
function doSavePreferences : boolean; virtual;
|
function doSavePreferences : boolean; virtual;
|
||||||
procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); virtual;
|
procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); virtual;
|
||||||
|
function doNavigationVisitorResultAvailable(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer) : boolean; virtual;
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
@ -504,6 +506,7 @@ type
|
|||||||
procedure RetrieveText(const aFrameName : ustring = ''); overload;
|
procedure RetrieveText(const aFrameName : ustring = ''); overload;
|
||||||
procedure RetrieveText(const aFrame : ICefFrame); overload;
|
procedure RetrieveText(const aFrame : ICefFrame); overload;
|
||||||
procedure RetrieveText(const aFrameIdentifier : int64); overload;
|
procedure RetrieveText(const aFrameIdentifier : int64); overload;
|
||||||
|
procedure GetNavigationEntries(currentOnly: Boolean);
|
||||||
function GetFrameNames(var aFrameNames : TStrings) : boolean;
|
function GetFrameNames(var aFrameNames : TStrings) : boolean;
|
||||||
function GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean;
|
function GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean;
|
||||||
procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameName : ustring = ''; aStartLine : integer = 0); overload;
|
procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameName : ustring = ''; aStartLine : integer = 0); overload;
|
||||||
@ -636,15 +639,16 @@ type
|
|||||||
property ProxyByPassList : ustring read FProxyByPassList write SetProxyByPassList;
|
property ProxyByPassList : ustring read FProxyByPassList write SetProxyByPassList;
|
||||||
|
|
||||||
published
|
published
|
||||||
property OnTextResultAvailable : TOnTextResultAvailableEvent read FOnTextResultAvailable write FOnTextResultAvailable;
|
property OnTextResultAvailable : TOnTextResultAvailableEvent read FOnTextResultAvailable write FOnTextResultAvailable;
|
||||||
property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished;
|
property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished;
|
||||||
property OnPrefsAvailable : TOnPrefsAvailableEvent read FOnPrefsAvailable write FOnPrefsAvailable;
|
property OnPrefsAvailable : TOnPrefsAvailableEvent read FOnPrefsAvailable write FOnPrefsAvailable;
|
||||||
property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted;
|
property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted;
|
||||||
property OnResolvedHostAvailable : TOnResolvedIPsAvailableEvent read FOnResolvedHostAvailable write FOnResolvedHostAvailable;
|
property OnResolvedHostAvailable : TOnResolvedIPsAvailableEvent read FOnResolvedHostAvailable write FOnResolvedHostAvailable;
|
||||||
|
property OnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent read FOnNavigationVisitorResultAvailable write FOnNavigationVisitorResultAvailable;
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
|
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
|
||||||
property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg;
|
property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg;
|
||||||
property OnRenderCompMsg : TOnCompMsgEvent read FOnRenderCompMsg write FOnRenderCompMsg;
|
property OnRenderCompMsg : TOnCompMsgEvent read FOnRenderCompMsg write FOnRenderCompMsg;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
// ICefClient
|
// ICefClient
|
||||||
@ -762,7 +766,7 @@ uses
|
|||||||
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
|
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
|
||||||
uCEFApplication, uCEFProcessMessage, uCEFRequestContext, {$IFNDEF FPC}uOLEDragAndDrop,{$ENDIF}
|
uCEFApplication, uCEFProcessMessage, uCEFRequestContext, {$IFNDEF FPC}uOLEDragAndDrop,{$ENDIF}
|
||||||
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
|
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
|
||||||
uCEFListValue;
|
uCEFListValue, uCEFNavigationEntryVisitor;
|
||||||
|
|
||||||
constructor TChromium.Create(AOwner: TComponent);
|
constructor TChromium.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
@ -1103,15 +1107,16 @@ begin
|
|||||||
FOnFindResult := nil;
|
FOnFindResult := nil;
|
||||||
|
|
||||||
// Custom
|
// Custom
|
||||||
FOnTextResultAvailable := nil;
|
FOnTextResultAvailable := nil;
|
||||||
FOnPdfPrintFinished := nil;
|
FOnPdfPrintFinished := nil;
|
||||||
FOnPrefsAvailable := nil;
|
FOnPrefsAvailable := nil;
|
||||||
FOnCookiesDeleted := nil;
|
FOnCookiesDeleted := nil;
|
||||||
FOnResolvedHostAvailable := nil;
|
FOnResolvedHostAvailable := nil;
|
||||||
|
FOnNavigationVisitorResultAvailable := nil;
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
FOnBrowserCompMsg := nil;
|
FOnBrowserCompMsg := nil;
|
||||||
FOnWidgetCompMsg := nil;
|
FOnWidgetCompMsg := nil;
|
||||||
FOnRenderCompMsg := nil;
|
FOnRenderCompMsg := nil;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2228,6 +2233,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChromium.GetNavigationEntries(currentOnly: Boolean);
|
||||||
|
var
|
||||||
|
TempVisitor : TCustomCefNavigationEntryVisitor;
|
||||||
|
begin
|
||||||
|
if Initialized then
|
||||||
|
begin
|
||||||
|
TempVisitor := TCustomCefNavigationEntryVisitor.Create(self);
|
||||||
|
FBrowser.Host.GetNavigationEntries(TempVisitor, currentOnly);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TChromium.GetFrameNames(var aFrameNames : TStrings) : boolean;
|
function TChromium.GetFrameNames(var aFrameNames : TStrings) : boolean;
|
||||||
begin
|
begin
|
||||||
Result := Initialized and FBrowser.GetFrameNames(aFrameNames);
|
Result := Initialized and FBrowser.GetFrameNames(aFrameNames);
|
||||||
@ -2882,6 +2898,17 @@ begin
|
|||||||
if assigned(FOnResolvedHostAvailable) then FOnResolvedHostAvailable(self, result, resolvedIps);
|
if assigned(FOnResolvedHostAvailable) then FOnResolvedHostAvailable(self, result, resolvedIps);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TChromium.doNavigationVisitorResultAvailable(const entry : ICefNavigationEntry;
|
||||||
|
current : Boolean;
|
||||||
|
index : Integer;
|
||||||
|
total : Integer) : boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
if assigned(FOnNavigationVisitorResultAvailable) then
|
||||||
|
FOnNavigationVisitorResultAvailable(entry, current, index, total, Result);
|
||||||
|
end;
|
||||||
|
|
||||||
function TChromium.MustCreateLoadHandler : boolean;
|
function TChromium.MustCreateLoadHandler : boolean;
|
||||||
begin
|
begin
|
||||||
Result := assigned(FOnLoadStart) or
|
Result := assigned(FOnLoadStart) or
|
||||||
|
@ -156,13 +156,14 @@ type
|
|||||||
TOnFindResult = procedure(Sender: TObject; const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean) of Object;
|
TOnFindResult = procedure(Sender: TObject; const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean) of Object;
|
||||||
|
|
||||||
// Custom
|
// Custom
|
||||||
TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object;
|
TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object;
|
||||||
TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object;
|
TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object;
|
||||||
TOnPrefsAvailableEvent = procedure(Sender: TObject; aResultOK : boolean) of object;
|
TOnPrefsAvailableEvent = procedure(Sender: TObject; aResultOK : boolean) of object;
|
||||||
TOnCookiesDeletedEvent = procedure(Sender: TObject; numDeleted : integer) of object;
|
TOnCookiesDeletedEvent = procedure(Sender: TObject; numDeleted : integer) of object;
|
||||||
TOnResolvedIPsAvailableEvent = procedure(Sender: TObject; result: TCefErrorCode; const resolvedIps: TStrings) of object;
|
TOnResolvedIPsAvailableEvent = procedure(Sender: TObject; result: TCefErrorCode; const resolvedIps: TStrings) of object;
|
||||||
|
TOnNavigationVisitorResultAvailableEvent = procedure(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer; var aResult : boolean) of object;
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
TOnCompMsgEvent = procedure (var aMessage: TMessage; var aHandled: Boolean) of object;
|
TOnCompMsgEvent = procedure (var aMessage: TMessage; var aHandled: Boolean) of object;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
@ -148,6 +148,4 @@ begin
|
|||||||
creation, lastAccess, expires, count, total, deleteCookie);
|
creation, lastAccess, expires, count, total, deleteCookie);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -371,6 +371,7 @@ type
|
|||||||
procedure doUpdateOwnPreferences;
|
procedure doUpdateOwnPreferences;
|
||||||
function doSavePreferences : boolean;
|
function doSavePreferences : boolean;
|
||||||
procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings);
|
procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings);
|
||||||
|
function doNavigationVisitorResultAvailable(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer) : boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
IServerEvents = interface
|
IServerEvents = interface
|
||||||
|
@ -70,9 +70,25 @@ type
|
|||||||
constructor Create(const proc: TCefNavigationEntryVisitorProc); reintroduce;
|
constructor Create(const proc: TCefNavigationEntryVisitorProc); reintroduce;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TCustomCefNavigationEntryVisitor = class(TCefNavigationEntryVisitorOwn)
|
||||||
|
protected
|
||||||
|
FEvents : Pointer;
|
||||||
|
|
||||||
|
function Visit(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer): Boolean; override;
|
||||||
|
|
||||||
|
public
|
||||||
|
constructor Create(const aEvents : IChromiumEvents); reintroduce;
|
||||||
|
destructor Destroy; override;
|
||||||
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
{$IFDEF DELPHI16_UP}
|
||||||
|
System.SysUtils,
|
||||||
|
{$ELSE}
|
||||||
|
SysUtils,
|
||||||
|
{$ENDIF}
|
||||||
uCEFTypes, uCEFMiscFunctions, uCEFNavigationEntry;
|
uCEFTypes, uCEFMiscFunctions, uCEFNavigationEntry;
|
||||||
|
|
||||||
function cef_navigation_entry_visitor_visit(self : PCefNavigationEntryVisitor;
|
function cef_navigation_entry_visitor_visit(self : PCefNavigationEntryVisitor;
|
||||||
@ -127,4 +143,36 @@ begin
|
|||||||
Result := FVisitor(entry, current, index, total);
|
Result := FVisitor(entry, current, index, total);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// TCustomCefNavigationEntryVisitor
|
||||||
|
|
||||||
|
constructor TCustomCefNavigationEntryVisitor.Create(const aEvents : IChromiumEvents);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
|
||||||
|
FEvents := Pointer(aEvents);
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TCustomCefNavigationEntryVisitor.Destroy;
|
||||||
|
begin
|
||||||
|
FEvents := nil;
|
||||||
|
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomCefNavigationEntryVisitor.Visit(const entry : ICefNavigationEntry;
|
||||||
|
current : Boolean;
|
||||||
|
index : Integer;
|
||||||
|
total : Integer): Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
try
|
||||||
|
if (FEvents <> nil) then
|
||||||
|
Result := IChromiumEvents(FEvents).doNavigationVisitorResultAvailable(entry, current, index, total);
|
||||||
|
except
|
||||||
|
on e : exception do
|
||||||
|
if CustomExceptionHandler('TCustomCefNavigationEntryVisitor.Visit', e) then raise;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -212,14 +212,15 @@ type
|
|||||||
FOnFindResult : TOnFindResult;
|
FOnFindResult : TOnFindResult;
|
||||||
|
|
||||||
// Custom
|
// Custom
|
||||||
FOnTextResultAvailable : TOnTextResultAvailableEvent;
|
FOnTextResultAvailable : TOnTextResultAvailableEvent;
|
||||||
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
|
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
|
||||||
FOnCookiesDeleted : TOnCookiesDeletedEvent;
|
FOnCookiesDeleted : TOnCookiesDeletedEvent;
|
||||||
FOnResolvedHostAvailable : TOnResolvedIPsAvailableEvent;
|
FOnResolvedHostAvailable : TOnResolvedIPsAvailableEvent;
|
||||||
|
FOnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent;
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
FOnBrowserCompMsg : TOnCompMsgEvent;
|
FOnBrowserCompMsg : TOnCompMsgEvent;
|
||||||
FOnWidgetCompMsg : TOnCompMsgEvent;
|
FOnWidgetCompMsg : TOnCompMsgEvent;
|
||||||
FOnRenderCompMsg : TOnCompMsgEvent;
|
FOnRenderCompMsg : TOnCompMsgEvent;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
function GetIsLoading : boolean;
|
function GetIsLoading : boolean;
|
||||||
@ -436,6 +437,7 @@ type
|
|||||||
procedure doUpdateOwnPreferences; virtual;
|
procedure doUpdateOwnPreferences; virtual;
|
||||||
function doSavePreferences : boolean; virtual;
|
function doSavePreferences : boolean; virtual;
|
||||||
procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); virtual;
|
procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); virtual;
|
||||||
|
function doNavigationVisitorResultAvailable(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer) : boolean; virtual;
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
@ -472,6 +474,7 @@ type
|
|||||||
procedure RetrieveText(const aFrameName : ustring = ''); overload;
|
procedure RetrieveText(const aFrameName : ustring = ''); overload;
|
||||||
procedure RetrieveText(const aFrame : ICefFrame); overload;
|
procedure RetrieveText(const aFrame : ICefFrame); overload;
|
||||||
procedure RetrieveText(const aFrameIdentifier : int64); overload;
|
procedure RetrieveText(const aFrameIdentifier : int64); overload;
|
||||||
|
procedure GetNavigationEntries(currentOnly: Boolean);
|
||||||
function GetFrameNames(var aFrameNames : TStrings) : boolean;
|
function GetFrameNames(var aFrameNames : TStrings) : boolean;
|
||||||
function GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean;
|
function GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean;
|
||||||
procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameName : ustring = ''; aStartLine : integer = 0); overload;
|
procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameName : ustring = ''; aStartLine : integer = 0); overload;
|
||||||
@ -594,10 +597,11 @@ type
|
|||||||
property ProxyByPassList : ustring read FProxyByPassList write SetProxyByPassList;
|
property ProxyByPassList : ustring read FProxyByPassList write SetProxyByPassList;
|
||||||
|
|
||||||
published
|
published
|
||||||
property OnTextResultAvailable : TOnTextResultAvailableEvent read FOnTextResultAvailable write FOnTextResultAvailable;
|
property OnTextResultAvailable : TOnTextResultAvailableEvent read FOnTextResultAvailable write FOnTextResultAvailable;
|
||||||
property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished;
|
property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished;
|
||||||
property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted;
|
property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted;
|
||||||
property OnResolvedHostAvailable : TOnResolvedIPsAvailableEvent read FOnResolvedHostAvailable write FOnResolvedHostAvailable;
|
property OnResolvedHostAvailable : TOnResolvedIPsAvailableEvent read FOnResolvedHostAvailable write FOnResolvedHostAvailable;
|
||||||
|
property OnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent read FOnNavigationVisitorResultAvailable write FOnNavigationVisitorResultAvailable;
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
|
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
|
||||||
property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg;
|
property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg;
|
||||||
@ -709,7 +713,7 @@ uses
|
|||||||
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
|
uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame,
|
||||||
uCEFApplication, uCEFProcessMessage, uCEFRequestContext,
|
uCEFApplication, uCEFProcessMessage, uCEFRequestContext,
|
||||||
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
|
uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor,
|
||||||
uCEFListValue;
|
uCEFListValue, uCEFNavigationEntryVisitor;
|
||||||
|
|
||||||
constructor TFMXChromium.Create(AOwner: TComponent);
|
constructor TFMXChromium.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
@ -1006,10 +1010,11 @@ begin
|
|||||||
FOnFindResult := nil;
|
FOnFindResult := nil;
|
||||||
|
|
||||||
// Custom
|
// Custom
|
||||||
FOnTextResultAvailable := nil;
|
FOnTextResultAvailable := nil;
|
||||||
FOnPdfPrintFinished := nil;
|
FOnPdfPrintFinished := nil;
|
||||||
FOnCookiesDeleted := nil;
|
FOnCookiesDeleted := nil;
|
||||||
FOnResolvedHostAvailable := nil;
|
FOnResolvedHostAvailable := nil;
|
||||||
|
FOnNavigationVisitorResultAvailable := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFMXChromium.CreateBrowser(const aWindowName : ustring;
|
function TFMXChromium.CreateBrowser(const aWindowName : ustring;
|
||||||
@ -2014,6 +2019,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFMXChromium.GetNavigationEntries(currentOnly: Boolean);
|
||||||
|
var
|
||||||
|
TempVisitor : TCustomCefNavigationEntryVisitor;
|
||||||
|
begin
|
||||||
|
if Initialized then
|
||||||
|
begin
|
||||||
|
TempVisitor := TCustomCefNavigationEntryVisitor.Create(self);
|
||||||
|
FBrowser.Host.GetNavigationEntries(TempVisitor, currentOnly);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TFMXChromium.GetFrameNames(var aFrameNames : TStrings) : boolean;
|
function TFMXChromium.GetFrameNames(var aFrameNames : TStrings) : boolean;
|
||||||
begin
|
begin
|
||||||
Result := Initialized and FBrowser.GetFrameNames(aFrameNames);
|
Result := Initialized and FBrowser.GetFrameNames(aFrameNames);
|
||||||
@ -2614,6 +2630,17 @@ begin
|
|||||||
if assigned(FOnResolvedHostAvailable) then FOnResolvedHostAvailable(self, result, resolvedIps);
|
if assigned(FOnResolvedHostAvailable) then FOnResolvedHostAvailable(self, result, resolvedIps);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFMXChromium.doNavigationVisitorResultAvailable(const entry : ICefNavigationEntry;
|
||||||
|
current : Boolean;
|
||||||
|
index : Integer;
|
||||||
|
total : Integer) : boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
if assigned(FOnNavigationVisitorResultAvailable) then
|
||||||
|
FOnNavigationVisitorResultAvailable(entry, current, index, total, Result);
|
||||||
|
end;
|
||||||
|
|
||||||
function TFMXChromium.MustCreateLoadHandler : boolean;
|
function TFMXChromium.MustCreateLoadHandler : boolean;
|
||||||
begin
|
begin
|
||||||
Result := assigned(FOnLoadStart) or
|
Result := assigned(FOnLoadStart) or
|
||||||
|
Reference in New Issue
Block a user