mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-04-07 06:50:04 +02:00
Bug fix #98
This commit is contained in:
parent
4155f11128
commit
d31825a7a5
@ -95,8 +95,8 @@ type
|
||||
function GetRequestContext: ICefRequestContext;
|
||||
function GetZoomLevel: Double;
|
||||
procedure SetZoomLevel(zoomLevel: Double);
|
||||
procedure RunFileDialog(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefRunFileDialogCallback);
|
||||
procedure RunFileDialogProc(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: TCefRunFileDialogCallbackProc);
|
||||
procedure RunFileDialog(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefRunFileDialogCallback);
|
||||
procedure RunFileDialogProc(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: TCefRunFileDialogCallbackProc);
|
||||
procedure StartDownload(const url: ustring);
|
||||
procedure DownloadImage(const imageUrl: ustring; isFavicon: Boolean; maxImageSize: Cardinal; bypassCache: Boolean; const callback: ICefDownloadImageCallback);
|
||||
procedure DownloadImageProc(const imageUrl: ustring; isFavicon: Boolean; maxImageSize: Cardinal; bypassCache: Boolean; const callback: TOnDownloadImageFinishedProc);
|
||||
@ -223,7 +223,7 @@ end;
|
||||
function TCefBrowserRef.GetFrameNames(var aFrameNames : TStrings) : boolean;
|
||||
var
|
||||
TempSL : TCefStringList;
|
||||
i, j : Integer;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
TempSL := nil;
|
||||
@ -235,7 +235,6 @@ begin
|
||||
begin
|
||||
TempSL := cef_string_list_alloc;
|
||||
PCefBrowser(FData)^.get_frame_names(PCefBrowser(FData), TempSL);
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempSL);
|
||||
@ -452,9 +451,12 @@ begin
|
||||
PCefBrowserHost(FData).replace_misspelling(FData, @str);
|
||||
end;
|
||||
|
||||
procedure TCefBrowserHostRef.RunFileDialog(mode: TCefFileDialogMode;
|
||||
const title, defaultFilePath: ustring; acceptFilters: TStrings;
|
||||
selectedAcceptFilter: Integer; const callback: ICefRunFileDialogCallback);
|
||||
procedure TCefBrowserHostRef.RunFileDialog( mode : TCefFileDialogMode;
|
||||
const title : ustring;
|
||||
const defaultFilePath : ustring;
|
||||
const acceptFilters : TStrings;
|
||||
selectedAcceptFilter : Integer;
|
||||
const callback : ICefRunFileDialogCallback);
|
||||
var
|
||||
t, f: TCefString;
|
||||
list: TCefStringList;
|
||||
@ -470,19 +472,20 @@ begin
|
||||
item := CefString(acceptFilters[i]);
|
||||
cef_string_list_append(list, @item);
|
||||
end;
|
||||
PCefBrowserHost(FData).run_file_dialog(PCefBrowserHost(FData), mode, @t, @f,
|
||||
list, selectedAcceptFilter, CefGetData(callback));
|
||||
PCefBrowserHost(FData).run_file_dialog(PCefBrowserHost(FData), mode, @t, @f, list, selectedAcceptFilter, CefGetData(callback));
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefBrowserHostRef.RunFileDialogProc(mode: TCefFileDialogMode;
|
||||
const title, defaultFilePath: ustring; acceptFilters: TStrings;
|
||||
selectedAcceptFilter: Integer; const callback: TCefRunFileDialogCallbackProc);
|
||||
procedure TCefBrowserHostRef.RunFileDialogProc( mode : TCefFileDialogMode;
|
||||
const title : ustring;
|
||||
const defaultFilePath : ustring;
|
||||
const acceptFilters : TStrings;
|
||||
selectedAcceptFilter : Integer;
|
||||
const callback : TCefRunFileDialogCallbackProc);
|
||||
begin
|
||||
RunFileDialog(mode, title, defaultFilePath, acceptFilters, selectedAcceptFilter,
|
||||
TCefFastRunFileDialogCallback.Create(callback));
|
||||
RunFileDialog(mode, title, defaultFilePath, acceptFilters, selectedAcceptFilter, TCefFastRunFileDialogCallback.Create(callback));
|
||||
end;
|
||||
|
||||
procedure TCefBrowserHostRef.AddWordToDictionary(const word: ustring);
|
||||
|
@ -48,9 +48,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFTypes, uCEFInterfaces;
|
||||
|
||||
@ -64,17 +64,17 @@ type
|
||||
procedure InitFromString(const commandLine: ustring);
|
||||
procedure Reset;
|
||||
function GetCommandLineString: ustring;
|
||||
procedure GetArgv(args: TStrings);
|
||||
procedure GetArgv(var args: TStrings);
|
||||
function GetProgram: ustring;
|
||||
procedure SetProgram(const prog: ustring);
|
||||
function HasSwitches: Boolean;
|
||||
function HasSwitch(const name: ustring): Boolean;
|
||||
function GetSwitchValue(const name: ustring): ustring;
|
||||
procedure GetSwitches(switches: TStrings);
|
||||
procedure GetSwitches(var switches: TStrings);
|
||||
procedure AppendSwitch(const name: ustring);
|
||||
procedure AppendSwitchWithValue(const name, value: ustring);
|
||||
function HasArguments: Boolean;
|
||||
procedure GetArguments(arguments: TStrings);
|
||||
procedure GetArguments(var arguments: TStrings);
|
||||
procedure AppendArgument(const argument: ustring);
|
||||
procedure PrependWrapper(const wrapper: ustring);
|
||||
|
||||
@ -119,43 +119,73 @@ begin
|
||||
Result := UnWrap(PCefCommandLine(FData).copy(PCefCommandLine(FData)));
|
||||
end;
|
||||
|
||||
procedure TCefCommandLineRef.GetArguments(arguments: TStrings);
|
||||
procedure TCefCommandLineRef.GetArguments(var arguments : TStrings);
|
||||
var
|
||||
list: TCefStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
TempSL : TCefStringList;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := cef_string_list_alloc;
|
||||
TempSL := nil;
|
||||
|
||||
try
|
||||
PCefCommandLine(FData).get_arguments(PCefCommandLine(FData), list);
|
||||
for i := 0 to cef_string_list_size(list) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(list, i, @str);
|
||||
arguments.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
if (arguments <> nil) then
|
||||
begin
|
||||
TempSL := cef_string_list_alloc;
|
||||
PCefCommandLine(FData).get_arguments(PCefCommandLine(FData), TempSL);
|
||||
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempSL);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempSL, i, @TempString);
|
||||
arguments.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefCommandLineRef.GetArguments', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
if (TempSL <> nil) then cef_string_list_free(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefCommandLineRef.GetArgv(args: TStrings);
|
||||
procedure TCefCommandLineRef.GetArgv(var args: TStrings);
|
||||
var
|
||||
list: TCefStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
TempSL : TCefStringList;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := cef_string_list_alloc;
|
||||
TempSL := nil;
|
||||
|
||||
try
|
||||
PCefCommandLine(FData).get_argv(FData, list);
|
||||
for i := 0 to cef_string_list_size(list) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(list, i, @str);
|
||||
args.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
if (args <> nil) then
|
||||
begin
|
||||
TempSL := cef_string_list_alloc;
|
||||
PCefCommandLine(FData).get_argv(PCefCommandLine(FData), TempSL);
|
||||
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempSL);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempSL, i, @TempString);
|
||||
args.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefCommandLineRef.GetArgv', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
if (TempSL <> nil) then cef_string_list_free(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -169,23 +199,38 @@ begin
|
||||
Result := CefStringFreeAndGet(PCefCommandLine(FData).get_program(PCefCommandLine(FData)));
|
||||
end;
|
||||
|
||||
procedure TCefCommandLineRef.GetSwitches(switches: TStrings);
|
||||
procedure TCefCommandLineRef.GetSwitches(var switches: TStrings);
|
||||
var
|
||||
list: TCefStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
TempSL : TCefStringList;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := cef_string_list_alloc;
|
||||
TempSL := nil;
|
||||
|
||||
try
|
||||
PCefCommandLine(FData).get_switches(PCefCommandLine(FData), list);
|
||||
for i := 0 to cef_string_list_size(list) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(list, i, @str);
|
||||
switches.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
if (switches <> nil) then
|
||||
begin
|
||||
TempSL := cef_string_list_alloc;
|
||||
PCefCommandLine(FData).get_switches(PCefCommandLine(FData), TempSL);
|
||||
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempSL);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempSL, i, @TempString);
|
||||
switches.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefCommandLineRef.GetSwitches', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
if (TempSL <> nil) then cef_string_list_free(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -48,9 +48,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
@ -88,25 +88,43 @@ uses
|
||||
uCEFMiscFunctions, uCEFLibFunctions;
|
||||
|
||||
|
||||
function TCefContextMenuParamsRef.GetDictionarySuggestions(
|
||||
const suggestions: TStringList): Boolean;
|
||||
function TCefContextMenuParamsRef.GetDictionarySuggestions(const suggestions : TStringList): Boolean;
|
||||
var
|
||||
list: TCefStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
TempSL : TCefStringList;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := cef_string_list_alloc;
|
||||
TempSL := nil;
|
||||
Result := False;
|
||||
|
||||
try
|
||||
Result := PCefContextMenuParams(FData).get_dictionary_suggestions(PCefContextMenuParams(FData), list) <> 0;
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
for i := 0 to cef_string_list_size(list) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(list, i, @str);
|
||||
suggestions.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
if (suggestions <> nil) then
|
||||
begin
|
||||
TempSL := cef_string_list_alloc;
|
||||
|
||||
if (PCefContextMenuParams(FData).get_dictionary_suggestions(PCefContextMenuParams(FData), TempSL) <> 0) then
|
||||
begin
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempSL);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempSL, i, @TempString);
|
||||
suggestions.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefContextMenuParamsRef.GetDictionarySuggestions', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
if (TempSL <> nil) then cef_string_list_free(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -48,17 +48,17 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
type
|
||||
TCefCookieManagerRef = class(TCefBaseRefCountedRef, ICefCookieManager)
|
||||
protected
|
||||
procedure SetSupportedSchemes(schemes: TStrings; const callback: ICefCompletionCallback);
|
||||
procedure SetSupportedSchemesProc(schemes: TStrings; const callback: TCefCompletionCallbackProc);
|
||||
procedure SetSupportedSchemes(const schemes: TStrings; const callback: ICefCompletionCallback);
|
||||
procedure SetSupportedSchemesProc(const schemes: TStrings; const callback: TCefCompletionCallbackProc);
|
||||
function VisitAllCookies(const visitor: ICefCookieVisitor): Boolean;
|
||||
function VisitAllCookiesProc(const visitor: TCefCookieVisitorProc): Boolean;
|
||||
function VisitUrlCookies(const url: ustring; includeHttpOnly: Boolean; const visitor: ICefCookieVisitor): Boolean;
|
||||
@ -194,30 +194,38 @@ begin
|
||||
Result := SetStoragePath(path, persistSessionCookies, TCefFastCompletionCallback.Create(callback));
|
||||
end;
|
||||
|
||||
procedure TCefCookieManagerRef.SetSupportedSchemes(schemes: TStrings; const callback: ICefCompletionCallback);
|
||||
procedure TCefCookieManagerRef.SetSupportedSchemes(const schemes: TStrings; const callback: ICefCompletionCallback);
|
||||
var
|
||||
list: TCefStringList;
|
||||
i: Integer;
|
||||
item: TCefString;
|
||||
TempSL : TCefStringList;
|
||||
i : Integer;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := cef_string_list_alloc();
|
||||
try
|
||||
if (schemes <> nil) then
|
||||
for i := 0 to schemes.Count - 1 do
|
||||
begin
|
||||
item := CefString(schemes[i]);
|
||||
cef_string_list_append(list, @item);
|
||||
end;
|
||||
PCefCookieManager(FData).set_supported_schemes(
|
||||
PCefCookieManager(FData), list, CefGetData(callback));
|
||||
TempSL := nil;
|
||||
|
||||
try
|
||||
try
|
||||
if (schemes <> nil) and (schemes.Count > 0) then
|
||||
begin
|
||||
TempSL := cef_string_list_alloc();
|
||||
|
||||
for i := 0 to schemes.Count - 1 do
|
||||
begin
|
||||
TempString := CefString(schemes[i]);
|
||||
cef_string_list_append(TempSL, @TempString);
|
||||
end;
|
||||
|
||||
PCefCookieManager(FData).set_supported_schemes(PCefCookieManager(FData), TempSL, CefGetData(callback));
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefCookieManagerRef.SetSupportedSchemes', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
if (TempSL <> nil) then cef_string_list_free(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefCookieManagerRef.SetSupportedSchemesProc(schemes: TStrings;
|
||||
const callback: TCefCompletionCallbackProc);
|
||||
procedure TCefCookieManagerRef.SetSupportedSchemesProc(const schemes: TStrings; const callback: TCefCompletionCallbackProc);
|
||||
begin
|
||||
SetSupportedSchemes(schemes, TCefFastCompletionCallback.Create(callback));
|
||||
end;
|
||||
|
@ -88,30 +88,49 @@ uses
|
||||
{$ENDIF}
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFileDialogCallback;
|
||||
|
||||
function cef_dialog_handler_on_file_dialog(self: PCefDialogHandler; browser: PCefBrowser;
|
||||
mode: TCefFileDialogMode; const title, default_file_path: PCefString;
|
||||
accept_filters: TCefStringList; selected_accept_filter: Integer;
|
||||
callback: PCefFileDialogCallback): Integer; stdcall;
|
||||
function cef_dialog_handler_on_file_dialog(self : PCefDialogHandler;
|
||||
browser : PCefBrowser;
|
||||
mode : TCefFileDialogMode;
|
||||
const title : PCefString;
|
||||
const default_file_path : PCefString;
|
||||
accept_filters : TCefStringList;
|
||||
selected_accept_filter : Integer;
|
||||
callback : PCefFileDialogCallback): Integer; stdcall;
|
||||
var
|
||||
list: TStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
TempSL : TStringList;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := TStringList.Create;
|
||||
try
|
||||
for i := 0 to cef_string_list_size(accept_filters) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(accept_filters, i, @str);
|
||||
list.Add(CefStringClearAndGet(str));
|
||||
end;
|
||||
TempSL := nil;
|
||||
Result := 0; // False
|
||||
|
||||
with TCefDialogHandlerOwn(CefGetObject(self)) do
|
||||
Result := Ord(OnFileDialog(TCefBrowserRef.UnWrap(browser), mode, CefString(title),
|
||||
CefString(default_file_path), list, selected_accept_filter,
|
||||
TCefFileDialogCallbackRef.UnWrap(callback)));
|
||||
try
|
||||
try
|
||||
TempSL := TStringList.Create;
|
||||
i := 0;
|
||||
j := cef_string_list_size(accept_filters);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(accept_filters, i, @TempString);
|
||||
TempSL.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
Result := Ord(TCefDialogHandlerOwn(CefGetObject(self)).OnFileDialog(TCefBrowserRef.UnWrap(browser),
|
||||
mode,
|
||||
CefString(title),
|
||||
CefString(default_file_path),
|
||||
TempSL,
|
||||
selected_accept_filter,
|
||||
TCefFileDialogCallbackRef.UnWrap(callback)));
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('cef_dialog_handler_on_file_dialog', e) then raise;
|
||||
end;
|
||||
finally
|
||||
list.Free;
|
||||
if (TempSL <> nil) then FreeAndNil(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -48,9 +48,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
@ -149,24 +149,43 @@ begin
|
||||
Result := PCefDictionaryValue(FData).get_int(PCefDictionaryValue(FData), @k);
|
||||
end;
|
||||
|
||||
function TCefDictionaryValueRef.GetKeys(const keys: TStrings): Boolean;
|
||||
function TCefDictionaryValueRef.GetKeys(const keys : TStrings): Boolean;
|
||||
var
|
||||
list: TCefStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
TempSL : TCefStringList;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := cef_string_list_alloc;
|
||||
TempSL := nil;
|
||||
Result := False;
|
||||
|
||||
try
|
||||
Result := PCefDictionaryValue(FData).get_keys(PCefDictionaryValue(FData), list) <> 0;
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
for i := 0 to cef_string_list_size(list) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(list, i, @str);
|
||||
keys.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
if (keys <> nil) then
|
||||
begin
|
||||
TempSL := cef_string_list_alloc;
|
||||
|
||||
if (PCefDictionaryValue(FData).get_keys(PCefDictionaryValue(FData), TempSL) <> 0) then
|
||||
begin
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempSL);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempSL, i, @TempString);
|
||||
keys.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefDictionaryValueRef.GetKeys', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
if (TempSL <> nil) then cef_string_list_free(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -123,26 +123,37 @@ begin
|
||||
OnTitleChange(TCefBrowserRef.UnWrap(browser), CefString(title));
|
||||
end;
|
||||
|
||||
procedure cef_display_handler_on_favicon_urlchange(self: PCefDisplayHandler;
|
||||
browser: PCefBrowser;
|
||||
icon_urls: TCefStringList); stdcall;
|
||||
procedure cef_display_handler_on_favicon_urlchange(self : PCefDisplayHandler;
|
||||
browser : PCefBrowser;
|
||||
icon_urls : TCefStringList); stdcall;
|
||||
var
|
||||
list: TStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
TempSL : TStringList;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := TStringList.Create;
|
||||
TempSL := nil;
|
||||
|
||||
try
|
||||
for i := 0 to cef_string_list_size(icon_urls) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(icon_urls, i, @str);
|
||||
list.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
TempSL := TStringList.Create;
|
||||
i := 0;
|
||||
j := cef_string_list_size(icon_urls);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(icon_urls, i, @TempString);
|
||||
TempSL.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
TCefDisplayHandlerOwn(CefGetObject(self)).OnFaviconUrlChange(TCefBrowserRef.UnWrap(browser), TempSL);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('cef_display_handler_on_favicon_urlchange', e) then raise;
|
||||
end;
|
||||
with TCefDisplayHandlerOwn(CefGetObject(self)) do
|
||||
OnFaviconUrlChange(TCefBrowserRef.UnWrap(browser), list);
|
||||
finally
|
||||
list.Free;
|
||||
if (TempSL <> nil) then FreeAndNil(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -48,9 +48,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
@ -70,7 +70,7 @@ type
|
||||
function GetFragmentBaseUrl: ustring;
|
||||
function GetFileName: ustring;
|
||||
function GetFileContents(const writer: ICefStreamWriter): NativeUInt;
|
||||
function GetFileNames(names: TStrings): Integer;
|
||||
function GetFileNames(var names: TStrings): Integer;
|
||||
procedure SetLinkUrl(const url: ustring);
|
||||
procedure SetLinkTitle(const title: ustring);
|
||||
procedure SetLinkMetadata(const data: ustring);
|
||||
@ -132,23 +132,43 @@ begin
|
||||
Result := CefStringFreeAndGet(PCefDragData(FData).get_file_name(FData));
|
||||
end;
|
||||
|
||||
function TCefDragDataRef.GetFileNames(names: TStrings): Integer;
|
||||
function TCefDragDataRef.GetFileNames(var names: TStrings): Integer;
|
||||
var
|
||||
list: TCefStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
TempSL : TCefStringList;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := cef_string_list_alloc;
|
||||
TempSL := nil;
|
||||
Result := 0;
|
||||
|
||||
try
|
||||
Result := PCefDragData(FData).get_file_names(FData, list);
|
||||
for i := 0 to cef_string_list_size(list) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(list, i, @str);
|
||||
names.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
if (names <> nil) then
|
||||
begin
|
||||
TempSL := cef_string_list_alloc;
|
||||
|
||||
if (PCefDragData(FData).get_file_names(FData, TempSL) <> 0) then
|
||||
begin
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempSL);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempSL, i, @TempString);
|
||||
names.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
Result := j;
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefDragDataRef.GetFileNames', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
if (TempSL <> nil) then cef_string_list_free(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -57,7 +57,7 @@ uses
|
||||
type
|
||||
TCefFileDialogCallbackRef = class(TCefBaseRefCountedRef, ICefFileDialogCallback)
|
||||
protected
|
||||
procedure Cont(selectedAcceptFilter: Integer; filePaths: TStrings);
|
||||
procedure Cont(selectedAcceptFilter: Integer; const filePaths: TStrings);
|
||||
procedure Cancel;
|
||||
public
|
||||
class function UnWrap(data: Pointer): ICefFileDialogCallback;
|
||||
@ -73,7 +73,7 @@ begin
|
||||
PCefFileDialogCallback(FData).cancel(FData);
|
||||
end;
|
||||
|
||||
procedure TCefFileDialogCallbackRef.Cont(selectedAcceptFilter: Integer; filePaths: TStrings);
|
||||
procedure TCefFileDialogCallbackRef.Cont(selectedAcceptFilter: Integer; const filePaths: TStrings);
|
||||
var
|
||||
list: TCefStringList;
|
||||
i: Integer;
|
||||
@ -92,11 +92,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TCefFileDialogCallbackRef.UnWrap(
|
||||
data: Pointer): ICefFileDialogCallback;
|
||||
class function TCefFileDialogCallbackRef.UnWrap(data: Pointer): ICefFileDialogCallback;
|
||||
begin
|
||||
if data <> nil then
|
||||
Result := Create(data) as ICefFileDialogCallback else
|
||||
if (data <> nil) then
|
||||
Result := Create(data) as ICefFileDialogCallback
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
|
@ -189,8 +189,8 @@ type
|
||||
function GetRequestContext: ICefRequestContext;
|
||||
function GetZoomLevel: Double;
|
||||
procedure SetZoomLevel(zoomLevel: Double);
|
||||
procedure RunFileDialog(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefRunFileDialogCallback);
|
||||
procedure RunFileDialogProc(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: TCefRunFileDialogCallbackProc);
|
||||
procedure RunFileDialog(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefRunFileDialogCallback);
|
||||
procedure RunFileDialogProc(mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: TCefRunFileDialogCallbackProc);
|
||||
procedure StartDownload(const url: ustring);
|
||||
procedure DownloadImage(const imageUrl: ustring; isFavicon: Boolean; maxImageSize: Cardinal; bypassCache: Boolean; const callback: ICefDownloadImageCallback);
|
||||
procedure Print;
|
||||
@ -840,17 +840,17 @@ type
|
||||
procedure InitFromString(const commandLine: ustring);
|
||||
procedure Reset;
|
||||
function GetCommandLineString: ustring;
|
||||
procedure GetArgv(args: TStrings);
|
||||
procedure GetArgv(var args: TStrings);
|
||||
function GetProgram: ustring;
|
||||
procedure SetProgram(const prog: ustring);
|
||||
function HasSwitches: Boolean;
|
||||
function HasSwitch(const name: ustring): Boolean;
|
||||
function GetSwitchValue(const name: ustring): ustring;
|
||||
procedure GetSwitches(switches: TStrings);
|
||||
procedure GetSwitches(var switches: TStrings);
|
||||
procedure AppendSwitch(const name: ustring);
|
||||
procedure AppendSwitchWithValue(const name, value: ustring);
|
||||
function HasArguments: Boolean;
|
||||
procedure GetArguments(arguments: TStrings);
|
||||
procedure GetArguments(var arguments: TStrings);
|
||||
procedure AppendArgument(const argument: ustring);
|
||||
procedure PrependWrapper(const wrapper: ustring);
|
||||
property CommandLineString: ustring read GetCommandLineString;
|
||||
@ -924,8 +924,8 @@ type
|
||||
|
||||
ICefCookieManager = Interface(ICefBaseRefCounted)
|
||||
['{CC1749E6-9AD3-4283-8430-AF6CBF3E8785}']
|
||||
procedure SetSupportedSchemes(schemes: TStrings; const callback: ICefCompletionCallback);
|
||||
procedure SetSupportedSchemesProc(schemes: TStrings; const callback: TCefCompletionCallbackProc);
|
||||
procedure SetSupportedSchemes(const schemes: TStrings; const callback: ICefCompletionCallback);
|
||||
procedure SetSupportedSchemesProc(const schemes: TStrings; const callback: TCefCompletionCallbackProc);
|
||||
function VisitAllCookies(const visitor: ICefCookieVisitor): Boolean;
|
||||
function VisitAllCookiesProc(const visitor: TCefCookieVisitorProc): Boolean;
|
||||
function VisitUrlCookies(const url: ustring;
|
||||
@ -1467,7 +1467,7 @@ type
|
||||
|
||||
ICefFileDialogCallback = interface(ICefBaseRefCounted)
|
||||
['{1AF659AB-4522-4E39-9C52-184000D8E3C7}']
|
||||
procedure Cont(selectedAcceptFilter: Integer; filePaths: TStrings);
|
||||
procedure Cont(selectedAcceptFilter: Integer; const filePaths: TStrings);
|
||||
procedure Cancel;
|
||||
end;
|
||||
|
||||
@ -1486,7 +1486,7 @@ type
|
||||
function GetFragmentBaseUrl: ustring;
|
||||
function GetFileName: ustring;
|
||||
function GetFileContents(const writer: ICefStreamWriter): NativeUInt;
|
||||
function GetFileNames(names: TStrings): Integer;
|
||||
function GetFileNames(var names: TStrings): Integer;
|
||||
procedure SetLinkUrl(const url: ustring);
|
||||
procedure SetLinkTitle(const title: ustring);
|
||||
procedure SetLinkMetadata(const data: ustring);
|
||||
|
@ -150,7 +150,7 @@ function CefParseUrl(const url: ustring; var parts: TUrlParts): Boolean;
|
||||
function CefCreateUrl(var parts: TUrlParts): ustring;
|
||||
function CefFormatUrlForSecurityDisplay(const originUrl: string): string;
|
||||
function CefGetMimeType(const extension: ustring): ustring;
|
||||
procedure CefGetExtensionsForMimeType(const mimeType: ustring; extensions: TStringList);
|
||||
procedure CefGetExtensionsForMimeType(const mimeType: ustring; var extensions: TStringList);
|
||||
|
||||
function CefBase64Encode(const data: Pointer; dataSize: NativeUInt): ustring;
|
||||
function CefBase64Decode(const data: ustring): ICefBinaryValue;
|
||||
@ -256,7 +256,7 @@ begin
|
||||
if (aSrcSL <> nil) and (aDstSL <> nil) then
|
||||
begin
|
||||
i := 0;
|
||||
j := pred(cef_string_list_size(aSrcSL));
|
||||
j := cef_string_list_size(aSrcSL);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
@ -1073,24 +1073,40 @@ begin
|
||||
Result := CefStringFreeAndGet(cef_get_mime_type(@s));
|
||||
end;
|
||||
|
||||
procedure CefGetExtensionsForMimeType(const mimeType: ustring; extensions: TStringList);
|
||||
procedure CefGetExtensionsForMimeType(const mimeType: ustring; var extensions: TStringList);
|
||||
var
|
||||
list: TCefStringList;
|
||||
s, str: TCefString;
|
||||
i: Integer;
|
||||
TempSL : TCefStringList;
|
||||
TempMimeType, TempString : TCefString;
|
||||
i, j : NativeUInt;
|
||||
begin
|
||||
list := cef_string_list_alloc();
|
||||
TempSL := nil;
|
||||
|
||||
try
|
||||
s := CefString(mimeType);
|
||||
cef_get_extensions_for_mime_type(@s, list);
|
||||
for i := 0 to cef_string_list_size(list) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(list, i, @str);
|
||||
extensions.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
if (extensions <> nil) then
|
||||
begin
|
||||
TempSL := cef_string_list_alloc;
|
||||
TempMimeType := CefString(mimeType);
|
||||
|
||||
cef_get_extensions_for_mime_type(@TempMimeType, TempSL);
|
||||
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempSL);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempSL, i, @TempString);
|
||||
extensions.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('CefGetExtensionsForMimeType', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
if (TempSL <> nil) then cef_string_list_free(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -48,9 +48,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
@ -86,8 +86,7 @@ begin
|
||||
Result := PCefPostData(FData)^.has_excluded_elements(PCefPostData(FData)) <> 0;
|
||||
end;
|
||||
|
||||
function TCefPostDataRef.AddElement(
|
||||
const element: ICefPostDataElement): Integer;
|
||||
function TCefPostDataRef.AddElement(const element: ICefPostDataElement): Integer;
|
||||
begin
|
||||
Result := PCefPostData(FData)^.add_element(PCefPostData(FData), CefGetData(element));
|
||||
end;
|
||||
@ -99,18 +98,33 @@ end;
|
||||
|
||||
function TCefPostDataRef.GetElements(Count: NativeUInt): IInterfaceList;
|
||||
var
|
||||
items: PCefPostDataElementArray;
|
||||
i: Integer;
|
||||
items : PCefPostDataElementArray;
|
||||
i : NativeUInt;
|
||||
begin
|
||||
Result := TInterfaceList.Create;
|
||||
GetMem(items, SizeOf(PCefPostDataElement) * Count);
|
||||
FillChar(items^, SizeOf(PCefPostDataElement) * Count, 0);
|
||||
Result := nil;
|
||||
items := nil;
|
||||
|
||||
try
|
||||
PCefPostData(FData)^.get_elements(PCefPostData(FData), @Count, items);
|
||||
for i := 0 to Count - 1 do
|
||||
Result.Add(TCefPostDataElementRef.UnWrap(items[i]));
|
||||
try
|
||||
GetMem(items, SizeOf(PCefPostDataElement) * Count);
|
||||
FillChar(items^, SizeOf(PCefPostDataElement) * Count, 0);
|
||||
|
||||
PCefPostData(FData)^.get_elements(PCefPostData(FData), @Count, items);
|
||||
|
||||
Result := TInterfaceList.Create;
|
||||
i := 0;
|
||||
|
||||
while (i < Count) do
|
||||
begin
|
||||
Result.Add(TCefPostDataElementRef.UnWrap(items[i]));
|
||||
inc(i);
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefPostDataRef.GetElements', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FreeMem(items);
|
||||
if (items <> nil) then FreeMem(items);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -48,9 +48,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
@ -237,22 +237,28 @@ function TCefRequestContextRef.ResolveHostCached(const origin : ustring;
|
||||
const resolvedIps : TStrings): TCefErrorCode;
|
||||
var
|
||||
ips : TCefStringList;
|
||||
o, str : TCefString;
|
||||
i : Integer;
|
||||
TempOrigin, TempString : TCefString;
|
||||
i, j : NativeUInt;
|
||||
begin
|
||||
ips := cef_string_list_alloc;
|
||||
|
||||
try
|
||||
o := CefString(origin);
|
||||
Result := PCefRequestContext(FData).resolve_host_cached(FData, @o, ips);
|
||||
TempOrigin := CefString(origin);
|
||||
Result := PCefRequestContext(FData).resolve_host_cached(FData, @TempOrigin, ips);
|
||||
|
||||
if Assigned(ips) then
|
||||
for i := 0 to cef_string_list_size(ips) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(ips, i, @str);
|
||||
resolvedIps.Add(CefStringClearAndGet(str));
|
||||
end;
|
||||
if (resolvedIps <> nil) and (ips <> nil) then
|
||||
begin
|
||||
i := 0;
|
||||
j := cef_string_list_size(ips);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(ips, i, @TempString);
|
||||
resolvedIps.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(ips);
|
||||
end;
|
||||
@ -285,29 +291,40 @@ end;
|
||||
function TCefRequestContextRef.GetExtensions(const extension_ids: TStringList): boolean;
|
||||
var
|
||||
TempIDs : TCefStringList;
|
||||
i, j : integer;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
TempIDs := cef_string_list_alloc;
|
||||
TempIDs := nil;
|
||||
Result := False;
|
||||
|
||||
try
|
||||
Result := PCefRequestContext(FData).get_extensions(FData, TempIDs) <> 0;
|
||||
try
|
||||
if (extension_ids <> nil) then
|
||||
begin
|
||||
TempIDs := cef_string_list_alloc;
|
||||
|
||||
if Assigned(TempIDs) then
|
||||
begin
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempIDs);
|
||||
if (PCefRequestContext(FData).get_extensions(PCefRequestContext(FData), TempIDs) <> 0) then
|
||||
begin
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempIDs);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempIDs, i, @TempString);
|
||||
extension_ids.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempIDs, i, @TempString);
|
||||
extension_ids.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefRequestContextRef.GetExtensions', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(TempIDs);
|
||||
if (TempIDs <> nil) then cef_string_list_free(TempIDs);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -84,8 +84,8 @@ procedure cef_resolve_callback_on_resolve_completed(self: PCefResolveCallback;
|
||||
resolved_ips: TCefStringList); stdcall;
|
||||
var
|
||||
TempSL : TStringList;
|
||||
i, j : Integer;
|
||||
str: TCefString;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
TempSL := nil;
|
||||
|
||||
@ -97,9 +97,9 @@ begin
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(resolved_ips, i, @str);
|
||||
TempSL.Add(CefStringClearAndGet(str));
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(resolved_ips, i, @TempString);
|
||||
TempSL.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
|
@ -48,9 +48,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces;
|
||||
|
||||
@ -78,24 +78,37 @@ implementation
|
||||
uses
|
||||
uCEFTypes, uCEFMiscFunctions, uCEFLibFunctions;
|
||||
|
||||
procedure cef_run_file_dialog_callback_on_file_dialog_dismissed(self: PCefRunFileDialogCallback; selected_accept_filter: Integer; file_paths: TCefStringList); stdcall;
|
||||
procedure cef_run_file_dialog_callback_on_file_dialog_dismissed(self : PCefRunFileDialogCallback;
|
||||
selected_accept_filter : Integer;
|
||||
file_paths : TCefStringList); stdcall;
|
||||
var
|
||||
TempSL : TStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
TempSL := TStringList.Create;
|
||||
TempSL := nil;
|
||||
|
||||
try
|
||||
for i := 0 to cef_string_list_size(file_paths) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(file_paths, i, @str);
|
||||
TempSL.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
TempSL := TStringList.Create;
|
||||
i := 0;
|
||||
j := cef_string_list_size(file_paths);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(file_paths, i, @TempString);
|
||||
TempSL.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
TCefRunFileDialogCallbackOwn(CefGetObject(self)).OnFileDialogDismissed(selected_accept_filter, TempSL);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('cef_run_file_dialog_callback_on_file_dialog_dismissed', e) then raise;
|
||||
end;
|
||||
with TCefRunFileDialogCallbackOwn(CefGetObject(self)) do
|
||||
OnFileDialogDismissed(selected_accept_filter, TempSL);
|
||||
finally
|
||||
TempSL.Free;
|
||||
if (TempSL <> nil) then FreeAndNil(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -99,46 +99,64 @@ implementation
|
||||
uses
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFv8Value, uCEFConstants;
|
||||
|
||||
function cef_v8_handler_execute(self: PCefv8Handler;
|
||||
const name: PCefString; obj: PCefv8Value; argumentsCount: NativeUInt;
|
||||
const arguments: PPCefV8Value; var retval: PCefV8Value;
|
||||
var exception: TCefString): Integer; stdcall;
|
||||
function cef_v8_handler_execute(self : PCefv8Handler;
|
||||
const name : PCefString;
|
||||
obj : PCefv8Value;
|
||||
argumentsCount : NativeUInt;
|
||||
const arguments : PPCefV8Value;
|
||||
var retval : PCefV8Value;
|
||||
var exception : TCefString): Integer; stdcall;
|
||||
var
|
||||
args: TCefv8ValueArray;
|
||||
i: NativeInt;
|
||||
ret: ICefv8Value;
|
||||
exc: ustring;
|
||||
args : TCefv8ValueArray;
|
||||
i, j : NativeInt;
|
||||
ret : ICefv8Value;
|
||||
exc : ustring;
|
||||
begin
|
||||
SetLength(args, argumentsCount);
|
||||
for i := 0 to argumentsCount - 1 do
|
||||
args[i] := TCefv8ValueRef.UnWrap(arguments[i]);
|
||||
i := 0;
|
||||
j := argumentsCount;
|
||||
|
||||
Result := -Ord(TCefv8HandlerOwn(CefGetObject(self)).Execute(
|
||||
CefString(name), TCefv8ValueRef.UnWrap(obj), args, ret, exc));
|
||||
retval := CefGetData(ret);
|
||||
ret := nil;
|
||||
SetLength(args, j);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
args[i] := TCefv8ValueRef.UnWrap(arguments[i]);
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
Result := -Ord(TCefv8HandlerOwn(CefGetObject(self)).Execute(CefString(name), TCefv8ValueRef.UnWrap(obj), args, ret, exc));
|
||||
retval := CefGetData(ret);
|
||||
ret := nil;
|
||||
exception := CefString(exc);
|
||||
end;
|
||||
|
||||
function TCefv8HandlerRef.Execute(const name: ustring; const obj: ICefv8Value;
|
||||
const arguments: TCefv8ValueArray; var retval: ICefv8Value;
|
||||
var exception: ustring): Boolean;
|
||||
function TCefv8HandlerRef.Execute(const name : ustring;
|
||||
const obj : ICefv8Value;
|
||||
const arguments : TCefv8ValueArray;
|
||||
var retval : ICefv8Value;
|
||||
var exception : ustring): Boolean;
|
||||
var
|
||||
args: array of PCefV8Value;
|
||||
i: Integer;
|
||||
ret: PCefV8Value;
|
||||
exc: TCefString;
|
||||
n: TCefString;
|
||||
args : array of PCefV8Value;
|
||||
i, j : Integer;
|
||||
ret : PCefV8Value;
|
||||
exc : TCefString;
|
||||
n : TCefString;
|
||||
begin
|
||||
SetLength(args, Length(arguments));
|
||||
for i := 0 to Length(arguments) - 1 do
|
||||
args[i] := CefGetData(arguments[i]);
|
||||
ret := nil;
|
||||
i := 0;
|
||||
j := Length(arguments);
|
||||
|
||||
SetLength(args, j);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
args[i] := CefGetData(arguments[i]);
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
FillChar(exc, SizeOf(exc), 0);
|
||||
n := CefString(name);
|
||||
Result := PCefv8Handler(FData)^.execute(PCefv8Handler(FData), @n,
|
||||
CefGetData(obj), Length(arguments), @args, ret, exc) <> 0;
|
||||
retval := TCefv8ValueRef.UnWrap(ret);
|
||||
ret := nil;
|
||||
n := CefString(name);
|
||||
Result := PCefv8Handler(FData).execute(PCefv8Handler(FData), @n, CefGetData(obj), Length(arguments), @args, ret, exc) <> 0;
|
||||
retval := TCefv8ValueRef.UnWrap(ret);
|
||||
exception := CefStringClearAndGet(exc);
|
||||
end;
|
||||
|
||||
@ -323,9 +341,9 @@ function TCefRTTIExtension.GetValue(pi: PTypeInfo; const v: ICefv8Value; var ret
|
||||
|
||||
function ProcessVariant: Boolean;
|
||||
var
|
||||
vr: Variant;
|
||||
i: Integer;
|
||||
vl: TValue;
|
||||
vr : Variant;
|
||||
i, j : Integer;
|
||||
vl : TValue;
|
||||
begin
|
||||
VarClear(vr);
|
||||
if v.IsString then vr := v.GetStringValue else
|
||||
@ -336,14 +354,20 @@ function TCefRTTIExtension.GetValue(pi: PTypeInfo; const v: ICefv8Value; var ret
|
||||
if v.IsNull then TVarData(vr).VType := varNull else
|
||||
if v.IsArray then
|
||||
begin
|
||||
vr := VarArrayCreate([0, v.GetArrayLength], varVariant);
|
||||
for i := 0 to v.GetArrayLength - 1 do
|
||||
begin
|
||||
if not GetValue(pi, v.GetValueByIndex(i), vl) then Exit(False);
|
||||
VarArrayPut(vr, vl.AsVariant, i);
|
||||
end;
|
||||
i := 0;
|
||||
j := v.GetArrayLength;
|
||||
vr := VarArrayCreate([0, j], varVariant);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
if not GetValue(pi, v.GetValueByIndex(i), vl) then Exit(False);
|
||||
VarArrayPut(vr, vl.AsVariant, i);
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
end else
|
||||
Exit(False);
|
||||
|
||||
TValue.Make(@vr, pi, ret);
|
||||
Result := True;
|
||||
end;
|
||||
|
@ -48,9 +48,9 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
System.Classes, System.SysUtils,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFv8Types;
|
||||
|
||||
@ -222,37 +222,80 @@ begin
|
||||
Result := PCefV8Value(FData)^.delete_value_bykey(PCefV8Value(FData), @k) <> 0;
|
||||
end;
|
||||
|
||||
function TCefv8ValueRef.ExecuteFunction(const obj: ICefv8Value;
|
||||
const arguments: TCefv8ValueArray): ICefv8Value;
|
||||
function TCefv8ValueRef.ExecuteFunction(const obj: ICefv8Value; const arguments: TCefv8ValueArray): ICefv8Value;
|
||||
var
|
||||
args: PPCefV8Value;
|
||||
i: Integer;
|
||||
args : PPCefV8Value;
|
||||
i, j : NativeUInt;
|
||||
begin
|
||||
GetMem(args, SizeOf(PCefV8Value) * Length(arguments));
|
||||
Result := nil;
|
||||
args := nil;
|
||||
|
||||
try
|
||||
for i := 0 to Length(arguments) - 1 do
|
||||
args[i] := CefGetData(arguments[i]);
|
||||
Result := TCefv8ValueRef.UnWrap(PCefV8Value(FData)^.execute_function(PCefV8Value(FData),
|
||||
CefGetData(obj), Length(arguments), args));
|
||||
try
|
||||
if (arguments <> nil) then
|
||||
begin
|
||||
i := 0;
|
||||
j := Length(arguments);
|
||||
|
||||
GetMem(args, SizeOf(PCefV8Value) * j);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
args[i] := CefGetData(arguments[i]);
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
Result := TCefv8ValueRef.UnWrap(PCefV8Value(FData).execute_function(PCefV8Value(FData),
|
||||
CefGetData(obj),
|
||||
j,
|
||||
args));
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefv8ValueRef.ExecuteFunction', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FreeMem(args);
|
||||
if (args <> nil) then FreeMem(args);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCefv8ValueRef.ExecuteFunctionWithContext(const context: ICefv8Context;
|
||||
const obj: ICefv8Value; const arguments: TCefv8ValueArray): ICefv8Value;
|
||||
function TCefv8ValueRef.ExecuteFunctionWithContext(const context : ICefv8Context;
|
||||
const obj : ICefv8Value;
|
||||
const arguments : TCefv8ValueArray): ICefv8Value;
|
||||
var
|
||||
args: PPCefV8Value;
|
||||
i: Integer;
|
||||
args : PPCefV8Value;
|
||||
i, j : NativeUInt;
|
||||
begin
|
||||
GetMem(args, SizeOf(PCefV8Value) * Length(arguments));
|
||||
Result := nil;
|
||||
args := nil;
|
||||
|
||||
try
|
||||
for i := 0 to Length(arguments) - 1 do
|
||||
args[i] := CefGetData(arguments[i]);
|
||||
Result := TCefv8ValueRef.UnWrap(PCefV8Value(FData)^.execute_function_with_context(PCefV8Value(FData),
|
||||
CefGetData(context), CefGetData(obj), Length(arguments), args));
|
||||
try
|
||||
if (arguments <> nil) then
|
||||
begin
|
||||
i := 0;
|
||||
j := Length(arguments);
|
||||
|
||||
GetMem(args, SizeOf(PCefV8Value) * j);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
args[i] := CefGetData(arguments[i]);
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
Result := TCefv8ValueRef.UnWrap(PCefV8Value(FData).execute_function_with_context(PCefV8Value(FData),
|
||||
CefGetData(context),
|
||||
CefGetData(obj),
|
||||
j,
|
||||
args));
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefv8ValueRef.ExecuteFunctionWithContext', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FreeMem(args);
|
||||
if (args <> nil) then FreeMem(args);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -303,22 +346,41 @@ end;
|
||||
|
||||
function TCefv8ValueRef.GetKeys(const keys: TStrings): Integer;
|
||||
var
|
||||
list: TCefStringList;
|
||||
i: Integer;
|
||||
str: TCefString;
|
||||
TempSL : TCefStringList;
|
||||
i, j : NativeUInt;
|
||||
TempString : TCefString;
|
||||
begin
|
||||
list := cef_string_list_alloc;
|
||||
TempSL := nil;
|
||||
Result := 0;
|
||||
|
||||
try
|
||||
Result := PCefV8Value(FData)^.get_keys(PCefV8Value(FData), list);
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
for i := 0 to cef_string_list_size(list) - 1 do
|
||||
begin
|
||||
FillChar(str, SizeOf(str), 0);
|
||||
cef_string_list_value(list, i, @str);
|
||||
keys.Add(CefStringClearAndGet(str));
|
||||
try
|
||||
if (keys <> nil) then
|
||||
begin
|
||||
TempSL := cef_string_list_alloc;
|
||||
|
||||
if (PCefV8Value(FData).get_keys(PCefV8Value(FData), TempSL) <> 0) then
|
||||
begin
|
||||
i := 0;
|
||||
j := cef_string_list_size(TempSL);
|
||||
|
||||
while (i < j) do
|
||||
begin
|
||||
FillChar(TempString, SizeOf(TempString), 0);
|
||||
cef_string_list_value(TempSL, i, @TempString);
|
||||
keys.Add(CefStringClearAndGet(TempString));
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
Result := j;
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefv8ValueRef.GetKeys', e) then raise;
|
||||
end;
|
||||
finally
|
||||
cef_string_list_free(list);
|
||||
if (TempSL <> nil) then cef_string_list_free(TempSL);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user