1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-06-12 22:07:39 +02:00
Files
.github
bin
demos
packages
source
res
00-DeleteDCUs.bat
cef.inc
uCEFAccessibilityHandler.pas
uCEFApp.pas
uCEFApplication.pas
uCEFApplicationCore.pas
uCEFAudioHandler.pas
uCEFAuthCallback.pas
uCEFBaseRefCounted.pas
uCEFBaseScopedWrapper.pas
uCEFBeforeDownloadCallback.pas
uCEFBinaryValue.pas
uCEFBitmapBitBuffer.pas
uCEFBoxLayout.pas
uCEFBrowser.pas
uCEFBrowserProcessHandler.pas
uCEFBrowserView.pas
uCEFBrowserViewComponent.pas
uCEFBrowserViewDelegate.pas
uCEFBufferPanel.pas
uCEFButton.pas
uCEFButtonComponent.pas
uCEFButtonDelegate.pas
uCEFCallback.pas
uCEFChromium.pas
uCEFChromiumCore.pas
uCEFChromiumEvents.pas
uCEFChromiumFontOptions.pas
uCEFChromiumOptions.pas
uCEFChromiumWindow.pas
uCEFClient.pas
uCEFCommandLine.pas
uCEFCompletionCallback.pas
uCEFConstants.pas
uCEFContextMenuHandler.pas
uCEFContextMenuParams.pas
uCEFCookieAccessFilter.pas
uCEFCookieManager.pas
uCEFCookieVisitor.pas
uCEFCustomStreamReader.pas
uCEFDeleteCookiesCallback.pas
uCEFDevToolsMessageObserver.pas
uCEFDialogHandler.pas
uCEFDictionaryValue.pas
uCEFDisplay.pas
uCEFDisplayHandler.pas
uCEFDomDocument.pas
uCEFDomNode.pas
uCEFDomVisitor.pas
uCEFDownLoadItem.pas
uCEFDownloadHandler.pas
uCEFDownloadImageCallBack.pas
uCEFDownloadItemCallback.pas
uCEFDragAndDropMgr.pas
uCEFDragData.pas
uCEFDragHandler.pas
uCEFEndTracingCallback.pas
uCEFExtension.pas
uCEFExtensionHandler.pas
uCEFFMXBufferPanel.pas
uCEFFMXChromium.pas
uCEFFMXWindowParent.pas
uCEFFMXWorkScheduler.pas
uCEFFileDialogCallback.pas
uCEFFillLayout.pas
uCEFFindHandler.pas
uCEFFocusHandler.pas
uCEFFrame.pas
uCEFGetExtensionResourceCallback.pas
uCEFImage.pas
uCEFInterfaces.pas
uCEFJsDialogCallback.pas
uCEFJsDialogHandler.pas
uCEFJson.pas
uCEFKeyboardHandler.pas
uCEFLabelButton.pas
uCEFLabelButtonComponent.pas
uCEFLayout.pas
uCEFLibFunctions.pas
uCEFLifeSpanHandler.pas
uCEFLinkedWindowParent.pas
uCEFListValue.pas
uCEFLoadHandler.pas
uCEFMediaObserver.pas
uCEFMediaRoute.pas
uCEFMediaRouteCreateCallback.pas
uCEFMediaRouter.pas
uCEFMediaSink.pas
uCEFMediaSinkDeviceInfoCallback.pas
uCEFMediaSource.pas
uCEFMenuButton.pas
uCEFMenuButtonComponent.pas
uCEFMenuButtonDelegate.pas
uCEFMenuButtonPressedLock.pas
uCEFMenuModel.pas
uCEFMenuModelDelegate.pas
uCEFMiscFunctions.pas
uCEFNavigationEntry.pas
uCEFNavigationEntryVisitor.pas
uCEFOAuth2Helper.pas
uCEFOLEDragAndDrop.pas
uCEFOSRIMEHandler.pas
uCEFPDFPrintCallback.pas
uCEFPDFPrintOptions.pas
uCEFPanel.pas
uCEFPanelComponent.pas
uCEFPanelDelegate.pas
uCEFPostData.pas
uCEFPostDataElement.pas
uCEFPrintDialogCallback.pas
uCEFPrintHandler.pas
uCEFPrintJobCallback.pas
uCEFPrintSettings.pas
uCEFProcessMessage.pas
uCEFRegisterCDMCallback.pas
uCEFRegistration.pas
uCEFRenderHandler.pas
uCEFRenderProcessHandler.pas
uCEFRequest.pas
uCEFRequestCallback.pas
uCEFRequestContext.pas
uCEFRequestContextHandler.pas
uCEFRequestHandler.pas
uCEFResolveCallback.pas
uCEFResourceBundle.pas
uCEFResourceBundleHandler.pas
uCEFResourceHandler.pas
uCEFResourceReadCallback.pas
uCEFResourceRequestHandler.pas
uCEFResourceSkipCallback.pas
uCEFResponse.pas
uCEFResponseFilter.pas
uCEFRunContextMenuCallback.pas
uCEFRunFileDialogCallback.pas
uCEFSSLStatus.pas
uCEFSchemeHandlerFactory.pas
uCEFSchemeRegistrar.pas
uCEFScrollView.pas
uCEFScrollViewComponent.pas
uCEFSelectClientCertificateCallback.pas
uCEFSentinel.pas
uCEFServer.pas
uCEFServerComponent.pas
uCEFServerEvents.pas
uCEFServerHandler.pas
uCEFSetCookieCallback.pas
uCEFSslInfo.pas
uCEFStreamReader.pas
uCEFStreamWriter.pas
uCEFStringList.pas
uCEFStringMap.pas
uCEFStringMultimap.pas
uCEFStringVisitor.pas
uCEFTask.pas
uCEFTaskRunner.pas
uCEFTextfield.pas
uCEFTextfieldComponent.pas
uCEFTextfieldDelegate.pas
uCEFThread.pas
uCEFTypes.pas
uCEFUrlRequest.pas
uCEFUrlRequestClientComponent.pas
uCEFUrlRequestClientEvents.pas
uCEFUrlrequestClient.pas
uCEFValue.pas
uCEFView.pas
uCEFViewComponent.pas
uCEFViewDelegate.pas
uCEFViewsFrameworkEvents.pas
uCEFWaitableEvent.pas
uCEFWebPluginInfo.pas
uCEFWebPluginInfoVisitor.pas
uCEFWebPluginUnstableCallback.pas
uCEFWinControl.pas
uCEFWindow.pas
uCEFWindowComponent.pas
uCEFWindowDelegate.pas
uCEFWindowParent.pas
uCEFWorkScheduler.pas
uCEFWorkSchedulerThread.pas
uCEFWriteHandler.pas
uCEFX509CertPrincipal.pas
uCEFX509Certificate.pas
uCEFXmlReader.pas
uCEFZipReader.pas
uCEFv8Accessor.pas
uCEFv8ArrayBufferReleaseCallback.pas
uCEFv8Context.pas
uCEFv8Exception.pas
uCEFv8Handler.pas
uCEFv8Interceptor.pas
uCEFv8StackFrame.pas
uCEFv8StackTrace.pas
uCEFv8Value.pas
tools
.gitignore
Delphinus.Info.json
Delphinus.Install.json
LICENSE.md
README.md
update_CEF4Delphi.json
CEF4Delphi/source/uCEFCommandLine.pas

