diff --git a/Component/cef3.lpk b/Component/cef3.lpk
index 2e3824f..767938e 100644
--- a/Component/cef3.lpk
+++ b/Component/cef3.lpk
@@ -18,8 +18,6 @@
-
-
@@ -27,14 +25,15 @@
+
-
-
+
+
@@ -72,6 +71,11 @@
+
+
+
+
+
diff --git a/Component/cef3.pas b/Component/cef3.pas
index effbea6..7f77fcf 100644
--- a/Component/cef3.pas
+++ b/Component/cef3.pas
@@ -8,13 +8,14 @@ interface
uses
cef3types, cef3api, cef3lib, cef3intf, cef3ref, cef3own, cef3gui, cef3lcl,
- LazarusPackageIntf;
+ cef3osr, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('cef3lcl', @cef3lcl.Register);
+ RegisterUnit('cef3osr', @cef3osr.Register);
end;
initialization
diff --git a/Component/cef3lcl.pas b/Component/cef3lcl.pas
index f711531..1ab26cf 100644
--- a/Component/cef3lcl.pas
+++ b/Component/cef3lcl.pas
@@ -64,7 +64,7 @@
{$ENDIF}
cef3types, cef3lib, cef3intf, cef3gui;
-type
+Type
{ TCustomChromium }
@@ -124,8 +124,9 @@ TCustomChromium = class(TWinControl, IChromiumEvents)
{ RenderHandler }
FOnPopupShow: TOnPopupShow;
FOnPopupSize: TOnPopupSize;
- FOnPaint: TOnPaint;
+ // FOnPaint: TOnPaint; {$NOTE !}
FOnCursorChange: TOnCursorChange;
+ FOnScrollOffsetChanged: TOnScrollOffsetChanged;
{ RequestHandler }
FOnBeforeBrowse: TOnBeforeBrowse;
FOnBeforeResourceLoad: TOnBeforeResourceLoad;
@@ -226,12 +227,14 @@ TCustomChromium = class(TWinControl, IChromiumEvents)
function doOnGetViewRect(const Browser: ICefBrowser; rect: PCefRect): Boolean;
function doOnGetScreenPoint(const Browser: ICefBrowser; viewX, viewY: Integer;
screenX, screenY: PInteger): Boolean;
+ function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean;
procedure doOnPopupShow(const Browser: ICefBrowser; doshow: Boolean);
procedure doOnPopupSize(const Browser: ICefBrowser; const rect: PCefRect);
procedure doOnPaint(const Browser: ICefBrowser; kind: TCefPaintElementType;
dirtyRectsCount: TSize; const dirtyRects: PCefRectArray;
const buffer: Pointer; awidth, aheight: Integer);
procedure doOnCursorChange(const Browser: ICefBrowser; acursor: TCefCursorHandle);
+ procedure doOnScrollOffsetChanged(const browser: ICefBrowser);
{ RequestHandler }
function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; isRedirect: Boolean): Boolean; virtual;
@@ -302,6 +305,7 @@ TCustomChromium = class(TWinControl, IChromiumEvents)
property OnLoadEnd: TOnLoadEnd read FOnLoadEnd write FOnLoadEnd;
property OnLoadError: TOnLoadError read FOnLoadError write FOnLoadError;
{ RenderHandler }
+ property OnScrollOffsetChanged: TOnScrollOffsetChanged read FOnScrollOffsetChanged write FOnScrollOffsetChanged;
{ RequestHandler }
property OnBeforeBrowse: TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse;
property OnBeforeResourceLoad: TOnBeforeResourceLoad read FOnBeforeResourceLoad write FOnBeforeResourceLoad;
@@ -345,61 +349,74 @@ TChromium = class(TCustomChromium)
property Visible;
property OnProcessMessageReceived;
- property OnLoadStart;
- property OnLoadEnd;
- property OnLoadError;
- property OnRenderProcessTerminated;
- property OnPluginCrashed;
- property OnTakeFocus;
- property OnSetFocus;
- property OnGotFocus;
property OnBeforeContextMenu;
property OnContextMenuCommand;
property OnContextMenuDismissed;
- property OnPreKeyEvent;
- property OnKeyEvent;
- property OnLoadingStateChange;
+
+ property OnFileDialog;
property OnAddressChange;
property OnTitleChange;
property OnTooltip;
property OnStatusMessage;
property OnConsoleMessage;
+
property OnBeforeDownload;
property OnDownloadUpdated;
+
+ property OnDragEnter;
+
+ property OnTakeFocus;
+ property OnSetFocus;
+ property OnGotFocus;
+
property OnRequestGeolocationPermission;
property OnCancelGeolocationPermission;
- property OnJsdialog;
+ property OnJsdialog;
property OnBeforeUnloadDialog;
property OnResetDialogState;
+
+ property OnPreKeyEvent;
+ property OnKeyEvent;
+
property OnBeforePopup;
property OnAfterCreated;
property OnBeforeClose;
property OnRunModal;
property OnClose;
+
+ property OnLoadingStateChange;
+ property OnLoadStart;
+ property OnLoadEnd;
+ property OnLoadError;
+
+ property OnScrollOffsetChanged;
+
+ property OnBeforeBrowse;
property OnBeforeResourceLoad;
property OnGetResourceHandler;
property OnResourceRedirect;
property OnGetAuthCredentials;
+ property OnQuotaRequest;
property OnGetCookieManager;
property OnProtocolExecution;
-
- property OnFileDialog;
-
+ property OnCertificateError;
+ property OnBeforePluginLoad;
+ property OnPluginCrashed;
+ property OnRenderProcessTerminated;
property Options;
property FontOptions;
property DefaultEncoding;
property UserStyleSheetLocation;
-
- property Handler;
end;
procedure Register;
Implementation
+
{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
Uses ExtCtrls;
Var
@@ -430,7 +447,7 @@ TWSChromiumControl = class(TWSWinControl)
procedure Register;
begin
- RegisterComponents('Chromium',[TChromium]);
+ RegisterComponents('Chromium', [TChromium]);
end;
{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
@@ -458,7 +475,7 @@ constructor TLCLClientHandler.Create(const crm : IChromiumEvents);
begin
Timer := TTimer.Create(nil);
Timer.Interval := 15;
- Timer.Enabled := false;
+ Timer.Enabled := False;
Timer.OnTimer := @OnTimer;
{$IFDEF DEBUG}
@@ -486,7 +503,7 @@ procedure TLCLClientHandler.Cleanup;
If CefInstances = 0 then
begin
- Timer.Enabled := false;
+ Timer.Enabled := False;
FreeAndNil(Timer);
@@ -522,8 +539,8 @@ procedure TCustomChromium.GetSettings(var settings : TCefBrowserSettings);
settings.minimum_font_size := FFontOptions.MinimumFontSize;
settings.minimum_logical_font_size := FFontOptions.MinimumLogicalFontSize;
settings.remote_fonts := FFontOptions.RemoteFonts;
- settings.default_encoding := CefString(DefaultEncoding);
- settings.user_style_sheet_location := CefString(UserStyleSheetLocation);
+ settings.default_encoding := CefString(FDefaultEncoding);
+ settings.user_style_sheet_location := CefString(FUserStyleSheetLocation);
settings.javascript := FOptions.Javascript;
settings.javascript_open_windows := FOptions.JavascriptOpenWindows;
@@ -663,9 +680,9 @@ procedure TCustomChromium.CreateBrowser;
GetSettings(settings);
{$IFDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
- CefBrowserHostCreate(@info, FHandler, FDefaultUrl, @settings, nil);
+ CefBrowserHostCreateBrowser(@info, FHandler, FDefaultUrl, @settings, nil);
{$ELSE}
- FBrowser := CefBrowserHostCreateSync(@info, FHandler, '', @settings, nil);
+ FBrowser := CefBrowserHostCreateBrowserSync(@info, FHandler, '', @settings, nil);
FBrowserId := FBrowser.Identifier;
{$ENDIF}
@@ -766,8 +783,7 @@ procedure TCustomChromium.doOnBeforeClose(const Browser: ICefBrowser);
procedure TCustomChromium.doOnBeforeContextMenu(const Browser: ICefBrowser; const Frame: ICefFrame;
const params: ICefContextMenuParams; const model: ICefMenuModel);
begin
- If Assigned(FOnBeforeContextMenu) then
- FOnBeforeContextMenu(Self, Browser, Frame, params, model);
+ If Assigned(FOnBeforeContextMenu) then FOnBeforeContextMenu(Self, Browser, Frame, params, model);
end;
procedure TCustomChromium.doOnBeforeDownload(const Browser: ICefBrowser;
@@ -843,11 +859,17 @@ procedure TCustomChromium.doOnContextMenuDismissed(const Browser: ICefBrowser; c
If Assigned(FOnContextMenuDismissed) then FOnContextMenuDismissed(Self, Browser, Frame);
end;
-procedure TCustomChromium.doOnCursorChange(const Browser: ICefBrowser; aCursor: TCefCursorHandle);
+procedure TCustomChromium.doOnCursorChange(const Browser : ICefBrowser;
+ acursor : TCefCursorHandle);
begin
If Assigned(FOnCursorChange) then FOnCursorChange(Self, Browser, aCursor);
end;
+procedure TCustomChromium.doOnScrollOffsetChanged(const browser : ICefBrowser);
+begin
+ If Assigned(FOnScrollOffsetChanged) then FOnScrollOffsetChanged(Self, browser);
+end;
+
function TCustomChromium.doOnBeforeBrowse(const browser : ICefBrowser;
const frame : ICefFrame; const request : ICefRequest; isRedirect : Boolean) : Boolean;
begin
@@ -866,8 +888,7 @@ function TCustomChromium.doOnDragEnter(const Browser: ICefBrowser; const dragDat
mask: TCefDragOperationsMask): Boolean;
begin
Result := False;
- If Assigned(FOnDragEnter) then
- FOnDragEnter(Self, Browser, dragData, mask, Result);
+ If Assigned(FOnDragEnter) then FOnDragEnter(Self, Browser, dragData, mask, Result);
end;
function TCustomChromium.doOnFileDialog(const Browser: ICefBrowser; mode: TCefFileDialogMode;
@@ -914,6 +935,12 @@ function TCustomChromium.doOnGetScreenPoint(const Browser: ICefBrowser; viewX,
Result := False;
end;
+function TCustomChromium.doOnGetScreenInfo(const browser : ICefBrowser;
+ var screenInfo : TCefScreenInfo) : Boolean;
+begin
+ Result := False;
+end;
+
function TCustomChromium.doOnGetViewRect(const Browser: ICefBrowser; rect: PCefRect): Boolean;
begin
Result := False;
@@ -1012,10 +1039,11 @@ procedure TCustomChromium.doOnProtocolExecution(const Browser: ICefBrowser;
end;
function TCustomChromium.doOnCertificateError(certError : TCefErrorcode;
- const requestUrl : ustring;
- callback : ICefAllowCertificateErrorCallback) : Boolean;
+ const requestUrl : ustring; callback : ICefAllowCertificateErrorCallback) : Boolean;
begin
- { TODO }
+ Result := False;
+ If Assigned(FOnCertificateError) then
+ FOnCertificateError(Self, certError, requestUrl, callback, Result);
end;
function TCustomChromium.doOnQuotaRequest(const Browser: ICefBrowser; const originUrl: ustring;
@@ -1125,6 +1153,6 @@ class procedure TWSChromiumControl.DestroyHandle(const AWinControl: TWinControl)
Initialization
RegisterWSComponent(TCustomChromium, TWSChromiumControl);
- {$I icon.lrs}
+ {$I icons.lrs}
end.
diff --git a/Component/cef3osr.pas b/Component/cef3osr.pas
new file mode 100644
index 0000000..304d3a6
--- /dev/null
+++ b/Component/cef3osr.pas
@@ -0,0 +1,1022 @@
+(*
+ * Free Pascal 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.
+ *
+ * Author: d.l.i.w
+ * Repository: http://github.com/dliw/fpCEF3
+ *
+ *)
+
+Unit cef3osr;
+
+{$MODE objfpc}{$H+}
+
+{$I cef.inc}
+
+Interface
+
+Uses
+ Classes, SysUtils, fpTimer,
+ cef3types, cef3lib, cef3intf, cef3gui;
+
+Type
+ TCustomChromiumOSR = class(TComponent, IChromiumEvents)
+ private
+ FHandler: ICefClient;
+ FBrowser: ICefBrowser;
+ FBrowserId: Integer;
+ FDefaultUrl: ustring;
+
+ { Client }
+ FOnProcessMessageReceived: TOnProcessMessageReceived;
+
+ { ContextMenuHandler }
+ FOnBeforeContextMenu: TOnBeforeContextMenu;
+ FOnContextMenuCommand: TOnContextMenuCommand;
+ FOnContextMenuDismissed: TOnContextMenuDismissed;
+
+ { DialogHandler }
+ FOnFileDialog: TOnFileDialog;
+
+ { DisplayHandler }
+ FOnAddressChange: TOnAddressChange;
+ FOnTitleChange: TOnTitleChange;
+ FOnTooltip: TOnTooltip;
+ FOnStatusMessage: TOnStatusMessage;
+ FOnConsoleMessage: TOnConsoleMessage;
+
+ { DownloadHandler }
+ FOnBeforeDownload: TOnBeforeDownload;
+ FOnDownloadUpdated: TOnDownloadUpdated;
+
+ { DragHandler }
+ FOnDragEnter: TOnDragEnter;
+
+ { FocusHandler }
+ FOnTakeFocus: TOnTakeFocus;
+ FOnSetFocus: TOnSetFocus;
+ FOnGotFocus: TOnGotFocus;
+
+ { GeolocationHandler }
+ FOnRequestGeolocationPermission: TOnRequestGeolocationPermission;
+ FOnCancelGeolocationPermission: TOnCancelGeolocationPermission;
+
+ { JsDialogHandler }
+ FOnJsdialog: TOnJsdialog;
+ FOnBeforeUnloadDialog: TOnBeforeUnloadDialog;
+ FOnResetDialogState: TOnResetDialogState;
+
+ { KeyboardHandler }
+ FOnPreKeyEvent: TOnPreKeyEvent;
+ FOnKeyEvent: TOnKeyEvent;
+
+ { LiveSpanHandler }
+ FOnBeforePopup: TOnBeforePopup;
+ FOnAfterCreated: TOnAfterCreated;
+ FOnBeforeClose: TOnBeforeClose;
+ FOnRunModal: TOnRunModal;
+ FOnClose: TOnClose;
+
+ { LoadHandler }
+ FOnLoadingStateChange: TOnLoadingStateChange;
+ FOnLoadStart: TOnLoadStart;
+ FOnLoadEnd: TOnLoadEnd;
+ FOnLoadError: TOnLoadError;
+
+ { RenderHandler }
+ FOnGetRootScreenRect: TOnGetRootScreenRect;
+ FOnGetViewRect: TOnGetViewRect;
+ FOnGetScreenPoint: TOnGetScreenPoint;
+ FOnGetScreenInfo: TOnGetScreenInfo;
+ FOnPopupShow: TOnPopupShow;
+ FOnPopupSize: TOnPopupSize;
+ FOnPaint: TOnPaint;
+ FOnCursorChange: TOnCursorChange;
+ FOnScrollOffsetChanged: TOnScrollOffsetChanged;
+
+ { RequestHandler }
+ FOnBeforeBrowse: TOnBeforeBrowse;
+ FOnBeforeResourceLoad: TOnBeforeResourceLoad;
+ FOnGetResourceHandler: TOnGetResourceHandler;
+ FOnResourceRedirect: TOnResourceRedirect;
+ FOnGetAuthCredentials: TOnGetAuthCredentials;
+ FOnQuotaRequest: TOnQuotaRequest;
+ FOnGetCookieManager: TOnGetCookieManager;
+ FOnProtocolExecution: TOnProtocolExecution;
+ FOnCertificateError: TOnCertificateError;
+ FOnBeforePluginLoad: TOnBeforePluginLoad;
+ FOnPluginCrashed: TOnPluginCrashed;
+ FOnRenderProcessTerminated: TOnRenderProcessTerminated;
+
+ FOptions: TChromiumOptions;
+ FUserStyleSheetLocation: ustring;
+ FDefaultEncoding: ustring;
+ FFontOptions: TChromiumFontOptions;
+
+ procedure GetSettings(var settings: TCefBrowserSettings);
+ procedure CreateBrowser;
+ protected
+ procedure Loaded; override;
+
+ { Client }
+ function doOnProcessMessageReceived(const Browser: ICefBrowser;
+ sourceProcess: TCefProcessId; const Message: ICefProcessMessage): Boolean; virtual;
+
+ { ContextMenuHandler }
+ procedure doOnBeforeContextMenu(const Browser: ICefBrowser; const Frame: ICefFrame;
+ const params: ICefContextMenuParams; const model: ICefMenuModel); virtual;
+ function doOnContextMenuCommand(const Browser: ICefBrowser; const Frame: ICefFrame;
+ const params: ICefContextMenuParams; commandId: Integer;
+ eventFlags: TCefEventFlags): Boolean; virtual;
+ procedure doOnContextMenuDismissed(const Browser: ICefBrowser; const Frame: ICefFrame); virtual;
+
+ { DialogHandler }
+ function doOnFileDialog(const Browser: ICefBrowser; mode: TCefFileDialogMode;
+ const title, defaultFileName: ustring; acceptTypes: TStrings;
+ const callback: ICefFileDialogCallback): Boolean;
+
+ { DisplayHandler }
+ procedure doOnAddressChange(const Browser: ICefBrowser; const Frame: ICefFrame; const url: ustring); virtual;
+ procedure doOnTitleChange(const Browser: ICefBrowser; const title: ustring); virtual;
+ function doOnTooltip(const Browser: ICefBrowser; var atext: ustring): Boolean; virtual;
+ procedure doOnStatusMessage(const Browser: ICefBrowser; const value: ustring); virtual;
+ function doOnConsoleMessage(const Browser: ICefBrowser; const Message, Source: ustring; line: Integer): Boolean; virtual;
+
+ { DownloadHandler }
+ procedure doOnBeforeDownload(const Browser: ICefBrowser; const downloadItem: ICefDownloadItem;
+ const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); virtual;
+ procedure doOnDownloadUpdated(const Browser: ICefBrowser; const downloadItem: ICefDownloadItem;
+ const callback: ICefDownloadItemCallback); virtual;
+
+ { DragHandler }
+ function doOnDragEnter(const Browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperationsMask): Boolean; virtual;
+
+ { FocusHandler }
+ procedure doOnTakeFocus(const Browser: ICefBrowser; next: Boolean); virtual;
+ function doOnSetFocus(const Browser: ICefBrowser; Source: TCefFocusSource): Boolean; virtual;
+ procedure doOnGotFocus(const Browser: ICefBrowser); virtual;
+
+ { GeolocationHandler }
+ procedure doOnRequestGeolocationPermission(const Browser: ICefBrowser;
+ const requestingUrl: ustring; requestId: Integer; const callback: ICefGeolocationCallback); virtual;
+ procedure doOnCancelGeolocationPermission(const Browser: ICefBrowser;
+ const requestingUrl: ustring; requestId: Integer); virtual;
+
+ { JsDialogHandler }
+ function doOnJsdialog(const Browser: ICefBrowser; const originUrl, acceptLang: ustring;
+ dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring;
+ callback: ICefJsDialogCallback; out suppressMessage: Boolean): Boolean; virtual;
+ function doOnBeforeUnloadDialog(const Browser: ICefBrowser;
+ const messageText: ustring; isReload: Boolean;
+ const callback: ICefJsDialogCallback): Boolean; virtual;
+ procedure doOnResetDialogState(const Browser: ICefBrowser); virtual;
+
+ { KeyboardHander }
+ function doOnPreKeyEvent(const Browser: ICefBrowser; const event: PCefKeyEvent;
+ osEvent: TCefEventHandle; out isKeyboardShortcut: Boolean): Boolean; virtual;
+ function doOnKeyEvent(const Browser: ICefBrowser; const event: PCefKeyEvent;
+ osEvent: TCefEventHandle): Boolean; virtual;
+
+ { LiveSpanHandler }
+ function doOnBeforePopup(const Browser: ICefBrowser;
+ const Frame: ICefFrame; const targetUrl, targetFrameName: ustring;
+ var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo;
+ var client: ICefClient; var settings: TCefBrowserSettings;
+ var noJavascriptAccess: Boolean): Boolean; virtual;
+ procedure doOnAfterCreated(const Browser: ICefBrowser); virtual;
+ procedure doOnBeforeClose(const Browser: ICefBrowser); virtual;
+ function doOnRunModal(const Browser: ICefBrowser): Boolean; virtual;
+ function doOnClose(const Browser: ICefBrowser): Boolean; virtual;
+
+ { LoadHandler }
+ procedure doOnLoadingStateChange(const Browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); virtual;
+ procedure doOnLoadStart(const Browser: ICefBrowser; const Frame: ICefFrame); virtual;
+ procedure doOnLoadEnd(const Browser: ICefBrowser; const Frame: ICefFrame; httpStatusCode: Integer); virtual;
+ procedure doOnLoadError(const Browser: ICefBrowser; const Frame: ICefFrame; errorCode: TCefErrorCode;
+ const errorText, failedUrl: ustring); virtual;
+
+ { RenderHandler }
+ function doOnGetRootScreenRect(const Browser: ICefBrowser; rect: PCefRect): Boolean;
+ function doOnGetViewRect(const Browser: ICefBrowser; rect: PCefRect): Boolean;
+ function doOnGetScreenPoint(const Browser: ICefBrowser; viewX, viewY: Integer;
+ screenX, screenY: PInteger): Boolean;
+ function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean;
+ procedure doOnPopupShow(const Browser: ICefBrowser; doshow: Boolean);
+ procedure doOnPopupSize(const Browser: ICefBrowser; const rect: PCefRect);
+ procedure doOnPaint(const Browser: ICefBrowser; kind: TCefPaintElementType;
+ dirtyRectsCount: TSize; const dirtyRects: PCefRectArray;
+ const buffer: Pointer; awidth, aheight: Integer);
+ procedure doOnCursorChange(const Browser: ICefBrowser; acursor: TCefCursorHandle);
+ procedure doOnScrollOffsetChanged(const browser: ICefBrowser);
+
+ { RequestHandler }
+ function doOnBeforeBrowse(const Browser: ICefBrowser; const frame: ICefFrame;
+ const request: ICefRequest; isRedirect: Boolean): Boolean; virtual;
+ function doOnBeforeResourceLoad(const Browser: ICefBrowser; const Frame: ICefFrame;
+ const request: ICefRequest): Boolean; virtual;
+ function doOnGetResourceHandler(const Browser: ICefBrowser; const Frame: ICefFrame;
+ const request: ICefRequest): ICefResourceHandler; virtual;
+ procedure doOnResourceRedirect(const Browser: ICefBrowser; const Frame: ICefFrame;
+ const oldUrl: ustring; var newUrl: ustring); virtual;
+ function doOnGetAuthCredentials(const Browser: ICefBrowser; const Frame: ICefFrame;
+ isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring;
+ const callback: ICefAuthCallback): Boolean; virtual;
+ function doOnQuotaRequest(const Browser: ICefBrowser; const originUrl: ustring;
+ newSize: Int64; const callback: ICefQuotaCallback): Boolean; virtual;
+ function doOnGetCookieManager(const Browser: ICefBrowser;
+ const mainUrl: ustring): ICefCookieManager; virtual;
+ procedure doOnProtocolExecution(const Browser: ICefBrowser;
+ const url: ustring; out allowOsExecution: Boolean); virtual;
+ function doOnCertificateError(certError: TCefErrorcode; const requestUrl: ustring;
+ callback: ICefAllowCertificateErrorCallback): Boolean;
+ function doOnBeforePluginLoad(const Browser: ICefBrowser; const url, policyUrl: ustring;
+ const info: ICefWebPluginInfo): Boolean; virtual;
+ procedure doOnPluginCrashed(const Browser: ICefBrowser; const pluginPath: ustring); virtual;
+ procedure doOnRenderProcessTerminated(const Browser: ICefBrowser; Status: TCefTerminationStatus); virtual;
+
+ { Client }
+ property OnProcessMessageReceived: TOnProcessMessageReceived read FOnProcessMessageReceived write FOnProcessMessageReceived;
+
+ { ContextMenuHandler }
+ property OnBeforeContextMenu: TOnBeforeContextMenu read FOnBeforeContextMenu write FOnBeforeContextMenu;
+ property OnContextMenuCommand: TOnContextMenuCommand read FOnContextMenuCommand write FOnContextMenuCommand;
+ property OnContextMenuDismissed: TOnContextMenuDismissed read FOnContextMenuDismissed write FOnContextMenuDismissed;
+
+ { DialogHandler }
+ property OFileDialog: TOnFileDialog read FOnFileDialog write FOnFileDialog;
+
+ { DisplayHandler }
+ property OnAddressChange: TOnAddressChange read FOnAddressChange write FOnAddressChange;
+ property OnTitleChange: TOnTitleChange read FOnTitleChange write FOnTitleChange;
+ property OnTooltip: TOnTooltip read FOnTooltip write FOnTooltip;
+ property OnStatusMessage: TOnStatusMessage read FOnStatusMessage write FOnStatusMessage;
+ property OnConsoleMessage: TOnConsoleMessage read FOnConsoleMessage write FOnConsoleMessage;
+
+ { DownloadHandler }
+ property OnBeforeDownload: TOnBeforeDownload read FOnBeforeDownload write FOnBeforeDownload;
+ property OnDownloadUpdated: TOnDownloadUpdated read FOnDownloadUpdated write FOnDownloadUpdated;
+
+ { DragHandler }
+ property OnDragEnter: TOnDragEnter read FOnDragEnter write FOnDragEnter;
+
+ { FocusHandler }
+ property OnTakeFocus: TOnTakeFocus read FOnTakeFocus write FOnTakeFocus;
+ property OnSetFocus: TOnSetFocus read FOnSetFocus write FOnSetFocus;
+ property OnGotFocus: TOnGotFocus read FOnGotFocus write FOnGotFocus;
+
+ { GeolocationHandler }
+ property OnRequestGeolocationPermission: TOnRequestGeolocationPermission read FOnRequestGeolocationPermission write FOnRequestGeolocationPermission;
+ property OnCancelGeolocationPermission: TOnCancelGeolocationPermission read FOnCancelGeolocationPermission write FOnCancelGeolocationPermission;
+
+ { JsDialogHandler }
+ property OnJsdialog: TOnJsdialog read FOnJsdialog write FOnJsdialog;
+ property OnBeforeUnloadDialog: TOnBeforeUnloadDialog read FOnBeforeUnloadDialog write FOnBeforeUnloadDialog;
+ property OnResetDialogState: TOnResetDialogState read FOnResetDialogState write FOnResetDialogState;
+
+ { KeyboardHandler }
+ property OnPreKeyEvent: TOnPreKeyEvent read FOnPreKeyEvent write FOnPreKeyEvent;
+ property OnKeyEvent: TOnKeyEvent read FOnKeyEvent write FOnKeyEvent;
+
+ { LiveSpanHandler }
+ property OnBeforePopup: TOnBeforePopup read FOnBeforePopup write FOnBeforePopup;
+ property OnAfterCreated: TOnAfterCreated read FOnAfterCreated write FOnAfterCreated;
+ property OnBeforeClose: TOnBeforeClose read FOnBeforeClose write FOnBeforeClose;
+ property OnRunModal: TOnRunModal read FOnRunModal write FOnRunModal;
+ property OnClose: TOnClose read FOnClose write FOnClose;
+
+ { LoadHandler }
+ property OnLoadingStateChange: TOnLoadingStateChange read FOnLoadingStateChange write FOnLoadingStateChange;
+ property OnLoadStart: TOnLoadStart read FOnLoadStart write FOnLoadStart;
+ property OnLoadEnd: TOnLoadEnd read FOnLoadEnd write FOnLoadEnd;
+ property OnLoadError: TOnLoadError read FOnLoadError write FOnLoadError;
+
+ { RenderHandler }
+ property OnGetRootScreenRect: TOnGetRootScreenRect read FOnGetRootScreenRect write FOnGetRootScreenRect;
+ property OnGetViewRect: TOnGetViewRect read FOnGetViewRect write FOnGetViewRect;
+ property OnGetScreenPoint: TOnGetScreenPoint read FOnGetScreenPoint write FOnGetScreenPoint;
+ property OnGetScreenInfo: TOnGetScreenInfo read FOnGetScreenInfo write FOnGetScreenInfo;
+ property OnPopupShow: TOnPopupShow read FOnPopupShow write FOnPopupShow;
+ property OnPopupSize: TOnPopupSize read FOnPopupSize write FOnPopupSize;
+ property OnPaint: TOnPaint read FOnPaint write FOnPaint;
+ property OnCursorChange: TOnCursorChange read FOnCursorChange write FOnCursorChange;
+ property OnScrollOffsetChanged: TOnScrollOffsetChanged read FOnScrollOffsetChanged write FOnScrollOffsetChanged;
+
+ { RequestHandler }
+ property OnBeforeBrowse: TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse;
+ property OnBeforeResourceLoad: TOnBeforeResourceLoad read FOnBeforeResourceLoad write FOnBeforeResourceLoad;
+ property OnGetResourceHandler: TOnGetResourceHandler read FOnGetResourceHandler write FOnGetResourceHandler;
+ property OnResourceRedirect: TOnResourceRedirect read FOnResourceRedirect write FOnResourceRedirect;
+ property OnGetAuthCredentials: TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials;
+ property OnQuotaRequest: TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest;
+ property OnGetCookieManager: TOnGetCookieManager read FOnGetCookieManager write FOnGetCookieManager;
+ property OnProtocolExecution: TOnProtocolExecution read FOnProtocolExecution write FOnProtocolExecution;
+ property OnCertificateError: TOnCertificateError read FOnCertificateError write FOnCertificateError;
+ property OnBeforePluginLoad: TOnBeforePluginLoad read FOnBeforePluginLoad write FOnBeforePluginLoad;
+ property OnPluginCrashed: TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed;
+ property OnRenderProcessTerminated: TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated;
+
+ property DefaultUrl: ustring read FDefaultUrl write FDefaultUrl;
+ property Options: TChromiumOptions read FOptions write FOptions;
+ property FontOptions: TChromiumFontOptions read FFontOptions;
+ property DefaultEncoding: ustring read FDefaultEncoding write FDefaultEncoding;
+ property UserStyleSheetLocation: ustring read FUserStyleSheetLocation write FUserStyleSheetLocation;
+ property BrowserId: Integer read FBrowserId;
+ property Browser: ICefBrowser read FBrowser;
+ public
+ constructor Create(AOwner: TComponent); override;
+ destructor Destroy; override;
+ procedure Load(const url: ustring);
+ end;
+
+ TChromiumOSR = class(TCustomChromiumOSR)
+ public
+ property BrowserId;
+ property Browser;
+ published
+ property DefaultUrl;
+
+ property OnProcessMessageReceived;
+
+ property OnBeforeContextMenu;
+ property OnContextMenuCommand;
+ property OnContextMenuDismissed;
+
+ property OFileDialog;
+
+ property OnAddressChange;
+ property OnTitleChange;
+ property OnTooltip;
+ property OnStatusMessage;
+ property OnConsoleMessage;
+
+ property OnBeforeDownload;
+ property OnDownloadUpdated;
+
+ property OnDragEnter;
+
+ property OnTakeFocus;
+ property OnSetFocus;
+ property OnGotFocus;
+
+ property OnRequestGeolocationPermission;
+ property OnCancelGeolocationPermission;
+
+ property OnJsdialog;
+ property OnBeforeUnloadDialog;
+ property OnResetDialogState;
+
+ property OnPreKeyEvent: TOnPreKeyEvent;
+ property OnKeyEvent: TOnKeyEvent;
+
+ property OnBeforePopup;
+ property OnAfterCreated;
+ property OnBeforeClose;
+ property OnRunModal;
+ property OnClose;
+
+ property OnLoadingStateChange;
+ property OnLoadStart;
+ property OnLoadEnd;
+ property OnLoadError;
+
+ property OnGetRootScreenRect;
+ property OnGetViewRect;
+ property OnGetScreenPoint;
+ property OnGetScreenInfo;
+ property OnPopupShow;
+ property OnPopupSize;
+ property OnPaint;
+ property OnCursorChange;
+ property OnScrollOffsetChanged;
+
+ property OnBeforeBrowse;
+ property OnBeforeResourceLoad;
+ property OnGetResourceHandler;
+ property OnResourceRedirect;
+ property OnGetAuthCredentials;
+ property OnQuotaRequest;
+ property OnGetCookieManager;
+ property OnProtocolExecution;
+ property OnCertificateError;
+ property OnBeforePluginLoad;
+ property OnPluginCrashed;
+ property OnRenderProcessTerminated;
+
+ property Options;
+ property FontOptions;
+ property DefaultEncoding;
+ property UserStyleSheetLocation;
+ end;
+
+procedure Register;
+
+Implementation
+
+{$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
+Uses ExtCtrls;
+Var
+ CefInstances : Integer = 0;
+ Timer : TFPTimer;
+ Looping : Boolean = False;
+{$ENDIF}
+
+Type
+
+ { TOSRClientHandler }
+
+ TOSRClientHandler = class(TCustomClientHandler)
+ private
+ class procedure OnTimer(Sender : TObject);
+ public
+ constructor Create(const crm: IChromiumEvents); override;
+ procedure Cleanup;
+ procedure StartTimer;
+ end;
+
+procedure Register;
+begin
+ RegisterComponents('Chromium', [TChromiumOSR]);
+end;
+
+class procedure TOSRClientHandler.OnTimer(Sender : TObject);
+begin
+ If Looping then Exit;
+ If CefInstances > 0 then
+ begin
+ Looping := True;
+ try
+ CefDoMessageLoopWork;
+ finally
+ Looping := False;
+ end;
+ end;
+end;
+
+constructor TOSRClientHandler.Create(const crm : IChromiumEvents);
+begin
+ inherited Create(crm);
+
+ {$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
+ If not assigned(Timer) then
+ begin
+ Timer := TFPTimer.Create(nil);
+ Timer.Interval := 15;
+ Timer.Enabled := False;
+ Timer.OnTimer := @OnTimer;
+
+ {$IFDEF DEBUG}
+ Debugln('Timer created.');
+ {$ENDIF}
+ end;
+
+ InterLockedIncrement(CefInstances);
+ {$ENDIF}
+
+ {$IFDEF DEBUG}
+ Debugln('ClientHandler instances: ', IntToStr(CefInstances));
+ {$ENDIF}
+end;
+
+procedure TOSRClientHandler.Cleanup;
+begin
+ { TODO : Check, why Destroy; override never gets called }
+ {$IFDEF DEBUG}
+ Debugln('LCLClientHandler.Cleanup');
+ {$ENDIF}
+
+ {$IFNDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
+ InterLockedDecrement(CefInstances);
+
+ If CefInstances = 0 then
+ begin
+ Timer.Enabled := False;
+
+ FreeAndNil(Timer);
+
+ {$IFDEF DEBUG}
+ Debugln('Timer cleaned.');
+ {$ENDIF}
+ end;
+ {$ENDIF}
+
+ // inherited;
+end;
+
+procedure TOSRClientHandler.StartTimer;
+begin
+ If not Assigned(Timer) then Exit;
+
+ Timer.Enabled := True;
+end;
+
+{ TCustomChromiumOSR }
+
+procedure TCustomChromiumOSR.GetSettings(var settings : TCefBrowserSettings);
+begin
+ If not (settings.size >= SizeOf(settings)) then raise Exception.Create('settings invalid');
+ settings.standard_font_family := CefString(FFontOptions.StandardFontFamily);
+ settings.fixed_font_family := CefString(FFontOptions.FixedFontFamily);
+ settings.serif_font_family := CefString(FFontOptions.SerifFontFamily);
+ settings.sans_serif_font_family := CefString(FFontOptions.SansSerifFontFamily);
+ settings.cursive_font_family := CefString(FFontOptions.CursiveFontFamily);
+ settings.fantasy_font_family := CefString(FFontOptions.FantasyFontFamily);
+ settings.default_font_size := FFontOptions.DefaultFontSize;
+ settings.default_fixed_font_size := FFontOptions.DefaultFixedFontSize;
+ settings.minimum_font_size := FFontOptions.MinimumFontSize;
+ settings.minimum_logical_font_size := FFontOptions.MinimumLogicalFontSize;
+ settings.remote_fonts := FFontOptions.RemoteFonts;
+ settings.default_encoding := CefString(FDefaultEncoding);
+ settings.user_style_sheet_location := CefString(FUserStyleSheetLocation);
+
+ settings.javascript := FOptions.Javascript;
+ settings.javascript_open_windows := FOptions.JavascriptOpenWindows;
+ settings.javascript_close_windows := FOptions.JavascriptCloseWindows;
+ settings.javascript_access_clipboard := FOptions.JavascriptAccessClipboard;
+ settings.javascript_dom_paste := FOptions.JavascriptDomPaste;
+ settings.caret_browsing := FOptions.CaretBrowsing;
+ settings.java := FOptions.Java;
+ settings.plugins := FOptions.Plugins;
+ settings.universal_access_from_file_urls := FOptions.UniversalAccessFromFileUrls;
+ settings.file_access_from_file_urls := FOptions.FileAccessFromFileUrls;
+ settings.web_security := FOptions.WebSecurity;
+ settings.image_loading := FOptions.ImageLoading;
+ settings.image_shrink_standalone_to_fit := FOptions.ImageShrinkStandaloneToFit;
+ settings.text_area_resize := FOptions.TextAreaResize;
+ settings.tab_to_links := FOptions.TabToLinks;
+ settings.author_and_user_styles := FOptions.AuthorAndUserStyles;
+ settings.local_storage := FOptions.LocalStorage;
+ settings.databases := FOptions.Databases;
+ settings.application_cache := FOptions.ApplicationCache;
+ settings.webgl := FOptions.Webgl;
+ settings.accelerated_compositing := FOptions.AcceleratedCompositing;
+end;
+
+procedure TCustomChromiumOSR.CreateBrowser;
+Var
+ info: TCefWindowInfo;
+ settings: TCefBrowserSettings;
+begin
+ If not (csDesigning in ComponentState) then
+ begin
+ FillChar(info, SizeOf(info), 0);
+ info.window_rendering_disabled := True;
+ // info.transparent_painting := ???;
+
+ FillChar(settings, SizeOf(TCefBrowserSettings), 0);
+ settings.size := SizeOf(TCefBrowserSettings);
+ GetSettings(settings);
+
+ {$IFDEF CEF_MULTI_THREADED_MESSAGE_LOOP}
+ CefBrowserHostCreateBrowser(@info, FHandler, FDefaultUrl, @settings, nil);
+ {$ELSE}
+ FBrowser := CefBrowserHostCreateBrowserSync(@info, FHandler, '', @settings, nil);
+ FBrowserId := FBrowser.Identifier;
+ {$ENDIF}
+
+ (FHandler as TOSRClientHandler).StartTimer;
+ end;
+end;
+
+
+procedure TCustomChromiumOSR.Loaded;
+begin
+ inherited;
+
+ CreateBrowser;
+ // Load(FDefaultUrl);
+end;
+
+function TCustomChromiumOSR.doOnProcessMessageReceived(const Browser : ICefBrowser;
+ sourceProcess : TCefProcessId; const Message : ICefProcessMessage) : Boolean;
+begin
+ Result := False;
+ if Assigned(FOnProcessMessageReceived) then
+ FOnProcessMessageReceived(Self, Browser, sourceProcess, message, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnBeforeContextMenu(const Browser : ICefBrowser;
+ const Frame : ICefFrame; const params : ICefContextMenuParams; const model : ICefMenuModel);
+begin
+ If Assigned(FOnBeforeContextMenu) then FOnBeforeContextMenu(Self, Browser, frame, params, model);
+end;
+
+function TCustomChromiumOSR.doOnContextMenuCommand(const Browser : ICefBrowser;
+ const Frame : ICefFrame; const params : ICefContextMenuParams;
+ commandId : Integer; eventFlags : TCefEventFlags) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnContextMenuCommand) then
+ FOnContextMenuCommand(Self, Browser, frame, params, commandId, eventFlags, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnContextMenuDismissed(const Browser : ICefBrowser;
+ const Frame : ICefFrame);
+begin
+ If Assigned(FOnContextMenuDismissed) then FOnContextMenuDismissed(Self, Browser, frame);
+end;
+
+function TCustomChromiumOSR.doOnFileDialog(const Browser : ICefBrowser;
+ mode : TCefFileDialogMode; const title, defaultFileName : ustring;
+ acceptTypes : TStrings; const callback : ICefFileDialogCallback) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnFileDialog) then
+ FOnFileDialog(Self, Browser, mode, title, defaultFileName, acceptTypes, callback, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnAddressChange(const Browser : ICefBrowser;
+ const Frame : ICefFrame; const url : ustring);
+begin
+ If Assigned(FOnAddressChange) then FOnAddressChange(Self, Browser, frame, url);
+end;
+
+procedure TCustomChromiumOSR.doOnTitleChange(const Browser : ICefBrowser; const title : ustring);
+begin
+ If Assigned(FOnTitleChange) then FOnTitleChange(Self, Browser, title);
+end;
+
+function TCustomChromiumOSR.doOnTooltip(const Browser : ICefBrowser; var atext : ustring) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnTooltip) then FOnTooltip(Self, Browser, atext, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnStatusMessage(const Browser : ICefBrowser; const value : ustring);
+begin
+ If Assigned(FOnStatusMessage) then FOnStatusMessage(Self, Browser, value);
+end;
+
+function TCustomChromiumOSR.doOnConsoleMessage(const Browser : ICefBrowser;
+ const Message, Source : ustring; line : Integer) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnConsoleMessage) then FOnConsoleMessage(Self, Browser, message, source, line, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnBeforeDownload(const Browser : ICefBrowser;
+ const downloadItem : ICefDownloadItem; const suggestedName : ustring;
+ const callback : ICefBeforeDownloadCallback);
+begin
+ If Assigned(FOnBeforeDownload) then
+ OnBeforeDownload(Self, Browser, downloadItem, suggestedName, callback);
+end;
+
+procedure TCustomChromiumOSR.doOnDownloadUpdated(const Browser : ICefBrowser;
+ const downloadItem : ICefDownloadItem;
+ const callback : ICefDownloadItemCallback);
+begin
+ If Assigned(FOnDownloadUpdated) then FOnDownloadUpdated(Self, Browser, downloadItem, callback);
+end;
+
+function TCustomChromiumOSR.doOnDragEnter(const Browser : ICefBrowser;
+ const dragData : ICefDragData; mask : TCefDragOperationsMask) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnDragEnter) then FOnDragEnter(Self, Browser, dragData, mask, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnTakeFocus(const Browser : ICefBrowser; next : Boolean);
+begin
+ If Assigned(FOnTakeFocus) then FOnTakeFocus(Self, Browser, next);
+end;
+
+function TCustomChromiumOSR.doOnSetFocus(const Browser : ICefBrowser;
+ Source : TCefFocusSource) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnSetFocus) then FOnSetFocus(Self, Browser, source, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnGotFocus(const Browser : ICefBrowser);
+begin
+ If Assigned(FOnGotFocus) then FOnGotFocus(Self, Browser);
+end;
+
+procedure TCustomChromiumOSR.doOnRequestGeolocationPermission(const Browser : ICefBrowser;
+ const requestingUrl : ustring; requestId : Integer;
+ const callback : ICefGeolocationCallback);
+begin
+ If Assigned(FOnRequestGeolocationPermission) then
+ FOnRequestGeolocationPermission(Self, Browser, requestingUrl, requestId, callback);
+end;
+
+procedure TCustomChromiumOSR.doOnCancelGeolocationPermission(const Browser : ICefBrowser;
+ const requestingUrl : ustring; requestId : Integer);
+begin
+ If Assigned(FOnCancelGeolocationPermission) then
+ FOnCancelGeolocationPermission(Self, Browser, requestingUrl, requestId);
+end;
+
+function TCustomChromiumOSR.doOnJsdialog(const Browser : ICefBrowser;
+ const originUrl, acceptLang : ustring; dialogType : TCefJsDialogType;
+ const messageText, defaultPromptText : ustring;
+ callback : ICefJsDialogCallback; out suppressMessage : Boolean) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnJsdialog) then
+ FOnJsdialog(Self, Browser, originUrl, acceptLang, dialogType,
+ messageText, defaultPromptText, callback, suppressMessage, Result);
+end;
+
+function TCustomChromiumOSR.doOnBeforeUnloadDialog(const Browser : ICefBrowser;
+ const messageText : ustring; isReload : Boolean;
+ const callback : ICefJsDialogCallback) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnBeforeUnloadDialog) then
+ FOnBeforeUnloadDialog(Self, Browser, messageText, isReload, callback, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnResetDialogState(const Browser : ICefBrowser);
+begin
+ If Assigned(FOnResetDialogState) then FOnResetDialogState(Self, Browser);
+end;
+
+function TCustomChromiumOSR.doOnPreKeyEvent(const Browser : ICefBrowser; const event : PCefKeyEvent;
+ osEvent : TCefEventHandle; out isKeyboardShortcut : Boolean) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnPreKeyEvent) then
+ FOnPreKeyEvent(Self, Browser, event, osEvent, isKeyboardShortcut, Result);
+end;
+
+function TCustomChromiumOSR.doOnKeyEvent(const Browser : ICefBrowser;
+ const event : PCefKeyEvent; osEvent : TCefEventHandle) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnKeyEvent) then FOnKeyEvent(Self, Browser, event, osEvent, Result);
+end;
+
+function TCustomChromiumOSR.doOnBeforePopup(const Browser : ICefBrowser;
+ const Frame : ICefFrame; const targetUrl, targetFrameName : ustring;
+ var popupFeatures : TCefPopupFeatures; var windowInfo : TCefWindowInfo;
+ var client : ICefClient; var settings : TCefBrowserSettings;
+ var noJavascriptAccess : Boolean) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnBeforePopup) then
+ FOnBeforePopup(Self, Browser, frame, targetUrl, targetFrameName, popupFeatures,
+ windowInfo, client, settings, noJavascriptAccess, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnAfterCreated(const Browser : ICefBrowser);
+begin
+ If Assigned(FOnAfterCreated) then FOnAfterCreated(Self, Browser);
+end;
+
+procedure TCustomChromiumOSR.doOnBeforeClose(const Browser : ICefBrowser);
+begin
+ If Assigned(FOnBeforeClose) then FOnBeforeClose(Self, Browser);
+end;
+
+function TCustomChromiumOSR.doOnRunModal(const Browser : ICefBrowser) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnRunModal) then FOnRunModal(Self, Browser, Result);
+end;
+
+function TCustomChromiumOSR.doOnClose(const Browser : ICefBrowser) : Boolean;
+begin
+ Result := False;
+ if Assigned(FOnClose) then FOnClose(Self, Browser, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnLoadingStateChange(const Browser : ICefBrowser;
+ isLoading, canGoBack, canGoForward : Boolean);
+begin
+ If Assigned(FOnLoadingStateChange) then
+ FOnLoadingStateChange(Self, Browser, isLoading, canGoBack, canGoForward);
+end;
+
+procedure TCustomChromiumOSR.doOnLoadStart(const Browser : ICefBrowser; const Frame : ICefFrame);
+begin
+ If Assigned(FOnLoadStart) then FOnLoadStart(Self, Browser, frame);
+end;
+
+procedure TCustomChromiumOSR.doOnLoadEnd(const Browser : ICefBrowser;
+ const Frame : ICefFrame; httpStatusCode : Integer);
+begin
+ If Assigned(FOnLoadEnd) then FOnLoadEnd(Self, Browser, frame, httpStatusCode);
+end;
+
+procedure TCustomChromiumOSR.doOnLoadError(const Browser : ICefBrowser;
+ const Frame : ICefFrame; errorCode : TCefErrorCode; const errorText, failedUrl : ustring);
+begin
+ If Assigned(FOnLoadError) then
+ FOnLoadError(Self, Browser, frame, errorCode, errorText, failedUrl);
+end;
+
+function TCustomChromiumOSR.doOnGetRootScreenRect(const Browser : ICefBrowser;
+ rect : PCefRect) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnGetRootScreenRect) then FOnGetRootScreenRect(Self, Browser, rect, Result);
+end;
+
+function TCustomChromiumOSR.doOnGetViewRect(const Browser : ICefBrowser; rect : PCefRect) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnGetViewRect) then FOnGetViewRect(Self, Browser, rect, Result);
+end;
+
+function TCustomChromiumOSR.doOnGetScreenPoint(const Browser : ICefBrowser;
+ viewX, viewY : Integer; screenX, screenY : PInteger) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnGetScreenPoint) then
+ FOnGetScreenPoint(Self, Browser, viewX, viewY, screenX, screenY, Result);
+end;
+
+function TCustomChromiumOSR.doOnGetScreenInfo(const browser : ICefBrowser;
+ var screenInfo : TCefScreenInfo) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnGetScreenInfo) then FOnGetScreenInfo(Self, Browser, screenInfo, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnPopupShow(const Browser : ICefBrowser; doshow : Boolean);
+begin
+ If Assigned(FOnPopupShow) then FOnPopupShow(Self, Browser, doshow);
+end;
+
+procedure TCustomChromiumOSR.doOnPopupSize(const Browser : ICefBrowser; const rect : PCefRect);
+begin
+ If Assigned(FOnPopupSize) then FOnPopupSize(Self, Browser, rect);
+end;
+
+procedure TCustomChromiumOSR.doOnPaint(const Browser : ICefBrowser;
+ kind : TCefPaintElementType; dirtyRectsCount : TSize; const dirtyRects : PCefRectArray;
+ const buffer : Pointer; awidth, aheight : Integer);
+begin
+ If Assigned(FOnPaint) then
+ FOnPaint(Self, Browser, kind, dirtyRectsCount, dirtyRects, buffer, awidth, aheight);
+end;
+
+procedure TCustomChromiumOSR.doOnCursorChange(const Browser : ICefBrowser;
+ acursor : TCefCursorHandle);
+begin
+ If Assigned(FOnCursorChange) then FOnCursorChange(Self, Browser, acursor);
+end;
+
+procedure TCustomChromiumOSR.doOnScrollOffsetChanged(const browser : ICefBrowser);
+begin
+ If Assigned(FOnScrollOffsetChanged) then FOnScrollOffsetChanged(Self, Browser);
+end;
+
+function TCustomChromiumOSR.doOnBeforeBrowse(const Browser : ICefBrowser;
+ const frame : ICefFrame; const request : ICefRequest; isRedirect : Boolean) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnBeforeBrowse) then
+ FOnBeforeBrowse(Self, Browser, frame, request, isRedirect, Result);
+end;
+
+function TCustomChromiumOSR.doOnBeforeResourceLoad(const Browser : ICefBrowser;
+ const Frame : ICefFrame; const request : ICefRequest) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnBeforeResourceLoad) then FOnBeforeResourceLoad(Self, Browser, frame, request, Result);
+end;
+
+function TCustomChromiumOSR.doOnGetResourceHandler(const Browser : ICefBrowser;
+ const Frame : ICefFrame; const request : ICefRequest) : ICefResourceHandler;
+begin
+ If Assigned(FOnGetResourceHandler) then FOnGetResourceHandler(Self, Browser, frame, request, Result)
+ Else Result := nil;
+end;
+
+procedure TCustomChromiumOSR.doOnResourceRedirect(const Browser : ICefBrowser;
+ const Frame : ICefFrame; const oldUrl : ustring; var newUrl : ustring);
+begin
+ If Assigned(FOnResourceRedirect) then FOnResourceRedirect(Self, Browser, frame, oldUrl, newUrl);
+end;
+
+function TCustomChromiumOSR.doOnGetAuthCredentials(const Browser : ICefBrowser;
+ const Frame : ICefFrame; isProxy : Boolean; const host : ustring;
+ port : Integer; const realm, scheme : ustring;
+ const callback : ICefAuthCallback) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnGetAuthCredentials) then
+ FOnGetAuthCredentials(Self, Browser, frame, isProxy, host, port, realm, scheme, callback, Result);
+end;
+
+function TCustomChromiumOSR.doOnQuotaRequest(const Browser : ICefBrowser;
+ const originUrl : ustring; newSize : Int64; const callback : ICefQuotaCallback) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnQuotaRequest) then
+ FOnQuotaRequest(Self, Browser, originUrl, newSize, callback, Result);
+end;
+
+function TCustomChromiumOSR.doOnGetCookieManager(const Browser : ICefBrowser;
+ const mainUrl : ustring) : ICefCookieManager;
+begin
+ If Assigned(FOnGetCookieManager) then FOnGetCookieManager(Self, Browser, mainUrl, Result)
+ Else Result := nil;
+end;
+
+procedure TCustomChromiumOSR.doOnProtocolExecution(const Browser : ICefBrowser;
+ const url : ustring; out allowOsExecution : Boolean);
+begin
+ If Assigned(FOnProtocolExecution) then
+ FOnProtocolExecution(Self, Browser, url, allowOsExecution);
+end;
+
+function TCustomChromiumOSR.doOnCertificateError(certError : TCefErrorcode;
+ const requestUrl : ustring; callback : ICefAllowCertificateErrorCallback) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnCertificateError) then
+ FOnCertificateError(Self, certError, requestUrl, callback, Result);
+end;
+
+function TCustomChromiumOSR.doOnBeforePluginLoad(const Browser : ICefBrowser;
+ const url, policyUrl : ustring; const info : ICefWebPluginInfo) : Boolean;
+begin
+ Result := False;
+ If Assigned(FOnBeforePluginLoad) then
+ FOnBeforePluginLoad(Self, Browser, url, policyUrl, info, Result);
+end;
+
+procedure TCustomChromiumOSR.doOnPluginCrashed(const Browser : ICefBrowser;
+ const pluginPath : ustring);
+begin
+ If Assigned(FOnPluginCrashed) then FOnPluginCrashed(Self, Browser, pluginPath);
+end;
+
+procedure TCustomChromiumOSR.doOnRenderProcessTerminated(const Browser : ICefBrowser;
+ Status : TCefTerminationStatus);
+begin
+ If Assigned(FOnRenderProcessTerminated) then FOnRenderProcessTerminated(Self, Browser, status);
+end;
+
+constructor TCustomChromiumOSR.Create(AOwner : TComponent);
+begin
+ inherited;
+
+ FDefaultUrl := 'about:blank';
+
+ If not (csDesigning in ComponentState) then
+ begin
+ FHandler := TOSRClientHandler.Create(Self);
+
+ If not Assigned(FHandler) then raise Exception.Create('FHandler is nil');
+ end;
+
+ FOptions := TChromiumOptions.Create;
+ FFontOptions := TChromiumFontOptions.Create;
+
+ FUserStyleSheetLocation := '';
+ FDefaultEncoding := '';
+ FBrowserId := 0;
+ FBrowser := nil;
+end;
+
+destructor TCustomChromiumOSR.Destroy;
+begin
+ // FreeAndNil(FCanvas);
+
+ If FBrowser <> nil then
+ begin
+ FBrowser.StopLoad;
+ FBrowser.Host.ParentWindowWillClose;
+ end;
+
+ If FHandler <> nil then
+ begin
+ (FHandler as TOSRClientHandler).Cleanup;
+ (FHandler as ICefClientHandler).Disconnect;
+ end;
+
+ FHandler := nil;
+ FBrowser := nil;
+ FFontOptions.Free;
+ FOptions.Free;
+
+ inherited;
+end;
+
+procedure TCustomChromiumOSR.Load(const url : ustring);
+Var Frame : ICefFrame;
+begin
+ If FBrowser <> nil then
+ begin
+ Frame := FBrowser.MainFrame;
+
+ If Frame <> nil then
+ begin
+ FBrowser.StopLoad;
+ Frame.LoadUrl(url);
+ end;
+ end;
+end;
+
+end.
+
diff --git a/Component/icon.lrs b/Component/icons.lrs
similarity index 51%
rename from Component/icon.lrs
rename to Component/icons.lrs
index b58735f..3ae5549 100644
--- a/Component/icon.lrs
+++ b/Component/icons.lrs
@@ -52,3 +52,55 @@ LazarusResources.Add('TChromium','PNG',[
+#226#176'M'#246#199#207#174#238'*]'#151'q'#187#127'['#254#5#220#135#138#30
+#220#236'H'#214#0#0#0#0'IEND'#174'B`'#130
]);
+LazarusResources.Add('TChromiumOSR','PNG',[
+ #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
+ +#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147#0#0#0#9'pHYs'#0#0#1'L'#0#0#1
+ +'L'#1'i'#134#189'9'#0#0#0#7'tIME'#7#222#8#16#10'0%'#29'\'#172#195#0#0#4'JIDA'
+ +'TH'#199#197#149'kh\E'#20#199#255'3s'#239#205#190#242#216'Mlt'#211#24#26#26
+ +'['#181#193#128'l'#146#214'B'#171'h4'#5#21'?$'#31#20'+R'#17#170' '#21'[Qi'
+ +#161#133'*j'#213'ZZZ'#165'T?'#8'F"'#149'j_'#148'j#'#177#16#237#131'bjkj4'#233
+ +#22'R['#187#224'f7'#221#189#143#185's'#252#176#217#187#143'FK'#17'q'#224#192
+ +#204'='#231#254#127#247#156'9s'#7#248#143#7#187#145#224#229'o|Q'#235#144#208
+ +'d'#139#149#248#188#183#215#253#215#128'''7'#29#10'J3'#253#140#224'|'#169#16
+ +#162#157's'#17#5#0'W'#145#173#148#28'u'#165#26#178'ms'#227#238#141'O'#196'o'
+ +#8#208#211#223'/p'#22'+5M['''#184#152'%8'#3#231#28#156'3'#128#0#151#20#148'"'
+ +#184'J'#193'UdI'#219#218'!y'#197#134'='#235#31'K^'#23#208#211#211'/'#228'|'
+ +#183'O'#211#140#30'O'#152'1p'#206#188'`E'#0'Q'#14#160#136#160#20'A'#186#242
+ +#162'cf'#150#238'{'#251#233#209#191#5',]?'#160#137'T'#252#171#128#223#215'm'
+ +#232#2#156#229#196#25'c`'#12'`'#211#209'4'#13'PyS'#4#219#145'0m'#231#162#233
+ +#152#11#143'ny'#246'B^S+'#6#184#137#243#239'+'#129#238#172'eC'#186#26#12'M@'
+ +#136#28#4#12#200#231'@ '#15'"]'#5'GJ'#216#142#11'W'#169#168#128#216#5#224#129
+ +'k2X'#177#237'T4T)F~8:Ti'#4#12'p'#206#192#25#131#16#28#130'sh'#26'Gc$'#148#14
+ +#6#253#21#137#180'iH'#169'r%R'#10'T$d92'#213#24#9#173#222#186'j'#217#206#146
+ +#12#12#31#173#11#6'|'#149#243#239'h'#193#240#143'gQY'#29#130#226#4'r]<'#218
+ +'q[r'#225#157's'#252'i['#25#138#184#17#14#234#200#186#10#137#140#132#224#12
+ +#130'3h'#130#193#208'8t'#13'UP'#244#218#214'U'#216'Y'#200#128#136#189#248#201
+ +#217'+'#149#161#138#218#128'O'#224#192#254#1'\'#205'd'#16#170#14#226#241#251
+ +#218#208#24#173#151'?MdJ'#202#217'R'#31#196#156#155#252#152't'#20'*t'#14#141
+ +#23'|'#4#224#207#137#203#209#174#197#243'~'#231#0#176#242#163#225'6'#161#137
+ +'ZMpp'#193#17#235'\'#0#199'q'#17#246#25#184'kn'#20#223#255':'#169'Me'#29#20
+ +#219#169#243'Id'#28#137#186#160#14']0'#175#1#242'C'#15#249#150#0#0#7#0'e'#201
+ +'&'#206#167'['#145#1#209#217#245#152#221'T'#143#174#216'\('#174'!'#157'uJ'
+ +#205#204#217#207#19'S'#8#234'*;'#211'Y'#210't'#163#221#3'H'#178'\V'#214#188
+ +#157#247#180#162'm'#222'-'#24#187'<'#133')'#211')'#181#233','#206'\'#152'DM'
+ +#200'WR:*;'#2#26#0'0'#198#157'\'#219#21#162#170#170'B'#176#9#178'!'#226#211
+ +#210'Yg'#198#223'@4'#236#195#228'U'#211#1'H'#167'2'#10#129#236#2#128'W$'#21
+ +#17#214'=2'#199#139#217'<'#24#199'oYR'#189#11#194'j'#203#254'Q'#190#231#149
+ +#197'%'#226#15#191#254#29#186'Z'#235#172#166#250#234'@9'#248#216'X'#18#142't'
+ +#139'N4'#17#155#206#142#222':'#24#167#252'|'#243'`'#156#134'F/'#167#243#235
+ +'%k'#143#208#146#181'G<'#255#129#147#151#188#249#137#241'$'#29#31'Oz'#235#237
+ +'_'#158#168'->h'#4#0#175#246#255#130#160'_'#135'ap'#188#252'`'#19#0#224#221
+ +#129'8^'#186'77'#255#250#228#132'i'#187#208#193#184'8'#247'G'#6#139'n'#143
+ +#160#163'9'#12#0'8>'#158#4#8#136'5'#215#148#236#1'/N'#205'r'#228#148'e'#187
+ +#144#178'PQ%'#11#254#251#239'n'#240'-ko'#16'{'#135#19'h'#168#243'C'#20#247'&'
+ +#149'l'#176'7J'#0#233'Tj'#141'e'#187'0-Y'#2'x'#243'`'#28#27#247#142'{'#207'v'
+ +#172'hEoG'#180'D0'#214'\'#131#246#178#175#191#6#176'se'#231#7#169#201#228#134
+ +'l'#17' cJd'#178#14'2'#166#196#154#190#17'<'#183#235#244#140'=y'#232't'#226
+ +#186#183#27#21#189'B'#0'h'#245#167'#'#180#166'o'#196#219#184#231'?>M'#239#236
+ +#27#243#214#199#198#10#155#250#225'@|p'#219#225's'#209'2'#157'k.'#28#207#177
+ +'|'#211#225'E'#129'p'#221'v'#193#245'6E'#132#29'+ZK'#2#15#12'_'#193'U'#203'E'
+ +'O'#236#230#153#180#242':'#236#159'/}"'#246#212'{'#223#196't_'#240'!a'#4'z'
+ +#27'"'#254#200#173#179#2#194'V'#238#165'l'#198'>#'#149#243#173#206#245#207'^'
+ +#232'nI'#225#255#26#127#1#156#132#30#239#25#155#183#7#0#0#0#0'IEND'#174'B`'
+ +#130
+]);
diff --git a/Examples/Examples.txt b/Examples/Examples.txt
index 80952be..4c8eed5 100644
--- a/Examples/Examples.txt
+++ b/Examples/Examples.txt
@@ -7,9 +7,19 @@ DOMAccess
GTK2Minimal
Minimal gtk2 example, doesn't use LCL and classes, direct use of cef3api
+JavaScript
+ Shows interaction with JavaScript
+
+ Thanks to stacho for sharing:
+ http://www.lazarusforum.de/viewtopic.php?p=70126#p70134
+
LCLSimple
Simple LCL example to get started
+OSRDemo
+ Basic example on how to use TChromiumOSR.
+ You need BGRAControls for this example (http://wiki.lazarus.freepascal.org/BGRAControls).
+
SubProcess
Minimal subprocess, can be used as is as long as no custom render handler is needed
diff --git a/Examples/JavaScript/handler.pas b/Examples/JavaScript/handler.pas
new file mode 100644
index 0000000..ce3b223
--- /dev/null
+++ b/Examples/JavaScript/handler.pas
@@ -0,0 +1,94 @@
+Unit Handler;
+
+{$MODE objfpc}{$H+}
+
+(*
+ * Everything in here is called from a render process, so there is no access to GUI and all the
+ * data of the main process.
+ *)
+
+Interface
+
+Uses
+ Classes, SysUtils,
+ cef3lcl, cef3types, cef3intf, cef3ref, cef3own, cef3lib;
+
+Type
+ { Custom handler for the render process }
+ TCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn)
+ protected
+ // Für Test Window Bindings
+ procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override;
+ // Für Test Extension
+ procedure OnWebKitInitialized; override;
+ end;
+
+ TMyHandler = class(TCefv8HandlerOwn)
+ protected
+ function Execute(const name: ustring; const obj: ICefv8Value;
+ const arguments: TCefv8ValueArray; var retval: ICefv8Value;
+ var exception: ustring): Boolean; override;
+ end;
+
+Implementation
+
+Var
+ mystr : String;
+
+{ TMyHandler }
+
+function TMyHandler.Execute(const name : ustring; const obj : ICefv8Value;
+ const arguments : TCefv8ValueArray; var retval : ICefv8Value;
+ var exception : ustring) : Boolean;
+begin
+ Result := False;
+
+ Writeln('Execute');
+end;
+
+{ TCustomRenderProcessHandler }
+
+procedure TCustomRenderProcessHandler.OnContextCreated(const browser : ICefBrowser;
+ const frame : ICefFrame; const context : ICefv8Context);
+Var
+ myWin : ICefv8Value;
+ str : String;
+ args : TCefv8ValueArray;
+begin
+ myWin := context.GetGlobal;
+ mystr := 'a test string';
+ SetLength(args,1);
+ args[0] := TCefv8ValueRef.NewString(mystr);
+ myWin.SetValueByKey('myval', args[0], V8_PROPERTY_ATTRIBUTE_NONE);
+end;
+
+procedure TCustomRenderProcessHandler.OnWebKitInitialized;
+Var
+ Code: ustring;
+begin
+ Code :=
+ 'var cef;'+
+ 'if (!cef)'+
+ ' cef = {};'+
+ 'if (!cef.test)'+
+ ' cef.test = {};'+
+ '(function() {'+
+ ' cef.test.__defineGetter__(''test_param'', function() {'+
+ ' native function GetTestParam();'+
+ ' return GetTestParam();'+
+ ' });'+
+ ' cef.test.__defineSetter__(''test_param'', function(b) {'+
+ ' native function SetTestParam();'+
+ ' if(b) SetTestParam(b);'+
+ ' });'+
+ ' cef.test.test_object = function() {'+
+ ' native function GetTestObject();'+
+ ' return GetTestObject();'+
+ ' };'+
+ '})();';
+
+ CefRegisterExtension('example/v8', Code, TMyHandler.Create as ICefv8Handler);
+end;
+
+end.
+
diff --git a/Examples/JavaScript/js.ico b/Examples/JavaScript/js.ico
new file mode 100644
index 0000000..0341321
Binary files /dev/null and b/Examples/JavaScript/js.ico differ
diff --git a/Examples/JavaScript/js.lpi b/Examples/JavaScript/js.lpi
new file mode 100644
index 0000000..d56cbb9
--- /dev/null
+++ b/Examples/JavaScript/js.lpi
@@ -0,0 +1,208 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/JavaScript/js.lpr b/Examples/JavaScript/js.lpr
new file mode 100644
index 0000000..a45eca0
--- /dev/null
+++ b/Examples/JavaScript/js.lpr
@@ -0,0 +1,20 @@
+Program js;
+
+{$MODE objfpc}{$H+}
+
+Uses
+ {$IFDEF UNIX}
+ cthreads,
+ {$ENDIF}
+ Interfaces, // this includes the LCL widgetset
+ Forms, Main;
+
+{$R *.res}
+
+begin
+ RequireDerivedFormResource := True;
+ Application.Initialize;
+ Application.CreateForm(TMainform, Mainform);
+ Application.Run;
+end.
+
diff --git a/Examples/JavaScript/main.lfm b/Examples/JavaScript/main.lfm
new file mode 100644
index 0000000..ca24903
--- /dev/null
+++ b/Examples/JavaScript/main.lfm
@@ -0,0 +1,113 @@
+object Mainform: TMainform
+ Left = 186
+ Height = 587
+ Top = 31
+ Width = 921
+ Anchors = []
+ Caption = 'Browser -'
+ ClientHeight = 587
+ ClientWidth = 921
+ OnCreate = FormCreate
+ LCLVersion = '1.2.4.0'
+ object Chromium: TChromium
+ AnchorSideLeft.Control = Owner
+ AnchorSideTop.Side = asrBottom
+ AnchorSideRight.Control = Owner
+ AnchorSideRight.Side = asrBottom
+ AnchorSideBottom.Control = Log
+ Left = 0
+ Height = 368
+ Top = 80
+ Width = 921
+ Anchors = [akTop, akLeft, akRight, akBottom]
+ DefaultUrl = 'www.google.de'
+ TabOrder = 0
+ OnTitleChange = ChromiumTitleChange
+ end
+ object BGo: TButton
+ AnchorSideTop.Control = Owner
+ AnchorSideRight.Control = Owner
+ AnchorSideRight.Side = asrBottom
+ Left = 837
+ Height = 25
+ Top = 10
+ Width = 79
+ Anchors = [akTop, akRight]
+ BorderSpacing.Top = 10
+ BorderSpacing.Right = 5
+ Caption = 'Go'
+ OnClick = BGoClick
+ TabOrder = 1
+ end
+ object LUrl: TStaticText
+ AnchorSideTop.Control = Owner
+ Left = 8
+ Height = 22
+ Top = 12
+ Width = 25
+ BorderSpacing.Top = 12
+ Caption = 'Url:'
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 2
+ end
+ object EUrl: TEdit
+ AnchorSideLeft.Control = LUrl
+ AnchorSideLeft.Side = asrBottom
+ AnchorSideTop.Control = Owner
+ AnchorSideRight.Control = BGo
+ Left = 38
+ Height = 25
+ Top = 10
+ Width = 794
+ Anchors = [akTop, akLeft, akRight]
+ AutoSize = False
+ BorderSpacing.Left = 5
+ BorderSpacing.Top = 10
+ BorderSpacing.Right = 5
+ OnKeyDown = EUrlKeyDown
+ TabOrder = 3
+ Text = 'http://'
+ end
+ object Log: TMemo
+ AnchorSideLeft.Control = Owner
+ AnchorSideRight.Control = Owner
+ AnchorSideRight.Side = asrBottom
+ AnchorSideBottom.Control = Owner
+ AnchorSideBottom.Side = asrBottom
+ Left = 0
+ Height = 139
+ Top = 448
+ Width = 921
+ Anchors = [akLeft, akRight, akBottom]
+ ScrollBars = ssAutoVertical
+ TabOrder = 4
+ end
+ object Button1: TButton
+ Left = 38
+ Height = 25
+ Top = 48
+ Width = 75
+ Caption = 'Button1'
+ OnClick = Button1Click
+ TabOrder = 5
+ end
+ object Button2: TButton
+ Left = 128
+ Height = 25
+ Top = 48
+ Width = 75
+ Caption = 'Button2'
+ OnClick = Button2Click
+ TabOrder = 6
+ end
+ object Button3: TButton
+ Left = 216
+ Height = 25
+ Top = 48
+ Width = 75
+ Caption = 'Button3'
+ OnClick = Button3Click
+ TabOrder = 7
+ end
+end
diff --git a/Examples/JavaScript/main.pas b/Examples/JavaScript/main.pas
new file mode 100644
index 0000000..f2386af
--- /dev/null
+++ b/Examples/JavaScript/main.pas
@@ -0,0 +1,87 @@
+Unit Main;
+
+{$MODE objfpc}{$H+}
+
+Interface
+
+Uses
+ Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, LCLType, ExtCtrls,
+ cef3types, cef3lib, cef3intf, cef3lcl,
+ Handler; // custom render process handler
+
+Type
+
+ { TMainform }
+
+ TMainform = class(TForm)
+ BGo : TButton;
+ Button1 : TButton;
+ Button2 : TButton;
+ Button3 : TButton;
+ Chromium : TChromium;
+ EUrl : TEdit;
+ LUrl : TStaticText;
+ Log : TMemo;
+ procedure BGoClick(Sender : TObject);
+ procedure Button1Click(Sender : TObject);
+ procedure Button2Click(Sender : TObject);
+ procedure Button3Click(Sender : TObject);
+ procedure ChromiumTitleChange(Sender : TObject; const Browser : ICefBrowser;
+ const title : ustring);
+ procedure EUrlKeyDown(Sender : TObject; var Key : Word; Shift : TShiftState);
+ procedure FormCreate(Sender : TObject);
+ private
+ { private declarations }
+ public
+ { public declarations }
+ end;
+
+Var
+ Mainform : TMainform;
+
+Implementation
+
+{$R *.lfm}
+
+{ TMainform }
+
+procedure TMainform.BGoClick(Sender : TObject);
+begin
+ Chromium.Load(EUrl.Text);
+end;
+
+procedure TMainform.Button1Click(Sender : TObject);
+begin
+ Chromium.Load('about:blank');
+end;
+
+// JavaScript shows value of window.myval
+procedure TMainform.Button2Click(Sender : TObject);
+begin
+ Chromium.Browser.MainFrame.ExecuteJavaScript('alert(window.myval);', 'about:blank', 0);
+end;
+
+// JavaScript executes TMyHandler.Execute
+procedure TMainform.Button3Click(Sender : TObject);
+begin
+ Chromium.Browser.MainFrame.ExecuteJavaScript('cef.test.test_object().GetMessage();', 'about:blank', 0);
+end;
+
+procedure TMainform.ChromiumTitleChange(Sender : TObject; const Browser : ICefBrowser; const title : ustring);
+begin
+ Caption := 'Browser - ' + UTF8Encode(title);
+end;
+
+procedure TMainform.EUrlKeyDown(Sender : TObject; var Key : Word; Shift : TShiftState);
+begin
+ If Key = VK_RETURN then BGoClick(Sender);
+end;
+
+procedure TMainform.FormCreate(Sender : TObject);
+begin
+ // No subprocess here
+ // If you want to use a subprocess, this CefRenderProcessHandler has to be registered in subprocess
+ CefRenderProcessHandler := TCustomRenderProcessHandler.Create;
+end;
+
+end.
diff --git a/Examples/OSRDemo/main.lfm b/Examples/OSRDemo/main.lfm
new file mode 100644
index 0000000..22c4673
--- /dev/null
+++ b/Examples/OSRDemo/main.lfm
@@ -0,0 +1,84 @@
+object Mainform: TMainform
+ Left = 338
+ Height = 475
+ Top = 133
+ Width = 762
+ Caption = 'Browser -'
+ ClientHeight = 475
+ ClientWidth = 762
+ OnCreate = FormCreate
+ LCLVersion = '1.2.4.0'
+ object BGo: TButton
+ AnchorSideTop.Control = Owner
+ AnchorSideRight.Control = Owner
+ AnchorSideRight.Side = asrBottom
+ Left = 678
+ Height = 25
+ Top = 10
+ Width = 79
+ Anchors = [akTop, akRight]
+ BorderSpacing.Top = 10
+ BorderSpacing.Right = 5
+ Caption = 'Go'
+ OnClick = BGoClick
+ TabOrder = 0
+ end
+ object LUrl: TStaticText
+ AnchorSideTop.Control = Owner
+ Left = 8
+ Height = 22
+ Top = 12
+ Width = 25
+ BorderSpacing.Top = 12
+ Caption = 'Url:'
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 1
+ end
+ object EUrl: TEdit
+ AnchorSideLeft.Control = LUrl
+ AnchorSideLeft.Side = asrBottom
+ AnchorSideTop.Control = Owner
+ AnchorSideRight.Control = BGo
+ Left = 38
+ Height = 25
+ Top = 10
+ Width = 635
+ Anchors = [akTop, akLeft, akRight]
+ AutoSize = False
+ BorderSpacing.Left = 5
+ BorderSpacing.Top = 10
+ BorderSpacing.Right = 5
+ OnKeyDown = EUrlKeyDown
+ TabOrder = 2
+ Text = 'http://'
+ end
+ object PaintBox: TPaintBox
+ AnchorSideLeft.Control = Owner
+ AnchorSideTop.Control = EUrl
+ AnchorSideTop.Side = asrBottom
+ AnchorSideRight.Control = Owner
+ AnchorSideRight.Side = asrBottom
+ AnchorSideBottom.Control = Owner
+ AnchorSideBottom.Side = asrBottom
+ Left = 0
+ Height = 430
+ Top = 45
+ Width = 762
+ Anchors = [akTop, akLeft, akRight, akBottom]
+ BorderSpacing.Top = 10
+ OnMouseDown = PaintBoxMouseDown
+ OnMouseMove = PaintBoxMouseMove
+ OnMouseUp = PaintBoxMouseUp
+ OnMouseWheel = PaintBoxMouseWheel
+ OnResize = PaintBoxResize
+ end
+ object Chromium: TChromiumOSR
+ DefaultUrl = 'about:blank'
+ OnGetRootScreenRect = ChromiumGetRootScreenRect
+ OnGetViewRect = ChromiumGetViewRect
+ OnPaint = ChromiumPaint
+ left = 8
+ top = 40
+ end
+end
diff --git a/Examples/OSRDemo/main.pas b/Examples/OSRDemo/main.pas
new file mode 100644
index 0000000..6bf74c6
--- /dev/null
+++ b/Examples/OSRDemo/main.pas
@@ -0,0 +1,197 @@
+Unit Main;
+
+{$MODE objfpc}{$H+}
+
+Interface
+
+Uses
+ Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, LCLType, ExtCtrls,
+ BGRABitmap, BGRABitmapTypes,
+ cef3types, cef3lib, cef3intf, cef3lcl, cef3osr, types;
+
+Type
+
+ { TMainform }
+
+ TMainform = class(TForm)
+ BGo : TButton;
+ Chromium : TChromiumOSR;
+ EUrl : TEdit;
+ LUrl : TStaticText;
+ PaintBox : TPaintBox;
+ procedure BGoClick(Sender : TObject);
+ procedure ChromiumGetRootScreenRect(Sender : TObject;
+ const Browser : ICefBrowser; rect : PCefRect; out Result : Boolean);
+ procedure ChromiumGetViewRect(Sender : TObject;
+ const Browser : ICefBrowser; rect : PCefRect; out Result : Boolean);
+ procedure ChromiumPaint(Sender : TObject; const Browser : ICefBrowser; kind : TCefPaintElementType;
+ dirtyRectsCount : Cardinal; const dirtyRects : PCefRectArray; const buffer : Pointer;
+ awidth, aheight : Integer);
+ procedure EUrlKeyDown(Sender : TObject; var Key : Word;
+ Shift : TShiftState);
+ procedure FormCreate(Sender : TObject);
+ procedure PaintBoxMouseDown(Sender : TObject; Button : TMouseButton;
+ Shift : TShiftState; X, Y : Integer);
+ procedure PaintBoxMouseMove(Sender : TObject; Shift : TShiftState;
+ X, Y : Integer);
+ procedure PaintBoxMouseUp(Sender : TObject; Button : TMouseButton;
+ Shift : TShiftState; X, Y : Integer);
+ procedure PaintBoxMouseWheel(Sender : TObject; Shift : TShiftState;
+ WheelDelta : Integer; MousePos : TPoint; var Handled : Boolean);
+ procedure PaintBoxResize(Sender : TObject);
+ private
+ { private declarations }
+ public
+ { public declarations }
+ end;
+
+Var
+ Mainform : TMainform;
+
+Implementation
+
+{$R *.lfm}
+
+function getModifiers(Shift: TShiftState): TCefEventFlags;
+begin
+ Result := [];
+ if ssShift in Shift then Include(Result, EVENTFLAG_SHIFT_DOWN);
+ if ssAlt in Shift then Include(Result, EVENTFLAG_ALT_DOWN);
+ if ssCtrl in Shift then Include(Result, EVENTFLAG_CONTROL_DOWN);
+ if ssLeft in Shift then Include(Result, EVENTFLAG_LEFT_MOUSE_BUTTON);
+ if ssRight in Shift then Include(Result, EVENTFLAG_RIGHT_MOUSE_BUTTON);
+ if ssMiddle in Shift then Include(Result, EVENTFLAG_MIDDLE_MOUSE_BUTTON);
+end;
+
+function getButton(Button: TMouseButton): TCefMouseButtonType;
+begin
+ Case Button of
+ TMouseButton.mbLeft: Result := MBT_LEFT;
+ TMouseButton.mbRight: Result := MBT_RIGHT;
+ TMouseButton.mbMiddle: Result := MBT_MIDDLE;
+ end;
+end;
+
+{ TMainform }
+
+procedure TMainform.BGoClick(Sender : TObject);
+begin
+ Chromium.Load(EUrl.Text);
+end;
+
+procedure TMainform.ChromiumGetRootScreenRect(Sender : TObject; const Browser : ICefBrowser;
+ rect : PCefRect; out Result : Boolean);
+begin
+ rect^.x := 0;
+ rect^.y := 0;
+ rect^.width := PaintBox.Width;
+ rect^.height := PaintBox.Height;
+ Result := True;
+end;
+
+procedure TMainform.ChromiumGetViewRect(Sender : TObject; const Browser : ICefBrowser;
+ rect : PCefRect; out Result : Boolean);
+Var
+ Point: TPoint;
+begin
+ Point.X := 0;
+ Point.Y := 0;
+
+ Point := PaintBox.ClientToScreen(Point);
+
+ rect^.x := Point.X;
+ rect^.y := Point.Y;
+ rect^.height := PaintBox.Height;
+ rect^.width := PaintBox.Width;
+
+ Result := True;
+end;
+
+procedure TMainform.ChromiumPaint(Sender : TObject; const Browser : ICefBrowser;
+ kind : TCefPaintElementType; dirtyRectsCount : Cardinal; const dirtyRects : PCefRectArray;
+ const buffer : Pointer; awidth, aheight : Integer);
+Var
+ Rect : TRect;
+begin
+ // Much more intelligent implementation possible here
+
+ {$IFDEF WINDOWS}
+ Rect.Bottom := aheight;
+ Rect.Top := 0;
+ {$ELSE}
+ Rect.Bottom := 0;
+ Rect.Top := aheight;
+ {$ENDIF}
+ Rect.Left := 0;
+ Rect.Right := awidth;
+
+ PaintBox.Canvas.Lock;
+ BGRABitmapDraw(PaintBox.Canvas, Rect, buffer, False, awidth, aheight, True);
+ PaintBox.Canvas.Unlock;
+end;
+
+procedure TMainform.EUrlKeyDown(Sender : TObject; var Key : Word; Shift : TShiftState);
+begin
+ If Key = VK_RETURN then BGoClick(Sender);
+end;
+
+procedure TMainform.PaintBoxMouseDown(Sender : TObject; Button : TMouseButton;
+ Shift : TShiftState; X, Y : Integer);
+Var
+ MouseEvent: TCefMouseEvent;
+begin
+ MouseEvent.x := X;
+ MouseEvent.y := Y;
+ MouseEvent.modifiers := getModifiers(Shift);
+ Chromium.Browser.Host.SendMouseClickEvent(MouseEvent, getButton(Button), False, 1);
+end;
+
+procedure TMainform.PaintBoxMouseMove(Sender : TObject; Shift : TShiftState; X, Y : Integer);
+Var
+ MouseEvent: TCefMouseEvent;
+begin
+ MouseEvent.x := X;
+ MouseEvent.y := Y;
+ MouseEvent.modifiers := getModifiers(Shift);
+
+ Chromium.Browser.Host.SendMouseMoveEvent(MouseEvent, not PaintBox.MouseEntered);
+end;
+
+procedure TMainform.PaintBoxMouseUp(Sender : TObject; Button : TMouseButton;
+ Shift : TShiftState; X, Y : Integer);
+Var
+ MouseEvent: TCefMouseEvent;
+begin
+ MouseEvent.x := X;
+ MouseEvent.y := Y;
+ MouseEvent.modifiers := getModifiers(Shift);
+ Chromium.Browser.Host.SendMouseClickEvent(MouseEvent, getButton(Button), True, 1);
+end;
+
+procedure TMainform.PaintBoxMouseWheel(Sender : TObject; Shift : TShiftState; WheelDelta : Integer;
+ MousePos : TPoint; var Handled : Boolean);
+Var
+ MouseEvent: TCefMouseEvent;
+begin
+ MouseEvent.x := MousePos.X;
+ MouseEvent.y := MousePos.Y;
+ MouseEvent.modifiers := getModifiers(Shift);
+
+ Chromium.Browser.Host.SendMouseWheelEvent(MouseEvent, 0, WheelDelta);
+ Handled := True;
+end;
+
+procedure TMainform.PaintBoxResize(Sender : TObject);
+begin
+ Chromium.Browser.Host.WasResized;
+ Chromium.Browser.Host.SendFocusEvent(1);
+ Application.ProcessMessages;
+end;
+
+procedure TMainform.FormCreate(Sender : TObject);
+begin
+ {$INFO subprocess is set here, uncomment to use a subprocess}
+ //CefBrowserSubprocessPath := '.' + PathDelim + 'subprocess'{$IFDEF WINDOWS}+'.exe'{$ENDIF};
+end;
+
+end.
diff --git a/Examples/OSRDemo/osrdemo.ico b/Examples/OSRDemo/osrdemo.ico
new file mode 100644
index 0000000..0341321
Binary files /dev/null and b/Examples/OSRDemo/osrdemo.ico differ
diff --git a/Examples/OSRDemo/osrdemo.lpi b/Examples/OSRDemo/osrdemo.lpi
new file mode 100644
index 0000000..0b2e134
--- /dev/null
+++ b/Examples/OSRDemo/osrdemo.lpi
@@ -0,0 +1,209 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/OSRDemo/osrdemo.lpr b/Examples/OSRDemo/osrdemo.lpr
new file mode 100644
index 0000000..56524e3
--- /dev/null
+++ b/Examples/OSRDemo/osrdemo.lpr
@@ -0,0 +1,20 @@
+Program osrdemo;
+
+{$MODE objfpc}{$H+}
+
+Uses
+ {$IFDEF UNIX}
+ cthreads,
+ {$ENDIF}
+ Interfaces, // this includes the LCL widgetset
+ Forms, Main, bgrabitmappack;
+
+{$R *.res}
+
+begin
+ RequireDerivedFormResource := True;
+ Application.Initialize;
+ Application.CreateForm(TMainform, Mainform);
+ Application.Run;
+end.
+
diff --git a/Examples/WinMinimal/minimal.lpr b/Examples/WinMinimal/minimal.lpr
index 5ad34c9..9d9cd9f 100644
--- a/Examples/WinMinimal/minimal.lpr
+++ b/Examples/WinMinimal/minimal.lpr
@@ -55,7 +55,7 @@ function CefWndProc(Wnd: HWND; message: UINT; wParam: Integer; lParam: Integer):
info.Height := rect.bottom - rect.top;
FillChar(setting, sizeof(setting), 0);
setting.size := SizeOf(setting);
- CefBrowserHostCreateSync(@info, handl, navigateto, @setting, nil);
+ CefBrowserHostCreateBrowserSync(@info, handl, navigateto, @setting, nil);
SetTimer(Wnd, 1, 100, nil);
result := 0;
end;
diff --git a/Readme.md b/Readme.md
index 7348c6c..c74dca8 100644
--- a/Readme.md
+++ b/Readme.md
@@ -68,8 +68,8 @@ Further details can be found [here][6].
## FAQ:
### Which versions of CEF are supported?
-fpCEF3 only supports CEF3, *no* support for CEF1.
-Version 3.1650 (and newer) should work.
+fpCEF3 only supports CEF3, *no* support for CEF1.
+See changelog for the latest supported version, older ones usually don't work, newer ones *may* work, but are *not* recommended.
### Which platforms are supported?
@@ -96,14 +96,13 @@ If you feel like contributing some more Pascal examples - please do.
- compatibility with Free Pascal / Lazarus
- reworked unit layout - more modular
- slightly changed mechanism for loading the library
-- cef3api_static unit
- _removed_ VLC and FMX component
### Can I help?
Of course - patches are always welcome :)
### Can you help?
-To a certain amount - yes, but don't expect too much.
+To a certain amount - yes.
## Links:
* [Chromium Embedded Framework](http://code.google.com/p/chromiumembedded)
diff --git a/cef3api.pas b/cef3api.pas
index a53f04f..2256602 100644
--- a/cef3api.pas
+++ b/cef3api.pas
@@ -4567,7 +4567,6 @@ TCefZipReader = record
cef_api_hash: function(entry: Integer): PChar; cdecl;
-
procedure CefLoadLibrary;
procedure CefCloseLibrary;
diff --git a/cef3api_static.pas b/cef3api_static.pas
deleted file mode 100644
index ca48218..0000000
--- a/cef3api_static.pas
+++ /dev/null
@@ -1,675 +0,0 @@
-(*
- * Free Pascal 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.
- *
- * Author: d.l.i.w
- * Repository: http://github.com/dliw/fpCEF3
- *
- *)
-
-Unit cef3api_static;
-
-{$MODE objfpc}{$H+}
-
-Interface
-
-Uses
- cef3lib;
-
-{$IFDEF WINDOWS}
- {$DEFINE DYNLINK}
-{$ENDIF}
-
-{$IF Defined(DYNLINK)}
-Const
-{$IF Defined(WINDOWS)}
- ceflib = 'libcef.dll';
-{$ELSEIF Defined(UNIX)}
- ceflib = 'libcef.so';
-{$ELSE}
- {$MESSAGE ERROR 'DYNLINK not supported'}
-{$IFEND}
-{$ELSEIF Defined(Darwin)}
- {$linkframework cef}
-{$ELSE}
- {$LINKLIB cef}
-{$ENDIF}
-
-// These functions set string values. If |copy| is true (1) the value will be
-// copied instead of referenced. It is up to the user to properly manage
-// the lifespan of references.
-//function cef_string_wide_set(const src: PWideChar; src_len: Cardinal; output: PCefStringWide; copy: Integer): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//function cef_string_utf8_set(const src: PAnsiChar; src_len: Cardinal; output: PCefStringUtf8; copy: Integer): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_utf16_set(const src: PChar16; src_len: Cardinal; output: PCefStringUtf16; copy: Integer): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_set(const src: PCefChar; src_len: Cardinal; output: PCefString; copy: Integer): Integer;
-
-
-// These functions clear string values. The structure itself is not freed.
-//procedure cef_string_wide_clear(str: PCefStringWide); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//procedure cef_string_utf8_clear(str: PCefStringUtf8); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-procedure cef_string_utf16_clear(str: PCefStringUtf16); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-procedure cef_string_clear(str: PCefString);
-
-
-// These functions compare two string values with the same results as strcmp().
-//function cef_string_wide_cmp(const str1, str2: PCefStringWide): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//function cef_string_utf8_cmp(const str1, str2: PCefStringUtf8): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_utf16_cmp(const str1, str2: PCefStringUtf16): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-
-// These functions convert between UTF-8, -16, and -32 strings. They are
-// potentially slow so unnecessary conversions should be avoided. The best
-// possible result will always be written to |output| with the boolean return
-// value indicating whether the conversion is 100% valid.
-//function cef_string_wide_to_utf8(const src: PWideChar; src_len: Cardinal; output: PCefStringUtf8): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//function cef_string_utf8_to_wide(const src: PAnsiChar; src_len: Cardinal; output: PCefStringWide): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-function cef_string_wide_to_utf16(const src: PWideChar; src_len: Cardinal; output: PCefStringUtf16): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//function cef_string_utf16_to_wide(const src: PChar16; src_len: Cardinal; output: PCefStringWide): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-function cef_string_utf8_to_utf16(const src: PAnsiChar; src_len: Cardinal; output: PCefStringUtf16): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//function cef_string_utf16_to_utf8(const src: PChar16; src_len: Cardinal; output: PCefStringUtf8): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-function cef_string_from_utf8(const src: PAnsiChar; src_len: Cardinal; output: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_from_utf16(const src: PChar16; src_len: Cardinal; output: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_from_wide(const src: PWideChar; src_len: Cardinal; output: PCefString): Integer;
-//function cef_string_to_utf8(const src: PCefChar; src_len: Cardinal; output: PCefStringUtf8): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_to_utf16(const src: PCefChar; src_len: Cardinal; output: PCefStringUtf16): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//function cef_string_to_wide(const src: PCefChar; src_len: Cardinal; output: PCefStringWide): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-
-// These functions convert an ASCII string, typically a hardcoded constant, to a
-// Wide/UTF16 string. Use instead of the UTF8 conversion routines if you know
-// the string is ASCII.
-//function cef_string_ascii_to_wide(const src: PAnsiChar; src_len: Cardinal; output: PCefStringWide): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_ascii_to_utf16(const src: PAnsiChar; src_len: Cardinal; output: PCefStringUtf16): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_from_ascii(const src: PAnsiChar; src_len: Cardinal; output: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-
-// These functions allocate a new string structure. They must be freed by
-// calling the associated free function.
-//function cef_string_userfree_wide_alloc(): PCefStringUserFreeWide; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//function cef_string_userfree_utf8_alloc(): PCefStringUserFreeUtf8; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_userfree_utf16_alloc(): PCefStringUserFreeUtf16; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_userfree_alloc(): PCefStringUserFree;
-
-
-// These functions free the string structure allocated by the associated
-// alloc function. Any string contents will first be cleared.
-//procedure cef_string_userfree_wide_free(str: PCefStringUserFreeWide); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//procedure cef_string_userfree_utf8_free(str: PCefStringUserFreeUtf8); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-procedure cef_string_userfree_utf16_free(str: PCefStringUserFreeUtf16); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-procedure cef_string_userfree_free(str: PCefStringUserFree);
-
-{
-
-// Convenience macros for copying values.
-function cef_string_wide_copy(const src: PWideChar; src_len: Cardinal; output: PCefStringWide): Integer;
-begin
- Result := cef_string_wide_set(src, src_len, output, ord(True))
-end;
-
-function cef_string_utf8_copy(const src: PAnsiChar; src_len: Cardinal; output: PCefStringUtf8): Integer;
-begin
- Result := cef_string_utf8_set(src, src_len, output, ord(True))
-end;
-
-function cef_string_utf16_copy(const src: PChar16; src_len: Cardinal; output: PCefStringUtf16): Integer;
-begin
- Result := cef_string_utf16_set(src, src_len, output, ord(True))
-end;
-
-function cef_string_copy(const src: PCefChar; src_len: Cardinal; output: PCefString): Integer;
-begin
- Result := cef_string_set(src, src_len, output, ord(True));
-end;
-
-}
-
-// Create a new browser window using the window parameters specified by
-// |windowInfo|. All values will be copied internally and the actual window will
-// be created on the UI thread. This function can be called on any browser
-// process thread and will not block.
-function cef_browser_host_create_browser(
- const windowInfo: PCefWindowInfo; client: PCefClient;
- const url: PCefString; const settings: PCefBrowserSettings): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new browser window using the window parameters specified by
-// |windowInfo|. This function can only be called on the browser process UI
-// thread.
-function cef_browser_host_create_browser_sync(
- const windowInfo: PCefWindowInfo; client: PCefClient;
- const url: PCefString; const settings: PCefBrowserSettings): PCefBrowser; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Perform a single iteration of CEF message loop processing. This function is
-// used to integrate the CEF message loop into an existing application message
-// loop. Care must be taken to balance performance against excessive CPU usage.
-// This function should only be called on the main application thread and only
-// if cef_initialize() is called with a CefSettings.multi_threaded_message_loop
-// value of false (0). This function will not block.
-procedure cef_do_message_loop_work(); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Run the CEF message loop. Use this function instead of an application-
-// provided message loop to get the best balance between performance and CPU
-// usage. This function should only be called on the main application thread and
-// only if cef_initialize() is called with a
-// CefSettings.multi_threaded_message_loop value of false (0). This function
-// will block until a quit message is received by the system.
-procedure cef_run_message_loop; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Quit the CEF message loop that was started by calling cef_run_message_loop().
-// This function should only be called on the main application thread and only
-// if cef_run_message_loop() was used.
-procedure cef_quit_message_loop; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a
-// modal message loop. Set to false (0) after exiting the modal message loop.
-procedure cef_set_osmodal_loop(osModalLoop : Integer); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// This function should be called from the application entry point function to
-// execute a secondary process. It can be used to run secondary processes from
-// the browser client executable (default behavior) or from a separate
-// executable specified by the CefSettings.browser_subprocess_path value. If
-// called for the browser process (identified by no "type" command-line value)
-// it will return immediately with a value of -1. If called for a recognized
-// secondary process it will block until the process should exit and then return
-// the process exit code. The |application| parameter may be NULL.
-function cef_execute_process(const args: PCefMainArgs; application: PCefApp): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// This function should be called on the main application thread to initialize
-// the CEF browser process. The |application| parameter may be NULL. A return
-// value of true (1) indicates that it succeeded and false (0) indicates that it
-// failed.
-function cef_initialize(const args: PCefMainArgs; const settings: PCefSettings; application: PCefApp): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// This function should be called on the main application thread to shut down
-// the CEF browser process before the application exits.
-procedure cef_shutdown(); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Allocate a new string map.
-function cef_string_map_alloc(): TCefStringMap; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-//function cef_string_map_size(map: TCefStringMap): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-function cef_string_map_size(map: TCefStringMap): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Return the value assigned to the specified key.
-function cef_string_map_find(map: TCefStringMap; const key: PCefString; var value: TCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Return the key at the specified zero-based string map index.
-function cef_string_map_key(map: TCefStringMap; index: Integer; var key: TCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Return the value at the specified zero-based string map index.
-function cef_string_map_value(map: TCefStringMap; index: Integer; var value: TCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Append a new key/value pair at the end of the string map.
-function cef_string_map_append(map: TCefStringMap; const key, value: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Clear the string map.
-procedure cef_string_map_clear(map: TCefStringMap); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Free the string map.
-procedure cef_string_map_free(map: TCefStringMap); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Allocate a new string map.
-function cef_string_list_alloc(): TCefStringList; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Return the number of elements in the string list.
-function cef_string_list_size(list: TCefStringList): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Retrieve the value at the specified zero-based string list index. Returns
-// true (1) if the value was successfully retrieved.
-function cef_string_list_value(list: TCefStringList; index: Integer; value: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Append a new value at the end of the string list.
-procedure cef_string_list_append(list: TCefStringList; const value: PCefString); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Clear the string list.
-procedure cef_string_list_clear(list: TCefStringList); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Free the string list.
-procedure cef_string_list_free(list: TCefStringList); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Creates a copy of an existing string list.
-function cef_string_list_copy(list: TCefStringList): TCefStringList; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-
-// Register a new V8 extension with the specified JavaScript extension code and
-// handler. Functions implemented by the handler are prototyped using the
-// keyword 'native'. The calling of a native function is restricted to the scope
-// in which the prototype of the native function is defined. This function may
-// only be called on the render process main thread.
-//
-// Example JavaScript extension code:
-//
-// // create the 'example' global object if it doesn't already exist.
-// if (!example)
-// example = {};
-// // create the 'example.test' global object if it doesn't already exist.
-// if (!example.test)
-// example.test = {};
-// (function() {
-// // Define the function 'example.test.myfunction'.
-// example.test.myfunction = function() {
-// // Call CefV8Handler::Execute() with the function name 'MyFunction'
-// // and no arguments.
-// native function MyFunction();
-// return MyFunction();
-// };
-// // Define the getter function for parameter 'example.test.myparam'.
-// example.test.__defineGetter__('myparam', function() {
-// // Call CefV8Handler::Execute() with the function name 'GetMyParam'
-// // and no arguments.
-// native function GetMyParam();
-// return GetMyParam();
-// });
-// // Define the setter function for parameter 'example.test.myparam'.
-// example.test.__defineSetter__('myparam', function(b) {
-// // Call CefV8Handler::Execute() with the function name 'SetMyParam'
-// // and a single argument.
-// native function SetMyParam();
-// if(b) SetMyParam(b);
-// });
-//
-// // Extension definitions can also contain normal JavaScript variables
-// // and functions.
-// var myint = 0;
-// example.test.increment = function() {
-// myint += 1;
-// return myint;
-// };
-// })();
-//
-// Example usage in the page:
-//
-// // Call the function.
-// example.test.myfunction();
-// // Set the parameter.
-// example.test.myparam = value;
-// // Get the parameter.
-// value = example.test.myparam;
-// // Call another function.
-// example.test.increment();
-//
-function cef_register_extension(const extension_name,
- javascript_code: PCefString; handler: PCefv8Handler): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Register a scheme handler factory for the specified |scheme_name| and
-// optional |domain_name|. An NULL |domain_name| value for a standard scheme
-// will cause the factory to match all domain names. The |domain_name| value
-// will be ignored for non-standard schemes. If |scheme_name| is a built-in
-// scheme and no handler is returned by |factory| then the built-in scheme
-// handler factory will be called. If |scheme_name| is a custom scheme the
-// CefRegisterCustomScheme() function should be called for that scheme. This
-// function may be called multiple times to change or remove the factory that
-// matches the specified |scheme_name| and optional |domain_name|. Returns false
-// (0) if an error occurs. This function may be called on any thread.
-function cef_register_scheme_handler_factory(
- const scheme_name, domain_name: PCefString;
- factory: PCefSchemeHandlerFactory): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Clear all registered scheme handler factories. Returns false (0) on error.
-// This function may be called on any thread.
-function cef_clear_scheme_handler_factories: Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Add an entry to the cross-origin access whitelist.
-//
-// The same-origin policy restricts how scripts hosted from different origins
-// (scheme + domain + port) can communicate. By default, scripts can only access
-// resources with the same origin. Scripts hosted on the HTTP and HTTPS schemes
-// (but no other schemes) can use the "Access-Control-Allow-Origin" header to
-// allow cross-origin requests. For example, https://source.example.com can make
-// XMLHttpRequest requests on http://target.example.com if the
-// http://target.example.com request returns an "Access-Control-Allow-Origin:
-// https://source.example.com" response header.
-//
-// Scripts in separate frames or iframes and hosted from the same protocol and
-// domain suffix can execute cross-origin JavaScript if both pages set the
-// document.domain value to the same domain suffix. For example,
-// scheme://foo.example.com and scheme://bar.example.com can communicate using
-// JavaScript if both domains set document.domain="example.com".
-//
-// This function is used to allow access to origins that would otherwise violate
-// the same-origin policy. Scripts hosted underneath the fully qualified
-// |source_origin| URL (like http://www.example.com) will be allowed access to
-// all resources hosted on the specified |target_protocol| and |target_domain|.
-// If |target_domain| is non-NULL and |allow_target_subdomains| if false (0)
-// only exact domain matches will be allowed. If |target_domain| is non-NULL and
-// |allow_target_subdomains| is true (1) sub-domain matches will be allowed. If
-// |target_domain| is NULL and |allow_target_subdomains| if true (1) all domains
-// and IP addresses will be allowed.
-//
-// This function cannot be used to bypass the restrictions on local or display
-// isolated schemes. See the comments on CefRegisterCustomScheme for more
-// information.
-//
-// This function may be called on any thread. Returns false (0) if
-// |source_origin| is invalid or the whitelist cannot be accessed.
-function cef_add_cross_origin_whitelist_entry(const source_origin, target_protocol,
- target_domain: PCefString; allow_target_subdomains: Integer): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Remove an entry from the cross-origin access whitelist. Returns false (0) if
-// |source_origin| is invalid or the whitelist cannot be accessed.
-function cef_remove_cross_origin_whitelist_entry(
- const source_origin, target_protocol, target_domain: PCefString;
- allow_target_subdomains: Integer): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Remove all entries from the cross-origin access whitelist. Returns false (0)
-// if the whitelist cannot be accessed.
-function cef_clear_cross_origin_whitelist: Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Returns true (1) if called on the specified thread. Equivalent to using
-// cef_task_runner_t::GetForThread(threadId)->belongs_to_current_thread().
-function cef_currently_on(threadId: TCefThreadId): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Post a task for execution on the specified thread. Equivalent to using
-// cef_task_runner_t::GetForThread(threadId)->PostTask(task).
-function cef_post_task(threadId: TCefThreadId; task: PCefTask): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Post a task for delayed execution on the specified thread. Equivalent to
-// using cef_task_runner_t::GetForThread(threadId)->PostDelayedTask(task,
-// delay_ms).
-function cef_post_delayed_task(threadId: TCefThreadId;
- task: PCefTask; delay_ms: Int64): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Parse the specified |url| into its component parts. Returns false (0) if the
-// URL is NULL or invalid.
-function cef_parse_url(const url: PCefString; var parts: TCefUrlParts): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Creates a URL from the specified |parts|, which must contain a non-NULL spec
-// or a non-NULL host and path (at a minimum), but not both. Returns false (0)
-// if |parts| isn't initialized as described.
-function cef_create_url(parts: PCefUrlParts; url: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new TCefRequest object.
-function cef_request_create(): PCefRequest; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new TCefPostData object.
-function cef_post_data_create(): PCefPostData; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new cef_post_data_Element object.
-function cef_post_data_element_create(): PCefPostDataElement; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new cef_stream_reader_t object from a file.
-function cef_stream_reader_create_for_file(const fileName: PCefString): PCefStreamReader; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_stream_reader_t object from data.
-function cef_stream_reader_create_for_data(data: Pointer; size: Cardinal): PCefStreamReader; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_stream_reader_t object from a custom handler.
-function cef_stream_reader_create_for_handler(handler: PCefReadHandler): PCefStreamReader; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new cef_stream_writer_t object for a file.
-function cef_stream_writer_create_for_file(const fileName: PCefString): PCefStreamWriter; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_stream_writer_t object for a custom handler.
-function cef_stream_writer_create_for_handler(handler: PCefWriteHandler): PCefStreamWriter; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Returns the current (top) context object in the V8 context stack.
-function cef_v8context_get_current_context(): PCefv8Context; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Returns the entered (bottom) context object in the V8 context stack.
-function cef_v8context_get_entered_context(): PCefv8Context; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Returns true (1) if V8 is currently inside a context.
-function cef_v8context_in_context(): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new cef_v8value_t object of type undefined.
-function cef_v8value_create_undefined(): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_v8value_t object of type null.
-function cef_v8value_create_null(): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_v8value_t object of type bool.
-function cef_v8value_create_bool(value: Integer): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_v8value_t object of type int.
-function cef_v8value_create_int(value: Integer): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_v8value_t object of type unsigned int.
-function cef_v8value_create_uint(value: Cardinal): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_v8value_t object of type double.
-function cef_v8value_create_double(value: Double): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_v8value_t object of type Date. This function should only be
-// called from within the scope of a cef_v8context_tHandler, cef_v8handler_t or
-// cef_v8accessor_t callback, or in combination with calling enter() and exit()
-// on a stored cef_v8context_t reference.
-function cef_v8value_create_date(const value: PCefTime): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_v8value_t object of type string.
-function cef_v8value_create_string(const value: PCefString): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new cef_v8value_t object of type object with optional accessor. This
-// function should only be called from within the scope of a
-// cef_v8context_tHandler, cef_v8handler_t or cef_v8accessor_t callback, or in
-// combination with calling enter() and exit() on a stored cef_v8context_t
-// reference.
-function cef_v8value_create_object(accessor: PCefV8Accessor): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_v8value_t object of type array with the specified |length|.
-// If |length| is negative the returned array will have length 0. This function
-// should only be called from within the scope of a cef_v8context_tHandler,
-// cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling
-// enter() and exit() on a stored cef_v8context_t reference.
-function cef_v8value_create_array(length: Integer): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-// Create a new cef_v8value_t object of type function.
-function cef_v8value_create_function(const name: PCefString; handler: PCefv8Handler): PCefv8Value; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Returns the stack trace for the currently active context. |frame_limit| is
-// the maximum number of frames that will be captured.
-function cef_v8stack_trace_get_current(frame_limit: Integer): PCefV8StackTrace; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new cef_xml_reader_t object. The returned object's functions can
-// only be called from the thread that created the object.
-function cef_xml_reader_create(stream: PCefStreamReader;
- encodingType: TCefXmlEncodingType; const URI: PCefString): PCefXmlReader; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new cef_zip_reader_t object. The returned object's functions can
-// only be called from the thread that created the object.
-function cef_zip_reader_create(stream: PCefStreamReader): PCefZipReader; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Allocate a new string multimap.
-function cef_string_multimap_alloc: TCefStringMultimap; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Return the number of elements in the string multimap.
-function cef_string_multimap_size(map: TCefStringMultimap): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Return the number of values with the specified key.
-function cef_string_multimap_find_count(map: TCefStringMultimap; const key: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Return the value_index-th value with the specified key.
-function cef_string_multimap_enumerate(map: TCefStringMultimap;
- const key: PCefString; value_index: Integer; var value: TCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Return the key at the specified zero-based string multimap index.
-function cef_string_multimap_key(map: TCefStringMultimap; index: Integer; var key: TCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Return the value at the specified zero-based string multimap index.
-function cef_string_multimap_value(map: TCefStringMultimap; index: Integer; var value: TCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Append a new key/value pair at the end of the string multimap.
-function cef_string_multimap_append(map: TCefStringMultimap; const key, value: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Clear the string multimap.
-procedure cef_string_multimap_clear(map: TCefStringMultimap); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Free the string multimap.
-procedure cef_string_multimap_free(map: TCefStringMultimap); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-function cef_build_revision: Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Returns the global cookie manager. By default data will be stored at
-// CefSettings.cache_path if specified or in memory otherwise.
-function cef_cookie_manager_get_global_manager(): PCefCookieManager; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Creates a new cookie manager. If |path| is NULL data will be stored in memory
-// only. Returns NULL if creation fails.
-function cef_cookie_manager_create_manager(const path: PCefString): PCefCookieManager; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new cef_command_line_t instance.
-function cef_command_line_create(): PCefCommandLine; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Returns the singleton global cef_command_line_t object. The returned object
-// will be read-only.
-function cef_command_line_get_global(): PCefCommandLine; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-
-// Create a new cef_process_message_t object with the specified name.
-function cef_process_message_create(const name: PCefString): PCefProcessMessage; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Creates a new object that is not owned by any other object. The specified
-// |data| will be copied.
-function cef_binary_value_create(const data: Pointer; data_size: Cardinal): PCefBinaryValue; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Creates a new object that is not owned by any other object.
-function cef_dictionary_value_create: PCefDictionaryValue; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Creates a new object that is not owned by any other object.
-function cef_list_value_create: PCefListValue; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Retrieve the path associated with the specified |key|. Returns true (1) on
-// success. Can be called on any thread in the browser process.
-function cef_get_path(key: TCefPathKey; path: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Launches the process specified via |command_line|. Returns true (1) upon
-// success. Must be called on the browser process TID_PROCESS_LAUNCHER thread.
-//
-// Unix-specific notes: - All file descriptors open in the parent process will
-// be closed in the
-// child process except for stdin, stdout, and stderr.
-// - If the first argument on the command line does not contain a slash,
-// PATH will be searched. (See man execvp.)
-function cef_launch_process(command_line: PCefCommandLine): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new cef_response_t object.
-function cef_response_create: PCefResponse; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request
-// functions are supported. The |request| object will be marked as read-only
-// after calling this function.
-function cef_urlrequest_create(request: PCefRequest; client: PCefUrlRequestClient): PCefUrlRequest; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Visit web plugin information.
-procedure cef_visit_web_plugin_info(visitor: PCefWebPluginInfoVisitor); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Cause the plugin list to refresh the next time it is accessed regardless of
-// whether it has already been loaded. Can be called on any thread in the
-// browser process.
-procedure cef_refresh_web_plugins; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Add a plugin path (directory + file). This change may not take affect until
-// after cef_refresh_web_plugins() is called. Can be called on any thread in the
-// browser process.
-procedure cef_add_web_plugin_path(const path: PCefString); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Add a plugin directory. This change may not take affect until after
-// cef_refresh_web_plugins() is called. Can be called on any thread in the
-// browser process.
-procedure cef_add_web_plugin_directory(const dir: PCefString); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Remove a plugin path (directory + file). This change may not take affect
-// until after cef_refresh_web_plugins() is called. Can be called on any thread
-// in the browser process.
-procedure cef_remove_web_plugin_path(const path: PCefString); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Unregister an internal plugin. This may be undone the next time
-// cef_refresh_web_plugins() is called. Can be called on any thread in the
-// browser process.
-procedure cef_unregister_internal_web_plugin(const path: PCefString); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Force a plugin to shutdown. Can be called on any thread in the browser
-// process but will be executed on the IO thread.
-procedure cef_force_web_plugin_shutdown(const path: PCefString); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Register a plugin crash. Can be called on any thread in the browser process
-// but will be executed on the IO thread.
-procedure cef_register_web_plugin_crash(const path: PCefString); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Query if a plugin is unstable. Can be called on any thread in the browser
-// process.
-procedure cef_is_web_plugin_unstable(const path: PCefString;
- callback: PCefWebPluginUnstableCallback); cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Request a one-time geolocation update. This function bypasses any user
-// permission checks so should only be used by code that is allowed to access
-// location information.
-function cef_get_geolocation(callback: PCefGetGeolocationCallback): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Returns the task runner for the current thread. Only CEF threads will have
-// task runners. An NULL reference will be returned if this function is called
-// on an invalid thread.
-function cef_task_runner_get_for_current_thread: PCefTaskRunner; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Returns the task runner for the specified CEF thread.
-function cef_task_runner_get_for_thread(threadId: TCefThreadId): PCefTaskRunner; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-
-
-// Start tracing events on all processes. Tracing begins immediately locally,
-// and asynchronously on child processes as soon as they receive the
-// BeginTracing request.
-//
-// If CefBeginTracing was called previously, or if a CefEndTracingAsync call is
-// pending, CefBeginTracing will fail and return false (0).
-//
-// |categories| is a comma-delimited list of category wildcards. A category can
-// have an optional '-' prefix to make it an excluded category. Having both
-// included and excluded categories in the same list is not supported.
-//
-// Example: "test_MyTest*" Example: "test_MyTest*,test_OtherStuff" Example:
-// "-excluded_category1,-excluded_category2"
-//
-// This function must be called on the browser process UI thread.
-function cef_begin_tracing(client: PCefTraceClient; const categories: PCefString): Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Get the maximum trace buffer percent full state across all processes.
-//
-// cef_trace_client_t::OnTraceBufferPercentFullReply will be called
-// asynchronously after the value is determibed. When any child process reaches
-// 100% full tracing will end automatically and
-// cef_trace_client_t::OnEndTracingComplete will be called. This function fails
-// and returns false (0) if trace is ending or disabled, no cef_trace_client_t
-// was passed to CefBeginTracing, or if a previous call to
-// CefGetTraceBufferPercentFullAsync is pending.
-//
-// This function must be called on the browser process UI thread.
-function cef_get_trace_buffer_percent_full_async: Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-// Stop tracing events on all processes.
-//
-// This function will fail and return false (0) if a previous call to
-// CefEndTracingAsync is already pending or if CefBeginTracing was not called.
-//
-// This function must be called on the browser process UI thread.
-function cef_end_tracing_async: Integer; cdecl; external {$IFDEF DYNLINK}ceflib{$ENDIF};
-
-{external {$IFDEF DYNLINK}ceflib{$ENDIF};}
-
-Implementation
-
-Uses Math;
-
-function cef_string_set(const src : PCefChar; src_len : Cardinal; output : PCefString; copy : Integer) : Integer;
-begin
- {$IFDEF CEF_STRING_TYPE_UTF16}
- Result := cef_string_set(src, src_len, output, copy);
- {$ENDIF}
-end;
-
-procedure cef_string_clear(str : PCefString);
-begin
- {$IFDEF CEF_STRING_TYPE_UTF16}
- cef_string_utf16_clear(str);
- {$ENDIF}
-end;
-
-function cef_string_from_wide(const src : PWideChar; src_len : Cardinal; output : PCefString) : Integer;
-begin
- {$IFDEF CEF_STRING_TYPE_UTF16}
- Result := cef_string_wide_to_utf16(src, src_len, output);
- {$ENDIF}
-end;
-
-function cef_string_userfree_alloc : PCefStringUserFree;
-begin
- {$IFDEF CEF_STRING_TYPE_UTF16}
- Result := cef_string_userfree_utf16_alloc;
- {$ENDIF}
-end;
-
-procedure cef_string_userfree_free(str : PCefStringUserFree);
-begin
- {$IFDEF CEF_STRING_TYPE_UTF16}
- cef_string_userfree_utf16_free(str);
- {$ENDIF}
-end;
-
-Initialization
- // Set exception masks
- Set8087CW(Get8087CW or $3F);
- SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);
-
-end.
\ No newline at end of file
diff --git a/cef3gui.pas b/cef3gui.pas
index 58a24e4..61924ca 100644
--- a/cef3gui.pas
+++ b/cef3gui.pas
@@ -116,15 +116,18 @@
rect: PCefRect; out Result: Boolean) of object;
TOnGetScreenPoint = procedure(Sender: TObject; const Browser: ICefBrowser;
viewX, viewY: Integer; screenX, screenY: PInteger; out Result: Boolean) of object;
+ TOnGetScreenInfo = procedure(Sender: TObject; const browser : ICefBrowser;
+ var screenInfo : TCefScreenInfo; out Result: Boolean) of object;
TOnPopupShow = procedure(Sender: TObject; const Browser: ICefBrowser;
- show: Boolean) of Object;
+ show_: Boolean) of object;
TOnPopupSize = procedure(Sender: TObject; const Browser: ICefBrowser;
const rect: PCefRect) of object;
TOnPaint = procedure(Sender: TObject; const Browser: ICefBrowser;
kind: TCefPaintElementType; dirtyRectsCount: Cardinal; const dirtyRects: PCefRectArray;
- const buffer: Pointer; width, height: Integer) of object;
+ const buffer: Pointer; awidth, aheight: Integer) of object;
TOnCursorChange = procedure(Sender: TObject; const Browser: ICefBrowser;
cursor: TCefCursorHandle) of object;
+ TOnScrollOffsetChanged = procedure(Sender: TObject; const Browser: ICefBrowser) of object;
{ RequestHandler }
TOnBeforeBrowse = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame;
@@ -145,8 +148,8 @@
const mainUrl: ustring; out Result: ICefCookieManager) of object;
TOnProtocolExecution = procedure(Sender: TObject; const Browser: ICefBrowser;
const url: ustring; out allowOsExecution: Boolean) of object;
- TOnCertificateError = function(Sender: TObject; certError: TCefErrorcode; const requestUrl: ustring;
- callback: ICefAllowCertificateErrorCallback): Boolean of object;
+ TOnCertificateError = procedure(Sender: TObject; certError: TCefErrorcode; const requestUrl: ustring;
+ callback: ICefAllowCertificateErrorCallback; out Result: Boolean) of object;
TOnBeforePluginLoad = procedure(Sender: TObject; const Browser: ICefBrowser;
const url, policyUrl: ustring; const info: ICefWebPluginInfo; out Result: Boolean) of object;
TOnPluginCrashed = procedure(Sender: TObject; const browser: ICefBrowser; const plugin_path: ustring) of object;
@@ -312,14 +315,14 @@ TChromiumFontOptions = class(TPersistent)
function doOnGetViewRect(const browser: ICefBrowser; rect: PCefRect): Boolean;
function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer;
screenX, screenY: PInteger): Boolean;
- // function doGetSceenInfo(browser: ICefBrowser; var screenInfo: PCefScreenInfo): Boolean; { TODO }
+ function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean;
procedure doOnPopupShow(const browser: ICefBrowser; show: Boolean);
procedure doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect);
procedure doOnPaint(const browser: ICefBrowser; kind: TCefPaintElementType;
dirtyRectsCount: TSize; const dirtyRects: PCefRectArray;
const buffer: Pointer; width, height: Integer);
procedure doOnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle);
- //procedure doOnScrollOffsetChanged(const browser: ICefBrowser); { TODO }
+ procedure doOnScrollOffsetChanged(const browser: ICefBrowser);
{ CefRequestHandler }
function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame;
@@ -557,12 +560,14 @@ TCustomRenderHandler = class(TCefRenderHandlerOwn)
function GetViewRect(const Browser: ICefBrowser; rect: PCefRect): Boolean; override;
function GetScreenPoint(const Browser: ICefBrowser; viewX, viewY: Integer;
screenX, screenY: PInteger): Boolean; override;
+ function GetScreenInfo(const Browser: ICefBrowser; screenInfo: PCefScreenInfo): Boolean; override;
procedure OnPopupShow(const Browser: ICefBrowser; show: Boolean); override;
procedure OnPopupSize(const Browser: ICefBrowser; const rect: PCefRect); override;
procedure OnPaint(const Browser: ICefBrowser; kind: TCefPaintElementType;
dirtyRectsCount: TSize; const dirtyRects: PCefRectArray;
const buffer: Pointer; width, height: Integer); override;
procedure OnCursorChange(const Browser: ICefBrowser; cursor: TCefCursorHandle); override;
+ procedure OnScrollOffsetChanged(const Browser: ICefBrowser); override;
public
constructor Create(const events: IChromiumEvents); reintroduce; virtual;
end;
@@ -612,6 +617,7 @@ constructor TCustomClientHandler.Create(const events: IChromiumEvents);
FKeyboardHandler := TCustomKeyboardHandler.Create(events);
FDisplayHandler := TCustomDisplayHandler.Create(events);
FDownloadHandler := TCustomDownloadHandler.Create(events);
+ FDragHandler := TCustomDragHandler.Create(events);
FGeolocationHandler := TCustomGeolocationHandler.Create(events);
FJsDialogHandler := TCustomJsDialogHandler.Create(events);
FLifeSpanHandler := TCustomLifeSpanHandler.Create(events);
@@ -629,6 +635,7 @@ procedure TCustomClientHandler.Disconnect;
FKeyboardHandler := nil;
FDisplayHandler := nil;
FDownloadHandler := nil;
+ FDragHandler := nil;
FGeolocationHandler := nil;
FJsDialogHandler := nil;
FLifeSpanHandler := nil;
@@ -1055,6 +1062,12 @@ function TCustomRenderHandler.GetScreenPoint(const Browser: ICefBrowser; viewX,
Result := FEvent.doOnGetScreenPoint(Browser, viewX, viewY, screenX, screenY);
end;
+function TCustomRenderHandler.GetScreenInfo(const Browser : ICefBrowser;
+ screenInfo : PCefScreenInfo) : Boolean;
+begin
+ Result := FEvent.doOnGetScreenInfo(Browser, screenInfo^);
+end;
+
function TCustomRenderHandler.GetViewRect(const Browser: ICefBrowser; rect: PCefRect): Boolean;
begin
Result := FEvent.doOnGetViewRect(Browser, rect);
@@ -1065,6 +1078,11 @@ procedure TCustomRenderHandler.OnCursorChange(const Browser: ICefBrowser; cursor
FEvent.doOnCursorChange(Browser, cursor);
end;
+procedure TCustomRenderHandler.OnScrollOffsetChanged(const Browser : ICefBrowser);
+begin
+ FEvent.doOnScrollOffsetChanged(Browser);
+end;
+
procedure TCustomRenderHandler.OnPaint(const Browser: ICefBrowser;
kind: TCefPaintElementType; dirtyRectsCount: TSize;
const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer);
diff --git a/cef3intf.pas b/cef3intf.pas
index d7a72bb..d44c849 100644
--- a/cef3intf.pas
+++ b/cef3intf.pas
@@ -700,7 +700,7 @@
function GetViewRect(const browser: ICefBrowser; rect: PCefRect): Boolean;
function GetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer;
screenX, screenY: PInteger): Boolean;
- function GetScreenInfo(browser: ICefBrowser; screenInfo: PCefScreenInfo): Boolean;
+ function GetScreenInfo(const browser: ICefBrowser; screenInfo: PCefScreenInfo): Boolean;
procedure OnPopupShow(const browser: ICefBrowser; show: Boolean);
procedure OnPopupSize(const browser: ICefBrowser; const rect: PCefRect);
procedure OnPaint(const browser: ICefBrowser; aType: TCefPaintElementType;
@@ -901,14 +901,14 @@
ICefUrlRequest = interface(ICefBase) ['{59226AC1-A0FA-4D59-9DF4-A65C42391A67}']
function GetRequest: ICefRequest;
- function GetClient: ICefClient; {$NOTE !}
+ function GetClient: ICefUrlRequestClient;
function GetRequestStatus: TCefUrlRequestStatus;
function GetRequestError: TCefErrorcode;
function GetResponse: ICefResponse;
procedure Cancel;
end;
- ICefUrlrequestClient = interface(ICefBase) ['{114155BD-C248-4651-9A4F-26F3F9A4F737}']
+ ICefUrlRequestClient = interface(ICefBase) ['{114155BD-C248-4651-9A4F-26F3F9A4F737}']
procedure OnRequestComplete(const request: ICefUrlRequest);
procedure OnUploadProgress(const request: ICefUrlRequest; current, total: UInt64);
procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: UInt64);
@@ -939,7 +939,6 @@
var exception: ustring): Boolean;
end;
- {$NOTE (u)string ?}
ICefV8Accessor = interface(ICefBase) ['{DCA6D4A2-726A-4E24-AA64-5E8C731D868A}']
function Get(const name: ustring; const obj: ICefv8Value;
out value: ICefv8Value; const exception: string): Boolean;
diff --git a/cef3lib.pas b/cef3lib.pas
index a74c7d0..a3afaef 100644
--- a/cef3lib.pas
+++ b/cef3lib.pas
@@ -73,8 +73,7 @@ function CefRemoveCrossOriginWhitelistEntry(
AllowTargetSubdomains: Boolean): Boolean;
function CefClearCrossOriginWhitelist: Boolean;
-function CefRegisterExtension(const name, code: ustring;
- const Handler: ICefv8Handler): Boolean;
+function CefRegisterExtension(const name, code: ustring; const Handler: ICefv8Handler): Boolean;
function CefCurrentlyOn(ThreadId: TCefThreadId): Boolean;
procedure CefPostTask(ThreadId: TCefThreadId; const task: ICefTask);
procedure CefPostDelayedTask(ThreadId: TCefThreadId; const task: ICefTask; delayMs: Int64);
@@ -105,14 +104,14 @@ procedure CefRunMessageLoop;
procedure CefQuitMessageLoop;
{$ENDIF}
-function CefBrowserHostCreateSync(windowInfo: PCefWindowInfo; const client: ICefClient;
+function CefBrowserHostCreateBrowserSync(windowInfo: PCefWindowInfo; const client: ICefClient;
const url: ustring; const settings: PCefBrowserSettings; const requestContext: ICefRequestContext): ICefBrowser;
function CefBrowserHostCreateBrowser(windowInfo: PCefWindowInfo; const client: ICefClient;
const url: ustring; const settings: PCefBrowserSettings; const requestContext: ICefRequestContext): Boolean;
-function CefRequestCreate:ICefRequest;
-function CefPostDataCreate:ICefPostData;
-function CefPostDataElementCreate:ICefPostDataElement;
+function CefRequestCreate: ICefRequest;
+function CefPostDataCreate: ICefPostData;
+function CefPostDataElementCreate: ICefPostDataElement;
function CefBeginTracing(const client: ICefTraceClient; const categories: ustring): Boolean;
function CefGetTraceBufferPercentFullAsync: Integer;
@@ -209,7 +208,6 @@ function CefInitialize(const Cache, UserAgent, ProductVersion, Locale, LogFile,
ErrCode: Integer;
Args : TCefMainArgs;
- i : Integer;
begin
{$IFDEF DEBUG}
Debugln('CefInitialize');
@@ -442,12 +440,12 @@ function CefClearCrossOriginWhitelist: Boolean;
Result := cef_clear_cross_origin_whitelist() <> 0;
end;
-function CefRegisterExtension(const name, code: ustring;
- const Handler: ICefv8Handler): Boolean;
+function CefRegisterExtension(const name, code: ustring; const Handler: ICefv8Handler): Boolean;
Var
n, c: TCefString;
begin
- CefInitDefault;
+ { TODO : Hier wird doppelt initialisiert? }
+ //CefInitDefault;
n := CefString(name);
c := CefString(code);
Result := cef_register_extension(@n, @c, CefGetData(handler)) <> 0;
@@ -615,19 +613,7 @@ procedure CefQuitMessageLoop;
end;
{$ENDIF}
-{$NOTE duplicate? }
-function CefBrowserHostCreate(windowInfo: PCefWindowInfo; const client: ICefClient;
- const url: ustring; const settings: PCefBrowserSettings; const requestContext: ICefRequestContext): Boolean;
-
-Var
- u: TCefString;
-begin
- CefInitDefault;
- u := CefString(url);
- Result := cef_browser_host_create_browser(windowInfo, CefGetData(client), @u, settings, CefGetData(requestContext)) <> 0;
-end;
-
-function CefBrowserHostCreateSync(windowInfo: PCefWindowInfo; const client: ICefClient;
+function CefBrowserHostCreateBrowserSync(windowInfo: PCefWindowInfo; const client: ICefClient;
const url: ustring; const settings: PCefBrowserSettings; const requestContext: ICefRequestContext): ICefBrowser;
Var
u: TCefString;
@@ -767,4 +753,4 @@ procedure TC.Execute;
Finalization
CefShutDown;
-end.
+end.
\ No newline at end of file
diff --git a/cef3own.pas b/cef3own.pas
index 37def50..dd13f08 100644
--- a/cef3own.pas
+++ b/cef3own.pas
@@ -286,14 +286,14 @@ TCefRenderHandlerOwn = class(TCefBaseOwn, ICefRenderHandler)
function GetViewRect(const browser: ICefBrowser; rect: PCefRect): Boolean; virtual;
function GetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer;
screenX, screenY: PInteger): Boolean; virtual;
- function GetScreenInfo(browser: ICefBrowser; screenInfo: PCefScreenInfo): Boolean;
+ function GetScreenInfo(const browser: ICefBrowser; screenInfo: PCefScreenInfo): Boolean; virtual;
procedure OnPopupShow(const browser: ICefBrowser; show: Boolean); virtual;
procedure OnPopupSize(const browser: ICefBrowser; const rect: PCefRect); virtual;
procedure OnPaint(const browser: ICefBrowser; kind: TCefPaintElementType;
dirtyRectsCount: TSize; const dirtyRects: PCefRectArray;
const buffer: Pointer; width, height: Integer); virtual;
procedure OnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle); virtual;
- procedure OnScrollOffsetChanged(const browser: ICefBrowser);
+ procedure OnScrollOffsetChanged(const browser: ICefBrowser); virtual;
public
constructor Create; virtual;
end;
@@ -364,7 +364,7 @@ TCefRequestHandlerOwn = class(TCefBaseOwn, ICefRequestHandler)
function OnBeforePluginLoad(const browser: ICefBrowser; const url, policyUrl: ustring;
const info: ICefWebPluginInfo): Boolean; virtual;
function OnCertificateError(certError: TCefErrorcode; const requestUrl: ustring;
- callback: ICefAllowCertificateErrorCallback): Boolean; {$NOTE !}
+ callback: ICefAllowCertificateErrorCallback): Boolean;
procedure OnPluginCrashed(const browser: ICefBrowser; const plugin_path: ustring);
procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus);
public
@@ -623,7 +623,7 @@ function cef_drag_handler_on_drag_enter(self: PCefDragHandler; browser: PCefBrow
dragData: PCefDragData; mask: TCefDragOperationsMask): Integer; cconv;
begin
Result := Ord(TCefDragHandlerOwn(CefGetObject(self)).OnDragEnter(
- TCefBrowserRef.UnWrap(browser), TCefDragDataRef(dragData), mask));
+ TCefBrowserRef.UnWrap(browser), TCefDragDataRef.UnWrap(dragData), mask));
end;
function TCefDragHandlerOwn.OnDragEnter(const browser : ICefBrowser; const dragData : ICefDragData;
@@ -672,7 +672,7 @@ constructor TCefBaseOwn.CreateData(size : TSize; owned : Boolean);
destructor TCefBaseOwn.Destroy;
begin
{$IFDEF DEBUG}
- WriteLn(Self.ClassName, '.Destroy; RefCount: ', Self.RefCount);
+ DebugLn(Self.ClassName, '.Destroy; RefCount: ', Self.RefCount);
{$ENDIF}
Dec(FData, SizeOf(Pointer));
@@ -1789,8 +1789,7 @@ procedure cef_render_handler_on_paint(self : PCefRenderHandler; browser: PCefBro
const buffer : Pointer; width, height : Integer); cconv;
begin
With TCefRenderHandlerOwn(CefGetObject(self)) do
- OnPaint(TCefBrowserRef.UnWrap(browser), type_, dirtyRectsCount, dirtyRects,
- buffer, width, height);
+ OnPaint(TCefBrowserRef.UnWrap(browser), type_, dirtyRectsCount, dirtyRects, buffer, width, height);
end;
procedure cef_render_handler_on_cursor_change(self : PCefRenderHandler; browser : PCefBrowser;
@@ -1823,7 +1822,7 @@ function TCefRenderHandlerOwn.GetScreenPoint(const browser : ICefBrowser;
Result := False;
end;
-function TCefRenderHandlerOwn.GetScreenInfo(browser : ICefBrowser;
+function TCefRenderHandlerOwn.GetScreenInfo(const browser : ICefBrowser;
screenInfo : PCefScreenInfo) : Boolean;
begin
Result := False;
@@ -2269,8 +2268,6 @@ function cef_request_handler_on_before_plugin_load(self : PCefRequestHandler; br
function cef_request_handler_on_certificate_error(self : PCefRequestHandler; cert_error : TCefErrorcode;
const request_url : PCefString; callback : PCefAllowCertificateErrorCallback) : Integer; cconv;
-Var
- r : ustring;
begin
With TCefRequestHandlerOwn(CefGetObject(self)) do
Result := Ord(OnCertificateError(cert_error, CefString(request_url),
diff --git a/cef3ref.pas b/cef3ref.pas
index b6489ee..0867e80 100644
--- a/cef3ref.pas
+++ b/cef3ref.pas
@@ -96,9 +96,9 @@ TCefBrowserHostRef = class(TCefBaseRef, ICefBrowserHost)
procedure WasResized;
procedure WasHidden(hidden: Boolean);
procedure NotifyScreenInfoChanged;
- procedure Invalidate(const dirtyRect:PCefRect; const aType:TCefPaintElementType);
+ procedure Invalidate(const dirtyRect: PCefRect; const aType: TCefPaintElementType);
procedure SendKeyEvent(const event:TCefKeyEvent);
- procedure SendMouseClickEvent(const event:TCefMouseEvent; aType:TCefMouseButtonType;
+ procedure SendMouseClickEvent(const event: TCefMouseEvent; aType: TCefMouseButtonType;
mouseUp: Boolean; clickCount: Integer);
procedure SendMouseMoveEvent(event:TCefMouseEvent; mouseLeave:boolean);
procedure SendMouseWheelEvent(const event:TCefMouseEvent; deltaX, deltaY: Integer);
@@ -596,7 +596,7 @@ TCefTaskRunnerRef = class(TCefBaseRef, ICefTaskRunner)
TCefUrlRequestRef = class(TCefBaseRef, ICefUrlRequest)
protected
function GetRequest: ICefRequest;
- function GetClient: ICefClient; {$NOTE !}
+ function GetClient: ICefUrlRequestClient;
function GetRequestStatus: TCefUrlRequestStatus;
function GetRequestError: TCefErrorcode;
function GetResponse: ICefResponse;
@@ -606,6 +606,18 @@ TCefUrlRequestRef = class(TCefBaseRef, ICefUrlRequest)
class function New(const request: ICefRequest; const client: ICefUrlRequestClient): ICefUrlRequest;
end;
+ TCefUrlRequestClientRef = class(TCefBaseRef, ICefUrlRequestClient)
+ protected
+ procedure OnRequestComplete(const request: ICefUrlRequest);
+ procedure OnUploadProgress(const request: ICefUrlRequest; current, total: UInt64);
+ procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: UInt64);
+ procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: TSize);
+ function GetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer;
+ const realm, scheme: ustring; callback: ICefAuthCallback): Boolean;
+ public
+ class function UnWrap(data: Pointer): ICefUrlRequestClient;
+ end;
+
TCefv8ContextRef = class(TCefBaseRef, ICefv8Context)
protected
function GetTaskRunner:ICefTaskRunner;
@@ -909,42 +921,6 @@ class function TCefAllowCertificateErrorCallbackRef.UnWrap(data : Pointer) : ICe
Else Result := nil;
end;
-{ TCefRequestContextHandlerRef }
-
-function TCefRequestContextHandlerRef.GetCookieManager : ICefCookieManager;
-begin
- Result := TCefCookieManagerRef.UnWrap(PCefRequestContextHandler(FData)^.get_cookie_manager(FData));
-end;
-
-class function TCefRequestContextHandlerRef.UnWrap(data : Pointer) : ICefRequestContextHandler;
-begin
- If data <> nil then Result := Create(data) as ICefRequestContextHandler
- Else Result := nil;
-end;
-
-{ TCefRequestContextRef }
-
-function TCefRequestContextRef.IsSame(other : ICefRequestContext) : Boolean;
-begin
- Result := PCefRequestContext(FData)^.is_same(PCefRequestContext(FData), CefGetData(other)) <> 0;
-end;
-
-function TCefRequestContextRef.IsGlobal : Boolean;
-begin
- Result := PCefRequestContext(FData)^.is_global(PCefRequestContext(FData)) <> 0;
-end;
-
-function TCefRequestContextRef.GetHandler : ICefRequestContextHandler;
-begin
- Result := TCefRequestContextHandlerRef.UnWrap(PCefRequestContext(FData)^.get_handler(PCefRequestContext(FData)));
-end;
-
-class function TCefRequestContextRef.UnWrap(data : Pointer) : ICefRequestContext;
-begin
- If data <> nil then Result := Create(data) as ICefRequestContext
- Else Result := nil;
-end;
-
{ TCefBaseRef }
constructor TCefBaseRef.Create(data : Pointer);
@@ -2973,6 +2949,42 @@ class function TCefPostDataElementRef.New : ICefPostDataElement;
Result := UnWrap(cef_post_data_element_create);
end;
+{ TCefRequestContextRef }
+
+function TCefRequestContextRef.IsSame(other : ICefRequestContext) : Boolean;
+begin
+ Result := PCefRequestContext(FData)^.is_same(PCefRequestContext(FData), CefGetData(other)) <> 0;
+end;
+
+function TCefRequestContextRef.IsGlobal : Boolean;
+begin
+ Result := PCefRequestContext(FData)^.is_global(PCefRequestContext(FData)) <> 0;
+end;
+
+function TCefRequestContextRef.GetHandler : ICefRequestContextHandler;
+begin
+ Result := TCefRequestContextHandlerRef.UnWrap(PCefRequestContext(FData)^.get_handler(PCefRequestContext(FData)));
+end;
+
+class function TCefRequestContextRef.UnWrap(data : Pointer) : ICefRequestContext;
+begin
+ If data <> nil then Result := Create(data) as ICefRequestContext
+ Else Result := nil;
+end;
+
+{ TCefRequestContextHandlerRef }
+
+function TCefRequestContextHandlerRef.GetCookieManager : ICefCookieManager;
+begin
+ Result := TCefCookieManagerRef.UnWrap(PCefRequestContextHandler(FData)^.get_cookie_manager(FData));
+end;
+
+class function TCefRequestContextHandlerRef.UnWrap(data : Pointer) : ICefRequestContextHandler;
+begin
+ If data <> nil then Result := Create(data) as ICefRequestContextHandler
+ Else Result := nil;
+end;
+
{ TCefAuthCallbackRef }
procedure TCefAuthCallbackRef.Cont(const username, password : ustring);
@@ -3218,10 +3230,9 @@ function TCefUrlRequestRef.GetRequest : ICefRequest;
Result := TCefRequestRef.UnWrap(PCefUrlRequest(FData)^.get_request(FData));
end;
-function TCefUrlRequestRef.GetClient : ICefClient;
+function TCefUrlRequestRef.GetClient : ICefUrlrequestClient;
begin
- {$NOTE TODO}
- // Result := TCefUrlRequestClientRef.UnWrap(PCefUrlRequest(FData)^.get_client(FData));
+ Result := TCefUrlRequestClientRef.UnWrap(PCefUrlRequest(FData)^.get_client(FData));
end;
function TCefUrlRequestRef.GetRequestStatus : TCefUrlRequestStatus;
@@ -3256,6 +3267,49 @@ class function TCefUrlRequestRef.New(const request : ICefRequest;
Result := UnWrap(cef_urlrequest_create(CefGetData(request), CefGetData(client)));
end;
+{ TCefUrlRequestClientRef }
+
+procedure TCefUrlRequestClientRef.OnRequestComplete(const request : ICefUrlRequest);
+begin
+ PCefUrlRequestClient(FData)^.on_request_complete(FData, CefGetData(request));
+end;
+
+procedure TCefUrlRequestClientRef.OnUploadProgress(const request : ICefUrlRequest;
+ current, total : UInt64);
+begin
+ PCefUrlRequestClient(FData)^.on_upload_progress(FData, CefGetData(request), current, total);
+end;
+
+procedure TCefUrlRequestClientRef.OnDownloadProgress(const request : ICefUrlRequest;
+ current, total : UInt64);
+begin
+ PCefUrlRequestClient(FData)^.on_download_progress(FData, CefGetData(request), current, total);
+end;
+
+procedure TCefUrlRequestClientRef.OnDownloadData(const request : ICefUrlRequest;
+ data : Pointer; dataLength : TSize);
+begin
+ PCefUrlRequestClient(FData)^.on_download_data(FData, CefGetData(request), data, dataLength);
+end;
+
+function TCefUrlRequestClientRef.GetAuthCredentials(isProxy : Boolean;
+ const host : ustring; port : Integer; const realm, scheme : ustring;
+ callback : ICefAuthCallback) : Boolean;
+Var
+ h, r, s: TCefString;
+begin
+ h := CefString(host);
+ r := CefString(realm);
+ s := CefString(scheme);
+ Result := PCefUrlRequestClient(FData)^.get_auth_credentials(FData, Ord(isProxy), @h, port, @r, @s, CefGetData(callback)) <> 0;
+end;
+
+class function TCefUrlRequestClientRef.UnWrap(data : Pointer) : ICefUrlRequestClient;
+begin
+ If data <> nil then Result := Create(data) as ICefUrlRequestClient
+ Else Result := nil;
+end;
+
{ TCefv8ContextRef }
function TCefv8ContextRef.GetTaskRunner : ICefTaskRunner;
diff --git a/cef3types.pas b/cef3types.pas
index 863d3ea..59a4d0a 100644
--- a/cef3types.pas
+++ b/cef3types.pas
@@ -248,23 +248,14 @@ TCefTime = record
// in a known order. Equivalent to the SkColor type.
TCefColor = UInt32;
-{ TODO
- // Return the alpha byte from a cef_color_t value.
- #define CefColorGetA(color) (((color) >> 24) & 0xFF)
- // Return the red byte from a cef_color_t value.
- #define CefColorGetR(color) (((color) >> 16) & 0xFF)
- // Return the green byte from a cef_color_t value.
- #define CefColorGetG(color) (((color) >> 8) & 0xFF)
- // Return the blue byte from a cef_color_t value.
- #define CefColorGetB(color) (((color) >> 0) & 0xFF)
-
- // Return an cef_color_t value with the specified byte component values.
- #define CefColorSetARGB(a, r, g, b) static_cast(\
- (static_cast(a) << 24) | \
- (static_cast(r) << 16) | \
- (static_cast(g) << 8) | \
- (static_cast(b) << 0))
-}
+function CefColorGetA(color: TCefColor): Byte;
+function CefColorGetR(color: TCefColor): Byte;
+function CefColorGetG(color: TCefColor): Byte;
+function CefColorGetB(color: TCefColor): Byte;
+
+function CefColorSetARGB(a, r, g, b: Byte): TCefColor;
+
+Type
// Log severity levels.
TCefLogSeverity = (
@@ -1109,7 +1100,7 @@ TCefScreenInfo = record
EVENTFLAG_NUM_LOCK_ON, //= 1 shl 8,
EVENTFLAG_IS_KEY_PAD, //= 1 shl 9,
EVENTFLAG_IS_LEFT, //= 1 shl 10,
- EVENTFLAG_IS_RIGHT //= 1 shl 11
+ EVENTFLAG_IS_RIGHT //= 1 shl 11
);
TCefEventFlags = set of TCefEventFlag;
@@ -1437,4 +1428,29 @@ TCefGeoposition = record
Implementation
+function CefColorGetA(color : TCefColor) : Byte;
+begin
+ Result := (color shr 24) and $FF;
+end;
+
+function CefColorGetR(color : TCefColor) : Byte;
+begin
+ Result := (color shr 16) and $FF;
+end;
+
+function CefColorGetG(color : TCefColor) : Byte;
+begin
+ Result := (color shr 8) and $FF;
+end;
+
+function CefColorGetB(color : TCefColor) : Byte;
+begin
+ Result := (color shr 0) and $FF;
+end;
+
+function CefColorSetARGB(a, r, g, b : Byte) : TCefColor;
+begin
+ Result := (a shl 24) or (r shl 16) or (g shl 8) or (b shl 0);
+end;
+
end.