331 lines
9.5 KiB
ObjectPascal
Raw Normal View History

2017-01-27 17:29:37 +01:00
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
2017-01-27 17:29:37 +01:00
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
2021-01-01 11:11:30 +01:00
// Copyright � 2021 Salvador Diaz Fau. All rights reserved.
2017-01-27 17:29:37 +01:00
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
unit uCEFCommandLine;
{$IFDEF FPC}
{$MODE OBJFPC}{$H+}
{$ENDIF}
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
{$MINENUMSIZE 4}
2017-01-27 17:29:37 +01:00
2017-02-05 20:56:46 +01:00
{$I cef.inc}
2017-01-27 17:29:37 +01:00
interface
uses
2017-02-05 20:56:46 +01:00
{$IFDEF DELPHI16_UP}
2018-02-26 18:40:51 +01:00
System.Classes, System.SysUtils,
2017-02-05 20:56:46 +01:00
{$ELSE}
2018-02-26 18:40:51 +01:00
Classes, SysUtils,
2017-02-05 20:56:46 +01:00
{$ENDIF}
uCEFBaseRefCounted, uCEFTypes, uCEFInterfaces;
2017-01-27 17:29:37 +01:00
type
TCefCommandLineRef = class(TCefBaseRefCountedRef, ICefCommandLine)
2017-01-27 17:29:37 +01:00
protected
function IsValid: Boolean;
function IsReadOnly: Boolean;
function Copy: ICefCommandLine;
procedure InitFromArgv(argc: Integer; const argv: PPAnsiChar);
procedure InitFromString(const commandLine: ustring);
procedure Reset;
function GetCommandLineString: ustring;
2018-02-26 18:40:51 +01:00
procedure GetArgv(var args: TStrings);
2017-01-27 17:29:37 +01:00
function GetProgram: ustring;
procedure SetProgram(const prog: ustring);
function HasSwitches: Boolean;
function HasSwitch(const name: ustring): Boolean;
function GetSwitchValue(const name: ustring): ustring;
function GetSwitches(var switches: TStrings): boolean; overload;
function GetSwitches(var SwitchKeys, SwitchValues: TStringList): boolean; overload;
2017-01-27 17:29:37 +01:00
procedure AppendSwitch(const name: ustring);
procedure AppendSwitchWithValue(const name, value: ustring);
function HasArguments: Boolean;
2018-02-26 18:40:51 +01:00
procedure GetArguments(var arguments: TStrings);
2017-01-27 17:29:37 +01:00
procedure AppendArgument(const argument: ustring);
procedure PrependWrapper(const wrapper: ustring);
public
class function UnWrap(data: Pointer): ICefCommandLine;
class function New: ICefCommandLine;
class function Global: ICefCommandLine;
end;
implementation
uses
2018-03-29 20:02:04 +02:00
uCEFMiscFunctions, uCEFLibFunctions, uCEFStringMap, uCefStringList;
2017-01-27 17:29:37 +01:00
procedure TCefCommandLineRef.AppendArgument(const argument: ustring);
var
2018-03-29 20:02:04 +02:00
TempArgument : TCefString;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
TempArgument := CefString(argument);
PCefCommandLine(FData)^.append_argument(PCefCommandLine(FData), @TempArgument);
2017-01-27 17:29:37 +01:00
end;
procedure TCefCommandLineRef.AppendSwitch(const name: ustring);
var
2018-03-29 20:02:04 +02:00
TempName : TCefString;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
TempName := CefString(name);
PCefCommandLine(FData)^.append_switch(PCefCommandLine(FData), @TempName);
2017-01-27 17:29:37 +01:00
end;
procedure TCefCommandLineRef.AppendSwitchWithValue(const name, value: ustring);
var
2018-03-29 20:02:04 +02:00
TempName, TempValue : TCefString;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
TempName := CefString(name);
TempValue := CefString(value);
PCefCommandLine(FData)^.append_switch_with_value(PCefCommandLine(FData), @TempName, @TempValue);
2017-01-27 17:29:37 +01:00
end;
function TCefCommandLineRef.Copy: ICefCommandLine;
begin
Result := UnWrap(PCefCommandLine(FData)^.copy(PCefCommandLine(FData)));
2017-01-27 17:29:37 +01:00
end;
2018-02-26 18:40:51 +01:00
procedure TCefCommandLineRef.GetArguments(var arguments : TStrings);
2017-01-27 17:29:37 +01:00
var
2018-03-29 20:02:04 +02:00
TempSL : ICefStringList;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
if (arguments <> nil) then
begin
TempSL := TCefStringListOwn.Create;
PCefCommandLine(FData)^.get_arguments(PCefCommandLine(FData), TempSL.Handle);
2018-03-29 20:02:04 +02:00
TempSL.CopyToStrings(arguments);
2017-01-27 17:29:37 +01:00
end;
end;
2018-02-26 18:40:51 +01:00
procedure TCefCommandLineRef.GetArgv(var args: TStrings);
2017-01-27 17:29:37 +01:00
var
2018-03-29 20:02:04 +02:00
TempSL : ICefStringList;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
if (args <> nil) then
begin
TempSL := TCefStringListOwn.Create;
PCefCommandLine(FData)^.get_argv(PCefCommandLine(FData), TempSL.Handle);
2018-03-29 20:02:04 +02:00
TempSL.CopyToStrings(args);
2017-01-27 17:29:37 +01:00
end;
end;
function TCefCommandLineRef.GetCommandLineString: ustring;
begin
Result := CefStringFreeAndGet(PCefCommandLine(FData)^.get_command_line_string(PCefCommandLine(FData)));
2017-01-27 17:29:37 +01:00
end;
function TCefCommandLineRef.GetProgram: ustring;
begin
Result := CefStringFreeAndGet(PCefCommandLine(FData)^.get_program(PCefCommandLine(FData)));
2017-01-27 17:29:37 +01:00
end;
function TCefCommandLineRef.GetSwitches(var switches: TStrings): boolean;
2017-01-27 17:29:37 +01:00
var
2018-03-29 20:02:04 +02:00
TempStrMap : ICefStringMap;
2018-02-26 18:40:51 +01:00
i, j : NativeUInt;
TempKey, TempValue : ustring;
2017-01-27 17:29:37 +01:00
begin
Result := False;
2018-03-29 20:02:04 +02:00
TempStrMap := nil;
2018-02-26 18:40:51 +01:00
2017-01-27 17:29:37 +01:00
try
2018-02-26 18:40:51 +01:00
try
if (switches <> nil) then
begin
2018-03-29 20:02:04 +02:00
TempStrMap := TCefStringMapOwn.Create;
PCefCommandLine(FData)^.get_switches(PCefCommandLine(FData), TempStrMap.Handle);
2018-02-26 18:40:51 +01:00
i := 0;
2018-03-29 20:02:04 +02:00
j := TempStrMap.Size;
2018-02-26 18:40:51 +01:00
while (i < j) do
begin
2018-03-29 20:02:04 +02:00
TempKey := TempStrMap.Key[i];
TempValue := TempStrMap.Value[i];
if (length(TempKey) > 0) and (length(TempValue) > 0) then
switches.Add(TempKey + switches.NameValueSeparator + TempValue)
else
if (length(TempKey) > 0) then
switches.Add(TempKey)
else
if (length(TempValue) > 0) then
switches.Add(TempValue);
2018-02-26 18:40:51 +01:00
inc(i);
end;
Result := (j > 0);
end;
except
on e : exception do
if CustomExceptionHandler('TCefCommandLineRef.GetSwitches', e) then raise;
end;
finally
TempStrMap := nil;
end;
end;
function TCefCommandLineRef.GetSwitches(var SwitchKeys, SwitchValues: TStringList): boolean;
var
TempStrMap : ICefStringMap;
i, j : NativeUInt;
begin
Result := False;
TempStrMap := nil;
try
try
if (SwitchKeys <> nil) and (SwitchValues <> nil) then
begin
TempStrMap := TCefStringMapOwn.Create;
PCefCommandLine(FData)^.get_switches(PCefCommandLine(FData), TempStrMap.Handle);
i := 0;
j := TempStrMap.Size;
while (i < j) do
begin
SwitchKeys.Add(TempStrMap.Key[i]);
SwitchValues.Add(TempStrMap.Value[i]);
inc(i);
end;
Result := (j > 0);
2018-02-26 18:40:51 +01:00
end;
except
on e : exception do
if CustomExceptionHandler('TCefCommandLineRef.GetSwitches', e) then raise;
2017-01-27 17:29:37 +01:00
end;
finally
2018-03-29 20:02:04 +02:00
TempStrMap := nil;
2017-01-27 17:29:37 +01:00
end;
end;
function TCefCommandLineRef.GetSwitchValue(const name: ustring): ustring;
var
2018-03-29 20:02:04 +02:00
TempName : TCefString;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
TempName := CefString(name);
Result := CefStringFreeAndGet(PCefCommandLine(FData)^.get_switch_value(PCefCommandLine(FData), @TempName));
2017-01-27 17:29:37 +01:00
end;
class function TCefCommandLineRef.Global: ICefCommandLine;
begin
Result := UnWrap(cef_command_line_get_global());
2017-01-27 17:29:37 +01:00
end;
function TCefCommandLineRef.HasArguments: Boolean;
begin
Result := PCefCommandLine(FData)^.has_arguments(PCefCommandLine(FData)) <> 0;
2017-01-27 17:29:37 +01:00
end;
function TCefCommandLineRef.HasSwitch(const name: ustring): Boolean;
var
2018-03-29 20:02:04 +02:00
TempName : TCefString;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
TempName := CefString(name);
Result := PCefCommandLine(FData)^.has_switch(PCefCommandLine(FData), @TempName) <> 0;
2017-01-27 17:29:37 +01:00
end;
function TCefCommandLineRef.HasSwitches: Boolean;
begin
Result := PCefCommandLine(FData)^.has_switches(PCefCommandLine(FData)) <> 0;
2017-01-27 17:29:37 +01:00
end;
2018-03-29 20:02:04 +02:00
procedure TCefCommandLineRef.InitFromArgv(argc: Integer; const argv: PPAnsiChar);
2017-01-27 17:29:37 +01:00
begin
PCefCommandLine(FData)^.init_from_argv(PCefCommandLine(FData), argc, argv);
2017-01-27 17:29:37 +01:00
end;
procedure TCefCommandLineRef.InitFromString(const commandLine: ustring);
var
2018-03-29 20:02:04 +02:00
TempCommandLine : TCefString;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
TempCommandLine := CefString(commandLine);
PCefCommandLine(FData)^.init_from_string(PCefCommandLine(FData), @TempCommandLine);
2017-01-27 17:29:37 +01:00
end;
function TCefCommandLineRef.IsReadOnly: Boolean;
begin
Result := PCefCommandLine(FData)^.is_read_only(PCefCommandLine(FData)) <> 0;
2017-01-27 17:29:37 +01:00
end;
function TCefCommandLineRef.IsValid: Boolean;
begin
Result := PCefCommandLine(FData)^.is_valid(PCefCommandLine(FData)) <> 0;
2017-01-27 17:29:37 +01:00
end;
class function TCefCommandLineRef.New: ICefCommandLine;
begin
Result := UnWrap(cef_command_line_create());
2017-01-27 17:29:37 +01:00
end;
procedure TCefCommandLineRef.PrependWrapper(const wrapper: ustring);
var
2018-03-29 20:02:04 +02:00
TempWrapper : TCefString;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
TempWrapper := CefString(wrapper);
PCefCommandLine(FData)^.prepend_wrapper(PCefCommandLine(FData), @TempWrapper);
2017-01-27 17:29:37 +01:00
end;
procedure TCefCommandLineRef.Reset;
begin
PCefCommandLine(FData)^.reset(PCefCommandLine(FData));
2017-01-27 17:29:37 +01:00
end;
procedure TCefCommandLineRef.SetProgram(const prog: ustring);
var
2018-03-29 20:02:04 +02:00
TempProgram : TCefString;
2017-01-27 17:29:37 +01:00
begin
2018-03-29 20:02:04 +02:00
TempProgram := CefString(prog);
PCefCommandLine(FData)^.set_program(PCefCommandLine(FData), @TempProgram);
2017-01-27 17:29:37 +01:00
end;
class function TCefCommandLineRef.UnWrap(data: Pointer): ICefCommandLine;
begin
2018-03-29 20:02:04 +02:00
if (data <> nil) then
Result := Create(data) as ICefCommandLine
else
2017-01-27 17:29:37 +01:00
Result := nil;
end;
end.