diff --git a/windows/src/CEF_VERSION.md b/windows/src/CEF_VERSION.md new file mode 100644 index 0000000000000000000000000000000000000000..e22bfacf27d63cc425316bc1251b9cf864868c52 --- /dev/null +++ b/windows/src/CEF_VERSION.md @@ -0,0 +1 @@ +89.0.18 \ No newline at end of file diff --git a/windows/src/Makefile b/windows/src/Makefile index a2764e76bdd69085517e7afa8813e78db30cc7ba..36c9ba9d1720225af48ff0136f1fc4c2dd01a28d 100644 --- a/windows/src/Makefile +++ b/windows/src/Makefile @@ -114,10 +114,14 @@ clean-pathdefines: test-releasebuildcheck # # Test that the CEF file path is accessible from env var KEYMAN_CEF4DELPHI_ROOT +# and checkout the appropriate version of CEF as determined by CEF_VERSION.md # test-release-cef-path: - @if not exist $(KEYMAN_CEF4DELPHI_ROOT)\libcef.dll echo The environment variable KEYMAN_CEF4DELPHI_ROOT is invalid. File libcef.dll could not be found. - @if not exist $(KEYMAN_CEF4DELPHI_ROOT)\libcef.dll exit 1 +!ifdef GIT_BASH_FOR_KEYMAN + $(GIT_BASH_FOR_KEYMAN) $(ROOT)\src\buildtools\cef-checkout.sh +!else + start /wait $(ROOT)\src\buildtools\cef-checkout.sh +!endif # # Test that certificate checking is enabled and that certificate is accessible diff --git a/windows/src/README.md b/windows/src/README.md index 3182c2211ac9bc37e478cb7010e444d39d88c96d..52eac1e637661c2934c4d6313800bbcce1af46ca 100644 --- a/windows/src/README.md +++ b/windows/src/README.md @@ -160,6 +160,11 @@ source the binary files from the https://github.com/keymanapp/CEF4Delphi_binary The `KEYMAN_CEF4DELPHI_ROOT` environment variable should be set to the root of this repo on your local machine. +The version of CEF in use is determined by CEF_VERSION.md. This maps to a branch +prefixed with `v` e.g. `v89.0.18` in the CEF4Delphi_binary repository. During a +release build, the buildtools/cef-checkout.sh script will checkout the correct +branch of the repository automatically and extract any compressed files found in it. + ### Crash Reporting Crash report dialogs as shown by tsysinfo have a few special secret hotkeys diff --git a/windows/src/buildtools/cef-checkout.sh b/windows/src/buildtools/cef-checkout.sh new file mode 100644 index 0000000000000000000000000000000000000000..90f229cfd9ec955ae7294051be33e371bf81fdee --- /dev/null +++ b/windows/src/buildtools/cef-checkout.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Checkout a matching version of CEF for the +# current release of Keyman. This tag is set in +# /windows/src/CEFVERSION.md + +# Terminate script if a command returns an error +set -e + +# Terminate script if an unset variable is used +set -u + +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +. "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh" +# . "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" +## END STANDARD BUILD SCRIPT INCLUDE + +pushd $KEYMAN_CEF4DELPHI_ROOT > /dev/null + +CEF_VERSION_MD="$KEYMAN_ROOT/windows/src/CEF_VERSION.md" +CEF_VERSION=`cat $CEF_VERSION_MD | tr -d "[:space:]"` + +# Switch to the version of CEF referenced in CEF_VERSION.md +# Note that 14.0 and earlier versions rely on the `master` +# branch, so that is the default branch checked out in the +# build configurations +git fetch origin "v$CEF_VERSION" +git switch "v$CEF_VERSION" + +# Some files are larger than GitHub's limit of 100MB. For now, +# we can work around this by zipping in the repo and unzipping +# at build time +for zip in *.zip; do + unzip "$zip" + rm "$zip" +done + +[ -f ./libcef.dll ] || die "File libcef.dll could not be found. Path $KEYMAN_CEF4DELPHI_ROOT may not be valid." + +popd > /dev/null + +exit 0 diff --git a/windows/src/ext/cef4delphi.txt b/windows/src/ext/cef4delphi.txt index ce8e68148b3843645b5eb27bef4fde1ddaa4eee2..39896182213c3539bf1fa65a241920b3b28b07ae 100644 --- a/windows/src/ext/cef4delphi.txt +++ b/windows/src/ext/cef4delphi.txt @@ -23,10 +23,10 @@ CEF4Delphi_binary repository is kept in sync with the cef4delphi source version. Build and notes ------------ +--------------- Cef4Delphi also requires the CEF binary distribution from -http://opensource.spotify.com/cefbuilds/index.html, cloned at +https://www.spotify.com/au/opensource/, cloned at https://github.com/keymanapp/CEF4Delphi_binary. Build agents will source this repository in order to build the installer for of Keyman Developer. On a development machine, clone the @@ -34,6 +34,18 @@ CEF4Delphi_binary repository and set the registry value [HKEY_CURRENT_USER\Software\Keyman\Debug] Debug_CEFPath [REG_SZ] to the root of the cloned repo in order to run Keyman Developer. +Note that some of the files in the CEF4Delphi_binary repo are larger +than 100MB, which GitHub does not handle, so they have been zipped. +buildtools/cef-checkout.sh will extract them during a release build, but +for development use, you'll need to extract them yourself. + +Debug symbols for CEF can be found at: +https://cef-builds.spotifycdn.com/index.html#windows32 + +Note that these symbols are too large to upload to sentry.keyman.com; +instead, it should be possible to upload them to downloads.keyman.com +using symsrv. + License - MPL 1.1 ----------------- diff --git a/windows/src/ext/cef4delphi/LICENSE.md b/windows/src/ext/cef4delphi/LICENSE.md new file mode 100644 index 0000000000000000000000000000000000000000..9454c48b70321c88fc97cbc018d4e2cda6b1cdde --- /dev/null +++ b/windows/src/ext/cef4delphi/LICENSE.md @@ -0,0 +1,33 @@ +# CEF4Delphi + +CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +browser in Delphi applications. + +The original license of DCEF3 still applies to CEF4Delphi. + +For more information about CEF4Delphi visit : + https://www.briskbard.com/index.php?lang=en&pageid=cef + + Copyright © 2021 Salvador Diaz Fau. All rights reserved. + + +## Original DCEF3 license + +### Delphi Chromium Embedded 3 + + Usage allowed under the restrictions of the Lesser GNU General Public License + or alternatively the restrictions of the Mozilla Public License 1.1 + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + the specific language governing rights and limitations under the License. + +
+
Unit owner :
Henri Gourvest
+
Web site :
http://www.progdigy.com
+
Repository :
http://code.google.com/p/delphichromiumembedded/
+
Group :
http://groups.google.com/group/delphichromiumembedded
+
+ + Embarcadero Technologies, Inc is not permitted to use or redistribute + this source code without explicit permission. diff --git a/windows/src/ext/cef4delphi/README.md b/windows/src/ext/cef4delphi/README.md new file mode 100644 index 0000000000000000000000000000000000000000..aa4eddfc3d41331f013e16f016d3a75f93044b7e --- /dev/null +++ b/windows/src/ext/cef4delphi/README.md @@ -0,0 +1,58 @@ +# CEF4Delphi [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Use%20CEF4Delphi%20to%20embed%20Chromium-based%20browsers%20in%20your%20application&url=https://github.com/salvadordf/CEF4Delphi&via=briskbard&hashtags=cef4delphi,delphi,lazarus,fpc) +CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with [Delphi](https://www.embarcadero.com/products/delphi/starter) or [Lazarus/FPC](https://www.lazarus-ide.org/) for Windows, Linux and MacOS. + +CEF4Delphi is based on DCEF3 and fpCEF3. The original license of those projects still applies to CEF4Delphi. Read the license terms in the first lines of any *.pas file. + +CEF4Delphi uses CEF 89.0.18 which includes Chromium 89.0.4389.114. +The CEF binaries used by CEF4Delphi are available for download at spotify : +* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.18%2Bgb36241d%2Bchromium-89.0.4389.114_windows32.tar.bz2) +* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.18%2Bgb36241d%2Bchromium-89.0.4389.114_windows64.tar.bz2) +* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.18%2Bgb36241d%2Bchromium-89.0.4389.114_linux32.tar.bz2) +* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.18%2Bgb36241d%2Bchromium-89.0.4389.114_linux64.tar.bz2) +* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.18%2Bgb36241d%2Bchromium-89.0.4389.114_linuxarm.tar.bz2) +* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.18%2Bgb36241d%2Bchromium-89.0.4389.114_linuxarm64.tar.bz2) +* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.18%2Bgb36241d%2Bchromium-89.0.4389.114_macosx64.tar.bz2) + +CEF4Delphi was developed and tested on Delphi 10.4.2 and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2, Delphi 10.3 and Lazarus 2.0.12/FPC 3.2.0. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components. + +CEF4Delphi demos have been tested in Windows 7, Windows 10, Linux Mint 20.1 and Raspberry Pi OS. + +## Links +* [Installation instructions and more information about CEF4Delphi](https://www.briskbard.com/index.php?lang=en&pageid=cef) +* [Developer Forums](https://www.briskbard.com/forum) +* The Windows components need Windows 7, 8, 8.1, 10 or newer to run. If you need Windows XP and Vista support use [OldCEF4Delphi](https://github.com/salvadordf/OldCEF4Delphi) + +## Stable releases +This is the development branch and it may have issues. Use the [latest release](https://github.com/salvadordf/CEF4Delphi/releases/latest) if you need a stable component. + +## Support +If you find this project useful, please consider making a donation. + +[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FTSD2CCGXTD86) + +You can also support this project with Patreon. + +Patreon donate button + +Additional: +Delphinus-Support + +## Attribution +Other projects : +* [DCEF3](https://github.com/hgourvest/dcef3) +* [fpCEF3](https://github.com/dliw/fpCEF3) +* [CEF](https://bitbucket.org/chromiumembedded/cef/) +* [DCPcrypt](http://www.cityinthesky.co.uk/opensource/dcpcrypt/) +* [Chromium](https://chromium.googlesource.com/chromium/src/) + +Some icons used in this project belong to these icon packages : +* [Fugue & Diagona icons](http://yusukekamiyamane.com/) +* [FatCow Farm-Fresh Web Icons](https://www.fatcow.com/free-icons) +* [Material Design Icons](https://github.com/google/material-design-icons) + +## Other resources +* [Learn Delphi](https://learndelphi.org/) +* [Essential Pascal by Marco Cantù](https://www.marcocantu.com/epascal/) +* [FreePascal from Square One by Jeff Duntemann](http://www.copperwood.com/pub/FreePascalFromSquareOne.pdf) +* [Pascal and Lazarus Books and Magazines](https://wiki.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines) +* [Lazarus Documentation](https://wiki.freepascal.org/Lazarus_Documentation) diff --git a/windows/src/ext/cef4delphi/packages/00-Delete.bat b/windows/src/ext/cef4delphi/packages/00-Delete.bat index 28d93f4c59b6c5d01c6120cbfa34250c0bd05407..84081b88cd71d125b4ce5e05fe67cf36e901234f 100644 --- a/windows/src/ext/cef4delphi/packages/00-Delete.bat +++ b/windows/src/ext/cef4delphi/packages/00-Delete.bat @@ -7,6 +7,7 @@ del /s /q *.stat del /s /q *.local del /s /q *.~* rmdir /S /Q Win32 +rmdir /S /Q Win64 rmdir /S /Q backup rmdir /S /Q lib rmdir /S /Q __history diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi.dpk b/windows/src/ext/cef4delphi/packages/CEF4Delphi.dpk index 9bfb01c3223e158a28c3b656ebdf5ce3aed3c039..4c0301bf18df7e031e6adf67e9f4693b897f435e 100644 --- a/windows/src/ext/cef4delphi/packages/CEF4Delphi.dpk +++ b/windows/src/ext/cef4delphi/packages/CEF4Delphi.dpk @@ -102,7 +102,7 @@ contains uCEFZipReader in '..\source\uCEFZipReader.pas', uCEFResponse in '..\source\uCEFResponse.pas', uCEFCookieVisitor in '..\source\uCEFCookieVisitor.pas', - uCEFV8Exception in '..\source\uCEFV8Exception.pas', + uCEFv8Exception in '..\source\uCEFv8Exception.pas', uCEFResourceBundleHandler in '..\source\uCEFResourceBundleHandler.pas', uCEFSetCookieCallback in '..\source\uCEFSetCookieCallback.pas', uCEFDeleteCookiesCallback in '..\source\uCEFDeleteCookiesCallback.pas', @@ -131,6 +131,7 @@ contains uCEFImage in '..\source\uCEFImage.pas', uCEFMenuModelDelegate in '..\source\uCEFMenuModelDelegate.pas', uCEFWindowParent in '..\source\uCEFWindowParent.pas', + uCEFChromiumCore in '..\source\uCEFChromiumCore.pas', uCEFChromium in '..\source\uCEFChromium.pas', uCEFChromiumEvents in '..\source\uCEFChromiumEvents.pas', uCEFChromiumOptions in '..\source\uCEFChromiumOptions.pas', @@ -148,12 +149,12 @@ contains uCEFBaseRefCounted in '..\source\uCEFBaseRefCounted.pas', uCEFBaseScopedWrapper in '..\source\uCEFBaseScopedWrapper.pas', uCEFAccessibilityHandler in '..\source\uCEFAccessibilityHandler.pas', - uOLEDragAndDrop in '..\source\uOLEDragAndDrop.pas', + uCEFOLEDragAndDrop in '..\source\uCEFOLEDragAndDrop.pas', uCEFDragAndDropMgr in '..\source\uCEFDragAndDropMgr.pas', uCEFGetExtensionResourceCallback in '..\source\uCEFGetExtensionResourceCallback.pas', uCEFExtension in '..\source\uCEFExtension.pas', uCEFExtensionHandler in '..\source\uCEFExtensionHandler.pas', - uBufferPanel in '..\source\uBufferPanel.pas', + uCEFBufferPanel in '..\source\uCEFBufferPanel.pas', uCEFApp in '..\source\uCEFApp.pas', uCEFWorkScheduler in '..\source\uCEFWorkScheduler.pas', uCEFWorkSchedulerThread in '..\source\uCEFWorkSchedulerThread.pas', @@ -162,7 +163,67 @@ contains uCEFServerEvents in '..\source\uCEFServerEvents.pas', uCEFServerComponent in '..\source\uCEFServerComponent.pas', uCEFStringList in '..\source\uCEFStringList.pas', - uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas'; + uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas', + uCEFWinControl in '..\source\uCEFWinControl.pas', + uCEFLinkedWindowParent in '..\source\uCEFLinkedWindowParent.pas', + uCEFUrlRequestClientEvents in '..\source\uCEFUrlRequestClientEvents.pas', + uCEFUrlRequestClientComponent in '..\source\uCEFUrlRequestClientComponent.pas', + uCEFOSRIMEHandler in '..\source\uCEFOSRIMEHandler.pas', + uCEFCookieAccessFilter in '..\source\uCEFCookieAccessFilter.pas', + uCEFResourceRequestHandler in '..\source\uCEFResourceRequestHandler.pas', + uCEFResourceSkipCallback in '..\source\uCEFResourceSkipCallback.pas', + uCEFResourceReadCallback in '..\source\uCEFResourceReadCallback.pas', + uCEFSentinel in '..\source\uCEFSentinel.pas', + uCEFApplicationCore in '..\source\uCEFApplicationCore.pas', + uCEFOAuth2Helper in '..\source\uCEFOAuth2Helper.pas', + uCEFMediaObserver in '..\source\uCEFMediaObserver.pas', + uCEFMediaRoute in '..\source\uCEFMediaRoute.pas', + uCEFMediaRouteCreateCallback in '..\source\uCEFMediaRouteCreateCallback.pas', + uCEFMediaRouter in '..\source\uCEFMediaRouter.pas', + uCEFMediaSink in '..\source\uCEFMediaSink.pas', + uCEFMediaSource in '..\source\uCEFMediaSource.pas', + uCEFRegistration in '..\source\uCEFRegistration.pas', + uCEFDisplay in '..\source\uCEFDisplay.pas', + uCEFLayout in '..\source\uCEFLayout.pas', + uCEFBoxLayout in '..\source\uCEFBoxLayout.pas', + uCEFFillLayout in '..\source\uCEFFillLayout.pas', + uCEFView in '..\source\uCEFView.pas', + uCEFViewDelegate in '..\source\uCEFViewDelegate.pas', + uCEFTextfield in '..\source\uCEFTextfield.pas', + uCEFTextfieldDelegate in '..\source\uCEFTextfieldDelegate.pas', + uCEFScrollView in '..\source\uCEFScrollView.pas', + uCEFPanel in '..\source\uCEFPanel.pas', + uCEFPanelDelegate in '..\source\uCEFPanelDelegate.pas', + uCEFBrowserView in '..\source\uCEFBrowserView.pas', + uCEFBrowserViewDelegate in '..\source\uCEFBrowserViewDelegate.pas', + uCEFButton in '..\source\uCEFButton.pas', + uCEFButtonDelegate in '..\source\uCEFButtonDelegate.pas', + uCEFLabelButton in '..\source\uCEFLabelButton.pas', + uCEFMenuButton in '..\source\uCEFMenuButton.pas', + uCEFMenuButtonPressedLock in '..\source\uCEFMenuButtonPressedLock.pas', + uCEFMenuButtonDelegate in '..\source\uCEFMenuButtonDelegate.pas', + uCEFWindow in '..\source\uCEFWindow.pas', + uCEFWindowDelegate in '..\source\uCEFWindowDelegate.pas', + uCEFViewsFrameworkEvents in '..\source\uCEFViewsFrameworkEvents.pas', + uCEFViewComponent in '..\source\uCEFViewComponent.pas', + uCEFTextfieldComponent in '..\source\uCEFTextfieldComponent.pas', + uCEFScrollViewComponent in '..\source\uCEFScrollViewComponent.pas', + uCEFPanelComponent in '..\source\uCEFPanelComponent.pas', + uCEFWindowComponent in '..\source\uCEFWindowComponent.pas', + uCEFBrowserViewComponent in '..\source\uCEFBrowserViewComponent.pas', + uCEFButtonComponent in '..\source\uCEFButtonComponent.pas', + uCEFLabelButtonComponent in '..\source\uCEFLabelButtonComponent.pas', + uCEFMenuButtonComponent in '..\source\uCEFMenuButtonComponent.pas', + uCEFAudioHandler in '..\source\uCEFAudioHandler.pas', + uCEFDevToolsMessageObserver in '..\source\uCEFDevToolsMessageObserver.pas', + uCEFMediaSinkDeviceInfoCallback in '..\source\uCEFMediaSinkDeviceInfoCallback.pas', + uCEFJson in '..\source\uCEFJson.pas', + uCEFBitmapBitBuffer in '..\source\uCEFBitmapBitBuffer.pas', + uCEFPrintHandler in '..\source\uCEFPrintHandler.pas', + uCEFPrintDialogCallback in '..\source\uCEFPrintDialogCallback.pas', + uCEFPrintJobCallback in '..\source\uCEFPrintJobCallback.pas', + uCEFWorkSchedulerQueueThread in '..\source\uCEFWorkSchedulerQueueThread.pas', + uCEFLinkedWinControlBase in '..\source\uCEFLinkedWinControlBase.pas'; end. diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi.dproj b/windows/src/ext/cef4delphi/packages/CEF4Delphi.dproj index 7bc0787a158373e4ab5514dc92324a50da426b6e..70b88cdfd4e2e362936314d455e6a58c7e9278fd 100644 --- a/windows/src/ext/cef4delphi/packages/CEF4Delphi.dproj +++ b/windows/src/ext/cef4delphi/packages/CEF4Delphi.dproj @@ -2,12 +2,12 @@ {2F51F1BD-0529-4B4A-BFD2-86FE96910A62} CEF4Delphi.dpk - 18.2 + 19.2 VCL True Debug Win32 - 1 + 3 Package @@ -70,6 +70,9 @@ false false false + ..\source;$(DCC_UnitSearchPath) + 3082 + CompanyName=;FileVersion=1.0.0.0;InternalName=CEF4Delphi;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=CEF4Delphi;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName) rtl;vcl;fmx;$(DCC_UsePackage) @@ -193,7 +196,7 @@ - + @@ -222,6 +225,7 @@ + @@ -239,12 +243,12 @@ - + - + @@ -254,6 +258,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Base @@ -279,28 +343,28 @@ CEF4Delphi.dpk - IP Abstraction Indy Implementation Design Time - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components + IP Abstraction Indy Implementation Design Time + DBExpress Enterprise Data Explorer Integration + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components - + + CEF4Delphi.bpl true - 1 - Contents\MacOS 0 @@ -309,6 +373,20 @@ classes 1 + + classes + 1 + + + + + res\xml + 1 + + + res\xml + 1 + @@ -321,90 +399,252 @@ library\lib\armeabi 1 + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + library\lib\mips 1 + + library\lib\mips + 1 + library\lib\armeabi-v7a 1 + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + res\drawable 1 + + res\drawable + 1 + res\values 1 + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + res\drawable 1 + + res\drawable + 1 + res\drawable-xxhdpi 1 + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + res\drawable-ldpi 1 + + res\drawable-ldpi + 1 + res\drawable-mdpi 1 + + res\drawable-mdpi + 1 + res\drawable-hdpi 1 + + res\drawable-hdpi + 1 + res\drawable-xhdpi 1 + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + res\drawable-small 1 + + res\drawable-small + 1 + res\drawable-normal 1 + + res\drawable-normal + 1 + res\drawable-large 1 + + res\drawable-large + 1 + res\drawable-xlarge 1 + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + @@ -422,6 +662,10 @@ 1 .framework + + 1 + .framework + 0 @@ -431,6 +675,10 @@ 1 .dylib + + 1 + .dylib + 0 .dll;.bpl @@ -453,6 +701,10 @@ 1 .dylib + + 1 + .dylib + 0 .bpl @@ -462,6 +714,9 @@ 0 + + 0 + 0 @@ -474,10 +729,39 @@ 0 + + 0 + 0 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + 1 @@ -489,6 +773,17 @@ 1 + + + 1 + + + 1 + + + 1 + + 1 @@ -500,6 +795,39 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + 1 @@ -511,6 +839,71 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + 1 @@ -522,6 +915,186 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + 1 @@ -533,6 +1106,16 @@ 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + 1 @@ -555,10 +1138,115 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + 1 + + 1 + @@ -573,6 +1261,7 @@ + 1 @@ -584,6 +1273,7 @@ 1 + @@ -591,12 +1281,20 @@ Contents\Resources 1 + + Contents\Resources + 1 + library\lib\armeabi-v7a 1 + + library\lib\arm64-v8a + 1 + 1 @@ -612,10 +1310,19 @@ 1 + + 1 + 0 + + + library\lib\armeabi-v7a + 1 + + 1 @@ -651,11 +1358,13 @@ + + True - False + True 12 diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi.res b/windows/src/ext/cef4delphi/packages/CEF4Delphi.res index 985ad241082301fe8838561e1717b2ff8e363a4e..b9b013c2123fcf20e24680fc5ad3191fc452d216 100644 Binary files a/windows/src/ext/cef4delphi/packages/CEF4Delphi.res and b/windows/src/ext/cef4delphi/packages/CEF4Delphi.res differ diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7.cfg b/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7.cfg index d8b626e5694df55186b09d761ea93ff8f25f8ca1..bd69e9620e19273faefdd180395fdbeabf04f3a1 100644 --- a/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7.cfg +++ b/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7.cfg @@ -30,7 +30,7 @@ -W+ -M -$M16384,1048576 --K$00400000 +-K$54C00000 -N"dcu\" -LE"c:\program files\borland\delphi7\Projects\Bpl" -LN"c:\program files\borland\delphi7\Projects\Bpl" diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7.dpk b/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7.dpk index e162fa95af065d5d6c2fc40053c5f602e9733fde..8e078b2cb2a1324d4aedf991a5aabd9b6793a605 100644 --- a/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7.dpk +++ b/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7.dpk @@ -21,7 +21,7 @@ package CEF4Delphi_D7; {$VARSTRINGCHECKS ON} {$WRITEABLECONST OFF} {$MINENUMSIZE 1} -{$IMAGEBASE $400000} +{$IMAGEBASE $54C00000} {$DESCRIPTION 'CEF4Delphi'} {$IMPLICITBUILD OFF} {$DEFINE DEBUG} @@ -100,7 +100,7 @@ contains uCEFZipReader in '..\source\uCEFZipReader.pas', uCEFResponse in '..\source\uCEFResponse.pas', uCEFCookieVisitor in '..\source\uCEFCookieVisitor.pas', - uCEFV8Exception in '..\source\uCEFV8Exception.pas', + uCEFv8Exception in '..\source\uCEFv8Exception.pas', uCEFResourceBundleHandler in '..\source\uCEFResourceBundleHandler.pas', uCEFSetCookieCallback in '..\source\uCEFSetCookieCallback.pas', uCEFDeleteCookiesCallback in '..\source\uCEFDeleteCookiesCallback.pas', @@ -130,6 +130,7 @@ contains uCEFMenuModelDelegate in '..\source\uCEFMenuModelDelegate.pas', uCEFWindowParent in '..\source\uCEFWindowParent.pas', uCEFChromium in '..\source\uCEFChromium.pas', + uCEFChromiumCore in '..\source\uCEFChromiumCore.pas', uCEFChromiumEvents in '..\source\uCEFChromiumEvents.pas', uCEFChromiumOptions in '..\source\uCEFChromiumOptions.pas', uCEFChromiumFontOptions in '..\source\uCEFChromiumFontOptions.pas', @@ -146,11 +147,11 @@ contains uCEFBaseRefCounted in '..\source\uCEFBaseRefCounted.pas', uCEFBaseScopedWrapper in '..\source\uCEFBaseScopedWrapper.pas', uCEFDragAndDropMgr in '..\source\uCEFDragAndDropMgr.pas', - uOLEDragAndDrop in '..\source\uOLEDragAndDrop.pas', + uCEFOLEDragAndDrop in '..\source\uCEFOLEDragAndDrop.pas', uCEFGetExtensionResourceCallback in '..\source\uCEFGetExtensionResourceCallback.pas', uCEFExtension in '..\source\uCEFExtension.pas', uCEFExtensionHandler in '..\source\uCEFExtensionHandler.pas', - uBufferPanel in '..\source\uBufferPanel.pas', + uCEFBufferPanel in '..\source\uCEFBufferPanel.pas', uCEFApp in '..\source\uCEFApp.pas', uCEFWorkScheduler in '..\source\uCEFWorkScheduler.pas', uCEFWorkSchedulerThread in '..\source\uCEFWorkSchedulerThread.pas', @@ -159,6 +160,66 @@ contains uCEFServerEvents in '..\source\uCEFServerEvents.pas', uCEFServerComponent in '..\source\uCEFServerComponent.pas', uCEFStringList in '..\source\uCEFStringList.pas', - uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas'; + uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas', + uCEFWinControl in '..\source\uCEFWinControl.pas', + uCEFLinkedWindowParent in '..\source\uCEFLinkedWindowParent.pas', + uCEFUrlRequestClientEvents in '..\source\uCEFUrlRequestClientEvents.pas', + uCEFUrlRequestClientComponent in '..\source\uCEFUrlRequestClientComponent.pas', + uCEFOSRIMEHandler in '..\source\uCEFOSRIMEHandler.pas', + uCEFCookieAccessFilter in '..\source\uCEFCookieAccessFilter.pas', + uCEFResourceRequestHandler in '..\source\uCEFResourceRequestHandler.pas', + uCEFResourceSkipCallback in '..\source\uCEFResourceSkipCallback.pas', + uCEFResourceReadCallback in '..\source\uCEFResourceReadCallback.pas', + uCEFSentinel in '..\source\uCEFSentinel.pas', + uCEFApplicationCore in '..\source\uCEFApplicationCore.pas', + uCEFOAuth2Helper in '..\source\uCEFOAuth2Helper.pas', + uCEFMediaSource in '..\source\uCEFMediaSource.pas', + uCEFMediaSink in '..\source\uCEFMediaSink.pas', + uCEFMediaRouteCreateCallback in '..\source\uCEFMediaRouteCreateCallback.pas', + uCEFMediaRoute in '..\source\uCEFMediaRoute.pas', + uCEFMediaObserver in '..\source\uCEFMediaObserver.pas', + uCEFMediaRouter in '..\source\uCEFMediaRouter.pas', + uCEFRegistration in '..\source\uCEFRegistration.pas', + uCEFDisplay in '..\source\uCEFDisplay.pas', + uCEFLayout in '..\source\uCEFLayout.pas', + uCEFBoxLayout in '..\source\uCEFBoxLayout.pas', + uCEFFillLayout in '..\source\uCEFFillLayout.pas', + uCEFView in '..\source\uCEFView.pas', + uCEFViewDelegate in '..\source\uCEFViewDelegate.pas', + uCEFTextfield in '..\source\uCEFTextfield.pas', + uCEFTextfieldDelegate in '..\source\uCEFTextfieldDelegate.pas', + uCEFScrollView in '..\source\uCEFScrollView.pas', + uCEFPanel in '..\source\uCEFPanel.pas', + uCEFPanelDelegate in '..\source\uCEFPanelDelegate.pas', + uCEFBrowserView in '..\source\uCEFBrowserView.pas', + uCEFBrowserViewDelegate in '..\source\uCEFBrowserViewDelegate.pas', + uCEFButton in '..\source\uCEFButton.pas', + uCEFButtonDelegate in '..\source\uCEFButtonDelegate.pas', + uCEFLabelButton in '..\source\uCEFLabelButton.pas', + uCEFMenuButton in '..\source\uCEFMenuButton.pas', + uCEFMenuButtonPressedLock in '..\source\uCEFMenuButtonPressedLock.pas', + uCEFMenuButtonDelegate in '..\source\uCEFMenuButtonDelegate.pas', + uCEFWindow in '..\source\uCEFWindow.pas', + uCEFWindowDelegate in '..\source\uCEFWindowDelegate.pas', + uCEFViewsFrameworkEvents in '..\source\uCEFViewsFrameworkEvents.pas', + uCEFViewComponent in '..\source\uCEFViewComponent.pas', + uCEFTextfieldComponent in '..\source\uCEFTextfieldComponent.pas', + uCEFScrollViewComponent in '..\source\uCEFScrollViewComponent.pas', + uCEFPanelComponent in '..\source\uCEFPanelComponent.pas', + uCEFWindowComponent in '..\source\uCEFWindowComponent.pas', + uCEFBrowserViewComponent in '..\source\uCEFBrowserViewComponent.pas', + uCEFButtonComponent in '..\source\uCEFButtonComponent.pas', + uCEFLabelButtonComponent in '..\source\uCEFLabelButtonComponent.pas', + uCEFMenuButtonComponent in '..\source\uCEFMenuButtonComponent.pas', + uCEFAudioHandler in '..\source\uCEFAudioHandler.pas', + uCEFDevToolsMessageObserver in '..\source\uCEFDevToolsMessageObserver.pas', + uCEFMediaSinkDeviceInfoCallback in '..\source\uCEFMediaSinkDeviceInfoCallback.pas', + uCEFJson in '..\source\uCEFJson.pas', + uCEFBitmapBitBuffer in '..\source\uCEFBitmapBitBuffer.pas', + uCEFPrintHandler in '..\source\uCEFPrintHandler.pas', + uCEFPrintDialogCallback in '..\source\uCEFPrintDialogCallback.pas', + uCEFPrintJobCallback in '..\source\uCEFPrintJobCallback.pas', + uCEFWorkSchedulerQueueThread in '..\source\uCEFWorkSchedulerQueueThread.pas', + uCEFLinkedWinControlBase in '..\source\uCEFLinkedWinControlBase.pas'; end. diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7_Register.pas b/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7_Register.pas index 4137d9feec49af4e4c626388b5d14c7831fb504c..3cff248be0a717271f3234651749a9d67569e413 100644 --- a/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7_Register.pas +++ b/windows/src/ext/cef4delphi/packages/CEF4Delphi_D7_Register.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -49,12 +49,23 @@ implementation uses Classes, - uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel, uCEFWorkScheduler, uCEFServerComponent; + uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFBufferPanel, uCEFWorkScheduler, + uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent, uCEFSentinel, + uCEFBrowserViewComponent, uCEFLabelButtonComponent, + uCEFMenuButtonComponent, uCEFPanelComponent, uCEFTextfieldComponent, + uCEFScrollViewComponent, uCEFWindowComponent; procedure Register; begin RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel, - TCEFWorkScheduler, TCEFServerComponent]); + TCEFWorkScheduler, TCEFServerComponent, TCEFLinkedWindowParent, + TCEFUrlRequestClientComponent, TCEFSentinel]); + + RegisterComponents('Chromium Views Framework', + [TCEFBrowserViewComponent, TCEFLabelButtonComponent, + TCEFMenuButtonComponent, TCEFPanelComponent, + TCEFTextfieldComponent, TCEFScrollViewComponent, + TCEFWindowComponent]); end; end. diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.dpk b/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.dpk index f1e0d3963fdedb331b632bad167956a52c9ec9c9..3d84d9d06b2cc03d809a1d53fdb8df58c13532c1 100644 --- a/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.dpk +++ b/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.dpk @@ -1,5 +1,4 @@ package CEF4Delphi_FMX; - {$R *.res} {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} {$ALIGN 8} @@ -12,18 +11,18 @@ package CEF4Delphi_FMX; {$LOCALSYMBOLS ON} {$LONGSTRINGS ON} {$OPENSTRINGS ON} -{$OPTIMIZATION OFF} +{$OPTIMIZATION ON} {$OVERFLOWCHECKS ON} {$RANGECHECKS ON} {$REFERENCEINFO ON} {$SAFEDIVIDE OFF} -{$STACKFRAMES ON} +{$STACKFRAMES OFF} {$TYPEDADDRESS OFF} {$VARSTRINGCHECKS ON} {$WRITEABLECONST OFF} {$MINENUMSIZE 1} {$IMAGEBASE $400000} -{$DEFINE DEBUG} +{$DEFINE $(FrameworkType)} {$ENDIF IMPLICITBUILDING} {$DESCRIPTION 'CEF4Delphi'} {$IMPLICITBUILD OFF} @@ -103,7 +102,7 @@ contains uCEFZipReader in '..\source\uCEFZipReader.pas', uCEFResponse in '..\source\uCEFResponse.pas', uCEFCookieVisitor in '..\source\uCEFCookieVisitor.pas', - uCEFV8Exception in '..\source\uCEFV8Exception.pas', + uCEFv8Exception in '..\source\uCEFv8Exception.pas', uCEFResourceBundleHandler in '..\source\uCEFResourceBundleHandler.pas', uCEFSetCookieCallback in '..\source\uCEFSetCookieCallback.pas', uCEFDeleteCookiesCallback in '..\source\uCEFDeleteCookiesCallback.pas', @@ -132,6 +131,7 @@ contains uCEFImage in '..\source\uCEFImage.pas', uCEFMenuModelDelegate in '..\source\uCEFMenuModelDelegate.pas', uCEFWindowParent in '..\source\uCEFWindowParent.pas', + uCEFChromiumCore in '..\source\uCEFChromiumCore.pas', uCEFChromium in '..\source\uCEFChromium.pas', uCEFChromiumEvents in '..\source\uCEFChromiumEvents.pas', uCEFChromiumOptions in '..\source\uCEFChromiumOptions.pas', @@ -149,12 +149,12 @@ contains uCEFBaseRefCounted in '..\source\uCEFBaseRefCounted.pas', uCEFBaseScopedWrapper in '..\source\uCEFBaseScopedWrapper.pas', uCEFAccessibilityHandler in '..\source\uCEFAccessibilityHandler.pas', - uOLEDragAndDrop in '..\source\uOLEDragAndDrop.pas', + uCEFOLEDragAndDrop in '..\source\uCEFOLEDragAndDrop.pas', uCEFDragAndDropMgr in '..\source\uCEFDragAndDropMgr.pas', uCEFGetExtensionResourceCallback in '..\source\uCEFGetExtensionResourceCallback.pas', uCEFExtension in '..\source\uCEFExtension.pas', uCEFExtensionHandler in '..\source\uCEFExtensionHandler.pas', - uBufferPanel in '..\source\uBufferPanel.pas', + uCEFBufferPanel in '..\source\uCEFBufferPanel.pas', uCEFApp in '..\source\uCEFApp.pas', uCEFWorkScheduler in '..\source\uCEFWorkScheduler.pas', uCEFWorkSchedulerThread in '..\source\uCEFWorkSchedulerThread.pas', @@ -162,12 +162,75 @@ contains uCEFServerHandler in '..\source\uCEFServerHandler.pas', uCEFServerEvents in '..\source\uCEFServerEvents.pas', uCEFServerComponent in '..\source\uCEFServerComponent.pas', - uFMXBufferPanel in '..\source\uFMXBufferPanel.pas', - uFMXChromium in '..\source\uFMXChromium.pas', - uFMXWorkScheduler in '..\source\uFMXWorkScheduler.pas', + uCEFFMXBufferPanel in '..\source\uCEFFMXBufferPanel.pas', + uCEFFMXChromium in '..\source\uCEFFMXChromium.pas', + uCEFFMXWorkScheduler in '..\source\uCEFFMXWorkScheduler.pas', uCEFStringList in '..\source\uCEFStringList.pas', - uFMXWindowParent in '..\source\uFMXWindowParent.pas', - uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas'; + uCEFFMXWindowParent in '..\source\uCEFFMXWindowParent.pas', + uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas', + uCEFWinControl in '..\source\uCEFWinControl.pas', + uCEFLinkedWindowParent in '..\source\uCEFLinkedWindowParent.pas', + uCEFUrlRequestClientEvents in '..\source\uCEFUrlRequestClientEvents.pas', + uCEFUrlRequestClientComponent in '..\source\uCEFUrlRequestClientComponent.pas', + uCEFOSRIMEHandler in '..\source\uCEFOSRIMEHandler.pas', + uCEFCookieAccessFilter in '..\source\uCEFCookieAccessFilter.pas', + uCEFResourceRequestHandler in '..\source\uCEFResourceRequestHandler.pas', + uCEFResourceSkipCallback in '..\source\uCEFResourceSkipCallback.pas', + uCEFResourceReadCallback in '..\source\uCEFResourceReadCallback.pas', + uCEFSentinel in '..\source\uCEFSentinel.pas', + uCEFApplicationCore in '..\source\uCEFApplicationCore.pas', + uCEFOAuth2Helper in '..\source\uCEFOAuth2Helper.pas', + uCEFMediaSource in '..\source\uCEFMediaSource.pas', + uCEFMediaSink in '..\source\uCEFMediaSink.pas', + uCEFMediaRouteCreateCallback in '..\source\uCEFMediaRouteCreateCallback.pas', + uCEFMediaRoute in '..\source\uCEFMediaRoute.pas', + uCEFMediaObserver in '..\source\uCEFMediaObserver.pas', + uCEFMediaRouter in '..\source\uCEFMediaRouter.pas', + uCEFRegistration in '..\source\uCEFRegistration.pas', + uCEFDisplay in '..\source\uCEFDisplay.pas', + uCEFLayout in '..\source\uCEFLayout.pas', + uCEFBoxLayout in '..\source\uCEFBoxLayout.pas', + uCEFFillLayout in '..\source\uCEFFillLayout.pas', + uCEFView in '..\source\uCEFView.pas', + uCEFViewDelegate in '..\source\uCEFViewDelegate.pas', + uCEFTextfield in '..\source\uCEFTextfield.pas', + uCEFTextfieldDelegate in '..\source\uCEFTextfieldDelegate.pas', + uCEFScrollView in '..\source\uCEFScrollView.pas', + uCEFPanel in '..\source\uCEFPanel.pas', + uCEFPanelDelegate in '..\source\uCEFPanelDelegate.pas', + uCEFBrowserView in '..\source\uCEFBrowserView.pas', + uCEFBrowserViewDelegate in '..\source\uCEFBrowserViewDelegate.pas', + uCEFButton in '..\source\uCEFButton.pas', + uCEFButtonDelegate in '..\source\uCEFButtonDelegate.pas', + uCEFLabelButton in '..\source\uCEFLabelButton.pas', + uCEFMenuButton in '..\source\uCEFMenuButton.pas', + uCEFMenuButtonPressedLock in '..\source\uCEFMenuButtonPressedLock.pas', + uCEFMenuButtonDelegate in '..\source\uCEFMenuButtonDelegate.pas', + uCEFWindow in '..\source\uCEFWindow.pas', + uCEFWindowDelegate in '..\source\uCEFWindowDelegate.pas', + uCEFViewsFrameworkEvents in '..\source\uCEFViewsFrameworkEvents.pas', + uCEFViewComponent in '..\source\uCEFViewComponent.pas', + uCEFTextfieldComponent in '..\source\uCEFTextfieldComponent.pas', + uCEFScrollViewComponent in '..\source\uCEFScrollViewComponent.pas', + uCEFPanelComponent in '..\source\uCEFPanelComponent.pas', + uCEFWindowComponent in '..\source\uCEFWindowComponent.pas', + uCEFBrowserViewComponent in '..\source\uCEFBrowserViewComponent.pas', + uCEFButtonComponent in '..\source\uCEFButtonComponent.pas', + uCEFLabelButtonComponent in '..\source\uCEFLabelButtonComponent.pas', + uCEFMenuButtonComponent in '..\source\uCEFMenuButtonComponent.pas', + uCEFAudioHandler in '..\source\uCEFAudioHandler.pas', + uCEFDevToolsMessageObserver in '..\source\uCEFDevToolsMessageObserver.pas', + uCEFMediaSinkDeviceInfoCallback in '..\source\uCEFMediaSinkDeviceInfoCallback.pas', + uCEFJson in '..\source\uCEFJson.pas', + uCEFBitmapBitBuffer in '..\source\uCEFBitmapBitBuffer.pas', + uCEFPrintHandler in '..\source\uCEFPrintHandler.pas', + uCEFPrintDialogCallback in '..\source\uCEFPrintDialogCallback.pas', + uCEFPrintJobCallback in '..\source\uCEFPrintJobCallback.pas', + uCEFLinuxConstants in '..\source\uCEFLinuxConstants.pas', + uCEFLinuxTypes in '..\source\uCEFLinuxTypes.pas', + uCEFLinuxFunctions in '..\source\uCEFLinuxFunctions.pas', + uCEFWorkSchedulerQueueThread in '..\source\uCEFWorkSchedulerQueueThread.pas', + uCEFLinkedWinControlBase in '..\source\uCEFLinkedWinControlBase.pas'; end. diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.dproj b/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.dproj index 8731efeaa5ec87eec8657f65f0f825625a9cc09f..030e648583c62511e1cb0071b922774f48ce2561 100644 --- a/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.dproj +++ b/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.dproj @@ -2,12 +2,12 @@ {2F51F1BD-0529-4B4A-BFD2-86FE96910A62} CEF4Delphi_FMX.dpk - 18.2 + 19.2 VCL True Debug Win32 - 1 + 3 Package @@ -34,6 +34,12 @@ true true + + true + Cfg_1 + true + true + true Base @@ -75,6 +81,10 @@ false false false + $(FrameworkType);$(DCC_Define) + 3082 + CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + ..\source;$(DCC_UnitSearchPath) rtl;vcl;fmx;$(DCC_UsePackage) @@ -100,6 +110,11 @@ true true + + true + 1033 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + false RELEASE;$(DCC_Define) @@ -203,7 +218,7 @@ - + @@ -232,6 +247,7 @@ + @@ -249,12 +265,12 @@ - + - + @@ -262,12 +278,75 @@ - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Base @@ -297,15 +376,15 @@ CEF4Delphi_FMX.dpk - File C:\Users\Public\Documents\Embarcadero\Studio\19.0\Bpl\DCLComponentes_UI.bpl not found - IP Abstraction Indy Implementation Design Time - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components + IP Abstraction Indy Implementation Design Time + DBExpress Enterprise Data Explorer Integration + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components - + CEF4Delphi_FMX.bpl true @@ -331,7 +410,6 @@ 1 - Contents\MacOS 0 @@ -340,6 +418,20 @@ classes 1 + + classes + 1 + + + + + res\xml + 1 + + + res\xml + 1 + @@ -352,90 +444,252 @@ library\lib\armeabi 1 + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + library\lib\mips 1 + + library\lib\mips + 1 + library\lib\armeabi-v7a 1 + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + res\drawable 1 + + res\drawable + 1 + res\values 1 + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + res\drawable 1 + + res\drawable + 1 + res\drawable-xxhdpi 1 + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + res\drawable-ldpi 1 + + res\drawable-ldpi + 1 + res\drawable-mdpi 1 + + res\drawable-mdpi + 1 + res\drawable-hdpi 1 + + res\drawable-hdpi + 1 + res\drawable-xhdpi 1 + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + res\drawable-small 1 + + res\drawable-small + 1 + res\drawable-normal 1 + + res\drawable-normal + 1 + res\drawable-large 1 + + res\drawable-large + 1 + res\drawable-xlarge 1 + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + @@ -453,6 +707,10 @@ 1 .framework + + 1 + .framework + 0 @@ -462,6 +720,10 @@ 1 .dylib + + 1 + .dylib + 0 .dll;.bpl @@ -484,6 +746,10 @@ 1 .dylib + + 1 + .dylib + 0 .bpl @@ -493,6 +759,9 @@ 0 + + 0 + 0 @@ -505,10 +774,39 @@ 0 + + 0 + 0 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + 1 @@ -520,6 +818,17 @@ 1 + + + 1 + + + 1 + + + 1 + + 1 @@ -531,6 +840,39 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + 1 @@ -542,6 +884,71 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + 1 @@ -553,6 +960,186 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + 1 @@ -564,6 +1151,16 @@ 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + 1 @@ -586,10 +1183,115 @@ 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + 1 + + 1 + @@ -604,6 +1306,7 @@ + 1 @@ -615,6 +1318,7 @@ 1 + @@ -622,12 +1326,20 @@ Contents\Resources 1 + + Contents\Resources + 1 + library\lib\armeabi-v7a 1 + + library\lib\arm64-v8a + 1 + 1 @@ -643,10 +1355,19 @@ 1 + + 1 + 0 + + + library\lib\armeabi-v7a + 1 + + 1 @@ -682,12 +1403,15 @@ + + True - False + True + False 12 diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.res b/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.res index 0b1d7bfebb7dc1e50dd62d97ee57ed52405f8ff3..391381f9dc4de3bb832da06585491df01ab8693f 100644 Binary files a/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.res and b/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX.res differ diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX_Register.pas b/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX_Register.pas index 5d5c2dd1e0524cc5d380e80c5d7e56502f2dd8fe..785f366c4e1e6afb155399cf42c106891fea2287 100644 --- a/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX_Register.pas +++ b/windows/src/ext/cef4delphi/packages/CEF4Delphi_FMX_Register.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -49,14 +49,28 @@ implementation uses System.Classes, - uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel, uCEFWorkScheduler, - uFMXBufferPanel, uFMXChromium, uFMXWorkScheduler, uCEFServerComponent; + uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFBufferPanel, + uCEFWorkScheduler, uCEFFMXBufferPanel, uCEFFMXChromium, uCEFFMXWorkScheduler, + uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent, + uCEFSentinel, uCEFBrowserViewComponent, uCEFLabelButtonComponent, + uCEFMenuButtonComponent, uCEFPanelComponent, uCEFTextfieldComponent, + uCEFScrollViewComponent, uCEFWindowComponent; procedure Register; begin - RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel, - TFMXBufferPanel, TFMXChromium, TFMXWorkScheduler, - TCEFWorkScheduler, TCEFServerComponent]); + RegisterComponents('Chromium', + [TChromium, TCEFWindowParent, TChromiumWindow, + TBufferPanel, TFMXBufferPanel, TFMXChromium, + TFMXWorkScheduler, TCEFWorkScheduler, + TCEFServerComponent, TCEFLinkedWindowParent, + TCEFUrlRequestClientComponent, + TCEFSentinel]); + + RegisterComponents('Chromium Views Framework', + [TCEFBrowserViewComponent, TCEFLabelButtonComponent, + TCEFMenuButtonComponent, TCEFPanelComponent, + TCEFTextfieldComponent, TCEFScrollViewComponent, + TCEFWindowComponent]); end; end. diff --git a/windows/src/ext/cef4delphi/packages/CEF4Delphi_Register.pas b/windows/src/ext/cef4delphi/packages/CEF4Delphi_Register.pas index 1ce23b155de2c1961330b9be3903bd124b791d91..e55a5de3b13b2e95ca17964713ea6d533feb32d6 100644 --- a/windows/src/ext/cef4delphi/packages/CEF4Delphi_Register.pas +++ b/windows/src/ext/cef4delphi/packages/CEF4Delphi_Register.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -53,13 +53,24 @@ uses {$ELSE} Classes, {$ENDIF} - uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel, uCEFWorkScheduler, - uCEFServerComponent; + uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFBufferPanel, + uCEFWorkScheduler, uCEFServerComponent, uCEFLinkedWindowParent, + uCEFUrlRequestClientComponent, uCEFSentinel, uCEFBrowserViewComponent, + uCEFLabelButtonComponent, uCEFMenuButtonComponent, uCEFPanelComponent, + uCEFTextfieldComponent, uCEFScrollViewComponent, uCEFWindowComponent; procedure Register; begin - RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel, - TCEFWorkScheduler, TCEFServerComponent]); + RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, + TBufferPanel, TCEFWorkScheduler, + TCEFServerComponent, TCEFLinkedWindowParent, + TCEFUrlRequestClientComponent, TCEFSentinel]); + + RegisterComponents('Chromium Views Framework', + [TCEFBrowserViewComponent, TCEFLabelButtonComponent, + TCEFMenuButtonComponent, TCEFPanelComponent, + TCEFTextfieldComponent, TCEFScrollViewComponent, + TCEFWindowComponent]); end; end. diff --git a/windows/src/ext/cef4delphi/packages/cef.inc b/windows/src/ext/cef4delphi/packages/cef.inc index 8ad3597bf10f95c08738bbf85ae6dc4210312421..c8ce967ee98b66e600679cad51d72cfa7f4705a8 100644 --- a/windows/src/ext/cef4delphi/packages/cef.inc +++ b/windows/src/ext/cef4delphi/packages/cef.inc @@ -144,7 +144,7 @@ {$DEFINE DELPHI15_UP} {$ENDIF} -// Delphi XE2 (First 64bit compiler) +// Delphi XE2 (First FireMonkey and 64bit compiler) {$IFDEF VER230} {$UNDEF DELPHI_VERSION_UNKNOW} {$DEFINE DELPHI5_UP} @@ -349,8 +349,64 @@ {$DEFINE DELPHI25_UP} {$ENDIF} +// Rad Studio 10.3 - Delphi Rio +{$IFDEF VER330} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} +{$ENDIF} + +// Rad Studio 10.4 - Delphi Sydney +{$IFDEF VER340} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} + {$DEFINE DELPHI27_UP} +{$ENDIF} + {$IFDEF FPC} {$DEFINE SUPPORTS_INLINE} + {$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)} + {$DEFINE FPC_VER_320} + {$IFEND} {$ELSE} {$IFDEF DELPHI_VERSION_UNKNOW} {$DEFINE DELPHI5_UP} @@ -373,6 +429,8 @@ {$DEFINE DELPHI23_UP} {$DEFINE DELPHI24_UP} {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} + {$DEFINE DELPHI27_UP} {$ENDIF} {$ENDIF} @@ -380,3 +438,31 @@ {$DEFINE SUPPORTS_INLINE} {$ENDIF} +{$IF DEFINED(CPUX32) OR + DEFINED(CPU386) OR + DEFINED(CPUi386) OR + DEFINED(CPUPOWERPC32) OR + DEFINED(CPUSPARC32) OR + DEFINED(CPU32BITS) OR + DEFINED(CPUARM32) OR + DEFINED(WIN32) OR + DEFINED(IOS32) OR + DEFINED(MACOS32) OR + DEFINED(LINUX32) OR + DEFINED(POSIX32) OR + DEFINED(ANDROID32)} + {$DEFINE TARGET_32BITS} +{$IFEND} + +// Delphi uses MACOS for the new MacOSX and DARWIN is not defined +// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7) +// We define MACOSX to avoid conflicts in both situations +{$IFDEF FPC} + {$IFDEF DARWIN} + {$DEFINE MACOSX} + {$ENDIF} +{$ELSE} + {$IFDEF MACOS} + {$DEFINE MACOSX} + {$ENDIF} +{$ENDIF} diff --git a/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.lpk b/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.lpk index 90231135c99ede0e6e5ce92b8e248535846d63f7..9d65b13b9fcc761dd94029a486f81a442b0b6659 100644 --- a/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.lpk +++ b/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.lpk @@ -19,9 +19,10 @@ - - - + + + + @@ -432,8 +433,8 @@ - - + + @@ -510,67 +511,357 @@ - - - + + - + - + - - + + + + + + + - - - - - - + + - - + + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + + + + + + + diff --git a/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.lps b/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.lps new file mode 100644 index 0000000000000000000000000000000000000000..ba92bfc9960aaab122ab6c0eb47cee46dd17d5dd --- /dev/null +++ b/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.lps @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.pas b/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.pas index 4b14ac9ea394e0a3254a19024ab0d6739b3e71d9..71c1d8694a4f7dbf7680ce1d24f5a8f3f4373974 100644 --- a/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.pas +++ b/windows/src/ext/cef4delphi/packages/cef4delphi_lazarus.pas @@ -39,13 +39,34 @@ uses uCEFStringMap, uCEFStringMultimap, uCEFStringVisitor, uCEFTask, uCEFTaskRunner, uCEFThread, uCEFTypes, uCEFUrlRequest, uCEFUrlrequestClient, uCEFv8Accessor, uCEFv8ArrayBufferReleaseCallback, uCEFv8Context, - uCEFV8Exception, uCEFv8Handler, uCEFv8Interceptor, uCEFv8StackFrame, + uCEFv8Exception, uCEFv8Handler, uCEFv8Interceptor, uCEFv8StackFrame, uCEFv8StackTrace, uCEFv8Value, uCEFValue, uCEFWaitableEvent, uCEFWebPluginInfo, uCEFWebPluginInfoVisitor, uCEFWebPluginUnstableCallback, uCEFWindowParent, uCEFWorkScheduler, uCEFWorkSchedulerThread, uCEFWriteHandler, uCEFX509Certificate, uCEFX509CertPrincipal, uCEFXmlReader, - uCEFZipReader, uCEFChromium, uBufferPanel, uCEFServer, uCEFServerComponent, - uCEFServerEvents, uCEFServerHandler, LazarusPackageIntf; + uCEFZipReader, uCEFChromiumCore, uCEFChromium, uCEFBufferPanel, uCEFServer, + uCEFServerComponent, uCEFServerEvents, uCEFServerHandler, uCEFWinControl, + uCEFLinkedWindowParent, uCEFUrlRequestClientEvents, + uCEFUrlRequestClientComponent, uCEFOSRIMEHandler, uCEFCookieAccessFilter, + uCEFResourceReadCallback, uCEFResourceRequestHandler, + uCEFResourceSkipCallback, uCEFSentinel, uCEFApplicationCore, + uCEFOAuth2Helper, uCEFMediaObserver, uCEFMediaRoute, + uCEFMediaRouteCreateCallback, uCEFMediaRouter, uCEFMediaSink, + uCEFMediaSource, uCEFRegistration, uCEFWindowDelegate, uCEFWindow, + uCEFMenuButtonDelegate, uCEFMenuButtonPressedLock, uCEFMenuButton, + uCEFLabelButton, uCEFButtonDelegate, uCEFButton, uCEFBrowserViewDelegate, + uCEFBrowserView, uCEFPanelDelegate, uCEFPanel, uCEFScrollView, + uCEFTextfieldDelegate, uCEFTextfield, uCEFViewDelegate, uCEFView, + uCEFFillLayout, uCEFBoxLayout, uCEFLayout, uCEFDisplay, + uCEFMenuButtonComponent, uCEFLabelButtonComponent, uCEFButtonComponent, + uCEFBrowserViewComponent, uCEFWindowComponent, uCEFPanelComponent, + uCEFScrollViewComponent, uCEFTextfieldComponent, uCEFViewComponent, + uCEFViewsFrameworkEvents, uCEFAudioHandler, uCEFDevToolsMessageObserver, + uCEFMediaSinkDeviceInfoCallback, uCEFJson, uCEFBitmapBitBuffer, + uCEFPrintDialogCallback, uCEFPrintHandler, uCEFPrintJobCallback, + uCEFLinuxFunctions, uCEFLinuxTypes, uCEFLinuxConstants, + uCEFWorkSchedulerQueueThread, uCEFLinkedWinControlBase, uCEFLazarusCocoa, + uCEFBrowserWindow, uCEFOsrBrowserWindow, LazarusPackageIntf; implementation @@ -55,8 +76,21 @@ begin RegisterUnit('uCEFWindowParent', @uCEFWindowParent.Register); RegisterUnit('uCEFWorkScheduler', @uCEFWorkScheduler.Register); RegisterUnit('uCEFChromium', @uCEFChromium.Register); - RegisterUnit('uBufferPanel', @uBufferPanel.Register); + RegisterUnit('uCEFBufferPanel', @uCEFBufferPanel.Register); RegisterUnit('uCEFServerComponent', @uCEFServerComponent.Register); + RegisterUnit('uCEFLinkedWindowParent', @uCEFLinkedWindowParent.Register); + RegisterUnit('uCEFUrlRequestClientComponent', + @uCEFUrlRequestClientComponent.Register); + RegisterUnit('uCEFSentinel', @uCEFSentinel.Register); + RegisterUnit('uCEFMenuButtonComponent', @uCEFMenuButtonComponent.Register); + RegisterUnit('uCEFLabelButtonComponent', @uCEFLabelButtonComponent.Register); + RegisterUnit('uCEFBrowserViewComponent', @uCEFBrowserViewComponent.Register); + RegisterUnit('uCEFWindowComponent', @uCEFWindowComponent.Register); + RegisterUnit('uCEFPanelComponent', @uCEFPanelComponent.Register); + RegisterUnit('uCEFScrollViewComponent', @uCEFScrollViewComponent.Register); + RegisterUnit('uCEFTextfieldComponent', @uCEFTextfieldComponent.Register); + RegisterUnit('uCEFBrowserWindow', @uCEFBrowserWindow.Register); + RegisterUnit('uCEFOsrBrowserWindow', @uCEFOsrBrowserWindow.Register); end; initialization diff --git a/windows/src/ext/cef4delphi/packages/res/00-CreateDelphiResources.bat b/windows/src/ext/cef4delphi/packages/res/00-CreateDelphiResources.bat index af5012b4d89f93b27116f89d37aaf8c7e3d6c028..6aa749e1ddd19e9791505b3f823f575e13eed664 100644 --- a/windows/src/ext/cef4delphi/packages/res/00-CreateDelphiResources.bat +++ b/windows/src/ext/cef4delphi/packages/res/00-CreateDelphiResources.bat @@ -1,2 +1,3 @@ brc32 chromium.rc -r -fochromium.dcr + pause \ No newline at end of file diff --git a/windows/src/ext/cef4delphi/packages/res/00-CreateLazarusResources.bat b/windows/src/ext/cef4delphi/packages/res/00-CreateLazarusResources.bat index 73ee3fde3b56ad75d3d1ee3f41e8717fdd3a6ed8..50c168e0c73422c2ce9adff959849523e24dbdfb 100644 --- a/windows/src/ext/cef4delphi/packages/res/00-CreateLazarusResources.bat +++ b/windows/src/ext/cef4delphi/packages/res/00-CreateLazarusResources.bat @@ -1,7 +1,16 @@ -e:\lazarus\tools\lazres.exe ..\..\source\res\tbufferpanel.lrs tbufferpanel.png -e:\lazarus\tools\lazres.exe ..\..\source\res\tcefservercomponent.lrs tcefservercomponent.png -e:\lazarus\tools\lazres.exe ..\..\source\res\tcefwindowparent.lrs tcefwindowparent.png -e:\lazarus\tools\lazres.exe ..\..\source\res\tcefworkscheduler.lrs tcefworkscheduler.png -e:\lazarus\tools\lazres.exe ..\..\source\res\tchromium.lrs tchromium.png -e:\lazarus\tools\lazres.exe ..\..\source\res\tchromiumwindow.lrs tchromiumwindow.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tbufferpanel.lrs tbufferpanel.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tcefservercomponent.lrs tcefservercomponent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tcefwindowparent.lrs tcefwindowparent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tceflinkedwindowparent.lrs tceflinkedwindowparent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tcefworkscheduler.lrs tcefworkscheduler.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tchromium.lrs tchromium.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tchromiumwindow.lrs tchromiumwindow.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tcefurlrequestclientcomponent.lrs tcefurlrequestclientcomponent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tceftextfieldcomponent.lrs tceftextfieldcomponent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tcefscrollviewcomponent.lrs tcefscrollviewcomponent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tcefpanelcomponent.lrs tcefpanelcomponent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tcefwindowcomponent.lrs tcefwindowcomponent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tcefbrowserviewcomponent.lrs tcefbrowserviewcomponent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tceflabelbuttoncomponent.lrs tceflabelbuttoncomponent.png +c:\lazarus\tools\lazres.exe ..\..\source\res\tcefmenubuttoncomponent.lrs tcefmenubuttoncomponent.png pause \ No newline at end of file diff --git a/windows/src/ext/cef4delphi/packages/res/chromium.dcr b/windows/src/ext/cef4delphi/packages/res/chromium.dcr index 9aadbeb31de30d9b1d16714a08ba330baeaf28ac..7936e2446a89aa4a4f213d90d2ebce1afd1825ce 100644 Binary files a/windows/src/ext/cef4delphi/packages/res/chromium.dcr and b/windows/src/ext/cef4delphi/packages/res/chromium.dcr differ diff --git a/windows/src/ext/cef4delphi/packages/res/chromium.rc b/windows/src/ext/cef4delphi/packages/res/chromium.rc index ebd5fea0773b25b666c32565b05bc4c5ae1a0ef7..a972275613eeae9f9966f0d5bdb6bf7fc37cb9a6 100644 --- a/windows/src/ext/cef4delphi/packages/res/chromium.rc +++ b/windows/src/ext/cef4delphi/packages/res/chromium.rc @@ -1,9 +1,19 @@ TChromium BITMAP "chromium.bmp" TFMXChromium BITMAP "chromium.bmp" TCEFWindowParent BITMAP "windowparent.bmp" +TCEFLinkedWindowParent BITMAP "windowparent.bmp" TChromiumWindow BITMAP "chromiumwindow.bmp" TBufferPanel BITMAP "bufferpanel.bmp" TFMXBufferPanel BITMAP "bufferpanel.bmp" TCEFWorkScheduler BITMAP "workscheduler.bmp" TFMXWorkScheduler BITMAP "workscheduler.bmp" -TCEFServerComponent BITMAP "server.bmp" \ No newline at end of file +TCEFServerComponent BITMAP "server.bmp" +TCEFUrlRequestClientComponent BITMAP "tcefurlrequestclientcomponent.bmp" +TCEFSentinel BITMAP "tcefsentinel.bmp" +TCEFTextfieldComponent BITMAP "tceftextfieldcomponent.bmp" +TCEFScrollViewComponent BITMAP "tcefscrollviewcomponent.bmp" +TCEFPanelComponent BITMAP "tcefpanelcomponent.bmp" +TCEFWindowComponent BITMAP "tcefwindowcomponent.bmp" +TCEFBrowserViewComponent BITMAP "tcefbrowserviewcomponent.bmp" +TCEFLabelButtonComponent BITMAP "tceflabelbuttoncomponent.bmp" +TCEFMenuButtonComponent BITMAP "tcefmenubuttoncomponent.bmp" \ No newline at end of file diff --git a/windows/src/ext/cef4delphi/packages/res/tcefbrowserviewcomponent.bmp b/windows/src/ext/cef4delphi/packages/res/tcefbrowserviewcomponent.bmp new file mode 100644 index 0000000000000000000000000000000000000000..5bcb0bb8b14e6d54938bff282aa307b790563fa5 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefbrowserviewcomponent.bmp differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefbrowserviewcomponent.png b/windows/src/ext/cef4delphi/packages/res/tcefbrowserviewcomponent.png new file mode 100644 index 0000000000000000000000000000000000000000..c3115d874bfdeaab979d1e3a016978db6ff02fac Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefbrowserviewcomponent.png differ diff --git a/windows/src/ext/cef4delphi/packages/res/tceflabelbuttoncomponent.bmp b/windows/src/ext/cef4delphi/packages/res/tceflabelbuttoncomponent.bmp new file mode 100644 index 0000000000000000000000000000000000000000..611d961aebb79035b8c2bd2954c7931344c2c796 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tceflabelbuttoncomponent.bmp differ diff --git a/windows/src/ext/cef4delphi/packages/res/tceflabelbuttoncomponent.png b/windows/src/ext/cef4delphi/packages/res/tceflabelbuttoncomponent.png new file mode 100644 index 0000000000000000000000000000000000000000..bc10ce3cd585fd7712e091b2a57e2e5427145abc Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tceflabelbuttoncomponent.png differ diff --git a/windows/src/ext/cef4delphi/packages/res/tceflinkedwindowparent.png b/windows/src/ext/cef4delphi/packages/res/tceflinkedwindowparent.png new file mode 100644 index 0000000000000000000000000000000000000000..e442de4737f990d5928d63df84360edf728aee53 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tceflinkedwindowparent.png differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefmenubuttoncomponent.bmp b/windows/src/ext/cef4delphi/packages/res/tcefmenubuttoncomponent.bmp new file mode 100644 index 0000000000000000000000000000000000000000..4515a93c645eaea17ab8788bab10af71121ba024 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefmenubuttoncomponent.bmp differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefmenubuttoncomponent.png b/windows/src/ext/cef4delphi/packages/res/tcefmenubuttoncomponent.png new file mode 100644 index 0000000000000000000000000000000000000000..8c4f83a02426b1af505e41c4382c78e727984a0e Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefmenubuttoncomponent.png differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefpanelcomponent.bmp b/windows/src/ext/cef4delphi/packages/res/tcefpanelcomponent.bmp new file mode 100644 index 0000000000000000000000000000000000000000..11dccd9b93cd0cc0b0a8cf4ee4890533dd33eb9b Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefpanelcomponent.bmp differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefpanelcomponent.png b/windows/src/ext/cef4delphi/packages/res/tcefpanelcomponent.png new file mode 100644 index 0000000000000000000000000000000000000000..7ccd4523641b747c860eaf61702983d2b8a6a4a1 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefpanelcomponent.png differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefscrollviewcomponent.bmp b/windows/src/ext/cef4delphi/packages/res/tcefscrollviewcomponent.bmp new file mode 100644 index 0000000000000000000000000000000000000000..6227525c8e46a273f5f05eb0119e6596b123c454 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefscrollviewcomponent.bmp differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefscrollviewcomponent.png b/windows/src/ext/cef4delphi/packages/res/tcefscrollviewcomponent.png new file mode 100644 index 0000000000000000000000000000000000000000..232e6919b9c977573bff313aca9e5aab3256b87c Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefscrollviewcomponent.png differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefsentinel.bmp b/windows/src/ext/cef4delphi/packages/res/tcefsentinel.bmp new file mode 100644 index 0000000000000000000000000000000000000000..2aa78befbd5172cb3738be64bf270bba306c3474 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefsentinel.bmp differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefsentinel.png b/windows/src/ext/cef4delphi/packages/res/tcefsentinel.png new file mode 100644 index 0000000000000000000000000000000000000000..1d8cecf40019a21fea0da02f3641584255e74db9 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefsentinel.png differ diff --git a/windows/src/ext/cef4delphi/packages/res/tceftextfieldcomponent.bmp b/windows/src/ext/cef4delphi/packages/res/tceftextfieldcomponent.bmp new file mode 100644 index 0000000000000000000000000000000000000000..6c3b22d18608e243f25392e2de5402bf9a8c2817 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tceftextfieldcomponent.bmp differ diff --git a/windows/src/ext/cef4delphi/packages/res/tceftextfieldcomponent.png b/windows/src/ext/cef4delphi/packages/res/tceftextfieldcomponent.png new file mode 100644 index 0000000000000000000000000000000000000000..d9e19afa3e09d8b88db24ad7f6dff41af78c1277 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tceftextfieldcomponent.png differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefurlrequestclientcomponent.bmp b/windows/src/ext/cef4delphi/packages/res/tcefurlrequestclientcomponent.bmp new file mode 100644 index 0000000000000000000000000000000000000000..5289965c02f257a57c877e60f39b2b2d8b67f3be Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefurlrequestclientcomponent.bmp differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefurlrequestclientcomponent.png b/windows/src/ext/cef4delphi/packages/res/tcefurlrequestclientcomponent.png new file mode 100644 index 0000000000000000000000000000000000000000..433249cb761919032f580b5e26798568f89d2d27 Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefurlrequestclientcomponent.png differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefwindowcomponent.bmp b/windows/src/ext/cef4delphi/packages/res/tcefwindowcomponent.bmp new file mode 100644 index 0000000000000000000000000000000000000000..ebfc6b99a7204e42d321260e579b190aadd2589b Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefwindowcomponent.bmp differ diff --git a/windows/src/ext/cef4delphi/packages/res/tcefwindowcomponent.png b/windows/src/ext/cef4delphi/packages/res/tcefwindowcomponent.png new file mode 100644 index 0000000000000000000000000000000000000000..7f40a3b0c481bee070fffb812fe469cd7b6fb34d Binary files /dev/null and b/windows/src/ext/cef4delphi/packages/res/tcefwindowcomponent.png differ diff --git a/windows/src/ext/cef4delphi/source/00-DeleteDCUs.bat b/windows/src/ext/cef4delphi/source/00-DeleteDCUs.bat index c546615dce90122bbc500797d1a69f3d40c85147..84bf22617c98e60c93f3c4a01e00c05f9ced5c6d 100644 --- a/windows/src/ext/cef4delphi/source/00-DeleteDCUs.bat +++ b/windows/src/ext/cef4delphi/source/00-DeleteDCUs.bat @@ -7,6 +7,7 @@ del /s /q *.stat del /s /q *.local del /s /q *.~* rmdir /S /Q Win32 +rmdir /S /Q Win64 rmdir /S /Q backup rmdir /S /Q __history rmdir /S /Q __recovery diff --git a/windows/src/ext/cef4delphi/source/cef.inc b/windows/src/ext/cef4delphi/source/cef.inc index 8ad3597bf10f95c08738bbf85ae6dc4210312421..c8ce967ee98b66e600679cad51d72cfa7f4705a8 100644 --- a/windows/src/ext/cef4delphi/source/cef.inc +++ b/windows/src/ext/cef4delphi/source/cef.inc @@ -144,7 +144,7 @@ {$DEFINE DELPHI15_UP} {$ENDIF} -// Delphi XE2 (First 64bit compiler) +// Delphi XE2 (First FireMonkey and 64bit compiler) {$IFDEF VER230} {$UNDEF DELPHI_VERSION_UNKNOW} {$DEFINE DELPHI5_UP} @@ -349,8 +349,64 @@ {$DEFINE DELPHI25_UP} {$ENDIF} +// Rad Studio 10.3 - Delphi Rio +{$IFDEF VER330} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} +{$ENDIF} + +// Rad Studio 10.4 - Delphi Sydney +{$IFDEF VER340} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} + {$DEFINE DELPHI27_UP} +{$ENDIF} + {$IFDEF FPC} {$DEFINE SUPPORTS_INLINE} + {$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)} + {$DEFINE FPC_VER_320} + {$IFEND} {$ELSE} {$IFDEF DELPHI_VERSION_UNKNOW} {$DEFINE DELPHI5_UP} @@ -373,6 +429,8 @@ {$DEFINE DELPHI23_UP} {$DEFINE DELPHI24_UP} {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} + {$DEFINE DELPHI27_UP} {$ENDIF} {$ENDIF} @@ -380,3 +438,31 @@ {$DEFINE SUPPORTS_INLINE} {$ENDIF} +{$IF DEFINED(CPUX32) OR + DEFINED(CPU386) OR + DEFINED(CPUi386) OR + DEFINED(CPUPOWERPC32) OR + DEFINED(CPUSPARC32) OR + DEFINED(CPU32BITS) OR + DEFINED(CPUARM32) OR + DEFINED(WIN32) OR + DEFINED(IOS32) OR + DEFINED(MACOS32) OR + DEFINED(LINUX32) OR + DEFINED(POSIX32) OR + DEFINED(ANDROID32)} + {$DEFINE TARGET_32BITS} +{$IFEND} + +// Delphi uses MACOS for the new MacOSX and DARWIN is not defined +// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7) +// We define MACOSX to avoid conflicts in both situations +{$IFDEF FPC} + {$IFDEF DARWIN} + {$DEFINE MACOSX} + {$ENDIF} +{$ELSE} + {$IFDEF MACOS} + {$DEFINE MACOSX} + {$ENDIF} +{$ENDIF} diff --git a/windows/src/ext/cef4delphi/source/res/tbrowserwindow.lrs b/windows/src/ext/cef4delphi/source/res/tbrowserwindow.lrs new file mode 100644 index 0000000000000000000000000000000000000000..9cb2f93db6380eeb681e9de221f17f37ce4e45b5 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tbrowserwindow.lrs @@ -0,0 +1,38 @@ +LazarusResources.Add('tlazarusbrowserwindow','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#2#0#0#0'o'#21#170#175 + +#0#0#0#9'pHYs'#0#0#13#215#0#0#13#215#1'B('#155'x'#0#0#0#7'tIME'#7#226#5#11#10 + +#31#18#187#205#226'X'#0#0#3#10'IDAT8'#203#173#149'Ml'#27'U'#16#199'g'#158'7' + +#222#197'Qk'#183'IIBl#'#156'JM'#12'V'#137#168#16'E *8Qn'#17' '#142#168#226 + +#200#181#189'p'#228#128#212'['#213#3'\'#171#194#165'= TQ'#129'P'#131#26#138 + +'d'#167#20'PE'#212'H'#9'_'#18'i'#226#218#241'G'#214'~'#187#222'}3'#195'a#w' + +#243'Q)'#144#206'i5o'#222'_3'#191#153'y'#139'"'#2#143#195','#215'u'#23#23#23 + +#247#169'R,'#22#161'\.'#19#145#236#195#136#168'\.+"RJ'#237''''#29#165#20#17 + +#237'I'#162'g'#246#192#232'Q'#7'k.\-'#223#191#241#253'M'#1#4#128#4#192#169 + +#215'_}'#231#197#241#177#131#143#22'b'#230'm'#222'Oo5'#191#190'v'#205'NZ'#153 + +'L'#26#5#1#128#133'ggg'#175'_'#15#222#255#224#204#187#147#187'4Z'#1#128#136 + +'p'#204'.'#220'l^'#186#252#133#149't'#208'Jv'#180#239'j'#175#165#187#237#142 + +'6'#146#224'D'#242#147#243#23#206']Y'#142#199'G'#3#180#153'Q'#127#154'j'#30 + +#206#207#223'N$'#157#182#246#200#176#31#154#227#133#209#3#169#228'j'#203#183 + +#5#6#149#12#165#7#239#222#254'a'#253#244'3'#135#156#205'+'#136#184')'#20'e' + +#20'y'#231#254#30'('#30'+'#212'j'#235'n'#167'{4w'#248#243#143#222'^m'#19#139 + +'d3'#214#221#127#186':'#228#148'm'#245#180'k'#148'b'#14#251']'#3#0'+R!'#162 + +#200'['#249'y!?>'#246#236'sS_~'#245#237#220#197'3'#31'_Y'#178#7#20'"z~xvfb' + +#249#129#7#28#218#142#179#244#231#253'L'#225'p'#31#144#136#168#168#180'X'#193 + +'@l'#242#217#209#247'N'#191#242#203#239#27#141#166#214':'#208#186#215'r{'#183 + +'~'#171#167#146#9'f'#16#129'-P'#153'w)'#141'X'#136#152#133#166'&'''#218#186 + +'Wk{'#134#24#17'Z:'#232#6#6#128#1#0#1#12#131'!V'#24'+'#173#159'Q$'#20#132#20 + +#24#177'mY'#217#8'_'#155#28'Zu'#189#7']'#31#1#12'K'#169#144#209#1'#'#2#3#244 + +#136'@'#152#5#250#211'cE*}F'''#166#167#23#238'-'#140#28'9d)u'#227#158#251#217 + +#135'/|sgMD'#222'x~'#196'0'#136#0' 4'#154#237'\6K'#180#209#135#205#204#219#25 + +#189'<'#214#233't}'#207'7'#134#184#222#9#175#222'i'#13#13#165#237#212#224#210 + +#154'oH'#16' 4'#208#236#132#25#232'lc'#180'} '#135#147#193'K'''#166'W'#170'u' + +#207#15'{'#129#17#162#229#170'n'#235#224#216'S'#131'!'#177#14#229#143#149'Zv' + +'|'#212#134'`'#247#129#140'o'#201'['#185#134#147'(}'#247#227#175#169''''#236 + +'t'#250'`h'#248#228#241#225#182'G'#213'zk'#221#13#158#206#231'rV3'#190'T'#15 + +#187#22'g'#20#217#169#145'F'#241#205#137#185'j'#166'2'#255#211#147#233#129 + +#191'V'#209#13'h'#234'h'#225#228#145#214#1#171#190'5v'#171#208#206#189#29#182 + +'{3'#249#234'L>'#23#243'U'#1'`G '#254#5'Ixq'#26'FW'#221'b'#0#0#0#0'IEN' + +'D'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tcefbrowserviewcomponent.lrs b/windows/src/ext/cef4delphi/source/res/tcefbrowserviewcomponent.lrs new file mode 100644 index 0000000000000000000000000000000000000000..1e243d43daa38232affc2898607d34a94aad3194 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tcefbrowserviewcomponent.lrs @@ -0,0 +1,59 @@ +LazarusResources.Add('tcefbrowserviewcomponent','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#11#19#0#0#11 + +#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#12'-_'#141#12'\'#0#0#4#227'IDA' + +'TH'#199#189#150'{'#136'TU'#28#199'?'#231#220#199'<'#246'5'#179#179#179#174 + +#235#234#170#227'+'#219'v'#181'B7'#203'P37'#133'D+D4'#11'2L!'#177'$'#9#162 + +#168'?R$EDB'#194'L'#5'I'#162'-+'#237'af'#178#153#230#163#215#154#175'|'#174 + +#142#235#234#248'Xgg'#156#199#157#153'{O'#127#236#154#174#146#134'A?8p'#206 + +#189#240#253#240#253#241';'#247'{'#197#170'5k'#244#130#194#194'nV:'#141#226 + +#191#151#148#18#183#203#21#127'r'#226#196'V'#0#189#165#165#165#239#240'P'#232 + +'`I '#240#159#1#2#16'B'#176'o'#255#254#221'@-'#128#30'>u'#202#19#156'8'#17 + +#191#191#24';'#151'C'#8'q[!'#5#160'T'#187#226'ue'#219#14'='#186'W'#240'{cc' + +#197#213'g'#186#163#20#10#16'(bI'#11']'#147#183#22'W'#10'C'#215'0t'#13#199'v' + +':'#189's'#156#246#179#195#181'f'#232'W7.'#211'`'#199#129#22#220#166'v'#139#6 + +#128#163#20#161'r'#31#161#174'>'#28')'#175'RA'#128'm'#223#236'^G)P'#138#156 + +'m'#243#204#136#16#226'o'#223#170'}'''#4'J'#129#165#4#134'i'#162'T;$i'#229 + +#200's'#27#216#182'C:'#147#195#235'1I'#166#172'k'#192#27#29#20#25#130#217#7 + +#203#232#162'E'#16'H'#18'"'#136#14'H''BV'#148'P'#215'U'#177#237#171'M'#4'J'#3 + +'$'#173','#179#198'V3w'#249#22'zW'#150'1'#163#174#138#185#203#183'0iT'#21#163 + +#130']n'#6'(@H'#141#144#247#28#243#210#247#3'&'#11#138'NPd'#157#196#21#30'C:' + +#127#10#249#158#183'x'#160#170#2'o~'#30#202'Ql'#219#223#204#178#217'u|'#179 + +#231'8'#187#14#159'e'#202#163'5x]'#237#237#189'~N'#244#235#6#152#2']BT'#128 + +#150'Oa'#16#236#227'or'#197#242'`['#27#177#227#147'x'#168'&'#132#144' '#20'H' + +#161'0<:'#227#134#244'F'#211'5p'#28'rY'#187#3' n'#6'H'#4#186#187#148#149'w' + +#159'F*'#8'X'#167'9|v='#166#167#146'L6'#138'Hl'#230#157#205'wQ'#26', '#147 + +#181#217#30#177'8'#167#231's'#224't'#4'M'#19'H'#161'3'#162'W'#144'EO'#212'Ph' + +#200#27#0'J!'#164'FI'#30'xe'#135'Eww'#24#246#17#151#214#190'H'#193#228#5#4 + +#186'=Fu'#239'S'#20#21#23#176#238'D'#154'1CS'#140#173'NP'#234#9'q'#238#138 + +#143#230'd'#132'X'#226'7'#230#127'_N['#216#184'yL'#133'+'#143#163#135'FP'#228 + +#14#0#2#129'@'#250#242'P'#191'dI?'#189#137'h\'#240#212#232')'#12'Y'#214#192 + +#156#209#131#24'Z'#153'#'#161#246#178#241'X'#21#210'UOs'#252#28'G'#218'Zxv' + +#244#28#246#253#241'q'#215'Of'#174#157#206'{'#211'>'#184#230'EB'#252'|+'#177 + +#11'Qb'#231#163'D'#207#183#210'z'#180#25#235#213'*'#162'G'#195#24'v'#150#9 + +#139#191#230#158#202#18#250#150#251#176#229'>'#28'}'#3'~'#255#219#152#158#21 + +#20#22#174'$'#145#241#179'pg>'#181#213#175#232'#'#6#214'<''&'#207#247#233#215 + +'_'#138#154#224#167#148#5#253'8'#202#193#212'5'#10#221':'#145#182#20#178'D' + +#210#211'_D'#179'k'#23#179#135#244#227#208#165#28'A'#247'H'#242#11#235'Q'#230 + +'j'#154'"'#15#163#180'#D'#226#195'9'#28'y'#153#133'{f'#241#224#128#147#195#26 + +#26#140#178'N'#128#186#218#30'h'#154#134#16#144#181#29#188#166'Ne'#206#11#10 + +#188'n'#131#230'h'#138'Cq'#19'igHe'#161'W'#209'N.gZ'#240'x'#235#209'D'#26#175 + +'y'#2'S'#171'd'#239#153'YTT|'#136#150'.'#246't'#2#188#180#244'3'#6#246#169' ' + +#145#206'0'#245#145'j'#222']'#255#19#229'A?y^'#147#251#186#251#137#197'l'#142 + +'%'#182'#'#173'{'#17#142'IY'#143'Fr'#10'<'#6#236'n'#154#195#159'g'#167#226 + +#208'D,'#237#226#219'c'#181#20#232#191#10#29')'#145'Z'#251#5'Y'#249#218#228 + +'N'#223#145'%'#179#199'w:'#15#222#149'&ko r%'#136#149#233#135#235#248'<'#250 + +#151#173' '#220':'#136'X'#170#130#140'}'#153'K'#201#0#241#140#27#203#234#129 + +')~tt'#151'a'#208#212#212'D8'#28'F'#169#127'N'#4#175'.'#152#16'P,'#217'QG' + +#159#158'>'#132's'#129#29#199#230'q'#250'r'#136#193#221#23#209#150#244#242'x' + +#245'xR'#25#193#217'X7~h'#152#209#152#10#31#138#10#192#15#148#3#238#127#145 + +')'#185#210'7'#190#248'2'#208'k@'#133'a'#186'Q'#128#149#241'p&'#22#228#253 + +#169#130#132#5'9G'#178#244#243#213#234'bc'#250#245'K'#171'^X'#162#1#25#160#13 + +#184'p'#187'%t3'#158'i'#252'n'#171#209#175'vd'#214'p'#21#167#28'I'#210#201 + +#146#206'9'#8#217'B'#206'r'#177'n'#235'|Z~'#22#203'.'#175#153#190'X'#184#242 + +#146#226#14#146'1_/.'#27#224#27'7s'#154#167#255#144#231#165#233#241':'#170'C' + +#166#245#248#158#139#13#155#150#165#246#212'7 d'#4#229#228#196#29'e'#175#225 + +#242#168#172'U'#12#248#0'WG'#26#217#192#21#160#181#163'#'#246#181#152#186#195 + +#31#8#192#184'A#'#215#177#254#191#250#11'6q'#245#154#205'O'#27#207#0#0#0#0'I' + +'END'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tceflabelbuttoncomponent.lrs b/windows/src/ext/cef4delphi/source/res/tceflabelbuttoncomponent.lrs new file mode 100644 index 0000000000000000000000000000000000000000..79adfd31aceedf3cdbabab3e0d10c4f8ca2fc04c --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tceflabelbuttoncomponent.lrs @@ -0,0 +1,23 @@ +LazarusResources.Add('tceflabelbuttoncomponent','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#11#19#0#0#11 + +#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#13#1'tNQ'#254#0#0#1#158'IDATH' + +#199#237#149#177'j'#149'A'#16#133#191#217#127's'#249'I'#8')'#180#189#22#150 + +#193'('#130#160'>'#193'-'#172'E'#240#5#196#202#218#222#23#176#18#219't'#226 + +#19#216#132'X'#10#130#8'!'#22#222'"D'#196#198'p'#137#185#145#127#255#221#153 + +#177#216#128'v'#22'w;='#15'p'#14'g'#206#156#25#248#143#191'@'#0'n=z'#177'1Xw' + +#169'('#2#190'2e'#236#240'>'#232#201#251#151#143#207#229#250#195'g'#155'7o\{' + +'}{{:'#139'!'#208'B'#160#152#241#238#240#203#155#15#31#15#238#199#31#139#239 + +#211';'#219'Wf'#247#238#238'p>'#148#11'O+'#192'a'#163#143#8'2{'#187#191'?' + +#141#227'r'#209#175#197#192'rP'#210'h'#200#138#2#238#224'(k10.'#23'}'#4#199 + +#28#198#162#140#170#248#138#19#18#1')`^'#237'D'#17'A'#29'RQR'#214'f'#171#163 + +#14'"B'#20#192#20'R1R'#177'6'#2'A0'#173'qF'#17'(n'#140'E'#201#165#141#3#9#149 + +'S'#4#162' '#152#193#152#141#164#214'bK!WNA'#136#8#20'3'#134'b'#140#185#205 + +#136#252#162#11#8#196' `'#6')+9k'#19#3'N'#229#12#2#17#4'U'#175#25'h'#155#12 + +'\@'#213#235#217#168'!;'#169#24'9['#147'&'#27'Bq'#255#29'r'#23#2#169'(?S!' + +#172'p'#238#132'Z'#176'u'#129'.'#132#26'r'#160#232#241#183#19#30#236'\eht*' + +#250'I'#224#213#225'g'#2'E'#227'|o'#247'h}'#235#242#211#131#249#241#19'w'#15 + +'-'#20'D'#196#206#190'~z>'#223#219'='#146'8'#233#187'2'#14'['#192'&'#208'5' + +#250'3'#10#156#197'I'#127'*'#127#140'Oh'#11'o'#240'\'#254#5#252#2'|'#157#212 + +#191'x:}'#193#0#0#0#0'IEND'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tceflinkedwindowparent.lrs b/windows/src/ext/cef4delphi/source/res/tceflinkedwindowparent.lrs new file mode 100644 index 0000000000000000000000000000000000000000..9c9bfb3a08ddd30b3945b50b61e73a376a246a56 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tceflinkedwindowparent.lrs @@ -0,0 +1,13 @@ +LazarusResources.Add('tceflinkedwindowparent','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#2#0#0#0'o'#21#170#175 + +#0#0#0#9'pHYs'#0#0#13#215#0#0#13#215#1'B('#155'x'#0#0#0#7'tIME'#7#226#5#11#10 + +#31'&'#154'y'#22#237#0#0#0#174'IDAT8'#203#173#148';'#14#196' '#12'D'#241#136 + +#130#179' q'#255'+'#144#27#228#20'i'#144#136#20'18'#5#171#253#148#27#219#189 + +#159#158#199#150'EU'#131'G'#197#214#218#190#239'FJ'#206'9'#212'ZI'#170#161'H' + +#214'ZA'#18#128'E'#7#0'I'#4#167'r'#3#197#16#194#156#211#7#180'2{'#140#16#145 + +#143#145#15'HU-'#211#173#165#199'E!i'#9'HU_'#163'Y'#140#188'G'#179#27#173#222 + +#184'('#150#140#0#204'9'#253#140#236#25#173#27't52f'#244#3#178#27#249#189#145 + +#235#186#0#164#148','#151#221'{'#151#227'8'#182'm;'#207's'#140#241#239#15#16 + +#17#17'I)'#149'R'#228#187#249'AR'#239#127#127#3#232'x'#222'a'#127#10#207#215 + +#0#0#0#0'IEND'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tcefmenubuttoncomponent.lrs b/windows/src/ext/cef4delphi/source/res/tcefmenubuttoncomponent.lrs new file mode 100644 index 0000000000000000000000000000000000000000..3b19cfb45574cb4e9088010958ffe0bcd7dfdf2c --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tcefmenubuttoncomponent.lrs @@ -0,0 +1,50 @@ +LazarusResources.Add('tcefmenubuttoncomponent','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#11#19#0#0#11 + +#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#13#28#23'H='''#0#0#4#18'IDATH' + +#199#173#148#205'oTU'#24#198#127#231#227#222';'#31'm-M'#234'\'#166#138#141'-' + +#26#252#128#208')E '#209#5#160#209#248#181#194#134#13';'#227'?`'#252#7#220#24 + +#227#127#192#2'w'#238'X'#209#13'1'#177'$l*('#198#0'*'#132#206#20'Z'#194#135 + +#216'N3'#237#220'{'#206'='#199#197'0'#183#182#20'H'#13'Or'#146#155#156's'#207 + +'s'#222#231'y'#223'G|p'#226#171#234#208#142#225'KJ'#169'A'#231'@'#176#30#30 + +#144#18'l'#150#185#133#185#250#200#212#247#223#212#217#2#244#252#205#198#224 + +#137#201'O'#7'k'#251'v'#147#164#217#166#135#162'Pq'#241#194#239#242#235's?' + +#246#179'Eh'#155#182'U+14'#155'+$'#169'El('#193'{'#136'BM'#171#157#146#153'T' + +'m'#153#192#3'JH*'#253'e'#140#177#155'J'#20#4#26'!$'#137#177'n'#203#4'='#133 + +#144'?o'#204#177#188#178'J'#230'6'#255'_I'#201#236#220#2#239#31'z'#243#139 + +#193#15''''#22#188#247#226'i'#23#23#139'%e'#140#249'N'#191#208'gx'#231#141#10 + +#187'v'#189#134#203#30#186#236'7!y'#251'u'#2#249#222#231#30#240#222'?'#241'r' + +#165'$'#151'/_'#230#212#169'S?'#232',s'#244#150#10#152#180#141'M'#13#198'Z' + +#194' D'#8#240#248'\'#178#164#13'&5'#232'@#'#165#196'='#166'Z'#239'=a'#24#18 + +'E'#17'KKK'#145#6'p'#30#148#210#24'a'#153#157#189#129#177#150'8'#142'I'#147 + +#20'!'#4#198#26#138#197'"W'#175'^'#161'R'#137#233#237#233#165':4D'#16#134'x' + +#231'p'#206#161#148#198'Z'#3#128'T'#154'n'#145#186#195#234#144#178#163#205 + +#221#187'w'#16'B'#176#180#248#15'I'#146'000@'#24'E'#172#174#172#16'Wbn'#223 + +'^`>s'#236'xi'#7#191'^'#248#153'J'#28#19#199#219#249#229#226#12#251'&'#246'c' + +#173'E)'#137#247'n'#141#160#163#155#162'\.'#243#209#199#159'0'#215'hP'#238 + +#237'e['#127'?'#222'{<'#29'k'#164#148'H)1'#198#144'e'#25#251#15#28#192'{'#143 + +'s'#142#183#14#28#196#24#131#148#18#165'd.Y'#254#165#132#196'{'#207'\'#163 + +#129#177#134#161#237'U'#180#210'('#169#136#130#16'k-'#215#174#253#197#226#226 + +'"'#133#168#144#251#224#157'G p'#153'CI'#133'R'#10')'#215#8'tw'#152#164#146 + +'`'#140#0#0#0#0'IEND'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tcefpanelcomponent.lrs b/windows/src/ext/cef4delphi/source/res/tcefpanelcomponent.lrs new file mode 100644 index 0000000000000000000000000000000000000000..c35fd55a2ed7fdd4d50f82c3898d2404aefcaf8c --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tcefpanelcomponent.lrs @@ -0,0 +1,22 @@ +LazarusResources.Add('tcefpanelcomponent','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#11#19#0#0#11 + +#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#13'1R'#151'aR'#0#0#1#128'IDATH' + +#199#173#149#191'.DA'#20#198#127#231#156#185#132'H('#196#18'TZ%'#149#135#240 + +#12'Z'#141#202'SP'#240#4#158#129'J'#167'RH4'#18'o@"'#132'D'#178#254#132#189 + +'3G'#177#139'{'#215#18#217#185'S'#206#220#156'o'#190#243#251#230#30#1#216'?8' + +#28#127#237#164#233'2F'#193#201'['#2#193#204#199#10#189#223#218'X'#127#9#0 + +#237#151#215#205#181#149#229#157#209#145'@'#19#2'o'#239'%'#167#231#151#219 + +#192'nW'#160#253#220'Z]^'#226#234#254#9'3'#205#170#31'cbqz'#130#227#147#179 + +#22'@'#0#240#20#197#221#137#201'Q'#241#161'M'#8#16#147#227#238'x'#138#242'%' + +#208'='#2#19'ATQ'#247#175#189#255'/'#199'E'#176#228'Tk'#134#234'''fFP'#25#162 + +#248'wA'#204'j'#187'5'#1'UAD'#178#24'h'#31#194#240'm'#16'L'#133'L'#198'@=' + +#233'?'#28#168#230'9'#232#143'H'#157#129#8#154#217#162'~|u'#129#160#217#2#162 + +#127':'#128#134#13#244#30#218''''#3#209'l'#1#239'I'#248#143#20'9'#152#229#199 + +#212#189#251#146#7#167'H'#26#16#248#188#237'`'#200'V;'#28#146'2'#177#147'~' + +#135#156#253#183#22#136#131'S'#228#168'*'#141#12#4'~iQP!e'#214#239#127'G'#161 + +#130#6#17#193'rsZ'#199#221#21'PU'#138'"'#208'T'#237#162#8'ho4'#6#128#137'Q{' + +#216';8'#186'+'#203'r'#200'YP'#191#185#153#190'w'#218#15#23#128'HknAno'#174 + +''''#129')@'#27#234'O'#9'<'#206#204#206#183#165#130#190#169#230'W!'#248#7#23 + +'^uMW'#166#136#214#0#0#0#0'IEND'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tcefscrollviewcomponent.lrs b/windows/src/ext/cef4delphi/source/res/tcefscrollviewcomponent.lrs new file mode 100644 index 0000000000000000000000000000000000000000..6f1b20f2a03930b215e1261271910bc6a6750292 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tcefscrollviewcomponent.lrs @@ -0,0 +1,34 @@ +LazarusResources.Add('tcefscrollviewcomponent','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#11#19#0#0#11 + +#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#14#4'/'#9#246#178#0#0#2#135'ID' + +'ATH'#199#181#148'Ak'#149'G'#20#134#159'sf'#238#229'ZSj'#23#1#17'Z'#16'q#' + +#182'va'#151']'#21#196#181#136#160#221'tS'#127#129#11#255'@'#215']'#185'T' + +#251#15#10#197#186'i'#161'EP,B'#13#130#136'Q'#131#130'&'#132'D'#19'5'#198'k' + +#190'o'#206#219#197#220#27#147'v'#211#239'V'#15#204'f'#152#225#204#251#188's' + +'^;'#251#253#185'={'#247#237#159#201#201#167'E'#247'r3'#214#214#135'k'#31#238 + +#220'1U"0'#0#131#210#198#210#220#220#189'/8'#249#221#153'C'#215'gf'#245#127 + +#234#135#31'/'#253'k'#239#250#204#172'N'#157'>s'#200#135#175'_'#165#182#4#0 + +#165'D'#167#21'Q'#239'!1l'#196#221#251#143#248#233#231#203#0#172#15'7x3\Oy' + +#140'%'#2#162'+#'#129';$7'#158',-s'#233#151#203#172#174'<#H'#236#218#253')' + +#201#156'l'#21#25'!'#213#23#153'u'#247#193#157#141#226#28#255#230'['#204#140 + +#166'm'#184'}'#231'>'#238'Ffd'#138'$B'#2'u'#149#145#232#245'2'#191'_'#185#129 + +'$4R'#229#230#184#161'<>V'#164#238#136#198'xKp'#248#240'A'#154#166#173#239'5' + +'cqq'#25'a'#182#217' Bl~'#179#255'nA'#189#171'j'#160'"'#144' %'#3#9'I'#21#145 + +#1#17'AL*'#1#200#217#137'pD5'#221#204#16#240'V'#193'$'#248'G*$'#200')'#17')' + +#144'DJ'#142#187#215#198'['#17'uU '#170#169#8'z='''#138'#D'#242#132'['#197 + +#148'1'#192#140'PP'#20#221#21#168'6'#234'y'#162#164'2B'#228#184#179#29#145 + +#162#174'I'#240#128#232#229'L'#219#150#17#162#132'['#237#176'm'#208#138':' + +#254'"'#189#197#148#179#147#147'oQ'#240#15#147#139'D'#196#4'3 '#144'A?%'#154 + +#148#128#177#2#3#180#5#209#232#223'vG$'#146#25'Mi)Q='#16#163'T'#192#200#140 + +#160#132'T'#7#166'#'#162#136#192#220'y0'#247#152#166'-'#155#147#188#186#250#2 + +#219#26#21'Q'#160#148#238#136'J'#136#141#141#150#175#190'<'#176'm'#255#218 + +#205'YJ'#137#237'Q1'#17'"'#192#221'XZY'#227#226#133#243','#204'?'#225#235'#G' + +#249'h'#250#19#204#141'<'#14#148'Pt'#142#235#26#190#194#205'Xo'#10#199'N'#156 + +'baa'#129#131#159'}'#206#181#27'3'#184#25#217#12'z91'#24#12'*'#195#142'i'#247 + +#193#160'O'#191#151'y'#254'jH'#219#22#166'>'#158#230#225#227'yJ'#136#148#220 + +#178'Q'#154'?'#254#188#181#210#182#127'5`'#157#211'T'#18#131'A'#159'_'#127 + +#187#186#153#174'5<'#155#229#167#139#243'/'#13#152#2'v'#1'}'#222'm'#13#129 + +#149#241' '#27#239#167#226'o'#7#159#225'V'#180#27'y'#213#0#0#0#0'IEND'#174'B' + +'`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tcefsentinel.lrs b/windows/src/ext/cef4delphi/source/res/tcefsentinel.lrs new file mode 100644 index 0000000000000000000000000000000000000000..7d5269fd2db69ed99a66eebb9b95e6b62fb6bf0a --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tcefsentinel.lrs @@ -0,0 +1,59 @@ +LazarusResources.Add('tcefsentinel','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#5#6'IDATx^'#181#211'[l\G'#29#128#241'o'#206#236#185#236'9{'#214#235#181 + +#157#198#137#227#144#218#169#9#165'$'#144#134'DEA\[B+E@i'#27'E'#225#5#137'B' + +#218'*'#8#132#130'P'#145#130'J'#11#15#180'@_'#10'<'#18'*5\BRPE'#220#10#25#169 + +#165'PH'#8'%u'#28#223#18'_c'#27';'#190#236#174#247'\g'#224#201'N'#240#241'#?' + +'i'#164'y'#251#230#175#191'F'#140']{'#147',37'#150#136#162#152#186#200#209 + +#209#218'Dei'#145' L'#208#128'm'#230'('#20'\'#174'W'#2#140'0'#192#0#220#188 + +'E'#22#131#255#171#245#3#18'8'#13'h'#224'I'#0#192#7'.'#0'!p'#4#0#216#10#244#3 + +'s'#192#17'2'#228'N'#158#250'#'#25'>'#178#235#238'w}fnz'#28#175#212'~7'#173 + +'M'#31#13#162'xG_'#127#255#206'(H'#140#214'M-'#135#186#182'wNX'#136#206#190 + +#225#193#219'[JR'#14#214#236#199'O'#191#244#234#201'5'#129#201#153#217#204 + +#240'ng+'#229#22#143'B'#222'9X'#171#215#14#166'ZcX'#2#223#206'a:'#242'@'#16 + +#135#7#156#156#162#212'hSjv'#24#156#158#181#1#1#232'['#2'hE'#22'i'#154'4'#183 + +#182'Q'#143#18'f'#230#199#240'\'#155#174';'#218#136#162#4#12#201#244#220#4 + +#142'#'#217#220#182#17#215'31'#196#156#150#134'\'#251#210'4'#213'd'#137'bE' + +#156#24'D'#145'&MM'#22'+`'#153#9'1'#6':'#138#145#134'M=V'#132'I'#136'WtH'#21 + +' '#196#218#128'a'#8#178'('#13#210#148#4#243#26#223#183#169#135#9#181'@'#227 + +'z9ja'#130#151#183'Hu'#130'V'#138'0'#21'$'#177'B(2&H'#20#217'$'#210#243')' + +#182#184'@'#130#231'H'#148'V'#196'IL'#243#198#18#203#181#16#19'I./'#137#132 + +#129#22#8#141'Z'#187#3#149'$d'#232'{'#163#231#31'W'#154'J'#162#203#182#243',' + +'U'#3#194'j'#130#237#26#184'y'#135#197#197':i'#172'h'#185#173'H'#148#212'IR' + +#147#153#235#213#179#128'Z3'#1#217'F'#22#230#166'z6'#149#203']/'#254#228#12 + +#31#188#231'Nv'#237#220'F'#239#229#171#156#237#249#23#135#14#127#18#179#168 + +'8'#249#179'3'#28'<'#184#15#225'5'#167#19#163'S'#167#132#153#177#131'B'#227 + +#218#198#179'O?'#15#240#229#211'/?'#247#232#133#243#19#236#221#191#135'm];' + +#184#220'?'#207#165#139#147'l'#127#186#147#249#217'e'#254'z~'#140#195'G'#238 + +''''#191#161#145#151'~'#241'l/'#192#131#143''#201#177#207'='#206#247#158'8'#193 + +#244#204#20'ab'#162'S'#143'J50X'#229#220#28'1'#186#187#187#249#239#1#144#245 + +#160#178#235#167'?'#127#230#235'gN'#141'`'#231'|'#26#202#22#203'aH'#144#166 + +#188#247'='#219'y'#224#195'['#248#208#251';'#216#183#163'H'#177'a#'#11#11')N' + +#193'B'#24#146#195#199';'#245'k'#231#159'?'#167'Q[Vw'#187'z'#17#19#227#147 + +#214#181#241#190#206#201#201#177'r'#131'P'#220#24']'#166#161#201'e'#254#154 + +'I'#177#0#197'&'#137'%%HA'#177#152#167#185#201'E[PY'#142#137#130'<'#127#235 + +#25#162'V'#127#234'^['#181#31#232'h'#221#247#194'J'#224#232#209#163#0'ttt' + +#202'T'#197#11'-]~m'#239'}'#237#133'2-'#140'_'#139'i,'#22#144#194'ajl'#145 + +#235#163#163'8'#133'"'#245'j'#194#236'\H'#185#165#132'-M'#202'%'#147#246#210 + +#30#230#134#7'x'#234#196#15#2#17#251#198#255'N'#160#187#187#207#197#192#200 + +#190'd'#243';'#31#127#184'}oci'#129#129#161'q'#194'z'#140#176#167#232#235#159 + +#196'h'#220'L'#185#173#149'@'#141'sud'#154#185#217'"'#166'3@'#221'|'#139#7#31 + +#187#139#151'_'#188'1'#248#135'_'#189#241#186#214#168#149#192#208#208#16#0'@' + +#4'\'#181#253#220#191#135'/'#207'Q'#173#245#242#169#7':'#185#227#206#143'Q' + +#240#203#236#222#191#23#183#208#192#185#215#191#195#219#151'fX'#206#247#240 + +#238#174'm'#252#242#183'/p'#229'R/'#239#251'@'#23#165#13#254',Z'#140#130#142 + +#178#254#129#2#194#137#193#197#191#136#208#191#223'kh'#162#191#247'5q'#225 + +#205'n]r'#247'/'#162','#25'%'#149#220#149#193#223#231#227#154#162':t'#145#225 + +'K'#223'"'#172'('#220'd'#19'c'#23#151#169#4'I'#5#168#176#138#255#0#174#140#28 + +'#'#173#140#155#148#0#0#0#0'IEND'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tceftextfieldcomponent.lrs b/windows/src/ext/cef4delphi/source/res/tceftextfieldcomponent.lrs new file mode 100644 index 0000000000000000000000000000000000000000..53742018b7e6512d206ead19848e6fdff89099c9 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tceftextfieldcomponent.lrs @@ -0,0 +1,27 @@ +LazarusResources.Add('tceftextfieldcomponent','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#11#19#0#0#11 + +#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#14#19#172#218'su'#0#0#1#248'ID' + +'ATH'#199#213#150'1o'#211'P'#20#133#191#251#252#226#16'Z'#181'M CQ'#165'vJ~' + +#1#12', '#22#22'`'#129#165#191' '#127#129#10#137#13'!'#196#128'D'#197#144'-' + +#12'H,H'#8#169#3#19'bA'#192#208'!C'#165'X'#136#165'-S'#221#8#136#161#196#207 + +#190#12'i'#147'4'#237#208'4^'#250'&'#235#13#231#220's'#238#241#177#225#172#31 + +'i4'#26#11#197'b'#241'k'#183#219#237'f'#9#236#251#190#223'n'#183#175#216'f' + +#179'Y'#170#213'j'#243#149'J%'#211#201#131' '#160'^'#175#151'l'#20'EVU'#217 + +#220#218#198'9'#151#9#184#181#22'U%'#138'"k'#135'/'#141'1'#168'N'#232#185#128 + +'1f@v'#240#224#25#131#239#9'"2'#17#129'j'#138#211#17#2'U'#165'8'#229's'#255 + +#221#6'q'#146'"BO'#137#142#15'>S'#154#227#225#181#5#218#187'#'#10'r'#231'|' + +#234#159#183#248#241#244#30#127#156#162#10#255#246#246#24'G'#208'y+'#220'~' + +#187#201'#k'#250#211#245#20#0'xB'#222'z'#172#127'X'#227#217#139':'#139#139'K' + +#172#172'<'#224'w'#167'sb'#130'K'#243#23#240's'#30'xrt'#7#224#145'&'#9#215'o' + +#222#226#229#235'7<_]e'''#220#165#148'/'#158#204')'#133'\'#161'@'#154'*'#136 + +'w<'#193'A'#132#146'$'#1'`vn'#150#177'bem'#143#201#152#254'P'#150#190'GB'#223 + +'pU:'#157#14#211#211#211#167#136#17#224#13'Rd'#6#183#130#160#236'|'#223'`' + +#249#238#29'>'#190'_;'#221'K'#230#201#0#246#176'E'#208#206#151'X^'#159#194'%' + +#151'QR'#30#191#250'6'#22'x'#206#19#190'l'#255#236#17#168#30'&H]'#140'>'#185 + +#1#164#19#22#197#18#137'K'#143'*H'#197#144#196#217't'#145#152'cRd'#196#144'J' + +'6Mjdh'#7'"'#189#254'1F0C'#204#19#171#216#199#181'q'#28'''a'#24#18#4#1':i' + +#149#14#129#135'aH'#28#199#137#148#203#229#139#213'j'#245#170'sn&'#203#15#142 + +#181#246'W'#171#213#250'$'#251'{('#140'F6'#131#227#128#191'g'#254#167#130#255 + +#186#155#181#212#227'?'#176#215#0#0#0#0'IEND'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tcefurlrequestclientcomponent.lrs b/windows/src/ext/cef4delphi/source/res/tcefurlrequestclientcomponent.lrs new file mode 100644 index 0000000000000000000000000000000000000000..b7987f515000321ccabf53ecbe60e41c25434547 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tcefurlrequestclientcomponent.lrs @@ -0,0 +1,23 @@ +LazarusResources.Add('tcefurlrequestclientcomponent','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#4'gAMA'#0#0#175#200'7'#5#138#233#0#0#0#25'tEXtSoftware'#0'Adobe ImageRe' + +'adyq'#201'e<'#0#0#1#175'IDATx'#218#180'U'#205'N'#2'1'#16'n'#187' '#8'B '#225 + +#180'g'#19'"O'#192'E^'#193'g'#128#196';'#9#241#188#252'\5'#225#238#129#248#8 + +#190#2'^9'#227#205#163'W'#19'b@'#20'Zg'#150'))'#13#203'.'#132'6'#249'R'#152 + +'N'#191#175'3'#237#204'r'#165#20's9'#4's<'#156#11#164'l'#195'h'#244'f'#155 + +#186#128' b'#127#143#214#183#163#217#188'M'#22'A'#173#230#135'@'#242'j'#213 + +'g'#190'_f'#249'|'#134#21#10'YV*'#229'X'#165'r'#21#174#25'~'#167#167#136'sr' + +#22#28'~'#243#240'?'#215#198'cS'#180'_'#128'3'#207'C'#136#144'\'#8#225'B@' + +#176'TJP'#4#27#193#179#9'`j6'#2#222'6='#24#133'c'#1#7#17#164#211'b'#155#178 + +#179#222#129#25#129'i;U lN'#211#233#231#206'%k'#17#251#233#130#159#221#204'x' + +#156#0'Vg'#208'h'#220#176#249'|'#9#248'a'#139#197'r'#239#169'u'#129#229'rY6' + +#153'|'#232#189#177#133#134#165#223#27#143#223'ac&'#220'|hX'#228#221#164#149 + +#156'H$'#142'<'#174#23#29#20'1'#201#201#247#248'^'#20'%'#146#148'|G`'#223#219 + +#174#215#175'y'#171#213#232')%'#251#166#8#146#163#13#214#250#232#131#136'l3' + +#250#147#201'7'#236#130'^V'#154'f'#143'lb8|}('#22#203#29#244#157#205#190#158 + +#218#237#187'Gz'#210#146#176#6#172#0#127'4K'#224'V'#166#0#18']'#0#176#209#23 + +#0'Y'#18#242#180#208'`'#240'r/'#165#228'A'#208'|6'#200#215#4'$^'#0#190#9#191 + +#192'-m'#1'<'#245'%'#166#25#144'1'#162#208#145'p'#171' M'#1'<5'#22#204#156 + +#132'V'#182#128#174'Ba'#128#27'3'#143#168'z-'#164'HH'#233#244#236#220#129#171 + +#241'/'#192#0'w'#144#160'*'#176#132'a'#207#0#0#0#0'IEND'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/res/tcefwindowcomponent.lrs b/windows/src/ext/cef4delphi/source/res/tcefwindowcomponent.lrs new file mode 100644 index 0000000000000000000000000000000000000000..1b8510b36e21025d533ff4ce635cb760735bd4fd --- /dev/null +++ b/windows/src/ext/cef4delphi/source/res/tcefwindowcomponent.lrs @@ -0,0 +1,22 @@ +LazarusResources.Add('tcefwindowcomponent','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#11#19#0#0#11 + +#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#14'!d'#13'"'#245#0#0#1'}IDATH' + +#199#237#148#189'N[A'#16#133#191#217#157#189#246#181#177#242#135#4#18#138#168 + +#226#146'2]"'#165#8'R'#202'('#188#2'o'#144#151#8#13'-'#18#21#15#128'h'#163 + +#164' u'#164'TtN'#149'"'#2'E'#209#5'$'#192#216#185#187'CqcL'#137#228'u'#199 + +'<'#192#249#230#156'3'#26#152#243#200#202#199#189#238'e'#249't'#243#170#142 + +#143'-'#129#204'(h'#128'8'#232#168'?'#235#14#171']'#173'N~?'#127#187#190#182 + +#253#230#197'2"y'#182'6'#131#195#159'''|'#253'r'#244'Y'#199#213'qg'#169'W' + +#176#243#163#226'|T#6'#163#184#192#163#150#242'z'#165'`\'#29'w4'#166#132#23 + +'G'#127#177#228'b\g'#137'h'#161'P'#188#12#137')'#161'DxV:>'#189'['#165'N'#150 + +'%"u'#194#214#183#1'DP'#12'T='#127'~'#13#24#142#254#205#220#131#25#148#173 + +#128#170#7#3#5#3'3'#202#178#196'i'#145#197'A+x'#176#17'`'#232'$'#185#160'J' + +#196#253'Oq'#166#203''''#168#3#174#155#184'&'#197#4#13'$IY'#28#4#239'n'#215 + +'T'#172'!'#132'BIu&'#128':&'#186#141#3'3'#130#22'$b&'#128#199#204#166#17#1'h' + +'P'#162#184',W'#164#234#166''';'#233#192#135'@'#145#169#3#175'w;'#152#190#168 + +#230'v'#179'M'#131'p'#243'~'#215#15#128#251#1'd'#14#194'r'#11#240'N'#218#193 + +'g'#7#180#131#7#239'Dz'#175'6'#250#241#229#135#131#171#218'-'#146#242#229#210 + +#209#244#215#127#223#127'/@'#9'<'#1#218#153'M\'#3#167'2'#231#178#211#13'''Au' + +#232#241#15''#246#236'sS_~'#245#237#220#197'3'#31'_Y'#178#7#20'"z~xvfb' + +#249#129#7#28#218#142#179#244#231#253'L'#225'p'#31#144#136#168#168#180'X'#193 + +'@l'#242#217#209#247'N'#191#242#203#239#27#141#166#214':'#208#186#215'r{'#183 + +'~'#171#167#146#9'f'#16#129'-P'#153'w)'#141'X'#136#152#133#166'&'''#218#186 + +'Wk{'#134#24#17'Z:'#232#6#6#128#1#0#1#12#131'!V'#24'+'#173#159'Q$'#20#132#20 + +#24#177'mY'#217#8'_'#155#28'Zu'#189#7']'#31#1#12'K'#169#144#209#1'#'#2#3#244 + +#136'@'#152#5#250#211'cE*}F'''#166#167#23#238'-'#140#28'9d)u'#227#158#251#217 + +#135'/|sgMD'#222'x~'#196'0'#136#0' 4'#154#237'\6K'#180#209#135#205#204#219#25 + +#189'<'#214#233't}'#207'7'#134#184#222#9#175#222'i'#13#13#165#237#212#224#210 + +#154'oH'#16' 4'#208#236#132#25#232'lc'#180'} '#135#147#193'K'''#166'W'#170'u' + +#207#15'{'#129#17#162#229#170'n'#235#224#216'S'#131'!'#177#14#229#143#149'Zv' + +'|'#212#134'`'#247#129#140'o'#201'['#185#134#147'(}'#247#227#175#169''''#236 + +'t'#250'`h'#248#228#241#225#182'G'#213'zk'#221#13#158#206#231'rV3'#190'T'#15 + +#187#22'g'#20#217#169#145'F'#241#205#137#185'j'#166'2'#255#211#147#233#129 + +#191'V'#209#13'h'#234'h'#225#228#145#214#1#171#190'5v'#171#208#206#189#29#182 + +'{3'#249#234'L>'#23#243'U'#1'`G '#254#5'Ixq'#26'FW'#221'b'#0#0#0#0'IEN' + +'D'#174'B`'#130 +]); diff --git a/windows/src/ext/cef4delphi/source/uBufferPanel.pas b/windows/src/ext/cef4delphi/source/uBufferPanel.pas deleted file mode 100644 index fd6457d4c348deb57b408acbf119b8f2d80849d6..0000000000000000000000000000000000000000 --- a/windows/src/ext/cef4delphi/source/uBufferPanel.pas +++ /dev/null @@ -1,427 +0,0 @@ -// ************************************************************************ -// ***************************** CEF4Delphi ******************************* -// ************************************************************************ -// -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based -// browser in Delphi applications. -// -// The original license of DCEF3 still applies to CEF4Delphi. -// -// For more information about CEF4Delphi visit : -// https://www.briskbard.com/index.php?lang=en&pageid=cef -// -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. -// -// ************************************************************************ -// ************ vvvv Original license and comments below vvvv ************* -// ************************************************************************ -(* - * Delphi Chromium Embedded 3 - * - * Usage allowed under the restrictions of the Lesser GNU General Public License - * or alternatively the restrictions of the Mozilla Public License 1.1 - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for - * the specific language governing rights and limitations under the License. - * - * Unit owner : Henri Gourvest - * Web site : http://www.progdigy.com - * Repository : http://code.google.com/p/delphichromiumembedded/ - * Group : http://groups.google.com/group/delphichromiumembedded - * - * Embarcadero Technologies, Inc is not permitted to use or redistribute - * this source code without explicit permission. - * - *) - -unit uBufferPanel; - -{$IFDEF FPC} - {$MODE OBJFPC}{$H+} -{$ENDIF} - -{$I cef.inc} - -interface - -uses - {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}Winapi.Windows, Winapi.Messages, Vcl.ExtCtrls, Vcl.Controls, Vcl.Graphics,{$ENDIF} - System.Classes, System.SyncObjs, System.SysUtils, - {$ELSE} - {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics, - {$IFDEF FPC} - LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, - {$ELSE} - Messages, - {$ENDIF} - ExtCtrls, SyncObjs, SysUtils, - {$ENDIF} - uCEFConstants; - -type - TBufferPanel = class(TCustomPanel) - protected - FMutex : THandle; - FBuffer : TBitmap; - FScanlineSize : integer; - - procedure CreateSyncObj; - - procedure DestroySyncObj; - procedure DestroyBuffer; - - function GetBufferBits : pointer; - function GetBufferWidth : integer; - function GetBufferHeight : integer; - - function CopyBuffer : boolean; - function SaveBufferToFile(const aFilename : string) : boolean; - - procedure Paint; override; - - procedure WMEraseBkgnd(var aMessage : TWMEraseBkgnd); message WM_ERASEBKGND; - - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure AfterConstruction; override; - function SaveToFile(const aFilename : string) : boolean; - function InvalidatePanel : boolean; - function BeginBufferDraw : boolean; - procedure EndBufferDraw; - procedure BufferDraw(x, y : integer; const aBitmap : TBitmap); - function UpdateBufferDimensions(aWidth, aHeight : integer) : boolean; - function BufferIsResized(aUseMutex : boolean = True) : boolean; - - property Buffer : TBitmap read FBuffer; - property ScanlineSize : integer read FScanlineSize; - property BufferWidth : integer read GetBufferWidth; - property BufferHeight : integer read GetBufferHeight; - property BufferBits : pointer read GetBufferBits; - - property DockManager; - - published - property Align; - property Alignment; - property Anchors; - property AutoSize; - {$IFDEF FPC} - property OnUTF8KeyPress; - {$ELSE} - property BevelEdges; - property BevelKind; - property Ctl3D; - property Locked; - property ParentBackground; - property ParentCtl3D; - property OnCanResize; - {$ENDIF} - property BevelInner; - property BevelOuter; - property BevelWidth; - property BiDiMode; - property BorderWidth; - property BorderStyle; - property Caption; - property Color; - property Constraints; - property UseDockManager default True; - property DockSite; - property DoubleBuffered; - property DragCursor; - property DragKind; - property DragMode; - property Enabled; - property FullRepaint; - property Font; - property ParentBiDiMode; - property ParentColor; - property ParentFont; - property ParentShowHint; - property PopupMenu; - property ShowHint; - property TabOrder; - property TabStop; - property Visible; - property OnClick; - property OnConstrainedResize; - property OnContextPopup; - property OnDockDrop; - property OnDockOver; - property OnDblClick; - property OnDragDrop; - property OnDragOver; - property OnEndDock; - property OnEndDrag; - property OnEnter; - property OnExit; - property OnGetSiteInfo; - property OnMouseDown; - property OnMouseMove; - property OnMouseUp; - property OnMouseWheel; - property OnKeyDown; - property OnKeyPress; - property OnKeyUp; - property OnResize; - property OnStartDock; - property OnStartDrag; - property OnUnDock; - {$IFDEF DELPHI9_UP} - property VerticalAlignment; - property OnAlignInsertBefore; - property OnAlignPosition; - {$ENDIF} - {$IFDEF DELPHI10_UP} - property Padding; - property OnMouseActivate; - property OnMouseEnter; - property OnMouseLeave; - {$ENDIF} - {$IFDEF DELPHI12_UP} - property ShowCaption; - property ParentDoubleBuffered; - {$ENDIF} - {$IFDEF DELPHI14_UP} - property Touch; - property OnGesture; - {$ENDIF} - {$IFDEF DELPHI17_UP} - property StyleElements; - {$ENDIF} - end; - -{$IFDEF FPC} -procedure Register; -{$ENDIF} - -implementation - -uses - uCEFMiscFunctions, uCEFApplication; - -constructor TBufferPanel.Create(AOwner: TComponent); -begin - inherited Create(AOwner); - - FMutex := 0; - FBuffer := nil; -end; - -destructor TBufferPanel.Destroy; -begin - DestroyBuffer; - DestroySyncObj; - - inherited Destroy; -end; - -procedure TBufferPanel.AfterConstruction; -begin - inherited AfterConstruction; - - CreateSyncObj; -end; - -procedure TBufferPanel.CreateSyncObj; -begin - FMutex := CreateMutex(nil, False, nil); -end; - -procedure TBufferPanel.DestroySyncObj; -begin - if (FMutex <> 0) then - begin - CloseHandle(FMutex); - FMutex := 0; - end; -end; - -procedure TBufferPanel.DestroyBuffer; -begin - if BeginBufferDraw then - begin - if (FBuffer <> nil) then FreeAndNil(FBuffer); - EndBufferDraw; - end; -end; - -function TBufferPanel.SaveBufferToFile(const aFilename : string) : boolean; -begin - Result := False; - - try - if (FBuffer <> nil) then - begin - FBuffer.SaveToFile(aFilename); - Result := True; - end; - except - on e : exception do - if CustomExceptionHandler('TBufferPanel.SaveBufferToFile', e) then raise; - end; -end; - -function TBufferPanel.SaveToFile(const aFilename : string) : boolean; -begin - Result := False; - - if BeginBufferDraw then - begin - Result := SaveBufferToFile(aFilename); - EndBufferDraw; - end; -end; - -function TBufferPanel.InvalidatePanel : boolean; -begin - Result := HandleAllocated and PostMessage(Handle, CM_INVALIDATE, 0, 0); -end; - -function TBufferPanel.BeginBufferDraw : boolean; -begin - Result := (FMutex <> 0) and (WaitForSingleObject(FMutex, 5000) = WAIT_OBJECT_0); -end; - -procedure TBufferPanel.EndBufferDraw; -begin - if (FMutex <> 0) then ReleaseMutex(FMutex); -end; - -function TBufferPanel.CopyBuffer : boolean; -begin - Result := False; - - if BeginBufferDraw then - begin - Result := (FBuffer <> nil) and - BitBlt(Canvas.Handle, 0, 0, Width, Height, - FBuffer.Canvas.Handle, 0, 0, - SrcCopy); - - EndBufferDraw; - end; -end; - -procedure TBufferPanel.Paint; -begin - if csDesigning in ComponentState then - begin - Canvas.Font.Assign(Font); - Canvas.Brush.Color := Color; - Canvas.Brush.Style := bsSolid; - Canvas.Pen.Style := psDash; - - Canvas.Rectangle(0, 0, Width, Height); - end - else - if not(CopyBuffer) then - begin - Canvas.Brush.Color := Color; - Canvas.Brush.Style := bsSolid; - Canvas.FillRect(rect(0, 0, Width, Height)); - end; -end; - -procedure TBufferPanel.WMEraseBkgnd(var aMessage : TWMEraseBkgnd); -begin - aMessage.Result := 1; -end; - -function TBufferPanel.GetBufferBits : pointer; -begin - if (FBuffer <> nil) then - Result := FBuffer.Scanline[pred(FBuffer.Height)] - else - Result := nil; -end; - -function TBufferPanel.GetBufferWidth : integer; -begin - if (FBuffer <> nil) then - Result := FBuffer.Width - else - Result := 0; -end; - -function TBufferPanel.GetBufferHeight : integer; -begin - if (FBuffer <> nil) then - Result := FBuffer.Height - else - Result := 0; -end; - -procedure TBufferPanel.BufferDraw(x, y : integer; const aBitmap : TBitmap); -begin - if (FBuffer <> nil) then FBuffer.Canvas.Draw(x, y, aBitmap); -end; - -function TBufferPanel.UpdateBufferDimensions(aWidth, aHeight : integer) : boolean; -begin - Result := False; - - if ((FBuffer = nil) or - (FBuffer.Width <> aWidth) or - (FBuffer.Height <> aHeight)) then - begin - if (FBuffer <> nil) then FreeAndNil(FBuffer); - - FBuffer := TBitmap.Create; - FBuffer.PixelFormat := pf32bit; - FBuffer.HandleType := bmDIB; - FBuffer.Width := aWidth; - FBuffer.Height := aHeight; - FScanlineSize := FBuffer.Width * SizeOf(TRGBQuad); - Result := True; - end; -end; - -function TBufferPanel.BufferIsResized(aUseMutex : boolean) : boolean; -var - TempDevWidth, TempLogWidth, TempDevHeight, TempLogHeight : integer; -begin - Result := False; - if (GlobalCEFApp = nil) then exit; - - if not(aUseMutex) or BeginBufferDraw then - begin - if (GlobalCEFApp.DeviceScaleFactor = 1) then - begin - Result := (FBuffer <> nil) and - (FBuffer.Width = Width) and - (FBuffer.Height = Height); - end - else - begin - // CEF and Chromium use 'floor' to round the float values in Device <-> Logical unit conversions - // and Delphi uses MulDiv, which uses the bankers rounding, to resize the components in high DPI mode. - // This is the cause of slight differences in size between the buffer and the panel in some occasions. - - TempLogWidth := DeviceToLogical(Width, GlobalCEFApp.DeviceScaleFactor); - TempLogHeight := DeviceToLogical(Height, GlobalCEFApp.DeviceScaleFactor); - - TempDevWidth := LogicalToDevice(TempLogWidth, GlobalCEFApp.DeviceScaleFactor); - TempDevHeight := LogicalToDevice(TempLogHeight, GlobalCEFApp.DeviceScaleFactor); - - Result := (FBuffer <> nil) and - (FBuffer.Width = TempDevWidth) and - (FBuffer.Height = TempDevHeight); - end; - - if aUseMutex then EndBufferDraw; - end; -end; - -{$IFDEF FPC} -procedure Register; -begin - {$I res/tbufferpanel.lrs} - RegisterComponents('Chromium', [TBufferPanel]); -end; -{$ENDIF} - -end. diff --git a/windows/src/ext/cef4delphi/source/uCEFAccessibilityHandler.pas b/windows/src/ext/cef4delphi/source/uCEFAccessibilityHandler.pas index 834558c0b5c69866c1c6604d4863e541192050d4..98a73c4e82922f603d2baf4f03f495dfef4bebd3 100644 --- a/windows/src/ext/cef4delphi/source/uCEFAccessibilityHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFAccessibilityHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFAccessibilityHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFApp.pas b/windows/src/ext/cef4delphi/source/uCEFApp.pas index 4b5de26ce7f13b11d1e8df716c29893eb52090d5..5983dac19304a156e4b6d6087839e1d32dd6b445 100644 --- a/windows/src/ext/cef4delphi/source/uCEFApp.pas +++ b/windows/src/ext/cef4delphi/source/uCEFApp.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFApp; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,7 +54,7 @@ uses {$ELSE} Classes, {$ENDIF} - uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar, uCEFApplication; + uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar, uCEFApplicationCore; type TCefAppOwn = class(TCefBaseRefCountedOwn, ICefApp) @@ -67,13 +65,15 @@ type procedure GetBrowserProcessHandler(var aHandler : ICefBrowserProcessHandler); virtual; abstract; procedure GetRenderProcessHandler(var aHandler : ICefRenderProcessHandler); virtual; abstract; + procedure RemoveReferences; virtual; abstract; + public constructor Create; virtual; end; TCustomCefApp = class(TCefAppOwn) protected - FCefApp : TCefApplication; + FCefApp : TCefApplicationCore; FResourceBundleHandler : ICefResourceBundleHandler; FBrowserProcessHandler : ICefBrowserProcessHandler; FRenderProcessHandler : ICefRenderProcessHandler; @@ -85,10 +85,11 @@ type procedure GetRenderProcessHandler(var aHandler : ICefRenderProcessHandler); override; procedure InitializeVars; + procedure RemoveReferences; override; public - constructor Create(const aCefApp : TCefApplication); reintroduce; - procedure BeforeDestruction; override; + constructor Create(const aCefApp : TCefApplicationCore); reintroduce; + destructor Destroy; override; end; @@ -100,15 +101,15 @@ uses {$ELSE} SysUtils, {$ENDIF} - uCEFLibFunctions, uCEFMiscFunctions, uCEFCommandLine, uCEFConstants, + uCEFMiscFunctions, uCEFCommandLine, uCEFConstants, uCEFBrowserProcessHandler, uCEFResourceBundleHandler, uCEFRenderProcessHandler; // TCefAppOwn -procedure cef_app_on_before_command_line_processing(self: PCefApp; - const process_type: PCefString; - command_line: PCefCommandLine); stdcall; +procedure cef_app_on_before_command_line_processing( self : PCefApp; + const process_type : PCefString; + command_line : PCefCommandLine); stdcall; var TempObject : TObject; begin @@ -119,7 +120,8 @@ begin TCefCommandLineRef.UnWrap(command_line)); end; -procedure cef_app_on_register_custom_schemes(self: PCefApp; registrar: PCefSchemeRegistrar); stdcall; +procedure cef_app_on_register_custom_schemes(self : PCefApp; + registrar : PCefSchemeRegistrar); stdcall; var TempWrapper : TCefSchemeRegistrarRef; TempObject : TObject; @@ -214,14 +216,14 @@ end; // TCustomCefApp -constructor TCustomCefApp.Create(const aCefApp : TCefApplication); +constructor TCustomCefApp.Create(const aCefApp : TCefApplicationCore); begin inherited Create; - FCefApp := aCefApp; - InitializeVars; + FCefApp := aCefApp; + if (FCefApp <> nil) then begin if FCefApp.MustCreateBrowserProcessHandler then @@ -235,22 +237,35 @@ begin end; end; -procedure TCustomCefApp.BeforeDestruction; +destructor TCustomCefApp.Destroy; begin - FCefApp := nil; - - InitializeVars; + RemoveReferences; - inherited BeforeDestruction; + inherited Destroy; end; procedure TCustomCefApp.InitializeVars; begin + FCefApp := nil; FResourceBundleHandler := nil; FBrowserProcessHandler := nil; FRenderProcessHandler := nil; end; +procedure TCustomCefApp.RemoveReferences; +begin + if (FResourceBundleHandler <> nil) then + FResourceBundleHandler.RemoveReferences; + + if (FBrowserProcessHandler <> nil) then + FBrowserProcessHandler.RemoveReferences; + + if (FRenderProcessHandler <> nil) then + FRenderProcessHandler.RemoveReferences; + + InitializeVars; +end; + procedure TCustomCefApp.OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine); begin try diff --git a/windows/src/ext/cef4delphi/source/uCEFApplication.pas b/windows/src/ext/cef4delphi/source/uCEFApplication.pas index aa2da54c1c8a5eb1f522ab7b57acf06ecf1b0350..d2784de0cee49b46f22e21c3d12fed9fc79e6b50 100644 --- a/windows/src/ext/cef4delphi/source/uCEFApplication.pas +++ b/windows/src/ext/cef4delphi/source/uCEFApplication.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFApplication; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -52,369 +50,152 @@ interface uses {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, System.UITypes, + {$IFDEF MSWINDOWS} + WinApi.Windows, WinApi.ActiveX, + {$IFDEF FMX} + FMX.Forms, + {$ELSE} + Vcl.Forms, + {$ENDIF} + {$ENDIF} + System.Classes, System.UITypes, {$ELSE} - {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, {$IFDEF FPC}dynlibs,{$ENDIF} + Forms, + {$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} Classes, Controls, {$IFDEF FPC}dynlibs,{$ENDIF} {$ENDIF} - uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar; + {$IFDEF FPC} + LCLProc, + {$ENDIF} + uCEFApplicationCore, uCEFTypes; const - CEF_SUPPORTED_VERSION_MAJOR = 3; - CEF_SUPPORTED_VERSION_MINOR = 3396; - CEF_SUPPORTED_VERSION_RELEASE = 1782; - CEF_SUPPORTED_VERSION_BUILD = 0; + CEF_SUPPORTED_VERSION_MAJOR = uCefApplicationCore.CEF_SUPPORTED_VERSION_MAJOR; + CEF_SUPPORTED_VERSION_MINOR = uCefApplicationCore.CEF_SUPPORTED_VERSION_MINOR; + CEF_SUPPORTED_VERSION_RELEASE = uCefApplicationCore.CEF_SUPPORTED_VERSION_RELEASE; + CEF_SUPPORTED_VERSION_BUILD = uCefApplicationCore.CEF_SUPPORTED_VERSION_BUILD; - CEF_CHROMEELF_VERSION_MAJOR = 67; - CEF_CHROMEELF_VERSION_MINOR = 0; - CEF_CHROMEELF_VERSION_RELEASE = 3396; - CEF_CHROMEELF_VERSION_BUILD = 79; + CEF_CHROMEELF_VERSION_MAJOR = uCefApplicationCore.CEF_CHROMEELF_VERSION_MAJOR; + CEF_CHROMEELF_VERSION_MINOR = uCefApplicationCore.CEF_CHROMEELF_VERSION_MINOR; + CEF_CHROMEELF_VERSION_RELEASE = uCefApplicationCore.CEF_CHROMEELF_VERSION_RELEASE; + CEF_CHROMEELF_VERSION_BUILD = uCefApplicationCore.CEF_CHROMEELF_VERSION_BUILD; - LIBCEF_DLL = 'libcef.dll'; - CHROMEELF_DLL = 'chrome_elf.dll'; + LIBCEF_DLL = uCefApplicationCore.LIBCEF_DLL; + CHROMEELF_DLL = uCefApplicationCore.CHROMEELF_DLL; type - TCefApplication = class + TCefApplication = class(TCefApplicationCore) protected - FCache : ustring; - FCookies : ustring; - FUserDataPath : ustring; - FUserAgent : ustring; - FProductVersion : ustring; - FLocale : ustring; - FLocalesRequired : ustring; - FLogFile : ustring; - FBrowserSubprocessPath : ustring; - FCustomFlashPath : ustring; - FFrameworkDirPath : ustring; - FLogSeverity : TCefLogSeverity; - FJavaScriptFlags : ustring; - FResourcesDirPath : ustring; - FLocalesDirPath : ustring; - FSingleProcess : Boolean; - FNoSandbox : Boolean; - FCommandLineArgsDisabled : Boolean; - FPackLoadingDisabled : Boolean; - FRemoteDebuggingPort : Integer; - FUncaughtExceptionStackSize : Integer; - FPersistSessionCookies : Boolean; - FPersistUserPreferences : boolean; - FIgnoreCertificateErrors : Boolean; - FEnableNetSecurityExpiration : boolean; - FBackgroundColor : TCefColor; - FAcceptLanguageList : ustring; - FWindowsSandboxInfo : Pointer; - FWindowlessRenderingEnabled : Boolean; - FMultiThreadedMessageLoop : boolean; - FExternalMessagePump : boolean; - FDeleteCache : boolean; - FDeleteCookies : boolean; - FCustomCommandLines : TStringList; - FCustomCommandLineValues : TStringList; - FFlashEnabled : boolean; - FEnableMediaStream : boolean; - FEnableSpeechInput : boolean; - FEnableGPU : boolean; - FCheckCEFFiles : boolean; - FLibLoaded : boolean; - FSmoothScrolling : TCefState; - FFastUnload : boolean; - FDisableSafeBrowsing : boolean; - FEnableHighDPISupport : boolean; - FMuteAudio : boolean; - FReRaiseExceptions : boolean; - FShowMessageDlg : boolean; - FSetCurrentDir : boolean; - FGlobalContextInitialized : boolean; - FSitePerProcess : boolean; - FDisableWebSecurity : boolean; - FDisablePDFExtension : boolean; - FChromeVersionInfo : TFileVersionInfo; + FDestroyApplicationObject : boolean; + FDestroyAppWindows : boolean; {$IFDEF FPC} - FLibHandle : TLibHandle; - {$ELSE} - FLibHandle : THandle; - {$ENDIF} - FOnRegisterCustomSchemes : TOnRegisterCustomSchemesEvent; - FAppSettings : TCefSettings; - FDeviceScaleFactor : single; - FCheckDevToolsResources : boolean; - FDisableGPUCache : boolean; - FStatus : TCefAplicationStatus; - FMissingLibFiles : string; - FProcessType : TCefProcessType; - FShutdownWaitTime : cardinal; - FWidevinePath : ustring; - FMustFreeLibrary : boolean; - - FMustCreateResourceBundleHandler : boolean; - FMustCreateBrowserProcessHandler : boolean; - FMustCreateRenderProcessHandler : boolean; + FContextInitializedHandlers: TMethodList; + FContextInitializedDone: Boolean; - // ICefBrowserProcessHandler - FOnContextInitialized : TOnContextInitializedEvent; - FOnBeforeChildProcessLaunch : TOnBeforeChildProcessLaunchEvent; - FOnRenderProcessThreadCreated : TOnRenderProcessThreadCreatedEvent; - FOnScheduleMessagePumpWork : TOnScheduleMessagePumpWorkEvent; - - // ICefResourceBundleHandler - FOnGetLocalizedString : TOnGetLocalizedStringEvent; - FOnGetDataResource : TOnGetDataResourceEvent; - FOnGetDataResourceForScale : TOnGetDataResourceForScaleEvent; - - // ICefRenderProcessHandler - FOnRenderThreadCreated : TOnRenderThreadCreatedEvent; - FOnWebKitInitialized : TOnWebKitInitializedEvent; - FOnBrowserCreated : TOnBrowserCreatedEvent; - FOnBrowserDestroyed : TOnBrowserDestroyedEvent; - FOnContextCreated : TOnContextCreatedEvent; - FOnContextReleased : TOnContextReleasedEvent; - FOnUncaughtException : TOnUncaughtExceptionEvent; - FOnFocusedNodeChanged : TOnFocusedNodeChangedEvent; - FOnProcessMessageReceived : TOnProcessMessageReceivedEvent; - - // ICefRegisterCDMCallback - FOnCDMRegistrationComplete : TOnCDMRegistrationCompleteEvent; - - procedure SetCache(const aValue : ustring); - procedure SetCookies(const aValue : ustring); - procedure SetUserDataPath(const aValue : ustring); - procedure SetBrowserSubprocessPath(const aValue : ustring); - procedure SetFrameworkDirPath(const aValue : ustring); - procedure SetResourcesDirPath(const aValue : ustring); - procedure SetLocalesDirPath(const aValue : ustring); - procedure SetOsmodalLoop(aValue : boolean); - - function GetChromeVersion : string; - function GetLibCefPath : string; - function GetChromeElfPath : string; - function GetMustCreateResourceBundleHandler : boolean; - function GetMustCreateBrowserProcessHandler : boolean; - function GetMustCreateRenderProcessHandler : boolean; - function GetGlobalContextInitialized : boolean; - function GetChildProcessesCount : integer; - - function LoadCEFlibrary : boolean; virtual; - function Load_cef_app_capi_h : boolean; - function Load_cef_browser_capi_h : boolean; - function Load_cef_command_line_capi_h : boolean; - function Load_cef_cookie_capi_h : boolean; - function Load_cef_crash_util_h : boolean; - function Load_cef_drag_data_capi_h : boolean; - function Load_cef_file_util_capi_h : boolean; - function Load_cef_image_capi_h : boolean; - function Load_cef_menu_model_capi_h : boolean; - function Load_cef_origin_whitelist_capi_h : boolean; - function Load_cef_parser_capi_h : boolean; - function Load_cef_path_util_capi_h : boolean; - function Load_cef_print_settings_capi_h : boolean; - function Load_cef_process_message_capi_h : boolean; - function Load_cef_process_util_capi_h : boolean; - function Load_cef_request_capi_h : boolean; - function Load_cef_request_context_capi_h : boolean; - function Load_cef_resource_bundle_capi_h : boolean; - function Load_cef_response_capi_h : boolean; - function Load_cef_server_capi_h : boolean; - function Load_cef_scheme_capi_h : boolean; - function Load_cef_ssl_info_capi_h : boolean; - function Load_cef_stream_capi_h : boolean; - function Load_cef_task_capi_h : boolean; - function Load_cef_thread_capi_h : boolean; - function Load_cef_trace_capi_h : boolean; - function Load_cef_urlrequest_capi_h : boolean; - function Load_cef_v8_capi_h : boolean; - function Load_cef_values_capi_h : boolean; - function Load_cef_waitable_event_capi_h : boolean; - function Load_cef_web_plugin_capi_h : boolean; - function Load_cef_xml_reader_capi_h : boolean; - function Load_cef_zip_reader_capi_h : boolean; - function Load_cef_logging_internal_h : boolean; - function Load_cef_string_list_h : boolean; - function Load_cef_string_map_h : boolean; - function Load_cef_string_multimap_h : boolean; - function Load_cef_string_types_h : boolean; - function Load_cef_thread_internal_h : boolean; - function Load_cef_trace_event_internal_h : boolean; - function Load_cef_browser_view_capi_h : boolean; - function Load_cef_display_capi_h : boolean; - function Load_cef_label_button_capi_h : boolean; - function Load_cef_menu_button_capi_h : boolean; - function Load_cef_panel_capi_h : boolean; - function Load_cef_scroll_view_capi_h : boolean; - function Load_cef_textfield_capi_h : boolean; - function Load_cef_window_capi_h : boolean; - function Load_cef_types_linux_h : boolean; + procedure CallContextInitializedHandlers(Data: PtrInt); + {$ENDIF} - procedure ShutDown; - procedure FreeLibcefLibrary; - function ExecuteProcess(const aApp : ICefApp) : integer; - procedure InitializeSettings(var aSettings : TCefSettings); - function InitializeLibrary(const aApp : ICefApp) : boolean; - function InitializeCookies : boolean; - function MultiExeProcessing : boolean; - function SingleExeProcessing : boolean; - function CheckCEFLibrary : boolean; - procedure DeleteDirContents(const aDirectory : string); - procedure RegisterWidevineCDM; - function FindFlashDLL(var aFileName : string) : boolean; - procedure ShowErrorMessageDlg(const aError : string); virtual; - function ParseProcessType : TCefProcessType; + procedure BeforeInitSubProcess; override; public constructor Create; destructor Destroy; override; - procedure AfterConstruction; override; - procedure AddCustomCommandLine(const aCommandLine : string; const aValue : string = ''); - function StartMainProcess : boolean; - function StartSubProcess : boolean; - - procedure DoMessageLoopWork; - procedure RunMessageLoop; - procedure QuitMessageLoop; - procedure UpdateDeviceScaleFactor; + procedure UpdateDeviceScaleFactor; override; - // Internal procedures. Only TInternalApp, TCefCustomBrowserProcessHandler, - // ICefResourceBundleHandler, ICefRenderProcessHandler and ICefRegisterCDMCallback - // should use them. - procedure Internal_OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine); - procedure Internal_OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef); - procedure Internal_OnContextInitialized; - procedure Internal_OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); - procedure Internal_OnRenderProcessThreadCreated(const extraInfo: ICefListValue); - procedure Internal_OnScheduleMessagePumpWork(const delayMs: Int64); - function Internal_GetLocalizedString(stringId: Integer; var stringVal: ustring) : boolean; - function Internal_GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt) : boolean; - function Internal_GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt) : boolean; - procedure Internal_OnRenderThreadCreated(const extraInfo: ICefListValue); - procedure Internal_OnWebKitInitialized; - procedure Internal_OnBrowserCreated(const browser: ICefBrowser); - procedure Internal_OnBrowserDestroyed(const browser: ICefBrowser); - procedure Internal_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); - procedure Internal_OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); - procedure Internal_OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); - procedure Internal_OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); - procedure Internal_OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage; var aHandled : boolean); - procedure Internal_OnCDMRegistrationComplete(result : TCefCDMRegistrationError; const error_message : ustring); + property DestroyApplicationObject: boolean read FDestroyApplicationObject write FDestroyApplicationObject; + property DestroyAppWindows : boolean read FDestroyAppWindows write FDestroyAppWindows; - property Cache : ustring read FCache write SetCache; - property Cookies : ustring read FCookies write SetCookies; - property UserDataPath : ustring read FUserDataPath write SetUserDataPath; - property UserAgent : ustring read FUserAgent write FUserAgent; - property ProductVersion : ustring read FProductVersion write FProductVersion; - property Locale : ustring read FLocale write FLocale; - property LogFile : ustring read FLogFile write FLogFile; - property BrowserSubprocessPath : ustring read FBrowserSubprocessPath write SetBrowserSubprocessPath; - property FrameworkDirPath : ustring read FFrameworkDirPath write SetFrameworkDirPath; - property LogSeverity : TCefLogSeverity read FLogSeverity write FLogSeverity; - property JavaScriptFlags : ustring read FJavaScriptFlags write FJavaScriptFlags; - property ResourcesDirPath : ustring read FResourcesDirPath write SetResourcesDirPath; - property LocalesDirPath : ustring read FLocalesDirPath write SetLocalesDirPath; - property SingleProcess : Boolean read FSingleProcess write FSingleProcess; - property NoSandbox : Boolean read FNoSandbox write FNoSandbox; - property CommandLineArgsDisabled : Boolean read FCommandLineArgsDisabled write FCommandLineArgsDisabled; - property PackLoadingDisabled : Boolean read FPackLoadingDisabled write FPackLoadingDisabled; - property RemoteDebuggingPort : Integer read FRemoteDebuggingPort write FRemoteDebuggingPort; - property UncaughtExceptionStackSize : Integer read FUncaughtExceptionStackSize write FUncaughtExceptionStackSize; - property PersistSessionCookies : Boolean read FPersistSessionCookies write FPersistSessionCookies; - property PersistUserPreferences : Boolean read FPersistUserPreferences write FPersistUserPreferences; - property IgnoreCertificateErrors : Boolean read FIgnoreCertificateErrors write FIgnoreCertificateErrors; - property EnableNetSecurityExpiration : boolean read FEnableNetSecurityExpiration write FEnableNetSecurityExpiration; - property BackgroundColor : TCefColor read FBackgroundColor write FBackgroundColor; - property AcceptLanguageList : ustring read FAcceptLanguageList write FAcceptLanguageList; - property WindowsSandboxInfo : Pointer read FWindowsSandboxInfo write FWindowsSandboxInfo; - property WindowlessRenderingEnabled : Boolean read FWindowlessRenderingEnabled write FWindowlessRenderingEnabled; - property MultiThreadedMessageLoop : boolean read FMultiThreadedMessageLoop write FMultiThreadedMessageLoop; - property ExternalMessagePump : boolean read FExternalMessagePump write FExternalMessagePump; - property DeleteCache : boolean read FDeleteCache write FDeleteCache; - property DeleteCookies : boolean read FDeleteCookies write FDeleteCookies; - property FlashEnabled : boolean read FFlashEnabled write FFlashEnabled; - property EnableMediaStream : boolean read FEnableMediaStream write FEnableMediaStream; - property EnableSpeechInput : boolean read FEnableSpeechInput write FEnableSpeechInput; - property EnableGPU : boolean read FEnableGPU write FEnableGPU; - property CheckCEFFiles : boolean read FCheckCEFFiles write FCheckCEFFiles; - property ShowMessageDlg : boolean read FShowMessageDlg write FShowMessageDlg; - property SetCurrentDir : boolean read FSetCurrentDir write FSetCurrentDir; - property GlobalContextInitialized : boolean read GetGlobalContextInitialized; - property ChromeMajorVer : uint16 read FChromeVersionInfo.MajorVer; - property ChromeMinorVer : uint16 read FChromeVersionInfo.MinorVer; - property ChromeRelease : uint16 read FChromeVersionInfo.Release; - property ChromeBuild : uint16 read FChromeVersionInfo.Build; - property ChromeVersion : string read GetChromeVersion; - property LibCefPath : string read GetLibCefPath; - property ChromeElfPath : string read GetChromeElfPath; - property SmoothScrolling : TCefState read FSmoothScrolling write FSmoothScrolling; - property FastUnload : boolean read FFastUnload write FFastUnload; - property DisableSafeBrowsing : boolean read FDisableSafeBrowsing write FDisableSafeBrowsing; - property LibLoaded : boolean read FLibLoaded; - property EnableHighDPISupport : boolean read FEnableHighDPISupport write FEnableHighDPISupport; - property MuteAudio : boolean read FMuteAudio write FMuteAudio; - property SitePerProcess : boolean read FSitePerProcess write FSitePerProcess; - property DisableWebSecurity : boolean read FDisableWebSecurity write FDisableWebSecurity; - property DisablePDFExtension : boolean read FDisablePDFExtension write FDisablePDFExtension; - property ReRaiseExceptions : boolean read FReRaiseExceptions write FReRaiseExceptions; - property DeviceScaleFactor : single read FDeviceScaleFactor; - property CheckDevToolsResources : boolean read FCheckDevToolsResources write FCheckDevToolsResources; - property LocalesRequired : ustring read FLocalesRequired write FLocalesRequired; - property CustomFlashPath : ustring read FCustomFlashPath write FCustomFlashPath; - property ProcessType : TCefProcessType read FProcessType; - property MustCreateResourceBundleHandler : boolean read GetMustCreateResourceBundleHandler write FMustCreateResourceBundleHandler; - property MustCreateBrowserProcessHandler : boolean read GetMustCreateBrowserProcessHandler write FMustCreateBrowserProcessHandler; - property MustCreateRenderProcessHandler : boolean read GetMustCreateRenderProcessHandler write FMustCreateRenderProcessHandler; - property OsmodalLoop : boolean write SetOsmodalLoop; - property Status : TCefAplicationStatus read FStatus; - property MissingLibFiles : string read FMissingLibFiles; - property ShutdownWaitTime : cardinal read FShutdownWaitTime write FShutdownWaitTime; - property WidevinePath : ustring read FWidevinePath write FWidevinePath; - property MustFreeLibrary : boolean read FMustFreeLibrary write FMustFreeLibrary; - property ChildProcessesCount : integer read GetChildProcessesCount; - - property OnRegCustomSchemes : TOnRegisterCustomSchemesEvent read FOnRegisterCustomSchemes write FOnRegisterCustomSchemes; - - // ICefBrowserProcessHandler - property OnContextInitialized : TOnContextInitializedEvent read FOnContextInitialized write FOnContextInitialized; - property OnBeforeChildProcessLaunch : TOnBeforeChildProcessLaunchEvent read FOnBeforeChildProcessLaunch write FOnBeforeChildProcessLaunch; - property OnRenderProcessThreadCreated : TOnRenderProcessThreadCreatedEvent read FOnRenderProcessThreadCreated write FOnRenderProcessThreadCreated; - property OnScheduleMessagePumpWork : TOnScheduleMessagePumpWorkEvent read FOnScheduleMessagePumpWork write FOnScheduleMessagePumpWork; - - // ICefResourceBundleHandler - property OnGetLocalizedString : TOnGetLocalizedStringEvent read FOnGetLocalizedString write FOnGetLocalizedString; - property OnGetDataResource : TOnGetDataResourceEvent read FOnGetDataResource write FOnGetDataResource; - property OnGetDataResourceForScale : TOnGetDataResourceForScaleEvent read FOnGetDataResourceForScale write FOnGetDataResourceForScale; - - // ICefRenderProcessHandler - property OnRenderThreadCreated : TOnRenderThreadCreatedEvent read FOnRenderThreadCreated write FOnRenderThreadCreated; - property OnWebKitInitialized : TOnWebKitInitializedEvent read FOnWebKitInitialized write FOnWebKitInitialized; - property OnBrowserCreated : TOnBrowserCreatedEvent read FOnBrowserCreated write FOnBrowserCreated; - property OnBrowserDestroyed : TOnBrowserDestroyedEvent read FOnBrowserDestroyed write FOnBrowserDestroyed; - property OnContextCreated : TOnContextCreatedEvent read FOnContextCreated write FOnContextCreated; - property OnContextReleased : TOnContextReleasedEvent read FOnContextReleased write FOnContextReleased; - property OnUncaughtException : TOnUncaughtExceptionEvent read FOnUncaughtException write FOnUncaughtException; - property OnFocusedNodeChanged : TOnFocusedNodeChangedEvent read FOnFocusedNodeChanged write FOnFocusedNodeChanged; - property OnProcessMessageReceived : TOnProcessMessageReceivedEvent read FOnProcessMessageReceived write FOnProcessMessageReceived; + {$IFDEF FPC} + procedure Internal_OnContextInitialized; override; // In UI thread - // ICefRegisterCDMCallback - property OnCDMRegistrationComplete : TOnCDMRegistrationCompleteEvent read FOnCDMRegistrationComplete write FOnCDMRegistrationComplete; + Procedure AddContextInitializedHandler(AHandler: TNotifyEvent); + Procedure RemoveContextInitializedHandler(AHandler: TNotifyEvent); + {$ENDIF} end; + TCEFDirectoryDeleterThread = uCEFApplicationCore.TCEFDirectoryDeleterThread; + var GlobalCEFApp : TCefApplication = nil; +function CefCursorToWindowsCursor(aCefCursor : TCefCursorType) : TCursor; procedure DestroyGlobalCEFApp; +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + implementation uses {$IFDEF DELPHI16_UP} - System.Math, System.IOUtils, System.SysUtils, {$IFDEF MSWINDOWS}WinApi.TlHelp32,{$ENDIF} + System.Math, System.IOUtils, System.SysUtils, {$IFDEF MSWINDOWS}WinApi.TlHelp32, WinApi.PSAPI,{$ENDIF} {$ELSE} Math, {$IFDEF DELPHI14_UP}IOUtils,{$ENDIF} SysUtils, {$IFDEF FPC} - {$IFDEF MSWINDOWS}jwatlhelp32,{$ENDIF} + {$IFDEF MSWINDOWS}jwatlhelp32, jwapsapi,{$ENDIF} {$ELSE} - TlHelp32, + TlHelp32, {$IFDEF MSWINDOWS}PSAPI,{$ENDIF} {$ENDIF} {$ENDIF} - uCEFLibFunctions, uCEFMiscFunctions, uCEFCommandLine, uCEFConstants, - uCEFSchemeHandlerFactory, uCEFCookieManager, uCEFApp, uCEFRegisterCDMCallback; + uCEFConstants, uCEFMiscFunctions; + +function CefCursorToWindowsCursor(aCefCursor : TCefCursorType) : TCursor; +begin + case aCefCursor of + CT_POINTER : Result := crArrow; + CT_CROSS : Result := crCross; + CT_HAND : Result := crHandPoint; + CT_IBEAM : Result := crIBeam; + CT_WAIT : Result := crHourGlass; + CT_HELP : Result := crHelp; + CT_EASTRESIZE : Result := crSizeWE; + CT_NORTHRESIZE : Result := crSizeNS; + CT_NORTHEASTRESIZE : Result := crSizeNESW; + CT_NORTHWESTRESIZE : Result := crSizeNWSE; + CT_SOUTHRESIZE : Result := crSizeNS; + CT_SOUTHEASTRESIZE : Result := crSizeNWSE; + CT_SOUTHWESTRESIZE : Result := crSizeNESW; + CT_WESTRESIZE : Result := crSizeWE; + CT_NORTHSOUTHRESIZE : Result := crSizeNS; + CT_EASTWESTRESIZE : Result := crSizeWE; + CT_NORTHEASTSOUTHWESTRESIZE : Result := crSizeNESW; + CT_NORTHWESTSOUTHEASTRESIZE : Result := crSizeNWSE; + CT_COLUMNRESIZE : Result := crHSplit; + CT_ROWRESIZE : Result := crVSplit; + CT_MOVE : Result := crSizeAll; + CT_PROGRESS : Result := crAppStart; + CT_NONE : Result := crNone; + CT_NODROP, + CT_NOTALLOWED : Result := crNo; + CT_GRAB, + CT_GRABBING : Result := crDrag; + + else Result := crDefault; + end; +end; procedure DestroyGlobalCEFApp; begin @@ -423,1752 +204,152 @@ end; constructor TCefApplication.Create; begin - inherited Create; - - FStatus := asLoading; - FMissingLibFiles := ''; - FLibHandle := 0; - FCache := ''; - FCookies := ''; - FUserDataPath := ''; - FUserAgent := ''; - FProductVersion := ''; - FLocale := ''; - FLogFile := ''; - FBrowserSubprocessPath := ''; - FCustomFlashPath := ''; - FFrameworkDirPath := ''; - FLogSeverity := LOGSEVERITY_DISABLE; - FJavaScriptFlags := ''; - FResourcesDirPath := ''; - FLocalesDirPath := ''; - FSingleProcess := False; - FNoSandbox := True; - FCommandLineArgsDisabled := False; - FPackLoadingDisabled := False; - FRemoteDebuggingPort := 0; - FUncaughtExceptionStackSize := 0; - FPersistSessionCookies := False; - FPersistUserPreferences := False; - FIgnoreCertificateErrors := False; - FEnableNetSecurityExpiration := False; - FBackgroundColor := 0; - FAcceptLanguageList := ''; - FWindowsSandboxInfo := nil; - FWindowlessRenderingEnabled := False; - FMultiThreadedMessageLoop := True; - FExternalMessagePump := False; - FDeleteCache := False; - FDeleteCookies := False; - FFlashEnabled := True; - FEnableMediaStream := True; - FEnableSpeechInput := True; - FEnableGPU := False; - FCustomCommandLines := nil; - FCustomCommandLineValues := nil; - FCheckCEFFiles := True; - FSmoothScrolling := STATE_DEFAULT; - FFastUnload := False; - FDisableSafeBrowsing := False; - FOnRegisterCustomSchemes := nil; - FEnableHighDPISupport := False; - FMuteAudio := False; - FSitePerProcess := False; - FDisableWebSecurity := False; - FDisablePDFExtension := False; - FReRaiseExceptions := False; - FLibLoaded := False; - FShowMessageDlg := True; - FSetCurrentDir := False; - FGlobalContextInitialized := False; - FCheckDevToolsResources := True; - FDisableGPUCache := True; - FLocalesRequired := ''; - FProcessType := ParseProcessType; - FShutdownWaitTime := 0; - FWidevinePath := ''; - FMustFreeLibrary := False; - - FMustCreateResourceBundleHandler := False; - FMustCreateBrowserProcessHandler := True; - FMustCreateRenderProcessHandler := False; - - // ICefBrowserProcessHandler - FOnContextInitialized := nil; - FOnBeforeChildProcessLaunch := nil; - FOnRenderProcessThreadCreated := nil; - FOnScheduleMessagePumpWork := nil; - - // ICefResourceBundleHandler - FOnGetLocalizedString := nil; - FOnGetDataResource := nil; - FOnGetDataResourceForScale := nil; - - // ICefRenderProcessHandler - FOnRenderThreadCreated := nil; - FOnWebKitInitialized := nil; - FOnBrowserCreated := nil; - FOnBrowserDestroyed := nil; - FOnContextCreated := nil; - FOnContextReleased := nil; - FOnUncaughtException := nil; - FOnFocusedNodeChanged := nil; - FOnProcessMessageReceived := nil; - - // ICefRegisterCDMCallback - FOnCDMRegistrationComplete := nil; - - UpdateDeviceScaleFactor; - - FillChar(FAppSettings, SizeOf(TCefSettings), 0); - FAppSettings.size := SizeOf(TCefSettings); - - FChromeVersionInfo.MajorVer := CEF_CHROMEELF_VERSION_MAJOR; - FChromeVersionInfo.MinorVer := CEF_CHROMEELF_VERSION_MINOR; - FChromeVersionInfo.Release := CEF_CHROMEELF_VERSION_RELEASE; - FChromeVersionInfo.Build := CEF_CHROMEELF_VERSION_BUILD; - - if (FProcessType = ptBrowser) then GetDLLVersion(ChromeElfPath, FChromeVersionInfo); + {$IFDEF FPC} + FContextInitializedHandlers := TMethodList.Create; + {$ENDIF} - IsMultiThread := True; + inherited Create; + if GlobalCEFApp = nil then + GlobalCEFApp := Self; - SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); + FDestroyApplicationObject := False; + FDestroyAppWindows := True; end; destructor TCefApplication.Destroy; begin - try - if (FProcessType = ptBrowser) then - begin - if (FShutdownWaitTime > 0) then sleep(FShutdownWaitTime); - - ShutDown; - end; - - FreeLibcefLibrary; - - if (FCustomCommandLines <> nil) then FreeAndNil(FCustomCommandLines); - if (FCustomCommandLineValues <> nil) then FreeAndNil(FCustomCommandLineValues); - finally - inherited Destroy; - end; -end; - -procedure TCefApplication.AfterConstruction; -begin - inherited AfterConstruction; - - FCustomCommandLines := TStringList.Create; - FCustomCommandLineValues := TStringList.Create; -end; - -procedure TCefApplication.AddCustomCommandLine(const aCommandLine, aValue : string); -begin - if (FCustomCommandLines <> nil) then FCustomCommandLines.Add(aCommandLine); - if (FCustomCommandLineValues <> nil) then FCustomCommandLineValues.Add(aValue); -end; - -// This function must only be called by the main executable when the application -// is configured to use a different executable for the subprocesses. -// The process calling ths function must be the browser process. -function TCefApplication.MultiExeProcessing : boolean; -var - TempApp : ICefApp; -begin - Result := False; - TempApp := nil; + if GlobalCEFApp = Self then + GlobalCEFApp := nil; + inherited Destroy; - try - try - if (ProcessType = ptBrowser) and - CheckCEFLibrary and - LoadCEFlibrary then - begin - TempApp := TCustomCefApp.Create(self); - Result := InitializeLibrary(TempApp); - end; - except - on e : exception do - if CustomExceptionHandler('TCefApplication.MultiExeProcessing', e) then raise; - end; - finally - TempApp := nil; - end; + {$IFDEF FPC} + FContextInitializedHandlers.Free; + {$ENDIF} end; -// This function will be called by all processes when the application is configured -// to use the same executable for all the processes : browser, render, etc. -function TCefApplication.SingleExeProcessing : boolean; +procedure TCefApplication.UpdateDeviceScaleFactor; +{$IFDEF MSWINDOWS} +{$IFNDEF FMX} var - TempApp : ICefApp; -begin - Result := False; - TempApp := nil; - - try - if CheckCEFLibrary and LoadCEFlibrary then - begin - TempApp := TCustomCefApp.Create(self); - Result := (ExecuteProcess(TempApp) < 0) and InitializeLibrary(TempApp); - end; - finally - TempApp := nil; - end; -end; - -function TCefApplication.GetChromeVersion : string; -begin - Result := FileVersionInfoToString(FChromeVersionInfo); -end; - -function TCefApplication.GetLibCefPath : string; -begin - if (length(FFrameworkDirPath) > 0) then - Result := IncludeTrailingPathDelimiter(FFrameworkDirPath) + LIBCEF_DLL - else - Result := LIBCEF_DLL; -end; - -function TCefApplication.GetChromeElfPath : string; -begin - if (length(FFrameworkDirPath) > 0) then - Result := IncludeTrailingPathDelimiter(FFrameworkDirPath) + CHROMEELF_DLL - else - Result := CHROMEELF_DLL; -end; - -procedure TCefApplication.SetCache(const aValue : ustring); -begin - if (length(aValue) > 0) then - begin - if CustomPathIsRelative(aValue) then - FCache := GetModulePath + aValue - else - FCache := aValue; - end - else - FCache := ''; - - FDisableGPUCache := (length(FCache) = 0); -end; - -procedure TCefApplication.SetCookies(const aValue : ustring); + TempHandle : HWND; + TempDPI : UINT; +{$ENDIF} +{$ENDIF} begin - if (length(aValue) > 0) then + {$IFDEF MSWINDOWS} + {$IFNDEF FMX} + if RunningWindows10OrNewer then begin - if CustomPathIsRelative(aValue) then - FCookies := GetModulePath + aValue + if assigned(screen.ActiveForm) and + screen.ActiveForm.HandleAllocated then + TempHandle := screen.ActiveForm.Handle else - FCookies := aValue; - end - else - FCookies := ''; -end; + if assigned(Application.MainForm) and + Application.MainForm.HandleAllocated then + TempHandle := Application.MainForm.Handle + else + TempHandle := Application.Handle; -procedure TCefApplication.SetUserDataPath(const aValue : ustring); -begin - if (length(aValue) > 0) then - begin - if CustomPathIsRelative(aValue) then - FUserDataPath := GetModulePath + aValue - else - FUserDataPath := aValue; + if GetDPIForHandle(TempHandle, TempDPI) then + FDeviceScaleFactor := TempDPI / USER_DEFAULT_SCREEN_DPI + else + inherited UpdateDeviceScaleFactor; end else - FUserDataPath := ''; + {$ENDIF} + inherited UpdateDeviceScaleFactor; + {$ELSE} + inherited UpdateDeviceScaleFactor; + {$ENDIF} end; -procedure TCefApplication.SetBrowserSubprocessPath(const aValue : ustring); -var - TempPath : string; +{$IFDEF FPC} +procedure TCefApplication.Internal_OnContextInitialized; begin - if (length(aValue) > 0) then - begin - if CustomPathIsRelative(aValue) then - TempPath := GetModulePath + aValue - else - TempPath := aValue; - - if FileExists(TempPath) then - FBrowserSubprocessPath := TempPath - else - FBrowserSubprocessPath := ''; - end - else - FBrowserSubprocessPath := ''; + inherited Internal_OnContextInitialized; + Application.QueueAsyncCall(@CallContextInitializedHandlers, 0); end; -procedure TCefApplication.SetFrameworkDirPath(const aValue : ustring); -var - TempPath : string; +procedure TCefApplication.AddContextInitializedHandler(AHandler: TNotifyEvent); begin - if (length(aValue) > 0) then - begin - if CustomPathIsRelative(aValue) then - TempPath := GetModulePath + aValue - else - TempPath := aValue; - - if DirectoryExists(TempPath) then - FFrameworkDirPath := TempPath - else - FFrameworkDirPath := ''; - end - else - FFrameworkDirPath := ''; - - if (FProcessType = ptBrowser) then GetDLLVersion(ChromeElfPath, FChromeVersionInfo); + FContextInitializedHandlers.Add(TMethod(AHandler)); + if FContextInitializedDone then + AHandler(Self); end; -procedure TCefApplication.SetResourcesDirPath(const aValue : ustring); -var - TempPath : string; +procedure TCefApplication.RemoveContextInitializedHandler(AHandler: TNotifyEvent); begin - if (length(aValue) > 0) then - begin - if CustomPathIsRelative(aValue) then - TempPath := GetModulePath + aValue - else - TempPath := aValue; - - if DirectoryExists(TempPath) then - FResourcesDirPath := TempPath - else - FResourcesDirPath := ''; - end - else - FResourcesDirPath := ''; + FContextInitializedHandlers.Remove(TMethod(AHandler)); end; +{$ENDIF} -procedure TCefApplication.SetLocalesDirPath(const aValue : ustring); -var - TempPath : string; +{$IFDEF FPC} +procedure TCefApplication.CallContextInitializedHandlers(Data: PtrInt); begin - if (length(aValue) > 0) then - begin - if CustomPathIsRelative(aValue) then - TempPath := GetModulePath + aValue - else - TempPath := aValue; - - if DirectoryExists(TempPath) then - FLocalesDirPath := TempPath - else - FLocalesDirPath := ''; - end - else - FLocalesDirPath := ''; + FContextInitializedHandlers.CallNotifyEvents(Self); + FContextInitializedDone := True; end; +{$ENDIF} -function TCefApplication.CheckCEFLibrary : boolean; +procedure TCefApplication.BeforeInitSubProcess; +{$IFNDEF FPC} +{$IFNDEF FMX} var - TempString, TempOldDir : string; - TempMissingFrm, TempMissingRsc, TempMissingLoc : boolean; + AppDestroy: procedure(Obj: TApplication; ReleaseMemoryFlag: Byte); +{$ENDIF} +{$ENDIF} begin - Result := False; - - if not(FCheckCEFFiles) or (FProcessType <> ptBrowser) then - Result := True - else + {$IFNDEF FPC} + {$IFNDEF FMX} + if Application <> nil then begin - if FSetCurrentDir then + if FDestroyApplicationObject then begin - TempOldDir := GetCurrentDir; - chdir(GetModulePath); - end; - - TempMissingFrm := not(CheckDLLs(FFrameworkDirPath, FMissingLibFiles)); - TempMissingRsc := not(CheckResources(FResourcesDirPath, FMissingLibFiles, FCheckDevToolsResources)); - TempMissingLoc := not(CheckLocales(FLocalesDirPath, FMissingLibFiles, FLocalesRequired)); - - if TempMissingFrm or TempMissingRsc or TempMissingLoc then - begin - FStatus := asErrorMissingFiles; - TempString := 'CEF3 binaries missing !'; - - if (length(FMissingLibFiles) > 0) then - TempString := TempString + CRLF + CRLF + - 'The missing files are :' + CRLF + - trim(FMissingLibFiles); - - ShowErrorMessageDlg(TempString); + // Call the destructor in "inherited Destroy" mode. This makes it possible to undo + // all the code that TApplication.Create did without actually releasing the Application + // object so that TControl.Destroy and DoneApplication dont't crash. + // + // Undoing also includes destroying the "AppWindows" and calling OleUninitialize what + // allows CEF to initialize the COM thread model the way it is required in the + // sub-processes (debug assertion). + AppDestroy := @TApplication.Destroy; + AppDestroy(Application, 0); + // Set all sub-objects to nil (we destroyed them already). This prevents the second + // TApplication.Destroy call in DoneApplication from trying to release already released + // objects. + TApplication.InitInstance(Application); end else - if CheckDLLVersion(LibCefPath, - CEF_SUPPORTED_VERSION_MAJOR, - CEF_SUPPORTED_VERSION_MINOR, - CEF_SUPPORTED_VERSION_RELEASE, - CEF_SUPPORTED_VERSION_BUILD) then - Result := True - else - begin - FStatus := asErrorDLLVersion; - TempString := 'Unsupported CEF version !' + - CRLF + CRLF + - 'Use only the CEF3 binaries specified in the CEF4Delphi Readme.md file at ' + - CRLF + CEF4DELPHI_URL; - - ShowErrorMessageDlg(TempString); - end; - - if FSetCurrentDir then chdir(TempOldDir); - - end; -end; - -function TCefApplication.StartMainProcess : boolean; -begin - if (FStatus <> asLoading) then - Result := False - else - if not(FSingleProcess) and (length(FBrowserSubprocessPath) > 0) then - Result := MultiExeProcessing - else - Result := SingleExeProcessing; -end; - -// This function can only be called by the executable used for the subprocesses. -// The application must be configured to use different executables for the subprocesses. -// The process calling this function can't be the browser process. -function TCefApplication.StartSubProcess : boolean; -var - TempApp : ICefApp; -begin - Result := False; - TempApp := nil; - - try - if not(FSingleProcess) and - (ProcessType <> ptBrowser) and - LoadCEFlibrary then - begin - TempApp := TCustomCefApp.Create(self); - Result := (ExecuteProcess(TempApp) >= 0); - end; - finally - TempApp := nil; - end; -end; - -procedure TCefApplication.DoMessageLoopWork; -begin - if FLibLoaded and - not(FMultiThreadedMessageLoop) and - FExternalMessagePump then - cef_do_message_loop_work(); -end; - -procedure TCefApplication.RunMessageLoop; -begin - if FLibLoaded and - not(FMultiThreadedMessageLoop) and - not(FExternalMessagePump) then - cef_run_message_loop(); -end; - -procedure TCefApplication.QuitMessageLoop; -begin - if FLibLoaded and - not(FMultiThreadedMessageLoop) and - not(FExternalMessagePump) then - cef_quit_message_loop(); -end; - -procedure TCefApplication.SetOsmodalLoop(aValue : boolean); -begin - if FLibLoaded then cef_set_osmodal_loop(Ord(aValue)); -end; - -procedure TCefApplication.UpdateDeviceScaleFactor; -begin - FDeviceScaleFactor := GetDeviceScaleFactor; -end; - -procedure TCefApplication.ShutDown; -begin - try - FStatus := asShuttingDown; - if FLibLoaded then cef_shutdown(); - except - on e : exception do - if CustomExceptionHandler('TCefApplication.ShutDown', e) then raise; - end; -end; - -procedure TCefApplication.FreeLibcefLibrary; -begin - try - try - if FMustFreeLibrary and (FLibHandle <> 0) then FreeLibrary(FLibHandle); - except - on e : exception do - if CustomExceptionHandler('TCefApplication.FreeLibcefLibrary', e) then raise; - end; - finally - FLibHandle := 0; - FLibLoaded := False; - FStatus := asUnloaded; - end; -end; - -function TCefApplication.ExecuteProcess(const aApp : ICefApp) : integer; -var - TempArgs : TCefMainArgs; -begin - Result := -1; - try - if (aApp <> nil) then - begin - {$IFDEF MSWINDOWS} - TempArgs.instance := HINSTANCE{$IFDEF FPC}(){$ENDIF}; - {$ELSE} - TempArgs.argc := argc; - TempArgs.argv := argv; - {$ENDIF} - - Result := cef_execute_process(@TempArgs, aApp.Wrap, FWindowsSandboxInfo); - end; - except - on e : exception do - begin - FStatus := asErrorExecutingProcess; - if CustomExceptionHandler('TCefApplication.ExecuteProcess', e) then raise; - end; - end; -end; - -procedure TCefApplication.InitializeSettings(var aSettings : TCefSettings); -begin - aSettings.size := SizeOf(TCefSettings); - aSettings.single_process := Ord(FSingleProcess); - aSettings.no_sandbox := Ord(FNoSandbox); - aSettings.browser_subprocess_path := CefString(FBrowserSubprocessPath); - aSettings.framework_dir_path := CefString(FFrameworkDirPath); - aSettings.multi_threaded_message_loop := Ord(FMultiThreadedMessageLoop); - aSettings.external_message_pump := Ord(FExternalMessagePump); - aSettings.windowless_rendering_enabled := Ord(FWindowlessRenderingEnabled); - aSettings.command_line_args_disabled := Ord(FCommandLineArgsDisabled); - aSettings.cache_path := CefString(FCache); - aSettings.user_data_path := CefString(FUserDataPath); - aSettings.persist_session_cookies := Ord(FPersistSessionCookies); - aSettings.persist_user_preferences := Ord(FPersistUserPreferences); - aSettings.user_agent := CefString(FUserAgent); - aSettings.product_version := CefString(FProductVersion); - aSettings.locale := CefString(FLocale); - aSettings.log_file := CefString(FLogFile); - aSettings.log_severity := FLogSeverity; - aSettings.javascript_flags := CefString(FJavaScriptFlags); - aSettings.resources_dir_path := CefString(FResourcesDirPath); - aSettings.locales_dir_path := CefString(FLocalesDirPath); - aSettings.pack_loading_disabled := Ord(FPackLoadingDisabled); - aSettings.remote_debugging_port := FRemoteDebuggingPort; - aSettings.uncaught_exception_stack_size := FUncaughtExceptionStackSize; - aSettings.ignore_certificate_errors := Ord(FIgnoreCertificateErrors); - aSettings.enable_net_security_expiration := Ord(FEnableNetSecurityExpiration); - aSettings.background_color := FBackgroundColor; - aSettings.accept_language_list := CefString(FAcceptLanguageList); -end; - -function TCefApplication.InitializeLibrary(const aApp : ICefApp) : boolean; -var - TempArgs : TCefMainArgs; -begin - Result := False; - - try - try - if (aApp <> nil) then begin - if FDeleteCache then DeleteDirContents(FCache); - if FDeleteCookies then DeleteDirContents(FCookies); - - RegisterWidevineCDM; - - InitializeSettings(FAppSettings); - - {$IFDEF MSWINDOWS} - TempArgs.instance := HINSTANCE{$IFDEF FPC}(){$ENDIF}; - {$ELSE} - TempArgs.argc := argc; - TempArgs.argv := argv; - {$ENDIF} - - if (cef_initialize(@TempArgs, @FAppSettings, aApp.Wrap, FWindowsSandboxInfo) <> 0) then + if FDestroyAppWindows then begin - Result := True; - FStatus := asInitialized; + // This is the fix for the issue #139 + // https://github.com/salvadordf/CEF4Delphi/issues/139 + // Subprocesses will never use these window handles but TApplication creates them + // before executing the code in the DPR file. Any other application trying to + // initiate a DDE conversation will use SendMessage or SendMessageTimeout to + // broadcast the WM_DDE_INITIATE to all top-level windows. The subprocesses never + // call Application.Run so the SendMessage freezes the other applications. + if (Application.Handle <> 0) then DestroyWindow(Application.Handle); + {$IFDEF DELPHI9_UP} + if (Application.PopupControlWnd <> 0) then DeallocateHWnd(Application.PopupControlWnd); + {$ENDIF} end; - end; - except - on e : exception do - if CustomExceptionHandler('TCefApplication.InitializeLibrary', e) then raise; - end; - finally - if not(Result) then FStatus := asErrorInitializingLibrary; - end; -end; - -function TCefApplication.InitializeCookies : boolean; -var - TempCookieManager : ICefCookieManager; -begin - Result := False; - - try - if (length(FCookies) > 0) then - begin - TempCookieManager := TCefCookieManagerRef.Global(nil); - - if (TempCookieManager <> nil) and - TempCookieManager.SetStoragePath(FCookies, FPersistSessionCookies, nil) then - Result := True - else - OutputDebugMessage('TCefApplication.InitializeCookies error : cookies cannot be accessed'); - end - else - Result := True; - except - on e : exception do - if CustomExceptionHandler('TCefApplication.InitializeCookies', e) then raise; - end; -end; - -procedure TCefApplication.DeleteDirContents(const aDirectory : string); -{$IFNDEF DELPHI14_UP} -var - TempRec : TSearchRec; -{$ENDIF} -begin - try - if (length(aDirectory) > 0) and DirectoryExists(aDirectory) then - begin - {$IFDEF DELPHI14_UP} - TDirectory.Delete(aDirectory, True); - {$ELSE} - if (FindFirst(aDirectory + '\*', faAnyFile, TempRec) = 0) then - begin - try - repeat - if ((TempRec.Attr and faDirectory) <> 0) then - begin - if (TempRec.Name <> '.') and (TempRec.Name <> '..') then - DeleteDirContents(aDirectory + '\' + TempRec.Name) - end - else - DeleteFile(aDirectory + '\' + TempRec.Name); - until (FindNext(TempRec) <> 0); - finally - FindClose(TempRec); + if not IsLibrary then + begin + // Undo the OleInitialize from TApplication.Create. The sub-processes want a different + // COM thread model and fail with an assertion if the Debug-DLLs are used. + OleUninitialize; end; - end; - {$ENDIF} - end; - except - on e : exception do - if CustomExceptionHandler('TCefApplication.DeleteDirContents', e) then raise; - end; -end; - -procedure TCefApplication.RegisterWidevineCDM; -var - TempPath : TCefString; - TempCallback : ICefRegisterCDMCallback; -begin - try - try - if FLibLoaded and (length(FWidevinePath) > 0) and DirectoryExists(FWidevinePath) then - begin - TempPath := CefString(FWidevinePath); - TempCallback := TCefCustomRegisterCDMCallback.Create(self); - - cef_register_widevine_cdm(@TempPath, TempCallback.Wrap); end; - except - on e : exception do - if CustomExceptionHandler('TCefApplication.RegisterWidevineCDM', e) then raise; end; - finally - TempCallback := nil; - end; -end; - -function TCefApplication.FindFlashDLL(var aFileName : string) : boolean; -var - TempSearchRec : TSearchRec; - TempProductName, TempPath : string; -begin - Result := False; - aFileName := ''; - - try - if (length(FCustomFlashPath) > 0) then - begin - TempPath := IncludeTrailingPathDelimiter(FCustomFlashPath); - - if (FindFirst(TempPath + '*.dll', faAnyFile, TempSearchRec) = 0) then - begin - repeat - if (TempSearchRec.Attr <> faDirectory) and - GetStringFileInfo(TempPath + TempSearchRec.Name, 'ProductName', TempProductName) and - (CompareText(TempProductName, 'Shockwave Flash') = 0) then - begin - aFileName := TempPath + TempSearchRec.Name; - Result := True; - end; - until Result or (FindNext(TempSearchRec) <> 0); - - FindClose(TempSearchRec); - end; - end; - except - on e : exception do - if CustomExceptionHandler('TCefApplication.FindFlashDLL', e) then raise; - end; -end; - -procedure TCefApplication.ShowErrorMessageDlg(const aError : string); -begin - OutputDebugMessage(aError); - - if FShowMessageDlg then - begin - {$IFDEF MSWINDOWS} - MessageBox(0, PChar(aError + #0), PChar('Error' + #0), MB_ICONERROR or MB_OK or MB_TOPMOST); - {$ENDIF} - end; -end; - -function TCefApplication.ParseProcessType : TCefProcessType; -const - TYPE_PARAMETER_NAME = '--type='; -var - i, TempLen : integer; - TempName, TempValue : string; -begin - Result := ptBrowser; - i := pred(paramCount); - TempLen := length(TYPE_PARAMETER_NAME); - - while (i >= 0) and (Result = ptBrowser) do - begin - TempName := copy(paramstr(i), 1, TempLen); - - if (CompareText(TempName, TYPE_PARAMETER_NAME) = 0) then - begin - TempValue := copy(paramstr(i), succ(TempLen), length(paramstr(i))); - - if (CompareText(TempValue, 'renderer') = 0) then - Result := ptRenderer - else - if (CompareText(TempValue, 'zygote') = 0) then - Result := ptZygote - else - if (CompareText(TempValue, 'gpu-process') = 0) then - Result := ptGPU - else - Result := ptOther; - end; - - dec(i); - end; -end; - -procedure TCefApplication.Internal_OnContextInitialized; -begin - InitializeCookies; - FGlobalContextInitialized := True; - - if assigned(FOnContextInitialized) then FOnContextInitialized(); -end; - -procedure TCefApplication.Internal_OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); -begin - if assigned(FOnBeforeChildProcessLaunch) then FOnBeforeChildProcessLaunch(commandLine); -end; - -procedure TCefApplication.Internal_OnRenderProcessThreadCreated(const extraInfo: ICefListValue); -begin - if assigned(FOnRenderProcessThreadCreated) then FOnRenderProcessThreadCreated(extraInfo); -end; - -procedure TCefApplication.Internal_OnScheduleMessagePumpWork(const delayMs: Int64); -begin - if assigned(FOnScheduleMessagePumpWork) then FOnScheduleMessagePumpWork(delayMs); -end; - -function TCefApplication.Internal_GetLocalizedString(stringid: Integer; var stringVal: ustring) : boolean; -begin - Result := False; - - // The stringId must be one of the values defined in the CEF file : - // /include/cef_pack_strings.h - // That file is available in the CEF3 binaries package. - if assigned(FOnGetLocalizedString) then FOnGetLocalizedString(stringId, stringVal, Result); -end; - -function TCefApplication.Internal_GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt) : boolean; -begin - Result := False; - - // The resourceId must be one of the values defined in the CEF file : - // /include/cef_pack_resources.h - // That file is available in the CEF3 binaries package. - if assigned(FOnGetDataResource) then FOnGetDataResource(resourceId, data, dataSize, Result); -end; - -function TCefApplication.Internal_GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt) : boolean; -begin - Result := False; - - // The resourceId must be one of the values defined in the CEF file : - // /include/cef_pack_resources.h - // That file is available in the CEF3 binaries package. - if assigned(FOnGetDataResourceForScale) then FOnGetDataResourceForScale(resourceId, scaleFactor, data, dataSize, Result); -end; - -procedure TCefApplication.Internal_OnRenderThreadCreated(const extraInfo: ICefListValue); -begin - if assigned(FOnRenderThreadCreated) then FOnRenderThreadCreated(extraInfo); -end; - -procedure TCefApplication.Internal_OnWebKitInitialized; -begin - if assigned(FOnWebKitInitialized) then FOnWebKitInitialized(); -end; - -procedure TCefApplication.Internal_OnBrowserCreated(const browser: ICefBrowser); -begin - if assigned(FOnBrowserCreated) then FOnBrowserCreated(browser); -end; - -procedure TCefApplication.Internal_OnBrowserDestroyed(const browser: ICefBrowser); -begin - if assigned(FOnBrowserDestroyed) then FOnBrowserDestroyed(browser); -end; - -procedure TCefApplication.Internal_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); -begin - if assigned(FOnContextCreated) then FOnContextCreated(browser, frame, context); -end; - -procedure TCefApplication.Internal_OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); -begin - if assigned(FOnContextReleased) then FOnContextReleased(browser, frame, context); -end; - -procedure TCefApplication.Internal_OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); -begin - if assigned(FOnUncaughtException) then FOnUncaughtException(browser, frame, context, exception, stackTrace); -end; - -procedure TCefApplication.Internal_OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); -begin - if assigned(FOnFocusedNodeChanged) then FOnFocusedNodeChanged(browser, frame, node); -end; - -procedure TCefApplication.Internal_OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage; var aHandled : boolean); -begin - if assigned(FOnProcessMessageReceived) then - FOnProcessMessageReceived(browser, sourceProcess, aMessage, aHandled) - else - aHandled := False; -end; - -procedure TCefApplication.Internal_OnCDMRegistrationComplete(result : TCefCDMRegistrationError; const error_message : ustring); -begin - if assigned(FOnCDMRegistrationComplete) then FOnCDMRegistrationComplete(result, error_message); -end; - -procedure TCefApplication.Internal_OnBeforeCommandLineProcessing(const processType : ustring; - const commandLine : ICefCommandLine); -var - i : integer; - TempVersionInfo : TFileVersionInfo; - TempFileName : string; -begin - if (commandLine <> nil) and (FProcessType = ptBrowser) and (processType = '') then - begin - if FindFlashDLL(TempFileName) and - GetDLLVersion(TempFileName, TempVersionInfo) then - begin - if FEnableGPU then commandLine.AppendSwitch('--enable-gpu-plugin'); - - commandLine.AppendSwitch('--enable-accelerated-plugins'); - commandLine.AppendSwitchWithValue('--ppapi-flash-path', TempFileName); - commandLine.AppendSwitchWithValue('--ppapi-flash-version', FileVersionInfoToString(TempVersionInfo)); - end - else - if FFlashEnabled then - begin - if FEnableGPU then commandLine.AppendSwitch('--enable-gpu-plugin'); - - commandLine.AppendSwitch('--enable-accelerated-plugins'); - commandLine.AppendSwitch('--enable-system-flash'); - end; - - commandLine.AppendSwitchWithValue('--enable-media-stream', IntToStr(Ord(FEnableMediaStream))); - commandLine.AppendSwitchWithValue('--enable-speech-input', IntToStr(Ord(FEnableSpeechInput))); - - if not(FEnableGPU) then - begin - commandLine.AppendSwitch('--disable-gpu'); - commandLine.AppendSwitch('--disable-gpu-compositing'); - end; - - case FSmoothScrolling of - STATE_ENABLED : commandLine.AppendSwitch('--enable-smooth-scrolling'); - STATE_DISABLED : commandLine.AppendSwitch('--disable-smooth-scrolling'); - end; - - if FFastUnload then - commandLine.AppendSwitch('--enable-fast-unload'); - - if FDisableGPUCache then - commandLine.AppendSwitch('--disable-gpu-shader-disk-cache'); - - if FDisableSafeBrowsing then - begin - commandLine.AppendSwitch('--disable-client-side-phishing-detection'); - commandLine.AppendSwitch('--safebrowsing-disable-auto-update'); - commandLine.AppendSwitch('--safebrowsing-disable-download-protection'); - end; - - if FMuteAudio then - commandLine.AppendSwitch('--mute-audio'); - - if FDisableWebSecurity then - commandLine.AppendSwitch('--disable-web-security'); - - if FDisablePDFExtension then - commandLine.AppendSwitch('--disable-pdf-extension'); - - if FSitePerProcess then - commandLine.AppendSwitch('--site-per-process'); - - if (FCustomCommandLines <> nil) and - (FCustomCommandLineValues <> nil) and - (FCustomCommandLines.Count = FCustomCommandLineValues.Count) then - begin - i := 0; - - while (i < FCustomCommandLines.Count) do - begin - if (length(FCustomCommandLines[i]) > 0) then - begin - if (length(FCustomCommandLineValues[i]) > 0) then - commandLine.AppendSwitchWithValue(FCustomCommandLines[i], FCustomCommandLineValues[i]) - else - commandLine.AppendSwitch(FCustomCommandLines[i]); - end; - - inc(i); - end; - end; - end; -end; - -procedure TCefApplication.Internal_OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef); -begin - if assigned(FOnRegisterCustomSchemes) then FOnRegisterCustomSchemes(registrar); -end; - -function TCefApplication.GetMustCreateResourceBundleHandler : boolean; -begin - Result := FSingleProcess or - ((FProcessType in [ptBrowser, ptRenderer]) and - (FMustCreateResourceBundleHandler or - assigned(FOnGetLocalizedString) or - assigned(FOnGetDataResource) or - assigned(FOnGetDataResourceForScale))); -end; - -function TCefApplication.GetMustCreateBrowserProcessHandler : boolean; -begin - Result := FSingleProcess or - ((FProcessType = ptBrowser) and - (FMustCreateBrowserProcessHandler or - assigned(FOnContextInitialized) or - assigned(FOnBeforeChildProcessLaunch) or - assigned(FOnRenderProcessThreadCreated) or - assigned(FOnScheduleMessagePumpWork))); -end; - -function TCefApplication.GetMustCreateRenderProcessHandler : boolean; -begin - Result := FSingleProcess or - ((FProcessType = ptRenderer) and - (FMustCreateRenderProcessHandler or - assigned(FOnRenderThreadCreated) or - assigned(FOnWebKitInitialized) or - assigned(FOnBrowserCreated) or - assigned(FOnBrowserDestroyed) or - assigned(FOnContextCreated) or - assigned(FOnContextReleased) or - assigned(FOnUncaughtException) or - assigned(FOnFocusedNodeChanged) or - assigned(FOnProcessMessageReceived))); -end; - -function TCefApplication.GetGlobalContextInitialized : boolean; -begin - Result := FGlobalContextInitialized or not(MustCreateBrowserProcessHandler); -end; - -function TCefApplication.GetChildProcessesCount : integer; -{$IFDEF MSWINDOWS} -var - TempHandle : THandle; - TempProcess : TProcessEntry32; - TempPID : DWORD; - TempMain, TempSubProc, TempName : string; -{$ENDIF} -begin - Result := 0; - -{$IFDEF MSWINDOWS} - TempHandle := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0); - TempProcess.dwSize := Sizeof(TProcessEntry32); - TempPID := GetCurrentProcessID; - TempMain := ExtractFileName(paramstr(0)); - TempSubProc := ExtractFileName(FBrowserSubprocessPath); - - Process32First(TempHandle, TempProcess); - - repeat - if (TempProcess.th32ProcessID <> TempPID) and - (TempProcess.th32ParentProcessID = TempPID) then - begin - TempName := TempProcess.szExeFile; - TempName := ExtractFileName(TempName); - - if (CompareText(TempName, TempMain) = 0) or - ((length(TempSubProc) > 0) and (CompareText(TempName, TempSubProc) = 0)) then - inc(Result); - end; - until not(Process32Next(TempHandle, TempProcess)); - - CloseHandle(TempHandle); -{$ENDIF} -end; - -function TCefApplication.LoadCEFlibrary : boolean; -var - TempOldDir, TempString : string; -begin - Result := False; - - if (FStatus <> asLoading) or FLibLoaded or (FLibHandle <> 0) then - begin - FStatus := asErrorLoadingLibrary; - TempString := 'GlobalCEFApp can only be initialized once per process.'; - - ShowErrorMessageDlg(TempString); - exit; - end; - - if FSetCurrentDir then - begin - TempOldDir := GetCurrentDir; - chdir(GetModulePath); - end; - - {$IFDEF MSWINDOWS} - FLibHandle := LoadLibraryEx(PChar(LibCefPath), 0, LOAD_WITH_ALTERED_SEARCH_PATH); - {$ELSE} - FLibHandle := LoadLibrary(PChar(LibCefPath)); + {$ELSE} // FMX + {$IFDEF MSWINDOWS} + // Undo the OleInitialize from FMX.Platform.Win::initialization. The sub-processes want a different + // COM thread model and fail with an assertion if the Debug-DLLs are used. + OleUninitialize; + {$ENDIF MSWINDOWS} {$ENDIF} - - if (FLibHandle = 0) then - begin - FStatus := asErrorLoadingLibrary; - TempString := 'Error loading libcef.dll' + CRLF + CRLF + - 'Error code : 0x' + inttohex(GetLastError, 8); - - ShowErrorMessageDlg(TempString); - exit; - end; - - - if Load_cef_app_capi_h and - Load_cef_browser_capi_h and - Load_cef_command_line_capi_h and - Load_cef_cookie_capi_h and - Load_cef_crash_util_h and - Load_cef_drag_data_capi_h and - Load_cef_file_util_capi_h and - Load_cef_image_capi_h and - Load_cef_menu_model_capi_h and - Load_cef_origin_whitelist_capi_h and - Load_cef_parser_capi_h and - Load_cef_path_util_capi_h and - Load_cef_print_settings_capi_h and - Load_cef_process_message_capi_h and - Load_cef_process_util_capi_h and - Load_cef_request_capi_h and - Load_cef_request_context_capi_h and - Load_cef_resource_bundle_capi_h and - Load_cef_response_capi_h and - Load_cef_server_capi_h and - Load_cef_scheme_capi_h and - Load_cef_ssl_info_capi_h and - Load_cef_stream_capi_h and - Load_cef_task_capi_h and - Load_cef_thread_capi_h and - Load_cef_trace_capi_h and - Load_cef_urlrequest_capi_h and - Load_cef_v8_capi_h and - Load_cef_values_capi_h and - Load_cef_waitable_event_capi_h and - Load_cef_web_plugin_capi_h and - Load_cef_xml_reader_capi_h and - Load_cef_zip_reader_capi_h and - Load_cef_logging_internal_h and - Load_cef_string_list_h and - Load_cef_string_map_h and - Load_cef_string_multimap_h and - Load_cef_string_types_h and - Load_cef_thread_internal_h and - Load_cef_trace_event_internal_h and - Load_cef_browser_view_capi_h and - Load_cef_display_capi_h and - Load_cef_label_button_capi_h and - Load_cef_menu_button_capi_h and - Load_cef_panel_capi_h and - Load_cef_scroll_view_capi_h and - Load_cef_textfield_capi_h and - Load_cef_window_capi_h and - Load_cef_types_linux_h then - begin - FStatus := asLoaded; - FLibLoaded := True; - Result := True; - - if FEnableHighDPISupport then cef_enable_highdpi_support(); - end - else - begin - FStatus := asErrorDLLVersion; - TempString := 'Unsupported CEF version !' + - CRLF + CRLF + - 'Use only the CEF3 binaries specified in the CEF4Delphi Readme.md file at ' + - CRLF + CEF4DELPHI_URL; - - ShowErrorMessageDlg(TempString); - end; - - if FSetCurrentDir then chdir(TempOldDir); -end; - -function TCefApplication.Load_cef_app_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_initialize{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_initialize'); - {$IFDEF FPC}Pointer({$ENDIF}cef_shutdown{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_shutdown'); - {$IFDEF FPC}Pointer({$ENDIF}cef_execute_process{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_execute_process'); - {$IFDEF FPC}Pointer({$ENDIF}cef_do_message_loop_work{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_do_message_loop_work'); - {$IFDEF FPC}Pointer({$ENDIF}cef_run_message_loop{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_run_message_loop'); - {$IFDEF FPC}Pointer({$ENDIF}cef_quit_message_loop{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_quit_message_loop'); - {$IFDEF FPC}Pointer({$ENDIF}cef_set_osmodal_loop{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_set_osmodal_loop'); - {$IFDEF FPC}Pointer({$ENDIF}cef_enable_highdpi_support{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_enable_highdpi_support'); - - Result := assigned(cef_initialize) and - assigned(cef_shutdown) and - assigned(cef_execute_process) and - assigned(cef_do_message_loop_work) and - assigned(cef_run_message_loop) and - assigned(cef_quit_message_loop) and - assigned(cef_set_osmodal_loop) and - assigned(cef_enable_highdpi_support); -end; - -function TCefApplication.Load_cef_browser_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_browser_host_create_browser{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_host_create_browser'); - {$IFDEF FPC}Pointer({$ENDIF}cef_browser_host_create_browser_sync{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_host_create_browser_sync'); - - Result := assigned(cef_browser_host_create_browser) and - assigned(cef_browser_host_create_browser_sync); -end; - -function TCefApplication.Load_cef_command_line_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_command_line_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_command_line_create'); - {$IFDEF FPC}Pointer({$ENDIF}cef_command_line_get_global{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_command_line_get_global'); - - Result := assigned(cef_command_line_create) and - assigned(cef_command_line_get_global); -end; - -function TCefApplication.Load_cef_cookie_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_cookie_manager_get_global_manager{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_cookie_manager_get_global_manager'); - {$IFDEF FPC}Pointer({$ENDIF}cef_cookie_manager_get_blocking_manager{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_cookie_manager_get_blocking_manager'); - {$IFDEF FPC}Pointer({$ENDIF}cef_cookie_manager_create_manager{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_cookie_manager_create_manager'); - - Result := assigned(cef_cookie_manager_get_global_manager) and - assigned(cef_cookie_manager_get_blocking_manager) and - assigned(cef_cookie_manager_create_manager); -end; - -function TCefApplication.Load_cef_crash_util_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_crash_reporting_enabled{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_crash_reporting_enabled'); - {$IFDEF FPC}Pointer({$ENDIF}cef_set_crash_key_value{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_set_crash_key_value'); - - Result := assigned(cef_crash_reporting_enabled) and - assigned(cef_set_crash_key_value); -end; - -function TCefApplication.Load_cef_drag_data_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_drag_data_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_drag_data_create'); - - Result := assigned(cef_drag_data_create); -end; - -function TCefApplication.Load_cef_file_util_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_create_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_directory'); - {$IFDEF FPC}Pointer({$ENDIF}cef_get_temp_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_temp_directory'); - {$IFDEF FPC}Pointer({$ENDIF}cef_create_new_temp_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_new_temp_directory'); - {$IFDEF FPC}Pointer({$ENDIF}cef_create_temp_directory_in_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_temp_directory_in_directory'); - {$IFDEF FPC}Pointer({$ENDIF}cef_directory_exists{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_directory_exists'); - {$IFDEF FPC}Pointer({$ENDIF}cef_delete_file{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_delete_file'); - {$IFDEF FPC}Pointer({$ENDIF}cef_zip_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_zip_directory'); - {$IFDEF FPC}Pointer({$ENDIF}cef_load_crlsets_file{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_load_crlsets_file'); - - Result := assigned(cef_create_directory) and - assigned(cef_get_temp_directory) and - assigned(cef_create_new_temp_directory) and - assigned(cef_create_temp_directory_in_directory) and - assigned(cef_directory_exists) and - assigned(cef_delete_file) and - assigned(cef_zip_directory) and - assigned(cef_load_crlsets_file); -end; - -function TCefApplication.Load_cef_image_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_image_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_image_create'); - - Result := assigned(cef_image_create); -end; - -function TCefApplication.Load_cef_menu_model_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_menu_model_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_menu_model_create'); - - Result := assigned(cef_menu_model_create); -end; - -function TCefApplication.Load_cef_origin_whitelist_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_add_cross_origin_whitelist_entry{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_add_cross_origin_whitelist_entry'); - {$IFDEF FPC}Pointer({$ENDIF}cef_remove_cross_origin_whitelist_entry{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_remove_cross_origin_whitelist_entry'); - {$IFDEF FPC}Pointer({$ENDIF}cef_clear_cross_origin_whitelist{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_clear_cross_origin_whitelist'); - - Result := assigned(cef_add_cross_origin_whitelist_entry) and - assigned(cef_remove_cross_origin_whitelist_entry) and - assigned(cef_clear_cross_origin_whitelist); -end; - -function TCefApplication.Load_cef_parser_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_parse_url{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_parse_url'); - {$IFDEF FPC}Pointer({$ENDIF}cef_create_url{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_url'); - {$IFDEF FPC}Pointer({$ENDIF}cef_format_url_for_security_display{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_format_url_for_security_display'); - {$IFDEF FPC}Pointer({$ENDIF}cef_get_mime_type{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_mime_type'); - {$IFDEF FPC}Pointer({$ENDIF}cef_get_extensions_for_mime_type{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_extensions_for_mime_type'); - {$IFDEF FPC}Pointer({$ENDIF}cef_base64encode{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_base64encode'); - {$IFDEF FPC}Pointer({$ENDIF}cef_base64decode{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_base64decode'); - {$IFDEF FPC}Pointer({$ENDIF}cef_uriencode{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_uriencode'); - {$IFDEF FPC}Pointer({$ENDIF}cef_uridecode{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_uridecode'); - {$IFDEF FPC}Pointer({$ENDIF}cef_parse_json{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_parse_json'); - {$IFDEF FPC}Pointer({$ENDIF}cef_parse_jsonand_return_error{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_parse_jsonand_return_error'); - {$IFDEF FPC}Pointer({$ENDIF}cef_write_json{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_write_json'); - - Result := assigned(cef_parse_url) and - assigned(cef_create_url) and - assigned(cef_format_url_for_security_display) and - assigned(cef_get_mime_type) and - assigned(cef_get_extensions_for_mime_type) and - assigned(cef_base64encode) and - assigned(cef_base64decode) and - assigned(cef_uriencode) and - assigned(cef_uridecode) and - assigned(cef_parse_json) and - assigned(cef_parse_jsonand_return_error) and - assigned(cef_write_json); -end; - -function TCefApplication.Load_cef_path_util_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_get_path{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_path'); - - Result := assigned(cef_get_path); -end; - -function TCefApplication.Load_cef_print_settings_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_print_settings_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_print_settings_create'); - - Result := assigned(cef_print_settings_create); -end; - -function TCefApplication.Load_cef_process_message_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_process_message_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_process_message_create'); - - Result := assigned(cef_process_message_create); -end; - -function TCefApplication.Load_cef_process_util_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_launch_process{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_launch_process'); - - Result := assigned(cef_launch_process); -end; - -function TCefApplication.Load_cef_request_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_request_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_request_create'); - {$IFDEF FPC}Pointer({$ENDIF}cef_post_data_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_post_data_create'); - {$IFDEF FPC}Pointer({$ENDIF}cef_post_data_element_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_post_data_element_create'); - - Result := assigned(cef_request_create) and - assigned(cef_post_data_create) and - assigned(cef_post_data_element_create); -end; - -function TCefApplication.Load_cef_request_context_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_request_context_get_global_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_request_context_get_global_context'); - {$IFDEF FPC}Pointer({$ENDIF}cef_request_context_create_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_request_context_create_context'); - {$IFDEF FPC}Pointer({$ENDIF}cef_create_context_shared{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_context_shared'); - - Result := assigned(cef_request_context_get_global_context) and - assigned(cef_request_context_create_context) and - assigned(cef_create_context_shared); -end; - -function TCefApplication.Load_cef_resource_bundle_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_resource_bundle_get_global{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_resource_bundle_get_global'); - - Result := assigned(cef_resource_bundle_get_global); -end; - -function TCefApplication.Load_cef_response_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_response_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_response_create'); - - Result := assigned(cef_response_create); -end; - -function TCefApplication.Load_cef_server_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_server_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_server_create'); - - Result := assigned(cef_server_create); -end; - -function TCefApplication.Load_cef_scheme_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_register_scheme_handler_factory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_register_scheme_handler_factory'); - {$IFDEF FPC}Pointer({$ENDIF}cef_clear_scheme_handler_factories{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_clear_scheme_handler_factories'); - - Result := assigned(cef_register_scheme_handler_factory) and - assigned(cef_clear_scheme_handler_factories); -end; - -function TCefApplication.Load_cef_ssl_info_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_is_cert_status_error{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_is_cert_status_error'); - {$IFDEF FPC}Pointer({$ENDIF}cef_is_cert_status_minor_error{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_is_cert_status_minor_error'); - - Result := assigned(cef_is_cert_status_error) and - assigned(cef_is_cert_status_minor_error); -end; - -function TCefApplication.Load_cef_stream_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_stream_reader_create_for_file{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_reader_create_for_file'); - {$IFDEF FPC}Pointer({$ENDIF}cef_stream_reader_create_for_data{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_reader_create_for_data'); - {$IFDEF FPC}Pointer({$ENDIF}cef_stream_reader_create_for_handler{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_reader_create_for_handler'); - {$IFDEF FPC}Pointer({$ENDIF}cef_stream_writer_create_for_file{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_writer_create_for_file'); - {$IFDEF FPC}Pointer({$ENDIF}cef_stream_writer_create_for_handler{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_writer_create_for_handler'); - - Result := assigned(cef_stream_reader_create_for_file) and - assigned(cef_stream_reader_create_for_data) and - assigned(cef_stream_reader_create_for_handler) and - assigned(cef_stream_writer_create_for_file) and - assigned(cef_stream_writer_create_for_handler); -end; - -function TCefApplication.Load_cef_task_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_task_runner_get_for_current_thread{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_task_runner_get_for_current_thread'); - {$IFDEF FPC}Pointer({$ENDIF}cef_task_runner_get_for_thread{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_task_runner_get_for_thread'); - {$IFDEF FPC}Pointer({$ENDIF}cef_currently_on{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_currently_on'); - {$IFDEF FPC}Pointer({$ENDIF}cef_post_task{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_post_task'); - {$IFDEF FPC}Pointer({$ENDIF}cef_post_delayed_task{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_post_delayed_task'); - - Result := assigned(cef_task_runner_get_for_current_thread) and - assigned(cef_task_runner_get_for_thread) and - assigned(cef_currently_on) and - assigned(cef_post_task) and - assigned(cef_post_delayed_task); -end; - -function TCefApplication.Load_cef_thread_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_thread_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_thread_create'); - - Result := assigned(cef_thread_create); -end; - -function TCefApplication.Load_cef_trace_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_begin_tracing{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_begin_tracing'); - {$IFDEF FPC}Pointer({$ENDIF}cef_end_tracing{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_end_tracing'); - {$IFDEF FPC}Pointer({$ENDIF}cef_now_from_system_trace_time{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_now_from_system_trace_time'); - - Result := assigned(cef_begin_tracing) and - assigned(cef_end_tracing) and - assigned(cef_now_from_system_trace_time); -end; - -function TCefApplication.Load_cef_urlrequest_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_urlrequest_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_urlrequest_create'); - - Result := assigned(cef_urlrequest_create); -end; - -function TCefApplication.Load_cef_v8_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_v8context_get_current_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8context_get_current_context'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8context_get_entered_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8context_get_entered_context'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8context_in_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8context_in_context'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_undefined{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_undefined'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_null{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_null'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_bool{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_bool'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_int{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_int'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_uint{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_uint'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_double{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_double'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_date{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_date'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_string{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_string'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_object{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_object'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_array{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_array'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_array_buffer{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_array_buffer'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_function{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_function'); - {$IFDEF FPC}Pointer({$ENDIF}cef_v8stack_trace_get_current{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8stack_trace_get_current'); - {$IFDEF FPC}Pointer({$ENDIF}cef_register_extension{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_register_extension'); - - Result := assigned(cef_v8context_get_current_context) and - assigned(cef_v8context_get_entered_context) and - assigned(cef_v8context_in_context) and - assigned(cef_v8value_create_undefined) and - assigned(cef_v8value_create_null) and - assigned(cef_v8value_create_bool) and - assigned(cef_v8value_create_int) and - assigned(cef_v8value_create_uint) and - assigned(cef_v8value_create_double) and - assigned(cef_v8value_create_date) and - assigned(cef_v8value_create_string) and - assigned(cef_v8value_create_object) and - assigned(cef_v8value_create_array) and - assigned(cef_v8value_create_array_buffer) and - assigned(cef_v8value_create_function) and - assigned(cef_v8stack_trace_get_current) and - assigned(cef_register_extension); -end; - -function TCefApplication.Load_cef_values_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_value_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_value_create'); - {$IFDEF FPC}Pointer({$ENDIF}cef_binary_value_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_binary_value_create'); - {$IFDEF FPC}Pointer({$ENDIF}cef_dictionary_value_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_dictionary_value_create'); - {$IFDEF FPC}Pointer({$ENDIF}cef_list_value_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_list_value_create'); - - Result := assigned(cef_value_create) and - assigned(cef_binary_value_create) and - assigned(cef_v8stack_trace_get_current) and - assigned(cef_list_value_create); -end; - -function TCefApplication.Load_cef_waitable_event_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_waitable_event_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_waitable_event_create'); - - Result := assigned(cef_waitable_event_create); -end; - -function TCefApplication.Load_cef_web_plugin_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_visit_web_plugin_info{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_visit_web_plugin_info'); - {$IFDEF FPC}Pointer({$ENDIF}cef_refresh_web_plugins{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_refresh_web_plugins'); - {$IFDEF FPC}Pointer({$ENDIF}cef_unregister_internal_web_plugin{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_unregister_internal_web_plugin'); - {$IFDEF FPC}Pointer({$ENDIF}cef_register_web_plugin_crash{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_register_web_plugin_crash'); - {$IFDEF FPC}Pointer({$ENDIF}cef_is_web_plugin_unstable{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_is_web_plugin_unstable'); - {$IFDEF FPC}Pointer({$ENDIF}cef_register_widevine_cdm{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_register_widevine_cdm'); - - Result := assigned(cef_visit_web_plugin_info) and - assigned(cef_refresh_web_plugins) and - assigned(cef_unregister_internal_web_plugin) and - assigned(cef_register_web_plugin_crash) and - assigned(cef_is_web_plugin_unstable) and - assigned(cef_register_widevine_cdm); -end; - -function TCefApplication.Load_cef_xml_reader_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_xml_reader_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_xml_reader_create'); - - Result := assigned(cef_xml_reader_create); -end; - -function TCefApplication.Load_cef_zip_reader_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_zip_reader_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_zip_reader_create'); - - Result := assigned(cef_zip_reader_create); -end; - -function TCefApplication.Load_cef_logging_internal_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_get_min_log_level{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_min_log_level'); - {$IFDEF FPC}Pointer({$ENDIF}cef_get_vlog_level{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_vlog_level'); - {$IFDEF FPC}Pointer({$ENDIF}cef_log{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_log'); - - Result := assigned(cef_get_min_log_level) and - assigned(cef_get_vlog_level) and - assigned(cef_log); -end; - -function TCefApplication.Load_cef_string_list_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_alloc'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_size{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_size'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_value{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_value'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_append{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_append'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_clear'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_free'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_copy{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_copy'); - - Result := assigned(cef_string_list_alloc) and - assigned(cef_string_list_size) and - assigned(cef_string_list_value) and - assigned(cef_string_list_append) and - assigned(cef_string_list_clear) and - assigned(cef_string_list_free) and - assigned(cef_string_list_copy); -end; - -function TCefApplication.Load_cef_string_map_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_alloc'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_size{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_size'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_find{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_find'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_key{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_key'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_value{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_value'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_append{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_append'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_clear'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_free'); - - Result := assigned(cef_string_map_alloc) and - assigned(cef_string_map_size) and - assigned(cef_string_map_find) and - assigned(cef_string_map_key) and - assigned(cef_string_map_value) and - assigned(cef_string_map_append) and - assigned(cef_string_map_clear) and - assigned(cef_string_map_free); -end; - -function TCefApplication.Load_cef_string_multimap_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_alloc'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_size{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_size'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_find_count{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_find_count'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_enumerate{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_enumerate'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_key{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_key'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_value{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_value'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_append{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_append'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_clear'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_free'); - - Result := assigned(cef_string_multimap_alloc) and - assigned(cef_string_multimap_size) and - assigned(cef_string_multimap_find_count) and - assigned(cef_string_multimap_enumerate) and - assigned(cef_string_multimap_key) and - assigned(cef_string_multimap_value) and - assigned(cef_string_multimap_append) and - assigned(cef_string_multimap_clear) and - assigned(cef_string_multimap_free); -end; - -function TCefApplication.Load_cef_string_types_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_set{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_set'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_set{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_set'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_set{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_set'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_clear'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_clear'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_clear'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_cmp{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_cmp'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_cmp{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_cmp'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_cmp{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_cmp'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_to_utf8{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_to_utf8'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_to_wide{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_to_wide'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_to_utf16{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_to_utf16'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_to_wide{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_to_wide'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_to_utf16{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_to_utf16'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_to_utf8{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_to_utf8'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_ascii_to_wide{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_ascii_to_wide'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_ascii_to_utf16{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_ascii_to_utf16'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_wide_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_wide_alloc'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_utf8_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_utf8_alloc'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_utf16_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_utf16_alloc'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_wide_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_wide_free'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_utf8_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_utf8_free'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_utf16_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_utf16_free'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_to_lower{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_to_lower'); - {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_to_upper{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_to_upper'); - - Result := assigned(cef_string_wide_set) and - assigned(cef_string_utf8_set) and - assigned(cef_string_utf16_set) and - assigned(cef_string_wide_clear) and - assigned(cef_string_utf8_clear) and - assigned(cef_string_utf16_clear) and - assigned(cef_string_wide_cmp) and - assigned(cef_string_utf8_cmp) and - assigned(cef_string_utf16_cmp) and - assigned(cef_string_wide_to_utf8) and - assigned(cef_string_utf8_to_wide) and - assigned(cef_string_wide_to_utf16) and - assigned(cef_string_utf16_to_wide) and - assigned(cef_string_utf8_to_utf16) and - assigned(cef_string_utf16_to_utf8) and - assigned(cef_string_ascii_to_wide) and - assigned(cef_string_ascii_to_utf16) and - assigned(cef_string_userfree_wide_alloc) and - assigned(cef_string_userfree_utf8_alloc) and - assigned(cef_string_userfree_utf16_alloc) and - assigned(cef_string_userfree_wide_free) and - assigned(cef_string_userfree_utf8_free) and - assigned(cef_string_userfree_utf16_free) and - assigned(cef_string_utf16_to_lower) and - assigned(cef_string_utf16_to_upper); -end; - -function TCefApplication.Load_cef_thread_internal_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_get_current_platform_thread_id{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_current_platform_thread_id'); - {$IFDEF FPC}Pointer({$ENDIF}cef_get_current_platform_thread_handle{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_current_platform_thread_handle'); - - Result := assigned(cef_get_current_platform_thread_id) and - assigned(cef_get_current_platform_thread_handle); -end; - -function TCefApplication.Load_cef_trace_event_internal_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_instant{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_instant'); - {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_begin{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_begin'); - {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_end{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_end'); - {$IFDEF FPC}Pointer({$ENDIF}cef_trace_counter{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_counter'); - {$IFDEF FPC}Pointer({$ENDIF}cef_trace_counter_id{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_counter_id'); - {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_async_begin{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_async_begin'); - {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_async_step_into{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_async_step_into'); - {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_async_step_past{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_async_step_past'); - {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_async_end{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_async_end'); - - Result := assigned(cef_trace_event_instant) and - assigned(cef_trace_event_begin) and - assigned(cef_trace_event_end) and - assigned(cef_trace_counter) and - assigned(cef_trace_counter_id) and - assigned(cef_trace_event_async_begin) and - assigned(cef_trace_event_async_step_into) and - assigned(cef_trace_event_async_step_past) and - assigned(cef_trace_event_async_end); -end; - -function TCefApplication.Load_cef_browser_view_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_browser_view_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_view_create'); - {$IFDEF FPC}Pointer({$ENDIF}cef_browser_view_get_for_browser{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_view_get_for_browser'); - - Result := assigned(cef_browser_view_create) and - assigned(cef_browser_view_get_for_browser); -end; - -function TCefApplication.Load_cef_display_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_primary{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_primary'); - {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_nearest_point{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_nearest_point'); - {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_matching_bounds{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_matching_bounds'); - {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_count{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_count'); - {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_alls{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_alls'); - - Result := assigned(cef_display_get_primary) and - assigned(cef_display_get_nearest_point) and - assigned(cef_display_get_matching_bounds) and - assigned(cef_display_get_count) and - assigned(cef_display_get_alls); -end; - -function TCefApplication.Load_cef_label_button_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_label_button_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_label_button_create'); - - Result := assigned(cef_label_button_create); -end; - -function TCefApplication.Load_cef_menu_button_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_menu_button_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_menu_button_create'); - - Result := assigned(cef_menu_button_create); -end; - -function TCefApplication.Load_cef_panel_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_panel_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_panel_create'); - - Result := assigned(cef_panel_create); -end; - -function TCefApplication.Load_cef_scroll_view_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_scroll_view_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_scroll_view_create'); - - Result := assigned(cef_scroll_view_create); -end; - -function TCefApplication.Load_cef_textfield_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_textfield_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_textfield_create'); - - Result := assigned(cef_textfield_create); -end; - -function TCefApplication.Load_cef_window_capi_h : boolean; -begin - {$IFDEF FPC}Pointer({$ENDIF}cef_window_create_top_level{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_window_create_top_level'); - - Result := assigned(cef_window_create_top_level); -end; - -function TCefApplication.Load_cef_types_linux_h : boolean; -begin - {$IFDEF LINUX} - {$IFDEF FPC}Pointer({$ENDIF}cef_get_xdisplay{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_xdisplay'); - - Result := assigned(cef_get_xdisplay); - {$ELSE} - Result := True; {$ENDIF} end; diff --git a/windows/src/ext/cef4delphi/source/uCEFApplicationCore.pas b/windows/src/ext/cef4delphi/source/uCEFApplicationCore.pas new file mode 100644 index 0000000000000000000000000000000000000000..3e35403999fe988d67e482eda63e861677e8a9c8 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFApplicationCore.pas @@ -0,0 +1,3325 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFApplicationCore; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +{$IFNDEF FPC}{$IFNDEF DELPHI12_UP} + // Workaround for "Internal error" in old Delphi versions caused by uint64 handling + {$R-} +{$ENDIF}{$ENDIF} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, System.UITypes, + {$IFDEF FMX}uCEFLinuxTypes,{$ENDIF} + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, {$IFDEF FPC}dynlibs,{$ENDIF} + {$ENDIF} + {$IFDEF LINUX}{$IFDEF FPC}xlib,{$ENDIF}{$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFBaseRefCounted, uCEFSchemeRegistrar; + +const + CEF_SUPPORTED_VERSION_MAJOR = 89; + CEF_SUPPORTED_VERSION_MINOR = 0; + CEF_SUPPORTED_VERSION_RELEASE = 18; + CEF_SUPPORTED_VERSION_BUILD = 0; + + CEF_CHROMEELF_VERSION_MAJOR = 89; + CEF_CHROMEELF_VERSION_MINOR = 0; + CEF_CHROMEELF_VERSION_RELEASE = 4389; + CEF_CHROMEELF_VERSION_BUILD = 114; + + {$IFDEF MSWINDOWS} + LIBCEF_DLL = 'libcef.dll'; + CHROMEELF_DLL = 'chrome_elf.dll'; + {$ENDIF} + + {$IFDEF MACOSX} + LIBCEF_DLL = 'Chromium Embedded Framework'; + LIBCEF_PREFIX = 'Contents/Frameworks/Chromium Embedded Framework.framework/'; + CHROMEELF_DLL = ''; + {$ENDIF} + + {$IFDEF LINUX} + LIBCEF_DLL = 'libcef.so'; + CHROMEELF_DLL = ''; + {$ENDIF} + + // for InitLibLocationFromArgs + LIBCEF_PAK = 'cef.pak'; + LIBCEF_LOCALE_DIR = 'locales'; + LIBCEF_LOCALE_ENUS = 'en-US.pak'; + +type + TCefApplicationCore = class + protected + FCache : ustring; + FRootCache : ustring; + FUserDataPath : ustring; + FUserAgent : ustring; + FProductVersion : ustring; + FLocale : ustring; + FLocalesRequired : ustring; + FLogFile : ustring; + FBrowserSubprocessPath : ustring; + FFrameworkDirPath : ustring; + FMainBundlePath : ustring; // Only used in macOS + FChromeRuntime : boolean; + FLogSeverity : TCefLogSeverity; + FJavaScriptFlags : ustring; + FResourcesDirPath : ustring; + FLocalesDirPath : ustring; + FSingleProcess : Boolean; + FNoSandbox : Boolean; + FCommandLineArgsDisabled : Boolean; + FPackLoadingDisabled : Boolean; + FRemoteDebuggingPort : Integer; + FUncaughtExceptionStackSize : Integer; + FPersistSessionCookies : Boolean; + FPersistUserPreferences : boolean; + FIgnoreCertificateErrors : Boolean; + FBackgroundColor : TCefColor; + FAcceptLanguageList : ustring; + FApplicationClientID : ustring; + FWindowsSandboxInfo : Pointer; + FWindowlessRenderingEnabled : Boolean; + FMultiThreadedMessageLoop : boolean; + FExternalMessagePump : boolean; + FDeleteCache : boolean; + FDeleteCookies : boolean; + FCustomCommandLines : TStringList; + FCustomCommandLineValues : TStringList; + FEnableMediaStream : boolean; + FEnableSpeechInput : boolean; + FUseFakeUIForMediaStream : boolean; + FEnableUsermediaScreenCapturing : boolean; + FEnableGPU : boolean; + FCheckCEFFiles : boolean; + FLibLoaded : boolean; + FSmoothScrolling : TCefState; + FFastUnload : boolean; + FDisableSafeBrowsing : boolean; + FEnableHighDPISupport : boolean; + FMuteAudio : boolean; + FReRaiseExceptions : boolean; + FShowMessageDlg : boolean; + FMissingBinariesException : boolean; + FSetCurrentDir : boolean; + FGlobalContextInitialized : boolean; + FSitePerProcess : boolean; + FDisableWebSecurity : boolean; + FDisablePDFExtension : boolean; + FLogProcessInfo : boolean; + FDisableSiteIsolationTrials : boolean; + FDisableChromeLoginPrompt : boolean; + FEnableFeatures : ustring; + FDisableFeatures : ustring; + FEnableBlinkFeatures : ustring; + FDisableBlinkFeatures : ustring; + FBlinkSettings : ustring; + FForceFieldTrials : ustring; + FForceFieldTrialParams : ustring; + FChromeVersionInfo : TFileVersionInfo; + {$IFDEF FPC} + FLibHandle : TLibHandle; + {$ELSE} + FLibHandle : THandle; + {$ENDIF} + FOnRegisterCustomSchemes : TOnRegisterCustomSchemesEvent; + FAppSettings : TCefSettings; + FCheckDevToolsResources : boolean; + FDisableExtensions : boolean; + FDisableGPUCache : boolean; + FStatus : TCefAplicationStatus; + FMissingLibFiles : string; + FProcessType : TCefProcessType; + FWidevinePath : ustring; + FMustFreeLibrary : boolean; + FAutoplayPolicy : TCefAutoplayPolicy; + FDisableBackgroundNetworking : boolean; + FMetricsRecordingOnly : boolean; + FAllowFileAccessFromFiles : boolean; + FAllowRunningInsecureContent : boolean; + FSupportedSchemes : TStringList; + FDisableNewBrowserInfoTimeout : boolean; + FDevToolsProtocolLogFile : ustring; + FDeviceScaleFactor : single; + FForcedDeviceScaleFactor : single; + FDisableZygote : boolean; + FUseMockKeyChain : boolean; + FLastErrorMessage : ustring; + + FPluginPolicy : TCefPluginPolicySwitch; + FDefaultEncoding : ustring; + FDisableJavascript : boolean; + FDisableJavascriptCloseWindows : boolean; + FDisableJavascriptAccessClipboard : boolean; + FDisableJavascriptDomPaste : boolean; + FAllowUniversalAccessFromFileUrls : boolean; + FDisableImageLoading : boolean; + FImageShrinkStandaloneToFit : boolean; + FDisableTextAreaResize : boolean; + FDisableTabToLinks : boolean; + FDisablePlugins : boolean; + FEnableProfanityFilter : boolean; + FDisableSpellChecking : boolean; + FOverrideSpellCheckLang : ustring; + FEnablePrintPreview : boolean; + FTouchEvents : TCefState; + FDisableReadingFromCanvas : boolean; + FHyperlinkAuditing : boolean; + + FMustCreateResourceBundleHandler : boolean; + FMustCreateBrowserProcessHandler : boolean; + FMustCreateRenderProcessHandler : boolean; + FMustCreateLoadHandler : boolean; + FMustCreatePrintHandler : boolean; + + // ICefBrowserProcessHandler + FOnGetCookieableSchemes : TOnGetCookieableSchemesEvent; + FOnContextInitialized : TOnContextInitializedEvent; + FOnBeforeChildProcessLaunch : TOnBeforeChildProcessLaunchEvent; + FOnScheduleMessagePumpWork : TOnScheduleMessagePumpWorkEvent; + FOnGetDefaultClient : TOnGetDefaultClientEvent; + + // ICefResourceBundleHandler + FOnGetLocalizedString : TOnGetLocalizedStringEvent; + FOnGetDataResource : TOnGetDataResourceEvent; + FOnGetDataResourceForScale : TOnGetDataResourceForScaleEvent; + + // ICefRenderProcessHandler + FOnWebKitInitialized : TOnWebKitInitializedEvent; + FOnBrowserCreated : TOnBrowserCreatedEvent; + FOnBrowserDestroyed : TOnBrowserDestroyedEvent; + FOnContextCreated : TOnContextCreatedEvent; + FOnContextReleased : TOnContextReleasedEvent; + FOnUncaughtException : TOnUncaughtExceptionEvent; + FOnFocusedNodeChanged : TOnFocusedNodeChangedEvent; + FOnProcessMessageReceived : TOnProcessMessageReceivedEvent; + + // ICefRegisterCDMCallback + FOnCDMRegistrationComplete : TOnCDMRegistrationCompleteEvent; + + // ICefLoadHandler + FOnLoadingStateChange : TOnRenderLoadingStateChange; + FOnLoadStart : TOnRenderLoadStart; + FOnLoadEnd : TOnRenderLoadEnd; + FOnLoadError : TOnRenderLoadError; + + // ICefPrintHandler + FOnPrintStart : TOnPrintStartEvent; + FOnPrintSettings : TOnPrintSettingsEvent; + FOnPrintDialog : TOnPrintDialogEvent; + FOnPrintJob : TOnPrintJobEvent; + FOnPrintReset : TOnPrintResetEvent; + FOnGetPDFPaperSize : TOnGetPDFPaperSizeEvent; + + procedure SetCache(const aValue : ustring); + procedure SetRootCache(const aValue : ustring); + procedure SetUserDataPath(const aValue : ustring); + procedure SetBrowserSubprocessPath(const aValue : ustring); + procedure SetFrameworkDirPath(const aValue : ustring); + procedure SetResourcesDirPath(const aValue : ustring); + procedure SetLocalesDirPath(const aValue : ustring); + procedure SetOsmodalLoop(aValue : boolean); + + function GetChromeVersion : ustring; + function GetLibCefVersion : ustring; + function GetLibCefPath : ustring; + function GetChromeElfPath : ustring; + function GetLocalesDirPath: ustring; + function GetResourcesDirPath: ustring; + function GetMustCreateResourceBundleHandler : boolean; virtual; + function GetMustCreateBrowserProcessHandler : boolean; virtual; + function GetMustCreateRenderProcessHandler : boolean; virtual; + function GetMustCreateLoadHandler : boolean; virtual; + function GetMustCreatePrintHandler : boolean; virtual; + function GetGlobalContextInitialized : boolean; + function GetChildProcessesCount : integer; + function GetUsedMemory : uint64; + function GetTotalSystemMemory : uint64; + function GetAvailableSystemMemory : uint64; + function GetSystemMemoryLoad : cardinal; + function GetApiHashUniversal : ustring; + function GetApiHashPlatform : ustring; + function GetApiHashCommit : ustring; + {$IFDEF LINUX} + function GetXDisplay : PXDisplay; + {$ENDIF} + + function LoadCEFlibrary : boolean; virtual; + function Load_cef_api_hash_h : boolean; + function Load_cef_app_capi_h : boolean; + function Load_cef_browser_capi_h : boolean; + function Load_cef_command_line_capi_h : boolean; + function Load_cef_cookie_capi_h : boolean; + function Load_cef_crash_util_h : boolean; + function Load_cef_drag_data_capi_h : boolean; + function Load_cef_file_util_capi_h : boolean; + function Load_cef_image_capi_h : boolean; + function Load_cef_menu_model_capi_h : boolean; + function Load_cef_media_router_capi_h : boolean; + function Load_cef_origin_whitelist_capi_h : boolean; + function Load_cef_parser_capi_h : boolean; + function Load_cef_path_util_capi_h : boolean; + function Load_cef_print_settings_capi_h : boolean; + function Load_cef_process_message_capi_h : boolean; + function Load_cef_process_util_capi_h : boolean; + function Load_cef_request_capi_h : boolean; + function Load_cef_request_context_capi_h : boolean; + function Load_cef_resource_bundle_capi_h : boolean; + function Load_cef_response_capi_h : boolean; + function Load_cef_server_capi_h : boolean; + function Load_cef_scheme_capi_h : boolean; + function Load_cef_ssl_info_capi_h : boolean; + function Load_cef_stream_capi_h : boolean; + function Load_cef_task_capi_h : boolean; + function Load_cef_thread_capi_h : boolean; + function Load_cef_trace_capi_h : boolean; + function Load_cef_urlrequest_capi_h : boolean; + function Load_cef_v8_capi_h : boolean; + function Load_cef_values_capi_h : boolean; + function Load_cef_waitable_event_capi_h : boolean; + function Load_cef_web_plugin_capi_h : boolean; + function Load_cef_xml_reader_capi_h : boolean; + function Load_cef_zip_reader_capi_h : boolean; + function Load_cef_logging_internal_h : boolean; + function Load_cef_string_list_h : boolean; + function Load_cef_string_map_h : boolean; + function Load_cef_string_multimap_h : boolean; + function Load_cef_string_types_h : boolean; + function Load_cef_thread_internal_h : boolean; + function Load_cef_trace_event_internal_h : boolean; + function Load_cef_browser_view_capi_h : boolean; + function Load_cef_display_capi_h : boolean; + function Load_cef_label_button_capi_h : boolean; + function Load_cef_menu_button_capi_h : boolean; + function Load_cef_panel_capi_h : boolean; + function Load_cef_scroll_view_capi_h : boolean; + function Load_cef_textfield_capi_h : boolean; + function Load_cef_window_capi_h : boolean; + function Load_cef_types_linux_h : boolean; + + procedure ShutDown; + procedure FreeLibcefLibrary; + function ExecuteProcess(const aApp : ICefApp) : integer; + procedure InitializeSettings(var aSettings : TCefSettings); + function InitializeLibrary(const aApp : ICefApp) : boolean; + procedure RenameAndDeleteDir(const aDirectory : string; aKeepCookies : boolean = False); + procedure DeleteCacheContents(const aDirectory : string); + procedure DeleteCookiesDB(const aDirectory : string); + procedure MoveCookiesDB(const aSrcDirectory, aDstDirectory : string); + function MultiExeProcessing : boolean; + function SingleExeProcessing : boolean; + procedure BeforeInitSubProcess; virtual; + function CheckCEFResources : boolean; + {$IFDEF MSWINDOWS} + function CheckCEFDLL : boolean; + {$ENDIF} + function CheckCEFLibrary : boolean; + procedure RegisterWidevineCDM; + procedure ShowErrorMessageDlg(const aError : string); virtual; + procedure UpdateSupportedSchemes(aIncludeDefaults : boolean = True); virtual; + function ParseProcessType : TCefProcessType; + procedure AddCustomCommandLineSwitches(var aKeys, aValues : TStringList); virtual; + procedure AppendSwitch(var aKeys, aValues : TStringList; const aNewKey : ustring; const aNewValue : ustring = ''); + procedure ReplaceSwitch(var aKeys, aValues : TStringList; const aNewKey : ustring; const aNewValue : ustring = ''); + procedure CleanupFeatures(var aKeys, aValues : TStringList; const aEnableKey, aDisableKey : string); + + public + constructor Create; + destructor Destroy; override; + procedure AfterConstruction; override; + procedure AddCustomCommandLine(const aCommandLine : string; const aValue : string = ''); + function StartMainProcess : boolean; + function StartSubProcess : boolean; + {$IFDEF MACOSX} + procedure InitLibLocationFromArgs; + {$ENDIF} + + procedure DoMessageLoopWork; + procedure RunMessageLoop; + procedure QuitMessageLoop; + procedure UpdateDeviceScaleFactor; virtual; + + // Internal procedures. Only ICefApp, ICefBrowserProcessHandler, + // ICefResourceBundleHandler, ICefRenderProcessHandler, ICefRegisterCDMCallback, + // ICefLoadHandler and ICefPrintHandler should use them. + procedure Internal_OnBeforeCommandLineProcessing(const processType: ustring; const commandLine: ICefCommandLine); + procedure Internal_OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef); + procedure Internal_OnContextInitialized; virtual; + procedure Internal_OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); + procedure Internal_OnScheduleMessagePumpWork(const delayMs: Int64); + function Internal_GetLocalizedString(stringId: Integer; var stringVal: ustring) : boolean; + function Internal_GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt) : boolean; + function Internal_GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt) : boolean; + procedure Internal_OnWebKitInitialized; + procedure Internal_OnBrowserCreated(const browser: ICefBrowser; const extra_info: ICefDictionaryValue); + procedure Internal_OnBrowserDestroyed(const browser: ICefBrowser); + procedure Internal_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); + procedure Internal_OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); + procedure Internal_OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); + procedure Internal_OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); + procedure Internal_OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage; var aHandled : boolean); + procedure Internal_OnCDMRegistrationComplete(result : TCefCDMRegistrationError; const error_message : ustring); + procedure Internal_OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); + procedure Internal_OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); + procedure Internal_OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); + procedure Internal_OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); + procedure Internal_GetCookieableSchemes(var schemes: TStringList; var include_defaults : boolean); + procedure Internal_GetDefaultClient(var aClient : ICefClient); + procedure Internal_OnPrintStart(const browser: ICefBrowser); + procedure Internal_OnPrintSettings(const browser: ICefBrowser; const settings: ICefPrintSettings; getDefaults: boolean); + procedure Internal_OnPrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult : boolean); + procedure Internal_OnPrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult : boolean); + procedure Internal_OnPrintReset(const browser: ICefBrowser); + procedure Internal_OnGetPDFPaperSize(deviceUnitsPerInch: Integer; var aResult : TCefSize); + + // Properties used to populate TCefSettings (cef_settings_t) + property NoSandbox : Boolean read FNoSandbox write FNoSandbox; + property BrowserSubprocessPath : ustring read FBrowserSubprocessPath write SetBrowserSubprocessPath; + property FrameworkDirPath : ustring read FFrameworkDirPath write SetFrameworkDirPath; + property MainBundlePath : ustring read FMainBundlePath write FMainBundlePath; // Only used in macOS + property ChromeRuntime : boolean read FChromeRuntime write FChromeRuntime; + property MultiThreadedMessageLoop : boolean read FMultiThreadedMessageLoop write FMultiThreadedMessageLoop; + property ExternalMessagePump : boolean read FExternalMessagePump write FExternalMessagePump; + property WindowlessRenderingEnabled : Boolean read FWindowlessRenderingEnabled write FWindowlessRenderingEnabled; + property CommandLineArgsDisabled : Boolean read FCommandLineArgsDisabled write FCommandLineArgsDisabled; + property Cache : ustring read FCache write SetCache; + property RootCache : ustring read FRootCache write SetRootCache; + property UserDataPath : ustring read FUserDataPath write SetUserDataPath; + property PersistSessionCookies : Boolean read FPersistSessionCookies write FPersistSessionCookies; + property PersistUserPreferences : Boolean read FPersistUserPreferences write FPersistUserPreferences; + property UserAgent : ustring read FUserAgent write FUserAgent; + property ProductVersion : ustring read FProductVersion write FProductVersion; + property Locale : ustring read FLocale write FLocale; + property LogFile : ustring read FLogFile write FLogFile; + property LogSeverity : TCefLogSeverity read FLogSeverity write FLogSeverity; + property JavaScriptFlags : ustring read FJavaScriptFlags write FJavaScriptFlags; + property ResourcesDirPath : ustring read GetResourcesDirPath write SetResourcesDirPath; + property LocalesDirPath : ustring read GetLocalesDirPath write SetLocalesDirPath; + property PackLoadingDisabled : Boolean read FPackLoadingDisabled write FPackLoadingDisabled; + property RemoteDebuggingPort : Integer read FRemoteDebuggingPort write FRemoteDebuggingPort; + property UncaughtExceptionStackSize : Integer read FUncaughtExceptionStackSize write FUncaughtExceptionStackSize; + property IgnoreCertificateErrors : Boolean read FIgnoreCertificateErrors write FIgnoreCertificateErrors; + property BackgroundColor : TCefColor read FBackgroundColor write FBackgroundColor; + property AcceptLanguageList : ustring read FAcceptLanguageList write FAcceptLanguageList; + property ApplicationClientID : ustring read FApplicationClientID write FApplicationClientID; + + // Properties used to set command line switches + property SingleProcess : Boolean read FSingleProcess write FSingleProcess; // --single-process + property EnableMediaStream : boolean read FEnableMediaStream write FEnableMediaStream; // --enable-media-stream + property EnableSpeechInput : boolean read FEnableSpeechInput write FEnableSpeechInput; // --enable-speech-input + property UseFakeUIForMediaStream : boolean read FUseFakeUIForMediaStream write FUseFakeUIForMediaStream; // --use-fake-ui-for-media-stream + property EnableUsermediaScreenCapturing : boolean read FEnableUsermediaScreenCapturing write FEnableUsermediaScreenCapturing; // --enable-usermedia-screen-capturing + property EnableGPU : boolean read FEnableGPU write FEnableGPU; // --enable-gpu-plugin + property EnableFeatures : ustring read FEnableFeatures write FEnableFeatures; // --enable-features + property DisableFeatures : ustring read FDisableFeatures write FDisableFeatures; // --disable-features + property EnableBlinkFeatures : ustring read FEnableBlinkFeatures write FEnableBlinkFeatures; // --enable-blink-features + property DisableBlinkFeatures : ustring read FDisableBlinkFeatures write FDisableBlinkFeatures; // --disable-blink-features + property BlinkSettings : ustring read FBlinkSettings write FBlinkSettings; // --blink-settings + property ForceFieldTrials : ustring read FForceFieldTrials write FForceFieldTrials; // --force-fieldtrials + property ForceFieldTrialParams : ustring read FForceFieldTrialParams write FForceFieldTrialParams; // --force-fieldtrial-params + property SmoothScrolling : TCefState read FSmoothScrolling write FSmoothScrolling; // --enable-smooth-scrolling + property FastUnload : boolean read FFastUnload write FFastUnload; // --enable-fast-unload + property DisableSafeBrowsing : boolean read FDisableSafeBrowsing write FDisableSafeBrowsing; // --safebrowsing-disable-auto-update + property MuteAudio : boolean read FMuteAudio write FMuteAudio; // --mute-audio + property SitePerProcess : boolean read FSitePerProcess write FSitePerProcess; // --site-per-process + property DisableWebSecurity : boolean read FDisableWebSecurity write FDisableWebSecurity; // --disable-web-security + property DisablePDFExtension : boolean read FDisablePDFExtension write FDisablePDFExtension; // --disable-pdf-extension + property DisableSiteIsolationTrials : boolean read FDisableSiteIsolationTrials write FDisableSiteIsolationTrials; // --disable-site-isolation-trials + property DisableChromeLoginPrompt : boolean read FDisableChromeLoginPrompt write FDisableChromeLoginPrompt; // --disable-chrome-login-prompt + property DisableExtensions : boolean read FDisableExtensions write FDisableExtensions; // --disable-extensions + property AutoplayPolicy : TCefAutoplayPolicy read FAutoplayPolicy write FAutoplayPolicy; // --autoplay-policy + property DisableBackgroundNetworking : boolean read FDisableBackgroundNetworking write FDisableBackgroundNetworking; // --disable-background-networking + property MetricsRecordingOnly : boolean read FMetricsRecordingOnly write FMetricsRecordingOnly; // --metrics-recording-only + property AllowFileAccessFromFiles : boolean read FAllowFileAccessFromFiles write FAllowFileAccessFromFiles; // --allow-file-access-from-files + property AllowRunningInsecureContent : boolean read FAllowRunningInsecureContent write FAllowRunningInsecureContent; // --allow-running-insecure-content + property EnablePrintPreview : boolean read FEnablePrintPreview write FEnablePrintPreview; // --enable-print-preview + property PluginPolicy : TCefPluginPolicySwitch read FPluginPolicy write FPluginPolicy; // --plugin-policy + property DefaultEncoding : ustring read FDefaultEncoding write FDefaultEncoding; // --default-encoding + property DisableJavascript : boolean read FDisableJavascript write FDisableJavascript; // --disable-javascript + property DisableJavascriptCloseWindows : boolean read FDisableJavascriptCloseWindows write FDisableJavascriptCloseWindows; // --disable-javascript-close-windows + property DisableJavascriptAccessClipboard : boolean read FDisableJavascriptAccessClipboard write FDisableJavascriptAccessClipboard; // --disable-javascript-access-clipboard + property DisableJavascriptDomPaste : boolean read FDisableJavascriptDomPaste write FDisableJavascriptDomPaste; // --disable-javascript-dom-paste + property AllowUniversalAccessFromFileUrls : boolean read FAllowUniversalAccessFromFileUrls write FAllowUniversalAccessFromFileUrls; // --allow-universal-access-from-files + property DisableImageLoading : boolean read FDisableImageLoading write FDisableImageLoading; // --disable-image-loading + property ImageShrinkStandaloneToFit : boolean read FImageShrinkStandaloneToFit write FImageShrinkStandaloneToFit; // --image-shrink-standalone-to-fit + property DisableTextAreaResize : boolean read FDisableTextAreaResize write FDisableTextAreaResize; // --disable-text-area-resize + property DisableTabToLinks : boolean read FDisableTabToLinks write FDisableTabToLinks; // --disable-tab-to-links + property DisablePlugins : boolean read FDisablePlugins write FDisablePlugins; // --disable-plugins + property EnableProfanityFilter : boolean read FEnableProfanityFilter write FEnableProfanityFilter; // --enable-profanity-filter + property DisableSpellChecking : boolean read FDisableSpellChecking write FDisableSpellChecking; // --disable-spell-checking + property OverrideSpellCheckLang : ustring read FOverrideSpellCheckLang write FOverrideSpellCheckLang; // --override-spell-check-lang + property TouchEvents : TCefState read FTouchEvents write FTouchEvents; // --touch-events + property DisableReadingFromCanvas : boolean read FDisableReadingFromCanvas write FDisableReadingFromCanvas; // --disable-reading-from-canvas + property HyperlinkAuditing : boolean read FHyperlinkAuditing write FHyperlinkAuditing; // --no-pings + property DisableNewBrowserInfoTimeout : boolean read FDisableNewBrowserInfoTimeout write FDisableNewBrowserInfoTimeout; // --disable-new-browser-info-timeout + property DevToolsProtocolLogFile : ustring read FDevToolsProtocolLogFile write FDevToolsProtocolLogFile; // --devtools-protocol-log-file + property ForcedDeviceScaleFactor : single read FForcedDeviceScaleFactor write FForcedDeviceScaleFactor; // --device-scale-factor + property DisableZygote : boolean read FDisableZygote write FDisableZygote; // --no-zygote + property UseMockKeyChain : boolean read FUseMockKeyChain write FUseMockKeyChain; // --use-mock-keychain + + // Properties used during the CEF initialization + property WindowsSandboxInfo : Pointer read FWindowsSandboxInfo write FWindowsSandboxInfo; + property EnableHighDPISupport : boolean read FEnableHighDPISupport write FEnableHighDPISupport; + + // Custom properties + property DeleteCache : boolean read FDeleteCache write FDeleteCache; + property DeleteCookies : boolean read FDeleteCookies write FDeleteCookies; + property CheckCEFFiles : boolean read FCheckCEFFiles write FCheckCEFFiles; + property ShowMessageDlg : boolean read FShowMessageDlg write FShowMessageDlg; + property MissingBinariesException : boolean read FMissingBinariesException write FMissingBinariesException; + property SetCurrentDir : boolean read FSetCurrentDir write FSetCurrentDir; + property GlobalContextInitialized : boolean read GetGlobalContextInitialized; + property ChromeMajorVer : uint16 read FChromeVersionInfo.MajorVer; + property ChromeMinorVer : uint16 read FChromeVersionInfo.MinorVer; + property ChromeRelease : uint16 read FChromeVersionInfo.Release; + property ChromeBuild : uint16 read FChromeVersionInfo.Build; + property ChromeVersion : ustring read GetChromeVersion; + property LibCefVersion : ustring read GetLibCefVersion; + property LibCefPath : ustring read GetLibCefPath; + property ChromeElfPath : ustring read GetChromeElfPath; + property LibLoaded : boolean read FLibLoaded; + property LogProcessInfo : boolean read FLogProcessInfo write FLogProcessInfo; + property ReRaiseExceptions : boolean read FReRaiseExceptions write FReRaiseExceptions; + property DeviceScaleFactor : single read FDeviceScaleFactor; + property CheckDevToolsResources : boolean read FCheckDevToolsResources write FCheckDevToolsResources; + property LocalesRequired : ustring read FLocalesRequired write FLocalesRequired; + property ProcessType : TCefProcessType read FProcessType; + property MustCreateResourceBundleHandler : boolean read GetMustCreateResourceBundleHandler write FMustCreateResourceBundleHandler; + property MustCreateBrowserProcessHandler : boolean read GetMustCreateBrowserProcessHandler write FMustCreateBrowserProcessHandler; + property MustCreateRenderProcessHandler : boolean read GetMustCreateRenderProcessHandler write FMustCreateRenderProcessHandler; + property MustCreateLoadHandler : boolean read GetMustCreateLoadHandler write FMustCreateLoadHandler; + property MustCreatePrintHandler : boolean read GetMustCreatePrintHandler write FMustCreatePrintHandler; + property OsmodalLoop : boolean write SetOsmodalLoop; + property Status : TCefAplicationStatus read FStatus; + property MissingLibFiles : string read FMissingLibFiles; + property WidevinePath : ustring read FWidevinePath write FWidevinePath; + property MustFreeLibrary : boolean read FMustFreeLibrary write FMustFreeLibrary; + property ChildProcessesCount : integer read GetChildProcessesCount; + property UsedMemory : uint64 read GetUsedMemory; + property TotalSystemMemory : uint64 read GetTotalSystemMemory; + property AvailableSystemMemory : uint64 read GetAvailableSystemMemory; + property SystemMemoryLoad : cardinal read GetSystemMemoryLoad; + property ApiHashUniversal : ustring read GetApiHashUniversal; + property ApiHashPlatform : ustring read GetApiHashPlatform; + property ApiHashCommit : ustring read GetApiHashCommit; + property SupportedSchemes : TStringList read FSupportedSchemes; + property LastErrorMessage : ustring read FLastErrorMessage; + {$IFDEF LINUX} + property XDisplay : PXDisplay read GetXDisplay; + {$ENDIF} + + // ICefApp + property OnRegCustomSchemes : TOnRegisterCustomSchemesEvent read FOnRegisterCustomSchemes write FOnRegisterCustomSchemes; + + // ICefBrowserProcessHandler + property OnGetCookieableSchemes : TOnGetCookieableSchemesEvent read FOnGetCookieableSchemes write FOnGetCookieableSchemes; + property OnContextInitialized : TOnContextInitializedEvent read FOnContextInitialized write FOnContextInitialized; + property OnBeforeChildProcessLaunch : TOnBeforeChildProcessLaunchEvent read FOnBeforeChildProcessLaunch write FOnBeforeChildProcessLaunch; + property OnScheduleMessagePumpWork : TOnScheduleMessagePumpWorkEvent read FOnScheduleMessagePumpWork write FOnScheduleMessagePumpWork; + property OnGetDefaultClient : TOnGetDefaultClientEvent read FOnGetDefaultClient write FOnGetDefaultClient; + + // ICefResourceBundleHandler + property OnGetLocalizedString : TOnGetLocalizedStringEvent read FOnGetLocalizedString write FOnGetLocalizedString; + property OnGetDataResource : TOnGetDataResourceEvent read FOnGetDataResource write FOnGetDataResource; + property OnGetDataResourceForScale : TOnGetDataResourceForScaleEvent read FOnGetDataResourceForScale write FOnGetDataResourceForScale; + + // ICefRenderProcessHandler + property OnWebKitInitialized : TOnWebKitInitializedEvent read FOnWebKitInitialized write FOnWebKitInitialized; + property OnBrowserCreated : TOnBrowserCreatedEvent read FOnBrowserCreated write FOnBrowserCreated; + property OnBrowserDestroyed : TOnBrowserDestroyedEvent read FOnBrowserDestroyed write FOnBrowserDestroyed; + property OnContextCreated : TOnContextCreatedEvent read FOnContextCreated write FOnContextCreated; + property OnContextReleased : TOnContextReleasedEvent read FOnContextReleased write FOnContextReleased; + property OnUncaughtException : TOnUncaughtExceptionEvent read FOnUncaughtException write FOnUncaughtException; + property OnFocusedNodeChanged : TOnFocusedNodeChangedEvent read FOnFocusedNodeChanged write FOnFocusedNodeChanged; + property OnProcessMessageReceived : TOnProcessMessageReceivedEvent read FOnProcessMessageReceived write FOnProcessMessageReceived; + + // ICefRegisterCDMCallback + property OnCDMRegistrationComplete : TOnCDMRegistrationCompleteEvent read FOnCDMRegistrationComplete write FOnCDMRegistrationComplete; + + // ICefLoadHandler + property OnLoadingStateChange : TOnRenderLoadingStateChange read FOnLoadingStateChange write FOnLoadingStateChange; + property OnLoadStart : TOnRenderLoadStart read FOnLoadStart write FOnLoadStart; + property OnLoadEnd : TOnRenderLoadEnd read FOnLoadEnd write FOnLoadEnd; + property OnLoadError : TOnRenderLoadError read FOnLoadError write FOnLoadError; + + // ICefPrintHandler + {$IFDEF LINUX} + property OnPrintStart : TOnPrintStartEvent read FOnPrintStart write FOnPrintStart; + property OnPrintSettings : TOnPrintSettingsEvent read FOnPrintSettings write FOnPrintSettings; + property OnPrintDialog : TOnPrintDialogEvent read FOnPrintDialog write FOnPrintDialog; + property OnPrintJob : TOnPrintJobEvent read FOnPrintJob write FOnPrintJob; + property OnPrintReset : TOnPrintResetEvent read FOnPrintReset write FOnPrintReset; + property OnGetPDFPaperSize : TOnGetPDFPaperSizeEvent read FOnGetPDFPaperSize write FOnGetPDFPaperSize; + {$ENDIF} + end; + + TCEFDirectoryDeleterThread = class(TThread) + protected + FDirectory : string; + + procedure Execute; override; + + public + constructor Create(const aDirectory : string); + end; + +var + GlobalCEFApp : TCefApplicationCore = nil; + +procedure DestroyGlobalCEFApp; + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.Math, System.IOUtils, System.SysUtils, + {$IFDEF MSWINDOWS}WinApi.TlHelp32, WinApi.PSAPI,{$ENDIF} + {$IFDEF LINUX}{$IFDEF FMX}Posix.Unistd, Posix.Stdio,{$ENDIF}{$ENDIF} + {$IFDEF MACOS}Posix.Stdio,{$ENDIF} + {$ELSE} + Math, {$IFDEF DELPHI14_UP}IOUtils,{$ENDIF} SysUtils, + {$IFDEF FPC} + {$IFDEF MSWINDOWS}jwatlhelp32, jwapsapi,{$ENDIF} + {$IFDEF LINUX}lcltype, Forms, InterfaceBase, uCEFLinuxFunctions,{$ENDIF} + {$ELSE} + TlHelp32, {$IFDEF MSWINDOWS}PSAPI,{$ENDIF} + {$ENDIF} + {$ENDIF} + uCEFLibFunctions, uCEFMiscFunctions, uCEFCommandLine, uCEFConstants, + uCEFSchemeHandlerFactory, uCEFCookieManager, uCEFApp, uCEFRegisterCDMCallback, + uCEFCompletionCallback, uCEFWaitableEvent; + +procedure DestroyGlobalCEFApp; +begin + if (GlobalCEFApp <> nil) then FreeAndNil(GlobalCEFApp); +end; + +constructor TCefApplicationCore.Create; +begin + inherited Create; + if GlobalCEFApp = nil then + GlobalCEFApp := Self; + + FStatus := asLoading; + FMissingLibFiles := ''; + FLibHandle := 0; + FCache := ''; + FRootCache := ''; + FUserDataPath := ''; + FUserAgent := ''; + FProductVersion := ''; + FLocale := ''; + FLogFile := ''; + FBrowserSubprocessPath := ''; + FFrameworkDirPath := ''; + {$IFDEF MACOSX} + FMainBundlePath := GetModulePath; + {$ELSE} + FMainBundlePath := ''; + {$ENDIF} + FChromeRuntime := False; + FLogSeverity := LOGSEVERITY_DISABLE; + FJavaScriptFlags := ''; + FResourcesDirPath := ''; + FLocalesDirPath := ''; + FSingleProcess := False; + FNoSandbox := True; + FCommandLineArgsDisabled := False; + FPackLoadingDisabled := False; + FRemoteDebuggingPort := 0; + FUncaughtExceptionStackSize := 0; + FPersistSessionCookies := False; + FPersistUserPreferences := False; + FIgnoreCertificateErrors := False; + FBackgroundColor := 0; + FAcceptLanguageList := ''; + FApplicationClientID := ''; + FWindowsSandboxInfo := nil; + FWindowlessRenderingEnabled := False; + FMultiThreadedMessageLoop := True; + FExternalMessagePump := False; + FDeleteCache := False; + FDeleteCookies := False; + FEnableMediaStream := True; + FEnableSpeechInput := False; + FUseFakeUIForMediaStream := False; + FEnableUsermediaScreenCapturing := False; + FEnableGPU := False; + FCustomCommandLines := nil; + FCustomCommandLineValues := nil; + {$IFDEF MACOSX} + FCheckCEFFiles := False; + {$ELSE} + FCheckCEFFiles := True; + {$ENDIF} + FSmoothScrolling := STATE_DEFAULT; + FFastUnload := False; + FDisableSafeBrowsing := False; + FOnRegisterCustomSchemes := nil; + FEnableHighDPISupport := False; + FMuteAudio := False; + FSitePerProcess := False; + FDisableWebSecurity := False; + FDisablePDFExtension := False; + FDisableSiteIsolationTrials := False; + FDisableChromeLoginPrompt := False; + FLogProcessInfo := False; + FReRaiseExceptions := False; + FLibLoaded := False; + FShowMessageDlg := True; + FMissingBinariesException := False; + FSetCurrentDir := False; + FGlobalContextInitialized := False; + FCheckDevToolsResources := True; + FDisableExtensions := False; + FDisableGPUCache := True; + FLocalesRequired := ''; + FProcessType := ParseProcessType; + FWidevinePath := ''; + FMustFreeLibrary := False; + FAutoplayPolicy := appDefault; + FDisableBackgroundNetworking := False; + FMetricsRecordingOnly := False; + FAllowFileAccessFromFiles := False; + FAllowRunningInsecureContent := False; + FPluginPolicy := PLUGIN_POLICY_SWITCH_ALLOW; + FDefaultEncoding := ''; + FDisableJavascript := False; + FEnableFeatures := ''; + FDisableFeatures := ''; + FEnableBlinkFeatures := ''; + FDisableBlinkFeatures := ''; + FForceFieldTrials := ''; + FForceFieldTrialParams := ''; + FBlinkSettings := ''; + FSupportedSchemes := nil; + FDisableNewBrowserInfoTimeout := False; + FDevToolsProtocolLogFile := ''; + FForcedDeviceScaleFactor := 0; + FDisableZygote := False; + FUseMockKeyChain := False; + FLastErrorMessage := ''; + + FDisableJavascriptCloseWindows := False; + FDisableJavascriptAccessClipboard := False; + FDisableJavascriptDomPaste := False; + FAllowUniversalAccessFromFileUrls := False; + FDisableImageLoading := False; + FImageShrinkStandaloneToFit := False; + FDisableTextAreaResize := False; + FDisableTabToLinks := False; + FDisablePlugins := False; + FEnableProfanityFilter := False; + FDisableSpellChecking := False; + FOverrideSpellCheckLang := ''; + FEnablePrintPreview := False; + FTouchEvents := STATE_DEFAULT; + FDisableReadingFromCanvas := False; + FHyperlinkAuditing := True; + + FMustCreateResourceBundleHandler := False; + FMustCreateBrowserProcessHandler := True; + FMustCreateRenderProcessHandler := False; + FMustCreateLoadHandler := False; + FMustCreatePrintHandler := False; + + // ICefBrowserProcessHandler + FOnGetCookieableSchemes := nil; + FOnContextInitialized := nil; + FOnBeforeChildProcessLaunch := nil; + FOnScheduleMessagePumpWork := nil; + FOnGetDefaultClient := nil; + + // ICefResourceBundleHandler + FOnGetLocalizedString := nil; + FOnGetDataResource := nil; + FOnGetDataResourceForScale := nil; + + // ICefRenderProcessHandler + FOnWebKitInitialized := nil; + FOnBrowserCreated := nil; + FOnBrowserDestroyed := nil; + FOnContextCreated := nil; + FOnContextReleased := nil; + FOnUncaughtException := nil; + FOnFocusedNodeChanged := nil; + FOnProcessMessageReceived := nil; + + // ICefRegisterCDMCallback + FOnCDMRegistrationComplete := nil; + + // ICefLoadHandler + FOnLoadingStateChange := nil; + FOnLoadStart := nil; + FOnLoadEnd := nil; + FOnLoadError := nil; + + // ICefPrintHandler + FOnPrintStart := nil; + FOnPrintSettings := nil; + FOnPrintDialog := nil; + FOnPrintJob := nil; + FOnPrintReset := nil; + FOnGetPDFPaperSize := nil; + + UpdateDeviceScaleFactor; + + FillChar(FAppSettings, SizeOf(TCefSettings), 0); + FAppSettings.size := SizeOf(TCefSettings); + + FChromeVersionInfo.MajorVer := CEF_CHROMEELF_VERSION_MAJOR; + FChromeVersionInfo.MinorVer := CEF_CHROMEELF_VERSION_MINOR; + FChromeVersionInfo.Release := CEF_CHROMEELF_VERSION_RELEASE; + FChromeVersionInfo.Build := CEF_CHROMEELF_VERSION_BUILD; + + {$IFDEF MSWINDOWS} + if (FProcessType = ptBrowser) then + GetDLLVersion(ChromeElfPath, FChromeVersionInfo); + {$ENDIF} + + IsMultiThread := True; + + SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); +end; + +destructor TCefApplicationCore.Destroy; +begin + if (GlobalCEFApp = Self) then + GlobalCEFApp := nil; + + try + if (FProcessType = ptBrowser) then + ShutDown; + + FreeLibcefLibrary; + + if (FCustomCommandLines <> nil) then FreeAndNil(FCustomCommandLines); + if (FCustomCommandLineValues <> nil) then FreeAndNil(FCustomCommandLineValues); + if (FSupportedSchemes <> nil) then FreeAndNil(FSupportedSchemes); + finally + inherited Destroy; + end; +end; + +procedure TCefApplicationCore.AfterConstruction; +begin + inherited AfterConstruction; + + FCustomCommandLines := TStringList.Create; + FCustomCommandLineValues := TStringList.Create; + FSupportedSchemes := TStringList.Create; +end; + +procedure TCefApplicationCore.AddCustomCommandLine(const aCommandLine, aValue : string); +begin + if (FCustomCommandLines <> nil) then FCustomCommandLines.Add(aCommandLine); + if (FCustomCommandLineValues <> nil) then FCustomCommandLineValues.Add(aValue); +end; + +{$IFDEF MACOSX} +{$WARN SYMBOL_PLATFORM OFF} +// This function checks if argv contains +// --framework-dir-path= +// --main-bundle-path= +// It sets the corresponding fields in the config +// This params are passed on Mac. +// The values can also be calculated, instead of calling this procedure +procedure TCefApplicationCore.InitLibLocationFromArgs; +const + PARAM_FRAME_PATH = '--framework-dir-path'; + PARAM_BUNDLE_PATH = '--main-bundle-path'; +type + PCharArray = Array of PAnsiChar; +var + i, l : Integer; + MBPath : ustring; + {$IFDEF FPC} + p : PChar; + TempArgCount : longint; + TempArgValues : PPChar; + {$ELSE} + p : PAnsiChar; + TempArgCount : integer; + TempArgValues : PCharArray; + {$ENDIF} +begin + {$IFDEF FPC} + TempArgCount := argc; + TempArgValues := argv; + {$ELSE} + TempArgCount := ArgCount; + TempArgValues := PCharArray(ArgValues^); + {$ENDIF} + for i := 0 to TempArgCount - 1 do + begin + p := strscan(TempArgValues[i], '='); + if p = nil then continue; + l := p - TempArgValues[i]; + + if (l = Length(PARAM_FRAME_PATH)) and + (strlcomp(TempArgValues[i], PAnsiChar(PARAM_FRAME_PATH), Length(PARAM_FRAME_PATH)) = 0) then + FrameworkDirPath := PChar(TempArgValues[i] + Length(PARAM_FRAME_PATH) + 1); + + if (l = Length(PARAM_BUNDLE_PATH)) and + (strlcomp(TempArgValues[i], PAnsiChar(PARAM_BUNDLE_PATH), Length(PARAM_BUNDLE_PATH)) = 0) then + begin + MBPath := PChar(TempArgValues[i] + Length(PARAM_BUNDLE_PATH) + 1); + MainBundlePath := MBPath; + end; + end; + + if (MBPath <> '') and (FrameworkDirPath = '') then + begin + MBPath := IncludeTrailingPathDelimiter(MBPath) + LIBCEF_PREFIX; + + if FileExists(MBPath + LIBCEF_DLL) then + FrameworkDirPath := MBPath; + end; +end; +{$WARN SYMBOL_PLATFORM ON} +{$ENDIF} + +// This function must only be called by the main executable when the application +// is configured to use a different executable for the subprocesses. +// The process calling ths function must be the browser process. +function TCefApplicationCore.MultiExeProcessing : boolean; +var + TempApp : ICefApp; +begin + Result := False; + TempApp := nil; + + try + try + if (ProcessType = ptBrowser) and + CheckCEFLibrary and + LoadCEFlibrary then + begin + TempApp := TCustomCefApp.Create(self); + + if InitializeLibrary(TempApp) then + Result := True + else + TempApp.RemoveReferences; + end; + except + on e : exception do + if CustomExceptionHandler('TCefApplicationCore.MultiExeProcessing', e) then raise; + end; + finally + TempApp := nil; + end; +end; + +// This function will be called by all processes when the application is configured +// to use the same executable for all the processes : browser, render, etc. +function TCefApplicationCore.SingleExeProcessing : boolean; +var + TempApp : ICefApp; +begin + Result := False; + TempApp := nil; + + try + try + if CheckCEFLibrary and LoadCEFlibrary then + begin + if (FProcessType <> ptBrowser) then + BeforeInitSubProcess; + + TempApp := TCustomCefApp.Create(self); + + if (ExecuteProcess(TempApp) < 0) and + InitializeLibrary(TempApp) then + Result := True + else + TempApp.RemoveReferences; + end; + except + on e : exception do + if CustomExceptionHandler('TCefApplicationCore.SingleExeProcessing', e) then raise; + end; + finally + TempApp := nil; + end; +end; + +procedure TCefApplicationCore.BeforeInitSubProcess; +begin + // Is implemented by TCefApplication +end; + +function TCefApplicationCore.GetChromeVersion : ustring; +begin + Result := FileVersionInfoToString(FChromeVersionInfo); +end; + +function TCefApplicationCore.GetLibCefVersion : ustring; +begin + Result := IntToStr(CEF_SUPPORTED_VERSION_MAJOR) + '.' + + IntToStr(CEF_SUPPORTED_VERSION_MINOR) + '.' + + IntToStr(CEF_SUPPORTED_VERSION_RELEASE) + '.' + + IntToStr(CEF_SUPPORTED_VERSION_BUILD); +end; + +function TCefApplicationCore.GetLibCefPath : ustring; +begin + if (length(FFrameworkDirPath) > 0) then + Result := IncludeTrailingPathDelimiter(FFrameworkDirPath) + LIBCEF_DLL + else + begin + {$IFDEF LINUX} + Result := GetModulePath + LIBCEF_DLL; + {$ELSE} + {$IFDEF MACOSX} + Result := GetModulePath + LIBCEF_PREFIX + LIBCEF_DLL; + {$ELSE} + Result := LIBCEF_DLL; + {$ENDIF} + {$ENDIF} + end; +end; + +function TCefApplicationCore.GetChromeElfPath : ustring; +begin + if (length(FFrameworkDirPath) > 0) then + Result := IncludeTrailingPathDelimiter(FFrameworkDirPath) + CHROMEELF_DLL + else + Result := CHROMEELF_DLL; +end; + +function TCefApplicationCore.GetLocalesDirPath: ustring; +begin + Result := FLocalesDirPath; + {$IFNDEF MACOSX} + if (Result = '') and (FrameworkDirPath <> '') then + begin + if FileExists(IncludeTrailingPathDelimiter(FrameworkDirPath + LIBCEF_LOCALE_DIR) + LIBCEF_LOCALE_ENUS) then + Result := FrameworkDirPath + LIBCEF_LOCALE_DIR; + end; + {$ENDIF} +end; + +function TCefApplicationCore.GetResourcesDirPath: ustring; +begin + Result := FResourcesDirPath; + {$IFNDEF MACOSX} + if (Result = '') and (FrameworkDirPath <> '') then + begin + if FileExists(IncludeTrailingPathDelimiter(FrameworkDirPath) + LIBCEF_PAK) then + Result := FrameworkDirPath; + end; + {$ENDIF} +end; + +procedure TCefApplicationCore.SetCache(const aValue : ustring); +begin + FCache := CustomAbsolutePath(aValue); + FDisableGPUCache := (length(FCache) = 0); +end; + +procedure TCefApplicationCore.SetRootCache(const aValue : ustring); +begin + FRootCache := CustomAbsolutePath(aValue); +end; + +procedure TCefApplicationCore.SetUserDataPath(const aValue : ustring); +begin + FUserDataPath := CustomAbsolutePath(aValue); +end; + +procedure TCefApplicationCore.SetBrowserSubprocessPath(const aValue : ustring); +begin + FBrowserSubprocessPath := CustomAbsolutePath(aValue); +end; + +procedure TCefApplicationCore.SetFrameworkDirPath(const aValue : ustring); +begin + FFrameworkDirPath := CustomAbsolutePath(aValue, True); + + {$IFDEF MSWINDOWS} + if (FProcessType = ptBrowser) then GetDLLVersion(ChromeElfPath, FChromeVersionInfo); + {$ENDIF} +end; + +procedure TCefApplicationCore.SetResourcesDirPath(const aValue : ustring); +begin + FResourcesDirPath := CustomAbsolutePath(aValue, True); +end; + +procedure TCefApplicationCore.SetLocalesDirPath(const aValue : ustring); +begin + FLocalesDirPath := CustomAbsolutePath(aValue, True); +end; + +function TCefApplicationCore.CheckCEFResources : boolean; +var + TempMissingFrm, TempMissingRsc, TempMissingLoc, TempMissingSubProc : boolean; +begin + Result := False; + + TempMissingSubProc := not(CheckSubprocessPath(FBrowserSubprocessPath, FMissingLibFiles)); + TempMissingFrm := not(CheckDLLs(FFrameworkDirPath, FMissingLibFiles)); + TempMissingRsc := not(CheckResources(ResourcesDirPath, FMissingLibFiles, FCheckDevToolsResources, not(FDisableExtensions))); + TempMissingLoc := not(CheckLocales(LocalesDirPath, FMissingLibFiles, FLocalesRequired)); + + if TempMissingFrm or TempMissingRsc or TempMissingLoc or TempMissingSubProc then + begin + FStatus := asErrorMissingFiles; + FLastErrorMessage := 'CEF binaries missing !'; + + if (length(FMissingLibFiles) > 0) then + FLastErrorMessage := FLastErrorMessage + CRLF + CRLF + + 'The missing files are :' + CRLF + + trim(FMissingLibFiles); + + ShowErrorMessageDlg(FLastErrorMessage); + end + else + Result := True; +end; + +{$IFDEF MSWINDOWS} +function TCefApplicationCore.CheckCEFDLL : boolean; +var + TempMachine : integer; + TempVersionInfo : TFileVersionInfo; +begin + Result := False; + + if CheckDLLVersion(LibCefPath, + CEF_SUPPORTED_VERSION_MAJOR, + CEF_SUPPORTED_VERSION_MINOR, + CEF_SUPPORTED_VERSION_RELEASE, + CEF_SUPPORTED_VERSION_BUILD) then + begin + if GetDLLHeaderMachine(LibCefPath, TempMachine) then + case TempMachine of + CEF_IMAGE_FILE_MACHINE_I386 : + if Is32BitProcess then + Result := True + else + begin + FStatus := asErrorDLLVersion; + FLastErrorMessage := 'Wrong CEF binaries !' + + CRLF + CRLF + + 'Use the 32 bit CEF binaries with 32 bits applications only.'; + + ShowErrorMessageDlg(FLastErrorMessage); + end; + + CEF_IMAGE_FILE_MACHINE_AMD64 : + if not(Is32BitProcess) then + Result := True + else + + begin + FStatus := asErrorDLLVersion; + FLastErrorMessage := 'Wrong CEF binaries !' + + CRLF + CRLF + + 'Use the 64 bit CEF binaries with 64 bits applications only.'; + + ShowErrorMessageDlg(FLastErrorMessage); + end; + + else + begin + FStatus := asErrorDLLVersion; + FLastErrorMessage := 'Unknown CEF binaries !' + + CRLF + CRLF + + 'Use only the CEF binaries specified in the CEF4Delphi Readme.md file at ' + + CEF4DELPHI_URL; + + ShowErrorMessageDlg(FLastErrorMessage); + end; + end + else + Result := True; + end + else + begin + FStatus := asErrorDLLVersion; + FLastErrorMessage := 'Unsupported CEF version !' + + CRLF + CRLF + + 'Use only the CEF binaries specified in the CEF4Delphi Readme.md file at ' + + CEF4DELPHI_URL; + + if GetDLLVersion(LibCefPath, TempVersionInfo) then + FLastErrorMessage := FLastErrorMessage + CRLF + CRLF + + 'Expected ' + LIBCEF_DLL + ' version : ' + LibCefVersion + CRLF + + 'Found ' + LIBCEF_DLL + ' version : ' + FileVersionInfoToString(TempVersionInfo); + + ShowErrorMessageDlg(FLastErrorMessage); + end; +end; +{$ENDIF} + +function TCefApplicationCore.CheckCEFLibrary : boolean; +var + TempOldDir : string; +begin + if not(FCheckCEFFiles) or (FProcessType <> ptBrowser) then + begin + Result := True; + exit; + end; + + if FSetCurrentDir then + begin + TempOldDir := GetCurrentDir; + chdir(GetModulePath); + end; + + Result := CheckCEFResources + {$IFDEF MSWINDOWS}and CheckCEFDLL{$ENDIF}; + + if FSetCurrentDir then chdir(TempOldDir); +end; + +function TCefApplicationCore.StartMainProcess : boolean; +begin + if (FStatus <> asLoading) then + Result := False + else + {$IFDEF MACOSX} + Result := MultiExeProcessing; + {$ELSE} + if not(FSingleProcess) and (length(FBrowserSubprocessPath) > 0) then + Result := MultiExeProcessing + else + Result := SingleExeProcessing; + {$ENDIF} +end; + +// This function can only be called by the executable used for the subprocesses. +// The application must be configured to use different executables for the subprocesses. +// The process calling this function can't be the browser process. +function TCefApplicationCore.StartSubProcess : boolean; +var + TempApp : ICefApp; +begin + Result := False; + TempApp := nil; + + try + try + if not(FSingleProcess) and + (ProcessType <> ptBrowser) and + LoadCEFlibrary then + begin + TempApp := TCustomCefApp.Create(self); + + if (ExecuteProcess(TempApp) >= 0) then + Result := True + else + TempApp.RemoveReferences; + end; + except + on e : exception do + if CustomExceptionHandler('TCefApplicationCore.StartSubProcess', e) then raise; + end; + finally + TempApp := nil; + end; +end; + +procedure TCefApplicationCore.DoMessageLoopWork; +begin + if FLibLoaded and + not(FMultiThreadedMessageLoop) and + FExternalMessagePump then + cef_do_message_loop_work(); +end; + +procedure TCefApplicationCore.RunMessageLoop; +begin + if FLibLoaded and + not(FMultiThreadedMessageLoop) and + not(FExternalMessagePump) then + cef_run_message_loop(); +end; + +procedure TCefApplicationCore.QuitMessageLoop; +begin + if FLibLoaded and + not(FMultiThreadedMessageLoop) and + not(FExternalMessagePump) then + cef_quit_message_loop(); +end; + +procedure TCefApplicationCore.SetOsmodalLoop(aValue : boolean); +begin + if (FStatus = asInitialized) then cef_set_osmodal_loop(Ord(aValue)); +end; + +procedure TCefApplicationCore.UpdateDeviceScaleFactor; +begin + if (FForcedDeviceScaleFactor <> 0) then + FDeviceScaleFactor := FForcedDeviceScaleFactor + else + FDeviceScaleFactor := GetDeviceScaleFactor; +end; + +procedure TCefApplicationCore.ShutDown; +begin + try + if (FStatus = asInitialized) then + begin + FStatus := asShuttingDown; + cef_shutdown(); + end; + except + on e : exception do + if CustomExceptionHandler('TCefApplicationCore.ShutDown', e) then raise; + end; +end; + +procedure TCefApplicationCore.FreeLibcefLibrary; +begin + try + try + if FMustFreeLibrary and (FLibHandle <> 0) then FreeLibrary(FLibHandle); + except + on e : exception do + if CustomExceptionHandler('TCefApplicationCore.FreeLibcefLibrary', e) then raise; + end; + finally + FLibHandle := 0; + FLibLoaded := False; + FStatus := asUnloaded; + end; +end; + +function TCefApplicationCore.ExecuteProcess(const aApp : ICefApp) : integer; +var + TempArgs : TCefMainArgs; +begin + Result := -1; + try + if (aApp <> nil) then + begin + {$WARN SYMBOL_PLATFORM OFF} + {$IFDEF MSWINDOWS} + TempArgs.instance := HINSTANCE{$IFDEF FPC}(){$ENDIF}; + {$ELSE} + {$IFDEF FPC} + TempArgs.argc := argc; + TempArgs.argv := argv; + {$ELSE} + TempArgs.argc := ArgCount; + TempArgs.argv := PPWideChar(ArgValues); + {$ENDIF} + {$ENDIF} + {$WARN SYMBOL_PLATFORM ON} + Result := cef_execute_process(@TempArgs, aApp.Wrap, FWindowsSandboxInfo); + end; + except + on e : exception do + begin + FStatus := asErrorExecutingProcess; + if CustomExceptionHandler('TCefApplicationCore.ExecuteProcess', e) then raise; + end; + end; +end; + +procedure TCefApplicationCore.InitializeSettings(var aSettings : TCefSettings); +begin + aSettings.size := SizeOf(TCefSettings); + aSettings.no_sandbox := Ord(FNoSandbox); + aSettings.browser_subprocess_path := CefString(FBrowserSubprocessPath); + aSettings.framework_dir_path := CefString(FFrameworkDirPath); + aSettings.main_bundle_path := CefString(FMainBundlePath); + aSettings.chrome_runtime := Ord(FChromeRuntime); + aSettings.multi_threaded_message_loop := Ord(FMultiThreadedMessageLoop); + aSettings.external_message_pump := Ord(FExternalMessagePump); + aSettings.windowless_rendering_enabled := Ord(FWindowlessRenderingEnabled); + aSettings.command_line_args_disabled := Ord(FCommandLineArgsDisabled); + aSettings.cache_path := CefString(FCache); + aSettings.root_cache_path := CefString(FRootCache); + aSettings.user_data_path := CefString(FUserDataPath); + aSettings.persist_session_cookies := Ord(FPersistSessionCookies); + aSettings.persist_user_preferences := Ord(FPersistUserPreferences); + aSettings.user_agent := CefString(FUserAgent); + aSettings.product_version := CefString(FProductVersion); + aSettings.locale := CefString(FLocale); + aSettings.log_file := CefString(FLogFile); + aSettings.log_severity := FLogSeverity; + aSettings.javascript_flags := CefString(FJavaScriptFlags); + aSettings.resources_dir_path := CefString(ResourcesDirPath); + aSettings.locales_dir_path := CefString(LocalesDirPath); + aSettings.pack_loading_disabled := Ord(FPackLoadingDisabled); + aSettings.remote_debugging_port := FRemoteDebuggingPort; + aSettings.uncaught_exception_stack_size := FUncaughtExceptionStackSize; + aSettings.ignore_certificate_errors := Ord(FIgnoreCertificateErrors); + aSettings.background_color := FBackgroundColor; + aSettings.accept_language_list := CefString(FAcceptLanguageList); + aSettings.application_client_id_for_file_scanning := CefString(FApplicationClientID); +end; + +function TCefApplicationCore.InitializeLibrary(const aApp : ICefApp) : boolean; +var + TempArgs : TCefMainArgs; +begin + Result := False; + + try + try + if (aApp <> nil) then + begin + if FDeleteCache and FDeleteCookies then + RenameAndDeleteDir(FCache) + else + if FDeleteCookies then + DeleteCookiesDB(FCache) + else + if FDeleteCache then + RenameAndDeleteDir(FCache, True); + + RegisterWidevineCDM; + + InitializeSettings(FAppSettings); + + {$IFDEF MSWINDOWS} + TempArgs.instance := HINSTANCE{$IFDEF FPC}(){$ENDIF}; + {$ELSE} + {$WARN SYMBOL_PLATFORM OFF} + {$IFDEF FPC} + TempArgs.argc := argc; + TempArgs.argv := argv; + {$ELSE} + TempArgs.argc := ArgCount; + TempArgs.argv := PPWideChar(ArgValues); + {$ENDIF} + {$WARN SYMBOL_PLATFORM ON} + {$ENDIF} + + if (cef_initialize(@TempArgs, @FAppSettings, aApp.Wrap, FWindowsSandboxInfo) <> 0) then + begin + Result := True; + FStatus := asInitialized; + end; + end; + except + on e : exception do + if CustomExceptionHandler('TCefApplicationCore.InitializeLibrary', e) then raise; + end; + finally + if not(Result) then FStatus := asErrorInitializingLibrary; + end; +end; + +procedure TCefApplicationCore.DeleteCacheContents(const aDirectory : string); +var + TempFiles : TStringList; +begin + TempFiles := TStringList.Create; + + try + TempFiles.Add('Cookies'); + TempFiles.Add('Cookies-journal'); + TempFiles.Add('LocalPrefs.json'); + + DeleteDirContents(aDirectory, TempFiles); + finally + FreeAndNil(TempFiles); + end; +end; + +procedure TCefApplicationCore.DeleteCookiesDB(const aDirectory : string); +var + TempFiles : TStringList; +begin + TempFiles := TStringList.Create; + + try + TempFiles.Add(IncludeTrailingPathDelimiter(aDirectory) + 'Cookies'); + TempFiles.Add(IncludeTrailingPathDelimiter(aDirectory) + 'Cookies-journal'); + + DeleteFileList(TempFiles); + finally + FreeAndNil(TempFiles); + end; +end; + +procedure TCefApplicationCore.MoveCookiesDB(const aSrcDirectory, aDstDirectory : string); +var + TempFiles : TStringList; +begin + TempFiles := TStringList.Create; + + try + TempFiles.Add('Cookies'); + TempFiles.Add('Cookies-journal'); + + MoveFileList(TempFiles, aSrcDirectory, aDstDirectory); + finally + FreeAndNil(TempFiles); + end; +end; + +procedure TCefApplicationCore.RenameAndDeleteDir(const aDirectory : string; aKeepCookies : boolean); +var + TempOldDir, TempNewDir : string; + i : integer; + TempThread : TCEFDirectoryDeleterThread; +begin + try + if (length(aDirectory) = 0) or not(DirectoryExists(aDirectory)) then exit; + + TempOldDir := ExcludeTrailingPathDelimiter(aDirectory); + + if (Pos(PathDelim, TempOldDir) > 0) and + (length(ExtractFileName(TempOldDir)) > 0) then + begin + i := 0; + + repeat + inc(i); + TempNewDir := TempOldDir + '(' + inttostr(i) + ')'; + until not(DirectoryExists(TempNewDir)); + + if RenameFile(TempOldDir, TempNewDir) then + begin + if aKeepCookies then MoveCookiesDB(TempNewDir, TempOldDir); + + TempThread := TCEFDirectoryDeleterThread.Create(TempNewDir); + {$IFDEF DELPHI14_UP} + TempThread.Start; + {$ELSE} + {$IFNDEF FPC} + TempThread.Resume; + {$ELSE} + TempThread.Start; + {$ENDIF} + {$ENDIF} + end + else + if aKeepCookies then + DeleteCacheContents(aDirectory) + else + DeleteDirContents(aDirectory); + end + else + if aKeepCookies then + DeleteCacheContents(aDirectory) + else + DeleteDirContents(aDirectory); + except + on e : exception do + if CustomExceptionHandler('TCefApplicationCore.RenameAndDeleteDir', e) then raise; + end; +end; + +procedure TCefApplicationCore.RegisterWidevineCDM; +var + TempPath : TCefString; + TempCallback : ICefRegisterCDMCallback; +begin + try + try + if FLibLoaded and (length(FWidevinePath) > 0) and DirectoryExists(FWidevinePath) then + begin + TempPath := CefString(FWidevinePath); + TempCallback := TCefCustomRegisterCDMCallback.Create(self); + + cef_register_widevine_cdm(@TempPath, TempCallback.Wrap); + end; + except + on e : exception do + if CustomExceptionHandler('TCefApplicationCore.RegisterWidevineCDM', e) then raise; + end; + finally + TempCallback := nil; + end; +end; + +procedure TCefApplicationCore.ShowErrorMessageDlg(const aError : string); +begin + OutputDebugMessage(aError); + + if FShowMessageDlg then + begin + {$IFDEF MSWINDOWS} + MessageBox(0, PChar(aError + #0), PChar('Error' + #0), MB_ICONERROR or MB_OK or MB_TOPMOST); + {$ELSE} + {$IFDEF LINUX} + {$IFDEF FPC} + if (WidgetSet <> nil) then + Application.MessageBox(PChar(aError + #0), PChar('Error' + #0), MB_ICONERROR or MB_OK) + else + ShowX11Message(aError); + {$ENDIF} + {$ENDIF} + {$ENDIF} + end; + + if FMissingBinariesException then + raise Exception.Create(aError); +end; + +procedure TCefApplicationCore.UpdateSupportedSchemes(aIncludeDefaults : boolean); +var + TempManager : ICefCookieManager; +begin + try + if (FSupportedSchemes <> nil) and + (FSupportedSchemes.Count > 0) then + begin + TempManager := TCefCookieManagerRef.Global(nil); + + if (TempManager <> nil) then + TempManager.SetSupportedSchemes(FSupportedSchemes, aIncludeDefaults, nil); + end; + finally + TempManager := nil; + end; +end; + +function TCefApplicationCore.ParseProcessType : TCefProcessType; +const + TYPE_PARAMETER_NAME = '--type='; +var + i, TempLen : integer; + TempName, TempValue : string; +begin + Result := ptBrowser; + i := paramCount; + TempLen := length(TYPE_PARAMETER_NAME); + + while (i >= 1) and (Result = ptBrowser) do + begin + TempName := copy(paramstr(i), 1, TempLen); + + if (CompareText(TempName, TYPE_PARAMETER_NAME) = 0) then + begin + TempValue := copy(paramstr(i), succ(TempLen), length(paramstr(i))); + + if (CompareText(TempValue, 'renderer') = 0) then + Result := ptRenderer + else + if (CompareText(TempValue, 'zygote') = 0) then + Result := ptZygote + else + if (CompareText(TempValue, 'gpu-process') = 0) then + Result := ptGPU + else + if (CompareText(TempValue, 'utility') = 0) then + Result := ptUtility + else + if (CompareText(TempValue, 'broker') = 0) then + Result := ptBroker + else + Result := ptOther; + end; + + dec(i); + end; +end; + +procedure TCefApplicationCore.Internal_OnContextInitialized; +begin + FGlobalContextInitialized := True; + UpdateSupportedSchemes; + + if assigned(FOnContextInitialized) then + FOnContextInitialized(); +end; + +procedure TCefApplicationCore.Internal_OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); +begin + if assigned(FOnBeforeChildProcessLaunch) then + FOnBeforeChildProcessLaunch(commandLine); +end; + +procedure TCefApplicationCore.Internal_OnScheduleMessagePumpWork(const delayMs: Int64); +begin + if assigned(FOnScheduleMessagePumpWork) then + FOnScheduleMessagePumpWork(delayMs); +end; + +function TCefApplicationCore.Internal_GetLocalizedString(stringid: Integer; var stringVal: ustring) : boolean; +begin + Result := False; + + // The stringId must be one of the values defined in the CEF file : + // /include/cef_pack_strings.h + // That file is available in the CEF binaries package. + if assigned(FOnGetLocalizedString) then + FOnGetLocalizedString(stringId, stringVal, Result); +end; + +function TCefApplicationCore.Internal_GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt) : boolean; +begin + Result := False; + + // The resourceId must be one of the values defined in the CEF file : + // /include/cef_pack_resources.h + // That file is available in the CEF binaries package. + if assigned(FOnGetDataResource) then + FOnGetDataResource(resourceId, data, dataSize, Result); +end; + +function TCefApplicationCore.Internal_GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt) : boolean; +begin + Result := False; + + // The resourceId must be one of the values defined in the CEF file : + // /include/cef_pack_resources.h + // That file is available in the CEF binaries package. + if assigned(FOnGetDataResourceForScale) then + FOnGetDataResourceForScale(resourceId, scaleFactor, data, dataSize, Result); +end; + +procedure TCefApplicationCore.Internal_OnWebKitInitialized; +begin + if assigned(FOnWebKitInitialized) then + FOnWebKitInitialized(); +end; + +procedure TCefApplicationCore.Internal_OnBrowserCreated(const browser: ICefBrowser; const extra_info: ICefDictionaryValue); +begin + if assigned(FOnBrowserCreated) then + FOnBrowserCreated(browser, extra_info); +end; + +procedure TCefApplicationCore.Internal_OnBrowserDestroyed(const browser: ICefBrowser); +begin + if assigned(FOnBrowserDestroyed) then + FOnBrowserDestroyed(browser); +end; + +procedure TCefApplicationCore.Internal_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); +begin + if assigned(FOnContextCreated) then + FOnContextCreated(browser, frame, context); +end; + +procedure TCefApplicationCore.Internal_OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); +begin + if assigned(FOnContextReleased) then + FOnContextReleased(browser, frame, context); +end; + +procedure TCefApplicationCore.Internal_OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); +begin + if assigned(FOnUncaughtException) then + FOnUncaughtException(browser, frame, context, exception, stackTrace); +end; + +procedure TCefApplicationCore.Internal_OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); +begin + if assigned(FOnFocusedNodeChanged) then + FOnFocusedNodeChanged(browser, frame, node); +end; + +procedure TCefApplicationCore.Internal_OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage; var aHandled : boolean); +begin + if assigned(FOnProcessMessageReceived) then + FOnProcessMessageReceived(browser, frame, sourceProcess, aMessage, aHandled) + else + aHandled := False; +end; + +procedure TCefApplicationCore.Internal_OnCDMRegistrationComplete(result : TCefCDMRegistrationError; const error_message : ustring); +begin + if assigned(FOnCDMRegistrationComplete) then + FOnCDMRegistrationComplete(result, error_message); +end; + +procedure TCefApplicationCore.Internal_OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); +begin + if assigned(FOnLoadingStateChange) then + FOnLoadingStateChange(browser, isLoading, canGoBack, canGoForward); +end; + +procedure TCefApplicationCore.Internal_OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); +begin + if assigned(FOnLoadStart) then + FOnLoadStart(browser, frame, transitionType); +end; + +procedure TCefApplicationCore.Internal_OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); +begin + if assigned(FOnLoadEnd) then + FOnLoadEnd(browser, frame, httpStatusCode); +end; + +procedure TCefApplicationCore.Internal_OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); +begin + if assigned(FOnLoadError) then + FOnLoadError(browser, frame, errorCode, errorText, failedUrl); +end; + +procedure TCefApplicationCore.Internal_GetCookieableSchemes(var schemes: TStringList; var include_defaults : boolean); +begin + if assigned(FOnGetCookieableSchemes) then + FOnGetCookieableSchemes(schemes, include_defaults); +end; + +procedure TCefApplicationCore.Internal_GetDefaultClient(var aClient : ICefClient); +begin + if assigned(FOnGetDefaultClient) then + FOnGetDefaultClient(aClient); +end; + +procedure TCefApplicationCore.Internal_OnPrintStart(const browser: ICefBrowser); +begin + if assigned(FOnPrintStart) then + FOnPrintStart(browser); +end; + +procedure TCefApplicationCore.Internal_OnPrintSettings(const browser: ICefBrowser; const settings: ICefPrintSettings; getDefaults: boolean); +begin + if assigned(FOnPrintSettings) then + FOnPrintSettings(browser, settings, getDefaults); +end; + +procedure TCefApplicationCore.Internal_OnPrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult : boolean); +begin + if assigned(FOnPrintDialog) then + FOnPrintDialog(browser, hasSelection, callback, aResult); +end; + +procedure TCefApplicationCore.Internal_OnPrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult : boolean); +begin + if assigned(FOnPrintJob) then + FOnPrintJob(browser, documentName, PDFFilePath, callback, aResult); +end; + +procedure TCefApplicationCore.Internal_OnPrintReset(const browser: ICefBrowser); +begin + if assigned(FOnPrintReset) then + FOnPrintReset(browser); +end; + +procedure TCefApplicationCore.Internal_OnGetPDFPaperSize(deviceUnitsPerInch: Integer; var aResult : TCefSize); +begin + if assigned(FOnGetPDFPaperSize) then + FOnGetPDFPaperSize(deviceUnitsPerInch, aResult); +end; + +procedure TCefApplicationCore.AppendSwitch(var aKeys, aValues : TStringList; const aNewKey, aNewValue : ustring); +var + TempKey, TempHyphenatedKey : ustring; + i : integer; +begin + if (copy(aNewKey, 1, 2) = '--') then + begin + TempHyphenatedKey := aNewKey; + TempKey := copy(aNewKey, 3, length(aNewKey)); + end + else + begin + TempHyphenatedKey := '--' + aNewKey; + TempKey := aNewKey; + end; + + i := aKeys.IndexOf(TempKey); + + if (i < 0) then + begin + i := aKeys.IndexOf(TempHyphenatedKey); + + if (i < 0) then + begin + aKeys.Add(aNewKey); + aValues.Add(aNewValue); + exit; + end; + end; + + if (length(aNewValue) > 0) then + begin + if (length(aValues[i]) > 0) then + aValues[i] := aValues[i] + ',' + aNewValue + else + aValues[i] := aNewValue; + end; +end; + +procedure TCefApplicationCore.CleanupFeatures(var aKeys, aValues : TStringList; const aEnableKey, aDisableKey : string); +var + i, j, k, n : integer; + TempEnabledValues, TempDisabledValues : TStringList; + TempEnableKey, TempHyphenatedEnableKey, TempDisableKey, TempHyphenatedDisableKey : ustring; +begin + if (copy(aEnableKey, 1, 2) = '--') then + begin + TempHyphenatedEnableKey := aEnableKey; + TempEnableKey := copy(aEnableKey, 3, length(aEnableKey)); + end + else + begin + TempHyphenatedEnableKey := '--' + aEnableKey; + TempEnableKey := aEnableKey; + end; + + if (copy(aDisableKey, 1, 2) = '--') then + begin + TempHyphenatedDisableKey := aDisableKey; + TempDisableKey := copy(aDisableKey, 3, length(aDisableKey)); + end + else + begin + TempHyphenatedDisableKey := '--' + aDisableKey; + TempDisableKey := aDisableKey; + end; + + i := aKeys.IndexOf(TempEnableKey); + if (i < 0) then i := aKeys.IndexOf(TempHyphenatedEnableKey); + + j := aKeys.IndexOf(TempDisableKey); + if (j < 0) then j := aKeys.IndexOf(TempHyphenatedDisableKey); + + if (i < 0) or (j < 0) then exit; + + TempEnabledValues := TStringList.Create; + TempDisabledValues := TStringList.Create; + TempEnabledValues.CommaText := aValues[i]; + TempDisabledValues.CommaText := aValues[j]; + + k := 0; + while (k < TempDisabledValues.Count) do + begin + if (length(TempDisabledValues[k]) > 0) then + begin + n := TempEnabledValues.IndexOf(TempDisabledValues[k]); + if (n >= 0) then TempEnabledValues.Delete(n); + end; + + inc(k); + end; + + if (TempEnabledValues.Count > 0) then + aValues[i] := TempEnabledValues.CommaText + else + begin + aKeys.Delete(i); + aValues.Delete(i); + end; + + FreeAndNil(TempEnabledValues); + FreeAndNil(TempDisabledValues); +end; + +procedure TCefApplicationCore.ReplaceSwitch(var aKeys, aValues : TStringList; const aNewKey, aNewValue : ustring); +var + TempKey, TempHyphenatedKey : ustring; + i : integer; +begin + if (copy(aNewKey, 1, 2) = '--') then + begin + TempHyphenatedKey := aNewKey; + TempKey := copy(aNewKey, 3, length(aNewKey)); + end + else + begin + TempHyphenatedKey := '--' + aNewKey; + TempKey := aNewKey; + end; + + i := aKeys.IndexOf(TempKey); + + if (i < 0) then + begin + i := aKeys.IndexOf(TempHyphenatedKey); + + if (i < 0) then + begin + aKeys.Add(aNewKey); + aValues.Add(aNewValue); + end + else + aValues[i] := aNewValue; + end + else + aValues[i] := aNewValue; +end; + +procedure TCefApplicationCore.AddCustomCommandLineSwitches(var aKeys, aValues : TStringList); +var + i : integer; + TempFormatSettings : TFormatSettings; +begin + ReplaceSwitch(aKeys, aValues, '--enable-media-stream', IntToStr(Ord(FEnableMediaStream))); + + if FEnableSpeechInput then + ReplaceSwitch(aKeys, aValues, '--enable-speech-input'); + + if FUseFakeUIForMediaStream then + ReplaceSwitch(aKeys, aValues, '--use-fake-ui-for-media-stream'); + + if FEnableUsermediaScreenCapturing then + ReplaceSwitch(aKeys, aValues, '--enable-usermedia-screen-capturing'); + + if not(FEnableGPU) then + begin + ReplaceSwitch(aKeys, aValues, '--disable-gpu'); + ReplaceSwitch(aKeys, aValues, '--disable-gpu-compositing'); + end; + + if FSingleProcess then + ReplaceSwitch(aKeys, aValues, '--single-process'); + + case FSmoothScrolling of + STATE_ENABLED : ReplaceSwitch(aKeys, aValues, '--enable-smooth-scrolling'); + STATE_DISABLED : ReplaceSwitch(aKeys, aValues, '--disable-smooth-scrolling'); + end; + + case FTouchEvents of + STATE_ENABLED : ReplaceSwitch(aKeys, aValues, '--touch-events', 'enabled'); + STATE_DISABLED : ReplaceSwitch(aKeys, aValues, '--touch-events', 'disabled'); + end; + + if FDisableReadingFromCanvas then + ReplaceSwitch(aKeys, aValues, '--disable-reading-from-canvas'); + + if not(FHyperlinkAuditing) then + ReplaceSwitch(aKeys, aValues, '--no-pings'); + + case FAutoplayPolicy of + appDocumentUserActivationRequired : + ReplaceSwitch(aKeys, aValues, '--autoplay-policy', 'document-user-activation-required'); + + appNoUserGestureRequired : + ReplaceSwitch(aKeys, aValues, '--autoplay-policy', 'no-user-gesture-required'); + + appUserGestureRequired : + ReplaceSwitch(aKeys, aValues, '--autoplay-policy', 'user-gesture-required'); + end; + + if FFastUnload then + ReplaceSwitch(aKeys, aValues, '--enable-fast-unload'); + + if FDisableGPUCache then + ReplaceSwitch(aKeys, aValues, '--disable-gpu-shader-disk-cache'); + + if FDisableSafeBrowsing then + begin + ReplaceSwitch(aKeys, aValues, '--disable-client-side-phishing-detection'); + ReplaceSwitch(aKeys, aValues, '--safebrowsing-disable-auto-update'); + ReplaceSwitch(aKeys, aValues, '--safebrowsing-disable-download-protection'); + end; + + if FMuteAudio then + ReplaceSwitch(aKeys, aValues, '--mute-audio'); + + if FDisableWebSecurity then + ReplaceSwitch(aKeys, aValues, '--disable-web-security'); + + if FDisablePDFExtension then + ReplaceSwitch(aKeys, aValues, '--disable-pdf-extension'); + + if FDisableSiteIsolationTrials then + ReplaceSwitch(aKeys, aValues, '--disable-site-isolation-trials'); + + if FDisableChromeLoginPrompt then + ReplaceSwitch(aKeys, aValues, '--disable-chrome-login-prompt'); + + if FSitePerProcess then + ReplaceSwitch(aKeys, aValues, '--site-per-process'); + + if FDisableExtensions then + ReplaceSwitch(aKeys, aValues, '--disable-extensions'); + + if FDisableBackgroundNetworking then + ReplaceSwitch(aKeys, aValues, '--disable-background-networking'); + + if FMetricsRecordingOnly then + ReplaceSwitch(aKeys, aValues, '--metrics-recording-only'); + + if FAllowFileAccessFromFiles then + ReplaceSwitch(aKeys, aValues, '--allow-file-access-from-files'); + + if FAllowRunningInsecureContent then + ReplaceSwitch(aKeys, aValues, '--allow-running-insecure-content'); + + if FEnablePrintPreview then + ReplaceSwitch(aKeys, aValues, '--enable-print-preview'); + + if FDisableNewBrowserInfoTimeout then + ReplaceSwitch(aKeys, aValues, '--disable-new-browser-info-timeout'); + + if (length(FDevToolsProtocolLogFile) > 0) then + ReplaceSwitch(aKeys, aValues, '--devtools-protocol-log-file', FDevToolsProtocolLogFile); + + case FPluginPolicy of + PLUGIN_POLICY_SWITCH_DETECT : ReplaceSwitch(aKeys, aValues, '--plugin-policy', 'detect'); + PLUGIN_POLICY_SWITCH_BLOCK : ReplaceSwitch(aKeys, aValues, '--plugin-policy', 'block'); + end; + + if (length(FDefaultEncoding) > 0) then + ReplaceSwitch(aKeys, aValues, '--default-encoding', FDefaultEncoding); + + if FDisableJavascript then + ReplaceSwitch(aKeys, aValues, '--disable-javascript'); + + if FDisableJavascriptCloseWindows then + ReplaceSwitch(aKeys, aValues, '--disable-javascript-close-windows'); + + if FDisableJavascriptAccessClipboard then + ReplaceSwitch(aKeys, aValues, '--disable-javascript-access-clipboard'); + + if FDisableJavascriptDomPaste then + ReplaceSwitch(aKeys, aValues, '--disable-javascript-dom-paste'); + + if FAllowUniversalAccessFromFileUrls then + ReplaceSwitch(aKeys, aValues, '--allow-universal-access-from-files'); + + if FDisableImageLoading then + ReplaceSwitch(aKeys, aValues, '--disable-image-loading'); + + if FImageShrinkStandaloneToFit then + ReplaceSwitch(aKeys, aValues, '--image-shrink-standalone-to-fit'); + + if FDisableTextAreaResize then + ReplaceSwitch(aKeys, aValues, '--disable-text-area-resize'); + + if FDisableTabToLinks then + ReplaceSwitch(aKeys, aValues, '--disable-tab-to-links'); + + if FDisablePlugins then + ReplaceSwitch(aKeys, aValues, '--disable-plugins'); + + if FEnableProfanityFilter then + ReplaceSwitch(aKeys, aValues, '--enable-profanity-filter'); + + if FDisableSpellChecking then + ReplaceSwitch(aKeys, aValues, '--disable-spell-checking'); + + if (length(FOverrideSpellCheckLang) > 0) then + ReplaceSwitch(aKeys, aValues, '--override-spell-check-lang', FOverrideSpellCheckLang); + + // This is a workaround for the CEF issue #2899 + // https://bitbucket.org/chromiumembedded/cef/issues/2899/cefsettingsignore_certificate_errors-true + if FIgnoreCertificateErrors then + ReplaceSwitch(aKeys, aValues, '--ignore-certificate-errors'); + + if (FForcedDeviceScaleFactor <> 0) then + begin + {$IFDEF FPC} + TempFormatSettings.DecimalSeparator := '.'; + {$ELSE} + {$IFDEF DELPHI24_UP} + TempFormatSettings := TFormatSettings.Create('en-US'); + {$ELSE} + GetLocaleFormatSettings(GetThreadLocale, TempFormatSettings); + TempFormatSettings.DecimalSeparator := '.'; + {$ENDIF} + {$ENDIF} + ReplaceSwitch(aKeys, aValues, '--force-device-scale-factor', FloatToStr(FForcedDeviceScaleFactor, TempFormatSettings)); + end; + + if FDisableZygote then + ReplaceSwitch(aKeys, aValues, '--no-zygote'); + + if FUseMockKeyChain then + ReplaceSwitch(aKeys, aValues, '--use-mock-keychain'); + + // The list of features you can enable is here : + // https://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_features.cc + if (length(FEnableFeatures) > 0) then + AppendSwitch(aKeys, aValues, '--enable-features', FEnableFeatures); + + // The list of features you can disable is here : + // https://chromium.googlesource.com/chromium/src/+/master/chrome/common/chrome_features.cc + if (length(FDisableFeatures) > 0) then + AppendSwitch(aKeys, aValues, '--disable-features', FDisableFeatures); + + CleanupFeatures(aKeys, aValues, '--enable-features', '--disable-features'); + + // The list of Blink features you can enable is here : + // https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5 + if (length(FEnableBlinkFeatures) > 0) then + AppendSwitch(aKeys, aValues, '--enable-blink-features', FEnableBlinkFeatures); + + // The list of Blink features you can disable is here : + // https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5 + if (length(FDisableBlinkFeatures) > 0) then + AppendSwitch(aKeys, aValues, '--disable-blink-features', FDisableBlinkFeatures); + + CleanupFeatures(aKeys, aValues, '--enable-blink-features', '--disable-blink-features'); + + // The list of Blink settings you can modify is here : + // https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/settings.json5 + if (length(FBlinkSettings) > 0) then + ReplaceSwitch(aKeys, aValues, '--blink-settings', FBlinkSettings); + + // https://source.chromium.org/chromium/chromium/src/+/master:base/base_switches.cc + if (length(FForceFieldTrials) > 0) then + ReplaceSwitch(aKeys, aValues, '--force-fieldtrials', FForceFieldTrials); + + // https://source.chromium.org/chromium/chromium/src/+/master:components/variations/variations_switches.cc + if (length(FForceFieldTrialParams) > 0) then + ReplaceSwitch(aKeys, aValues, '--force-fieldtrial-params', FForceFieldTrialParams); + + if (FCustomCommandLines <> nil) and + (FCustomCommandLineValues <> nil) and + (FCustomCommandLines.Count = FCustomCommandLineValues.Count) then + begin + i := 0; + while (i < FCustomCommandLines.Count) do + begin + if (length(FCustomCommandLines[i]) > 0) then + ReplaceSwitch(aKeys, aValues, FCustomCommandLines[i], FCustomCommandLineValues[i]); + + inc(i); + end; + end; +end; + +procedure TCefApplicationCore.Internal_OnBeforeCommandLineProcessing(const processType : ustring; + const commandLine : ICefCommandLine); +var + i : integer; + TempKeys, TempValues : TStringList; +begin + TempKeys := nil; + TempValues := nil; + + try + if (commandLine <> nil) and + commandLine.IsValid and + (FProcessType = ptBrowser) and + (processType = '') then + begin + TempKeys := TStringList.Create; + TempValues := TStringList.Create; + commandLine.GetSwitches(TempKeys, TempValues); + + AddCustomCommandLineSwitches(TempKeys, TempValues); + + commandLine.Reset; + + i := 0; + while (i < TempKeys.Count) do + begin + if (length(TempKeys[i]) > 0) then + begin + if (length(TempValues[i]) > 0) then + commandLine.AppendSwitchWithValue(TempKeys[i], TempValues[i]) + else + commandLine.AppendSwitch(TempKeys[i]); + end; + + inc(i); + end; + end; + finally + if (TempKeys <> nil) then FreeAndNil(TempKeys); + if (TempValues <> nil) then FreeAndNil(TempValues); + end; +end; + +procedure TCefApplicationCore.Internal_OnRegisterCustomSchemes(const registrar: TCefSchemeRegistrarRef); +begin + if assigned(FOnRegisterCustomSchemes) then + FOnRegisterCustomSchemes(registrar); +end; + +function TCefApplicationCore.GetMustCreateResourceBundleHandler : boolean; +begin + Result := ((FSingleProcess or (FProcessType in [ptBrowser, ptRenderer, ptZygote])) and + (FMustCreateResourceBundleHandler or + assigned(FOnGetLocalizedString) or + assigned(FOnGetDataResource) or + assigned(FOnGetDataResourceForScale))); +end; + +function TCefApplicationCore.GetMustCreateBrowserProcessHandler : boolean; +begin + Result := ((FSingleProcess or (FProcessType = ptBrowser)) and + (FMustCreateBrowserProcessHandler or + MustCreatePrintHandler or + assigned(FOnGetCookieableSchemes) or + assigned(FOnContextInitialized) or + assigned(FOnBeforeChildProcessLaunch) or + assigned(FOnScheduleMessagePumpWork)) or + assigned(FOnGetDefaultClient)); +end; + +function TCefApplicationCore.GetMustCreateRenderProcessHandler : boolean; +begin + Result := ((FSingleProcess or (FProcessType in [ptRenderer, ptZygote])) and + (FMustCreateRenderProcessHandler or + MustCreateLoadHandler or + assigned(FOnWebKitInitialized) or + assigned(FOnBrowserCreated) or + assigned(FOnBrowserDestroyed) or + assigned(FOnContextCreated) or + assigned(FOnContextReleased) or + assigned(FOnUncaughtException) or + assigned(FOnFocusedNodeChanged) or + assigned(FOnProcessMessageReceived))); +end; + +function TCefApplicationCore.GetMustCreateLoadHandler : boolean; +begin + Result := ((FSingleProcess or (FProcessType in [ptRenderer, ptZygote])) and + (FMustCreateLoadHandler or + assigned(FOnLoadingStateChange) or + assigned(FOnLoadStart) or + assigned(FOnLoadEnd) or + assigned(FOnLoadError))); +end; + +function TCefApplicationCore.GetMustCreatePrintHandler : boolean; +begin + {$IFDEF LINUX} + Result := ((FSingleProcess or (FProcessType = ptBrowser)) and + (FMustCreatePrintHandler or + assigned(FOnPrintStart) or + assigned(FOnPrintSettings) or + assigned(FOnPrintDialog) or + assigned(FOnPrintJob) or + assigned(FOnPrintReset) or + assigned(FOnGetPDFPaperSize))); + {$ELSE} + Result := False; + {$ENDIF} +end; + +function TCefApplicationCore.GetGlobalContextInitialized : boolean; +begin + Result := FGlobalContextInitialized or not(MustCreateBrowserProcessHandler); +end; + +function TCefApplicationCore.GetChildProcessesCount : integer; +{$IFDEF MSWINDOWS} +var + TempHandle : THandle; + TempProcess : TProcessEntry32; + TempPID : DWORD; + TempMain, TempSubProc, TempName : string; +{$ENDIF} +begin + Result := 0; + +{$IFDEF MSWINDOWS} + TempHandle := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0); + if (TempHandle = INVALID_HANDLE_VALUE) then exit; + + ZeroMemory(@TempProcess, SizeOf(TProcessEntry32)); + TempProcess.dwSize := Sizeof(TProcessEntry32); + TempPID := GetCurrentProcessID; + TempMain := ExtractFileName(paramstr(0)); + TempSubProc := ExtractFileName(FBrowserSubprocessPath); + + Process32First(TempHandle, TempProcess); + + repeat + if (TempProcess.th32ProcessID <> TempPID) and + (TempProcess.th32ParentProcessID = TempPID) then + begin + TempName := TempProcess.szExeFile; + TempName := ExtractFileName(TempName); + + if (CompareText(TempName, TempMain) = 0) or + ((length(TempSubProc) > 0) and (CompareText(TempName, TempSubProc) = 0)) then + inc(Result); + end; + until not(Process32Next(TempHandle, TempProcess)); + + CloseHandle(TempHandle); +{$ENDIF} +end; + +function TCefApplicationCore.GetUsedMemory : uint64; +{$IFDEF MSWINDOWS} +var + TempHandle : THandle; + TempProcess : TProcessEntry32; + TempPID : DWORD; + TempProcHWND : HWND; + TempMemCtrs : TProcessMemoryCounters; + TempMain, TempSubProc, TempName : string; +{$ENDIF} +begin + Result := 0; + {$IFDEF MSWINDOWS} + TempHandle := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0); + if (TempHandle = INVALID_HANDLE_VALUE) then exit; + + ZeroMemory(@TempProcess, SizeOf(TProcessEntry32)); + TempProcess.dwSize := Sizeof(TProcessEntry32); + TempPID := GetCurrentProcessID; + TempMain := ExtractFileName(paramstr(0)); + TempSubProc := ExtractFileName(FBrowserSubprocessPath); + + Process32First(TempHandle, TempProcess); + + repeat + if (TempProcess.th32ProcessID = TempPID) or + (TempProcess.th32ParentProcessID = TempPID) then + begin + TempName := TempProcess.szExeFile; + TempName := ExtractFileName(TempName); + + if (CompareText(TempName, TempMain) = 0) or + ((length(TempSubProc) > 0) and (CompareText(TempName, TempSubProc) = 0)) then + begin + TempProcHWND := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, TempProcess.th32ProcessID); + + if (TempProcHWND <> 0) then + begin + ZeroMemory(@TempMemCtrs, SizeOf(TProcessMemoryCounters)); + TempMemCtrs.cb := SizeOf(TProcessMemoryCounters); + + if GetProcessMemoryInfo(TempProcHWND, {$IFNDEF FPC}@{$ENDIF}TempMemCtrs, TempMemCtrs.cb) then + inc(Result, TempMemCtrs.WorkingSetSize); + + CloseHandle(TempProcHWND); + end; + end; + end; + until not(Process32Next(TempHandle, TempProcess)); + + CloseHandle(TempHandle); + {$ENDIF} +end; + +function TCefApplicationCore.GetTotalSystemMemory : uint64; +{$IFDEF MSWINDOWS} +var + TempMemStatus : TMyMemoryStatusEx; +{$ENDIF} +begin + Result := 0; + {$IFDEF MSWINDOWS} + ZeroMemory(@TempMemStatus, SizeOf(TMyMemoryStatusEx)); + TempMemStatus.dwLength := SizeOf(TMyMemoryStatusEx); + if GetGlobalMemoryStatusEx(TempMemStatus) then + Result := TempMemStatus.ullTotalPhys; + {$ENDIF} +end; + +function TCefApplicationCore.GetAvailableSystemMemory : uint64; +{$IFDEF MSWINDOWS} +var + TempMemStatus : TMyMemoryStatusEx; +{$ENDIF} +begin + Result := 0; + {$IFDEF MSWINDOWS} + ZeroMemory(@TempMemStatus, SizeOf(TMyMemoryStatusEx)); + TempMemStatus.dwLength := SizeOf(TMyMemoryStatusEx); + if GetGlobalMemoryStatusEx(TempMemStatus) then + Result := TempMemStatus.ullAvailPhys; + {$ENDIF} +end; + +function TCefApplicationCore.GetSystemMemoryLoad : cardinal; +{$IFDEF MSWINDOWS} +var + TempMemStatus : TMyMemoryStatusEx; +{$ENDIF} +begin + Result := 0; + + {$IFDEF MSWINDOWS} + ZeroMemory(@TempMemStatus, SizeOf(TMyMemoryStatusEx)); + TempMemStatus.dwLength := SizeOf(TMyMemoryStatusEx); + if GetGlobalMemoryStatusEx(TempMemStatus) then Result := TempMemStatus.dwMemoryLoad; + {$ENDIF} +end; + +function TCefApplicationCore.GetApiHashUniversal : ustring; +var + TempHash : PAnsiChar; +begin + Result := ''; + if not(FLibLoaded) then exit; + + TempHash := cef_api_hash(CEF_API_HASH_UNIVERSAL); + + if (TempHash <> nil) then + Result := ustring(AnsiString(TempHash)); +end; + +function TCefApplicationCore.GetApiHashPlatform : ustring; +var + TempHash : PAnsiChar; +begin + Result := ''; + if not(FLibLoaded) then exit; + + TempHash := cef_api_hash(CEF_API_HASH_PLATFORM); + + if (TempHash <> nil) then + Result := ustring(AnsiString(TempHash)); +end; + +function TCefApplicationCore.GetApiHashCommit : ustring; +var + TempHash : PAnsiChar; +begin + Result := ''; + if not(FLibLoaded) then exit; + + TempHash := cef_api_hash(CEF_COMMIT_HASH); + + if (TempHash <> nil) then + Result := ustring(AnsiString(TempHash)); +end; + +{$IFDEF LINUX} +function TCefApplicationCore.GetXDisplay : PXDisplay; +begin + // This property can only be called in the CEF UI thread. + if FLibLoaded then + Result := cef_get_xdisplay{$IFDEF FPC}(){$ENDIF} + else + Result := nil; +end; +{$ENDIF} + +function TCefApplicationCore.LoadCEFlibrary : boolean; +var + TempOldDir : string; + {$IFDEF MSWINDOWS} + TempError : DWORD; + {$ENDIF} +begin + Result := False; + + if (FStatus <> asLoading) or FLibLoaded or (FLibHandle <> 0) then + begin + FStatus := asErrorLoadingLibrary; + FLastErrorMessage := 'GlobalCEFApp can only be initialized once per process.'; + + ShowErrorMessageDlg(FLastErrorMessage); + exit; + end; + + if FSetCurrentDir then + begin + TempOldDir := GetCurrentDir; + chdir(GetModulePath); + end; + + {$IFDEF MSWINDOWS} + FLibHandle := LoadLibraryExW(PWideChar(LibCefPath), 0, LOAD_WITH_ALTERED_SEARCH_PATH); + {$ELSE} + {$IFDEF FPC} + FLibHandle := LoadLibrary(LibCefPath); + {$ELSE} + FLibHandle := LoadLibrary(PChar(LibCefPath)); + {$ENDIF} + {$ENDIF} + + if (FLibHandle = 0) then + begin + FStatus := asErrorLoadingLibrary; + + {$IFDEF MSWINDOWS} + TempError := GetLastError; + FLastErrorMessage := 'Error loading ' + LIBCEF_DLL + CRLF + CRLF + + 'Error code : 0x' + inttohex(TempError, 8) + CRLF + + SysErrorMessage(TempError); + {$ELSE} + FLastErrorMessage := 'Error loading ' + LIBCEF_DLL; + {$ENDIF} + + ShowErrorMessageDlg(FLastErrorMessage); + exit; + end; + + + if Load_cef_api_hash_h and + Load_cef_app_capi_h and + Load_cef_browser_capi_h and + Load_cef_command_line_capi_h and + Load_cef_cookie_capi_h and + Load_cef_crash_util_h and + Load_cef_drag_data_capi_h and + Load_cef_file_util_capi_h and + Load_cef_image_capi_h and + Load_cef_menu_model_capi_h and + Load_cef_media_router_capi_h and + Load_cef_origin_whitelist_capi_h and + Load_cef_parser_capi_h and + Load_cef_path_util_capi_h and + Load_cef_print_settings_capi_h and + Load_cef_process_message_capi_h and + Load_cef_process_util_capi_h and + Load_cef_request_capi_h and + Load_cef_request_context_capi_h and + Load_cef_resource_bundle_capi_h and + Load_cef_response_capi_h and + Load_cef_server_capi_h and + Load_cef_scheme_capi_h and + Load_cef_ssl_info_capi_h and + Load_cef_stream_capi_h and + Load_cef_task_capi_h and + Load_cef_thread_capi_h and + Load_cef_trace_capi_h and + Load_cef_urlrequest_capi_h and + Load_cef_v8_capi_h and + Load_cef_values_capi_h and + Load_cef_waitable_event_capi_h and + Load_cef_web_plugin_capi_h and + Load_cef_xml_reader_capi_h and + Load_cef_zip_reader_capi_h and + Load_cef_logging_internal_h and + Load_cef_string_list_h and + Load_cef_string_map_h and + Load_cef_string_multimap_h and + Load_cef_string_types_h and + Load_cef_thread_internal_h and + Load_cef_trace_event_internal_h and + Load_cef_browser_view_capi_h and + Load_cef_display_capi_h and + Load_cef_label_button_capi_h and + Load_cef_menu_button_capi_h and + Load_cef_panel_capi_h and + Load_cef_scroll_view_capi_h and + Load_cef_textfield_capi_h and + Load_cef_window_capi_h and + Load_cef_types_linux_h then + begin + FStatus := asLoaded; + FLibLoaded := True; + Result := True; + + if FLogProcessInfo then CefDebugLog('Process started', CEF_LOG_SEVERITY_INFO); + if FEnableHighDPISupport then cef_enable_highdpi_support(); + end + else + begin + FStatus := asErrorDLLVersion; + FLastErrorMessage := 'Unsupported CEF version !' + + CRLF + CRLF + + 'Use only the CEF binaries specified in the CEF4Delphi Readme.md file at ' + + CRLF + CEF4DELPHI_URL; + + ShowErrorMessageDlg(FLastErrorMessage); + end; + + if FSetCurrentDir then chdir(TempOldDir); +end; + +function TCefApplicationCore.Load_cef_api_hash_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_api_hash{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_api_hash'); + + Result := assigned(cef_api_hash); +end; + +function TCefApplicationCore.Load_cef_app_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_initialize{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_initialize'); + {$IFDEF FPC}Pointer({$ENDIF}cef_shutdown{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_shutdown'); + {$IFDEF FPC}Pointer({$ENDIF}cef_execute_process{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_execute_process'); + {$IFDEF FPC}Pointer({$ENDIF}cef_do_message_loop_work{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_do_message_loop_work'); + {$IFDEF FPC}Pointer({$ENDIF}cef_run_message_loop{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_run_message_loop'); + {$IFDEF FPC}Pointer({$ENDIF}cef_quit_message_loop{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_quit_message_loop'); + {$IFDEF FPC}Pointer({$ENDIF}cef_set_osmodal_loop{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_set_osmodal_loop'); + {$IFDEF FPC}Pointer({$ENDIF}cef_enable_highdpi_support{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_enable_highdpi_support'); + + Result := assigned(cef_initialize) and + assigned(cef_shutdown) and + assigned(cef_execute_process) and + assigned(cef_do_message_loop_work) and + assigned(cef_run_message_loop) and + assigned(cef_quit_message_loop) and + assigned(cef_set_osmodal_loop) and + assigned(cef_enable_highdpi_support); +end; + +function TCefApplicationCore.Load_cef_browser_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_browser_host_create_browser{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_host_create_browser'); + {$IFDEF FPC}Pointer({$ENDIF}cef_browser_host_create_browser_sync{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_host_create_browser_sync'); + + Result := assigned(cef_browser_host_create_browser) and + assigned(cef_browser_host_create_browser_sync); +end; + +function TCefApplicationCore.Load_cef_command_line_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_command_line_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_command_line_create'); + {$IFDEF FPC}Pointer({$ENDIF}cef_command_line_get_global{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_command_line_get_global'); + + Result := assigned(cef_command_line_create) and + assigned(cef_command_line_get_global); +end; + +function TCefApplicationCore.Load_cef_cookie_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_cookie_manager_get_global_manager{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_cookie_manager_get_global_manager'); + + Result := assigned(cef_cookie_manager_get_global_manager); +end; + +function TCefApplicationCore.Load_cef_crash_util_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_crash_reporting_enabled{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_crash_reporting_enabled'); + {$IFDEF FPC}Pointer({$ENDIF}cef_set_crash_key_value{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_set_crash_key_value'); + + Result := assigned(cef_crash_reporting_enabled) and + assigned(cef_set_crash_key_value); +end; + +function TCefApplicationCore.Load_cef_drag_data_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_drag_data_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_drag_data_create'); + + Result := assigned(cef_drag_data_create); +end; + +function TCefApplicationCore.Load_cef_file_util_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_create_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_directory'); + {$IFDEF FPC}Pointer({$ENDIF}cef_get_temp_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_temp_directory'); + {$IFDEF FPC}Pointer({$ENDIF}cef_create_new_temp_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_new_temp_directory'); + {$IFDEF FPC}Pointer({$ENDIF}cef_create_temp_directory_in_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_temp_directory_in_directory'); + {$IFDEF FPC}Pointer({$ENDIF}cef_directory_exists{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_directory_exists'); + {$IFDEF FPC}Pointer({$ENDIF}cef_delete_file{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_delete_file'); + {$IFDEF FPC}Pointer({$ENDIF}cef_zip_directory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_zip_directory'); + {$IFDEF FPC}Pointer({$ENDIF}cef_load_crlsets_file{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_load_crlsets_file'); + + Result := assigned(cef_create_directory) and + assigned(cef_get_temp_directory) and + assigned(cef_create_new_temp_directory) and + assigned(cef_create_temp_directory_in_directory) and + assigned(cef_directory_exists) and + assigned(cef_delete_file) and + assigned(cef_zip_directory) and + assigned(cef_load_crlsets_file); +end; + +function TCefApplicationCore.Load_cef_image_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_image_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_image_create'); + + Result := assigned(cef_image_create); +end; + +function TCefApplicationCore.Load_cef_menu_model_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_menu_model_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_menu_model_create'); + + Result := assigned(cef_menu_model_create); +end; + +function TCefApplicationCore.Load_cef_media_router_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_media_router_get_global{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_media_router_get_global'); + + Result := assigned(cef_media_router_get_global); +end; + +function TCefApplicationCore.Load_cef_origin_whitelist_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_add_cross_origin_whitelist_entry{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_add_cross_origin_whitelist_entry'); + {$IFDEF FPC}Pointer({$ENDIF}cef_remove_cross_origin_whitelist_entry{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_remove_cross_origin_whitelist_entry'); + {$IFDEF FPC}Pointer({$ENDIF}cef_clear_cross_origin_whitelist{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_clear_cross_origin_whitelist'); + + Result := assigned(cef_add_cross_origin_whitelist_entry) and + assigned(cef_remove_cross_origin_whitelist_entry) and + assigned(cef_clear_cross_origin_whitelist); +end; + +function TCefApplicationCore.Load_cef_parser_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_parse_url{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_parse_url'); + {$IFDEF FPC}Pointer({$ENDIF}cef_create_url{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_url'); + {$IFDEF FPC}Pointer({$ENDIF}cef_format_url_for_security_display{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_format_url_for_security_display'); + {$IFDEF FPC}Pointer({$ENDIF}cef_get_mime_type{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_mime_type'); + {$IFDEF FPC}Pointer({$ENDIF}cef_get_extensions_for_mime_type{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_extensions_for_mime_type'); + {$IFDEF FPC}Pointer({$ENDIF}cef_base64encode{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_base64encode'); + {$IFDEF FPC}Pointer({$ENDIF}cef_base64decode{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_base64decode'); + {$IFDEF FPC}Pointer({$ENDIF}cef_uriencode{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_uriencode'); + {$IFDEF FPC}Pointer({$ENDIF}cef_uridecode{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_uridecode'); + {$IFDEF FPC}Pointer({$ENDIF}cef_parse_json{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_parse_json'); + {$IFDEF FPC}Pointer({$ENDIF}cef_parse_json_buffer{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_parse_json_buffer'); + {$IFDEF FPC}Pointer({$ENDIF}cef_parse_jsonand_return_error{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_parse_jsonand_return_error'); + {$IFDEF FPC}Pointer({$ENDIF}cef_write_json{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_write_json'); + + Result := assigned(cef_parse_url) and + assigned(cef_create_url) and + assigned(cef_format_url_for_security_display) and + assigned(cef_get_mime_type) and + assigned(cef_get_extensions_for_mime_type) and + assigned(cef_base64encode) and + assigned(cef_base64decode) and + assigned(cef_uriencode) and + assigned(cef_uridecode) and + assigned(cef_parse_json) and + assigned(cef_parse_json_buffer) and + assigned(cef_parse_jsonand_return_error) and + assigned(cef_write_json); +end; + +function TCefApplicationCore.Load_cef_path_util_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_get_path{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_path'); + + Result := assigned(cef_get_path); +end; + +function TCefApplicationCore.Load_cef_print_settings_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_print_settings_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_print_settings_create'); + + Result := assigned(cef_print_settings_create); +end; + +function TCefApplicationCore.Load_cef_process_message_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_process_message_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_process_message_create'); + + Result := assigned(cef_process_message_create); +end; + +function TCefApplicationCore.Load_cef_process_util_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_launch_process{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_launch_process'); + + Result := assigned(cef_launch_process); +end; + +function TCefApplicationCore.Load_cef_request_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_request_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_request_create'); + {$IFDEF FPC}Pointer({$ENDIF}cef_post_data_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_post_data_create'); + {$IFDEF FPC}Pointer({$ENDIF}cef_post_data_element_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_post_data_element_create'); + + Result := assigned(cef_request_create) and + assigned(cef_post_data_create) and + assigned(cef_post_data_element_create); +end; + +function TCefApplicationCore.Load_cef_request_context_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_request_context_get_global_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_request_context_get_global_context'); + {$IFDEF FPC}Pointer({$ENDIF}cef_request_context_create_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_request_context_create_context'); + {$IFDEF FPC}Pointer({$ENDIF}cef_create_context_shared{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_create_context_shared'); + + Result := assigned(cef_request_context_get_global_context) and + assigned(cef_request_context_create_context) and + assigned(cef_create_context_shared); +end; + +function TCefApplicationCore.Load_cef_resource_bundle_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_resource_bundle_get_global{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_resource_bundle_get_global'); + + Result := assigned(cef_resource_bundle_get_global); +end; + +function TCefApplicationCore.Load_cef_response_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_response_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_response_create'); + + Result := assigned(cef_response_create); +end; + +function TCefApplicationCore.Load_cef_server_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_server_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_server_create'); + + Result := assigned(cef_server_create); +end; + +function TCefApplicationCore.Load_cef_scheme_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_register_scheme_handler_factory{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_register_scheme_handler_factory'); + {$IFDEF FPC}Pointer({$ENDIF}cef_clear_scheme_handler_factories{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_clear_scheme_handler_factories'); + + Result := assigned(cef_register_scheme_handler_factory) and + assigned(cef_clear_scheme_handler_factories); +end; + +function TCefApplicationCore.Load_cef_ssl_info_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_is_cert_status_error{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_is_cert_status_error'); + + Result := assigned(cef_is_cert_status_error); +end; + +function TCefApplicationCore.Load_cef_stream_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_stream_reader_create_for_file{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_reader_create_for_file'); + {$IFDEF FPC}Pointer({$ENDIF}cef_stream_reader_create_for_data{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_reader_create_for_data'); + {$IFDEF FPC}Pointer({$ENDIF}cef_stream_reader_create_for_handler{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_reader_create_for_handler'); + {$IFDEF FPC}Pointer({$ENDIF}cef_stream_writer_create_for_file{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_writer_create_for_file'); + {$IFDEF FPC}Pointer({$ENDIF}cef_stream_writer_create_for_handler{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_stream_writer_create_for_handler'); + + Result := assigned(cef_stream_reader_create_for_file) and + assigned(cef_stream_reader_create_for_data) and + assigned(cef_stream_reader_create_for_handler) and + assigned(cef_stream_writer_create_for_file) and + assigned(cef_stream_writer_create_for_handler); +end; + +function TCefApplicationCore.Load_cef_task_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_task_runner_get_for_current_thread{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_task_runner_get_for_current_thread'); + {$IFDEF FPC}Pointer({$ENDIF}cef_task_runner_get_for_thread{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_task_runner_get_for_thread'); + {$IFDEF FPC}Pointer({$ENDIF}cef_currently_on{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_currently_on'); + {$IFDEF FPC}Pointer({$ENDIF}cef_post_task{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_post_task'); + {$IFDEF FPC}Pointer({$ENDIF}cef_post_delayed_task{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_post_delayed_task'); + + Result := assigned(cef_task_runner_get_for_current_thread) and + assigned(cef_task_runner_get_for_thread) and + assigned(cef_currently_on) and + assigned(cef_post_task) and + assigned(cef_post_delayed_task); +end; + +function TCefApplicationCore.Load_cef_thread_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_thread_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_thread_create'); + + Result := assigned(cef_thread_create); +end; + +function TCefApplicationCore.Load_cef_trace_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_begin_tracing{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_begin_tracing'); + {$IFDEF FPC}Pointer({$ENDIF}cef_end_tracing{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_end_tracing'); + {$IFDEF FPC}Pointer({$ENDIF}cef_now_from_system_trace_time{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_now_from_system_trace_time'); + + Result := assigned(cef_begin_tracing) and + assigned(cef_end_tracing) and + assigned(cef_now_from_system_trace_time); +end; + +function TCefApplicationCore.Load_cef_urlrequest_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_urlrequest_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_urlrequest_create'); + + Result := assigned(cef_urlrequest_create); +end; + +function TCefApplicationCore.Load_cef_v8_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_v8context_get_current_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8context_get_current_context'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8context_get_entered_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8context_get_entered_context'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8context_in_context{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8context_in_context'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_undefined{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_undefined'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_null{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_null'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_bool{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_bool'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_int{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_int'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_uint{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_uint'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_double{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_double'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_date{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_date'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_string{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_string'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_object{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_object'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_array{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_array'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_array_buffer{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_array_buffer'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8value_create_function{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8value_create_function'); + {$IFDEF FPC}Pointer({$ENDIF}cef_v8stack_trace_get_current{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_v8stack_trace_get_current'); + {$IFDEF FPC}Pointer({$ENDIF}cef_register_extension{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_register_extension'); + + Result := assigned(cef_v8context_get_current_context) and + assigned(cef_v8context_get_entered_context) and + assigned(cef_v8context_in_context) and + assigned(cef_v8value_create_undefined) and + assigned(cef_v8value_create_null) and + assigned(cef_v8value_create_bool) and + assigned(cef_v8value_create_int) and + assigned(cef_v8value_create_uint) and + assigned(cef_v8value_create_double) and + assigned(cef_v8value_create_date) and + assigned(cef_v8value_create_string) and + assigned(cef_v8value_create_object) and + assigned(cef_v8value_create_array) and + assigned(cef_v8value_create_array_buffer) and + assigned(cef_v8value_create_function) and + assigned(cef_v8stack_trace_get_current) and + assigned(cef_register_extension); +end; + +function TCefApplicationCore.Load_cef_values_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_value_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_value_create'); + {$IFDEF FPC}Pointer({$ENDIF}cef_binary_value_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_binary_value_create'); + {$IFDEF FPC}Pointer({$ENDIF}cef_dictionary_value_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_dictionary_value_create'); + {$IFDEF FPC}Pointer({$ENDIF}cef_list_value_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_list_value_create'); + + Result := assigned(cef_value_create) and + assigned(cef_binary_value_create) and + assigned(cef_v8stack_trace_get_current) and + assigned(cef_list_value_create); +end; + +function TCefApplicationCore.Load_cef_waitable_event_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_waitable_event_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_waitable_event_create'); + + Result := assigned(cef_waitable_event_create); +end; + +function TCefApplicationCore.Load_cef_web_plugin_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_visit_web_plugin_info{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_visit_web_plugin_info'); + {$IFDEF FPC}Pointer({$ENDIF}cef_refresh_web_plugins{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_refresh_web_plugins'); + {$IFDEF FPC}Pointer({$ENDIF}cef_unregister_internal_web_plugin{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_unregister_internal_web_plugin'); + {$IFDEF FPC}Pointer({$ENDIF}cef_register_web_plugin_crash{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_register_web_plugin_crash'); + {$IFDEF FPC}Pointer({$ENDIF}cef_is_web_plugin_unstable{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_is_web_plugin_unstable'); + {$IFDEF FPC}Pointer({$ENDIF}cef_register_widevine_cdm{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_register_widevine_cdm'); + + Result := assigned(cef_visit_web_plugin_info) and + assigned(cef_refresh_web_plugins) and + assigned(cef_unregister_internal_web_plugin) and + assigned(cef_register_web_plugin_crash) and + assigned(cef_is_web_plugin_unstable) and + assigned(cef_register_widevine_cdm); +end; + +function TCefApplicationCore.Load_cef_xml_reader_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_xml_reader_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_xml_reader_create'); + + Result := assigned(cef_xml_reader_create); +end; + +function TCefApplicationCore.Load_cef_zip_reader_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_zip_reader_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_zip_reader_create'); + + Result := assigned(cef_zip_reader_create); +end; + +function TCefApplicationCore.Load_cef_logging_internal_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_get_min_log_level{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_min_log_level'); + {$IFDEF FPC}Pointer({$ENDIF}cef_get_vlog_level{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_vlog_level'); + {$IFDEF FPC}Pointer({$ENDIF}cef_log{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_log'); + + Result := assigned(cef_get_min_log_level) and + assigned(cef_get_vlog_level) and + assigned(cef_log); +end; + +function TCefApplicationCore.Load_cef_string_list_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_alloc'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_size{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_size'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_value{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_value'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_append{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_append'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_clear'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_free'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_list_copy{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_list_copy'); + + Result := assigned(cef_string_list_alloc) and + assigned(cef_string_list_size) and + assigned(cef_string_list_value) and + assigned(cef_string_list_append) and + assigned(cef_string_list_clear) and + assigned(cef_string_list_free) and + assigned(cef_string_list_copy); +end; + +function TCefApplicationCore.Load_cef_string_map_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_alloc'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_size{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_size'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_find{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_find'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_key{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_key'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_value{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_value'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_append{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_append'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_clear'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_map_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_map_free'); + + Result := assigned(cef_string_map_alloc) and + assigned(cef_string_map_size) and + assigned(cef_string_map_find) and + assigned(cef_string_map_key) and + assigned(cef_string_map_value) and + assigned(cef_string_map_append) and + assigned(cef_string_map_clear) and + assigned(cef_string_map_free); +end; + +function TCefApplicationCore.Load_cef_string_multimap_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_alloc'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_size{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_size'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_find_count{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_find_count'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_enumerate{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_enumerate'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_key{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_key'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_value{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_value'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_append{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_append'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_clear'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_multimap_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_multimap_free'); + + Result := assigned(cef_string_multimap_alloc) and + assigned(cef_string_multimap_size) and + assigned(cef_string_multimap_find_count) and + assigned(cef_string_multimap_enumerate) and + assigned(cef_string_multimap_key) and + assigned(cef_string_multimap_value) and + assigned(cef_string_multimap_append) and + assigned(cef_string_multimap_clear) and + assigned(cef_string_multimap_free); +end; + +function TCefApplicationCore.Load_cef_string_types_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_set{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_set'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_set{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_set'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_set{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_set'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_clear'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_clear'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_clear{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_clear'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_cmp{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_cmp'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_cmp{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_cmp'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_cmp{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_cmp'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_to_utf8{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_to_utf8'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_to_wide{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_to_wide'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_wide_to_utf16{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_wide_to_utf16'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_to_wide{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_to_wide'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf8_to_utf16{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf8_to_utf16'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_to_utf8{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_to_utf8'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_ascii_to_wide{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_ascii_to_wide'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_ascii_to_utf16{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_ascii_to_utf16'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_wide_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_wide_alloc'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_utf8_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_utf8_alloc'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_utf16_alloc{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_utf16_alloc'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_wide_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_wide_free'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_utf8_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_utf8_free'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_userfree_utf16_free{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_userfree_utf16_free'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_to_lower{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_to_lower'); + {$IFDEF FPC}Pointer({$ENDIF}cef_string_utf16_to_upper{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_string_utf16_to_upper'); + + Result := assigned(cef_string_wide_set) and + assigned(cef_string_utf8_set) and + assigned(cef_string_utf16_set) and + assigned(cef_string_wide_clear) and + assigned(cef_string_utf8_clear) and + assigned(cef_string_utf16_clear) and + assigned(cef_string_wide_cmp) and + assigned(cef_string_utf8_cmp) and + assigned(cef_string_utf16_cmp) and + assigned(cef_string_wide_to_utf8) and + assigned(cef_string_utf8_to_wide) and + assigned(cef_string_wide_to_utf16) and + assigned(cef_string_utf16_to_wide) and + assigned(cef_string_utf8_to_utf16) and + assigned(cef_string_utf16_to_utf8) and + assigned(cef_string_ascii_to_wide) and + assigned(cef_string_ascii_to_utf16) and + assigned(cef_string_userfree_wide_alloc) and + assigned(cef_string_userfree_utf8_alloc) and + assigned(cef_string_userfree_utf16_alloc) and + assigned(cef_string_userfree_wide_free) and + assigned(cef_string_userfree_utf8_free) and + assigned(cef_string_userfree_utf16_free) and + assigned(cef_string_utf16_to_lower) and + assigned(cef_string_utf16_to_upper); +end; + +function TCefApplicationCore.Load_cef_thread_internal_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_get_current_platform_thread_id{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_current_platform_thread_id'); + {$IFDEF FPC}Pointer({$ENDIF}cef_get_current_platform_thread_handle{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_current_platform_thread_handle'); + + Result := assigned(cef_get_current_platform_thread_id) and + assigned(cef_get_current_platform_thread_handle); +end; + +function TCefApplicationCore.Load_cef_trace_event_internal_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_instant{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_instant'); + {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_begin{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_begin'); + {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_end{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_end'); + {$IFDEF FPC}Pointer({$ENDIF}cef_trace_counter{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_counter'); + {$IFDEF FPC}Pointer({$ENDIF}cef_trace_counter_id{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_counter_id'); + {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_async_begin{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_async_begin'); + {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_async_step_into{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_async_step_into'); + {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_async_step_past{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_async_step_past'); + {$IFDEF FPC}Pointer({$ENDIF}cef_trace_event_async_end{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_trace_event_async_end'); + + Result := assigned(cef_trace_event_instant) and + assigned(cef_trace_event_begin) and + assigned(cef_trace_event_end) and + assigned(cef_trace_counter) and + assigned(cef_trace_counter_id) and + assigned(cef_trace_event_async_begin) and + assigned(cef_trace_event_async_step_into) and + assigned(cef_trace_event_async_step_past) and + assigned(cef_trace_event_async_end); +end; + +function TCefApplicationCore.Load_cef_browser_view_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_browser_view_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_view_create'); + {$IFDEF FPC}Pointer({$ENDIF}cef_browser_view_get_for_browser{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_browser_view_get_for_browser'); + + Result := assigned(cef_browser_view_create) and + assigned(cef_browser_view_get_for_browser); +end; + +function TCefApplicationCore.Load_cef_display_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_primary{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_primary'); + {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_nearest_point{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_nearest_point'); + {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_matching_bounds{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_matching_bounds'); + {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_count{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_count'); + {$IFDEF FPC}Pointer({$ENDIF}cef_display_get_alls{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_display_get_alls'); + + Result := assigned(cef_display_get_primary) and + assigned(cef_display_get_nearest_point) and + assigned(cef_display_get_matching_bounds) and + assigned(cef_display_get_count) and + assigned(cef_display_get_alls); +end; + +function TCefApplicationCore.Load_cef_label_button_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_label_button_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_label_button_create'); + + Result := assigned(cef_label_button_create); +end; + +function TCefApplicationCore.Load_cef_menu_button_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_menu_button_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_menu_button_create'); + + Result := assigned(cef_menu_button_create); +end; + +function TCefApplicationCore.Load_cef_panel_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_panel_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_panel_create'); + + Result := assigned(cef_panel_create); +end; + +function TCefApplicationCore.Load_cef_scroll_view_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_scroll_view_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_scroll_view_create'); + + Result := assigned(cef_scroll_view_create); +end; + +function TCefApplicationCore.Load_cef_textfield_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_textfield_create{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_textfield_create'); + + Result := assigned(cef_textfield_create); +end; + +function TCefApplicationCore.Load_cef_window_capi_h : boolean; +begin + {$IFDEF FPC}Pointer({$ENDIF}cef_window_create_top_level{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_window_create_top_level'); + + Result := assigned(cef_window_create_top_level); +end; + +function TCefApplicationCore.Load_cef_types_linux_h : boolean; +begin + {$IFDEF LINUX} + {$IFDEF FPC}Pointer({$ENDIF}cef_get_xdisplay{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_get_xdisplay'); + + Result := assigned(cef_get_xdisplay); + {$ELSE} + Result := True; + {$ENDIF} +end; + + +// TCEFDirectoryDeleterThread + +constructor TCEFDirectoryDeleterThread.Create(const aDirectory : string); +begin + inherited Create(True); + + FDirectory := aDirectory; + FreeOnTerminate := True; +end; + +procedure TCEFDirectoryDeleterThread.Execute; +begin + + try + {$IFDEF DELPHI14_UP} + TDirectory.Delete(FDirectory, True); + {$ELSE} + if DeleteDirContents(FDirectory) then RemoveDir(FDirectory); + {$ENDIF} + except + on e : exception do + if CustomExceptionHandler('TCEFDirectoryDeleterThread.Execute', e) then raise; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFAudioHandler.pas b/windows/src/ext/cef4delphi/source/uCEFAudioHandler.pas new file mode 100644 index 0000000000000000000000000000000000000000..1120ac7737d9bf71162ba24965f07c5a088a110b --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFAudioHandler.pas @@ -0,0 +1,293 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFAudioHandler; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefAudioHandlerOwn = class(TCefBaseRefCountedOwn, ICefAudioHandler) + protected + procedure OnGetAudioParameters(const browser: ICefBrowser; var params: TCefAudioParameters; var aResult: boolean); virtual; + procedure OnAudioStreamStarted(const browser: ICefBrowser; const params: TCefAudioParameters; channels: integer); virtual; + procedure OnAudioStreamPacket(const browser: ICefBrowser; const data : PPSingle; frames: integer; pts: int64); virtual; + procedure OnAudioStreamStopped(const browser: ICefBrowser); virtual; + procedure OnAudioStreamError(const browser: ICefBrowser; const message_: ustring); virtual; + + procedure RemoveReferences; virtual; + + public + constructor Create; virtual; + end; + + TCustomAudioHandler = class(TCefAudioHandlerOwn) + protected + FEvents : Pointer; + + procedure OnGetAudioParameters(const browser: ICefBrowser; var params: TCefAudioParameters; var aResult: boolean); override; + procedure OnAudioStreamStarted(const browser: ICefBrowser; const params: TCefAudioParameters; channels: integer); override; + procedure OnAudioStreamPacket(const browser: ICefBrowser; const data : PPSingle; frames: integer; pts: int64); override; + procedure OnAudioStreamStopped(const browser: ICefBrowser); override; + procedure OnAudioStreamError(const browser: ICefBrowser; const message_: ustring); override; + + procedure RemoveReferences; override; + + public + constructor Create(const events : IChromiumEvents); reintroduce; virtual; + destructor Destroy; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser; + +function cef_audio_handler_get_audio_parameters(self : PCefAudioHandler; + browser : PCefBrowser; + params : PCefAudioParameters): Integer; stdcall; +var + TempObject : TObject; + TempParams : TCefAudioParameters; + TempResult : boolean; +begin + TempObject := CefGetObject(self); + TempResult := False; + + if (TempObject <> nil) and (TempObject is TCefAudioHandlerOwn) then + begin + TempParams := params^; + TCefAudioHandlerOwn(TempObject).OnGetAudioParameters(TCefBrowserRef.UnWrap(browser), + TempParams, + TempResult); + if TempResult then + params^ := TempParams; + end; + + Result := ord(TempResult); +end; + +procedure cef_audio_handler_on_audio_stream_started( self : PCefAudioHandler; + browser : PCefBrowser; + const params : PCefAudioParameters; + channels : integer); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefAudioHandlerOwn) then + TCefAudioHandlerOwn(TempObject).OnAudioStreamStarted(TCefBrowserRef.UnWrap(browser), + params^, + channels); +end; + +procedure cef_audio_handler_on_audio_stream_packet( self : PCefAudioHandler; + browser : PCefBrowser; + const data : PPSingle; + frames : integer; + pts : int64); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefAudioHandlerOwn) then + TCefAudioHandlerOwn(TempObject).OnAudioStreamPacket(TCefBrowserRef.UnWrap(browser), + data, + frames, + pts); +end; + +procedure cef_audio_handler_on_audio_stream_stopped(self: PCefAudioHandler; browser: PCefBrowser); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefAudioHandlerOwn) then + TCefAudioHandlerOwn(TempObject).OnAudioStreamStopped(TCefBrowserRef.UnWrap(browser)); +end; + +procedure cef_audio_handler_on_audio_stream_error(self: PCefAudioHandler; browser: PCefBrowser; const message_: PCefString); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefAudioHandlerOwn) then + TCefAudioHandlerOwn(TempObject).OnAudioStreamError(TCefBrowserRef.UnWrap(browser), + CefString(message_)); +end; + +constructor TCefAudioHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefAudioHandler)); + + with PCefAudioHandler(FData)^ do + begin + get_audio_parameters := {$IFDEF FPC}@{$ENDIF}cef_audio_handler_get_audio_parameters; + on_audio_stream_started := {$IFDEF FPC}@{$ENDIF}cef_audio_handler_on_audio_stream_started; + on_audio_stream_packet := {$IFDEF FPC}@{$ENDIF}cef_audio_handler_on_audio_stream_packet; + on_audio_stream_stopped := {$IFDEF FPC}@{$ENDIF}cef_audio_handler_on_audio_stream_stopped; + on_audio_stream_error := {$IFDEF FPC}@{$ENDIF}cef_audio_handler_on_audio_stream_error; + end; +end; + +procedure TCefAudioHandlerOwn.OnGetAudioParameters(const browser : ICefBrowser; + var params : TCefAudioParameters; + var aResult : boolean); +begin + // +end; + +procedure TCefAudioHandlerOwn.OnAudioStreamStarted(const browser : ICefBrowser; + const params : TCefAudioParameters; + channels : integer); +begin + // +end; + +procedure TCefAudioHandlerOwn.OnAudioStreamPacket(const browser : ICefBrowser; + const data : PPSingle; + frames : integer; + pts : int64); +begin + // +end; + +procedure TCefAudioHandlerOwn.OnAudioStreamStopped(const browser : ICefBrowser); +begin + // +end; + +procedure TCefAudioHandlerOwn.OnAudioStreamError(const browser : ICefBrowser; + const message_ : ustring); +begin + // +end; + +procedure TCefAudioHandlerOwn.RemoveReferences; +begin + // +end; + + +// TCustomAudioHandler + +constructor TCustomAudioHandler.Create(const events : IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +destructor TCustomAudioHandler.Destroy; +begin + RemoveReferences; + + inherited Destroy; +end; + +procedure TCustomAudioHandler.RemoveReferences; +begin + FEvents := nil; +end; + +procedure TCustomAudioHandler.OnGetAudioParameters(const browser : ICefBrowser; + var params : TCefAudioParameters; + var aResult : boolean); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnGetAudioParameters(browser, + params, + aResult); +end; + +procedure TCustomAudioHandler.OnAudioStreamStarted(const browser : ICefBrowser; + const params : TCefAudioParameters; + channels : integer); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnAudioStreamStarted(browser, + params, + channels); +end; + +procedure TCustomAudioHandler.OnAudioStreamPacket(const browser : ICefBrowser; + const data : PPSingle; + frames : integer; + pts : int64); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnAudioStreamPacket(browser, + data, + frames, + pts); +end; + +procedure TCustomAudioHandler.OnAudioStreamStopped(const browser : ICefBrowser); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnAudioStreamStopped(browser); +end; + +procedure TCustomAudioHandler.OnAudioStreamError(const browser : ICefBrowser; + const message_ : ustring); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnAudioStreamError(browser, + message_); +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFAuthCallback.pas b/windows/src/ext/cef4delphi/source/uCEFAuthCallback.pas index f589aff0640a4454ee0aa655cea92ac1e7d373b8..199c479a5e667013a848a113ffcafcccf47b14a0 100644 --- a/windows/src/ext/cef4delphi/source/uCEFAuthCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFAuthCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFAuthCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFBaseRefCounted.pas b/windows/src/ext/cef4delphi/source/uCEFBaseRefCounted.pas index 821b205f0198185882c5c01d9715dd1808ced122..53dec802d50b5a8aa55e80bda6e5e02da74d0175 100644 --- a/windows/src/ext/cef4delphi/source/uCEFBaseRefCounted.pas +++ b/windows/src/ext/cef4delphi/source/uCEFBaseRefCounted.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFBaseRefCounted; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -72,10 +70,15 @@ type protected FData: Pointer; + function HasOneRef : boolean; + function HasAtLeastOneRef : boolean; + public constructor CreateData(size: Cardinal; owned : boolean = False); virtual; destructor Destroy; override; - function SameAs(aData : Pointer) : boolean; + function SameAs(aData : Pointer) : boolean; overload; + function SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; overload; + procedure DestroyOtherRefs; function Wrap: Pointer; end; @@ -83,10 +86,15 @@ type protected FData: Pointer; + function HasOneRef : boolean; + function HasAtLeastOneRef : boolean; + public constructor Create(data: Pointer); virtual; destructor Destroy; override; - function SameAs(aData : Pointer) : boolean; + function SameAs(aData : Pointer) : boolean; overload; + function SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; overload; + procedure DestroyOtherRefs; function Wrap: Pointer; class function UnWrap(data: Pointer): ICefBaseRefCounted; end; @@ -96,7 +104,7 @@ type implementation uses - uCEFTypes, uCEFMiscFunctions, uCEFConstants, uCEFApplication; + uCEFTypes, uCEFMiscFunctions; // *********************************************** @@ -138,6 +146,18 @@ begin Result := Ord(False); end; +function cef_base_has_at_least_one_ref(self: PCefBaseRefCounted): Integer; stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefBaseRefCountedOwn) then + Result := Ord(TCefBaseRefCountedOwn(TempObject).FRefCount >= 1) + else + Result := Ord(False); +end; + procedure cef_base_add_ref_owned(self: PCefBaseRefCounted); stdcall; begin // @@ -153,6 +173,11 @@ begin Result := 1; end; +function cef_base_has_at_least_one_ref_owned(self: PCefBaseRefCounted): Integer; stdcall; +begin + Result := 1; +end; + constructor TCefBaseRefCountedOwn.CreateData(size: Cardinal; owned : boolean); begin GetMem(FData, size + SizeOf(Pointer)); @@ -163,15 +188,17 @@ begin if owned then begin - PCefBaseRefCounted(FData)^.add_ref := {$IFDEF FPC}@{$ENDIF}cef_base_add_ref_owned; - PCefBaseRefCounted(FData)^.release := {$IFDEF FPC}@{$ENDIF}cef_base_release_owned; - PCefBaseRefCounted(FData)^.has_one_ref := {$IFDEF FPC}@{$ENDIF}cef_base_has_one_ref_owned; + PCefBaseRefCounted(FData)^.add_ref := {$IFDEF FPC}@{$ENDIF}cef_base_add_ref_owned; + PCefBaseRefCounted(FData)^.release := {$IFDEF FPC}@{$ENDIF}cef_base_release_owned; + PCefBaseRefCounted(FData)^.has_one_ref := {$IFDEF FPC}@{$ENDIF}cef_base_has_one_ref_owned; + PCefBaseRefCounted(FData)^.has_at_least_one_ref := {$IFDEF FPC}@{$ENDIF}cef_base_has_at_least_one_ref_owned; end else begin - PCefBaseRefCounted(FData)^.add_ref := {$IFDEF FPC}@{$ENDIF}cef_base_add_ref; - PCefBaseRefCounted(FData)^.release := {$IFDEF FPC}@{$ENDIF}cef_base_release_ref; - PCefBaseRefCounted(FData)^.has_one_ref := {$IFDEF FPC}@{$ENDIF}cef_base_has_one_ref; + PCefBaseRefCounted(FData)^.add_ref := {$IFDEF FPC}@{$ENDIF}cef_base_add_ref; + PCefBaseRefCounted(FData)^.release := {$IFDEF FPC}@{$ENDIF}cef_base_release_ref; + PCefBaseRefCounted(FData)^.has_one_ref := {$IFDEF FPC}@{$ENDIF}cef_base_has_one_ref; + PCefBaseRefCounted(FData)^.has_at_least_one_ref := {$IFDEF FPC}@{$ENDIF}cef_base_has_at_least_one_ref; end; end; @@ -198,6 +225,32 @@ begin Result := (FData = aData); end; +function TCefBaseRefCountedOwn.SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; +var + TempData : Pointer; +begin + Result := False; + + if (aBaseRefCounted <> nil) then + begin + TempData := aBaseRefCounted.Wrap; + + if (TempData <> nil) then + begin + Result := SameAs(TempData); + + if assigned(PCefBaseRefCounted(TempData)^.release) then + PCefBaseRefCounted(TempData)^.release(PCefBaseRefCounted(TempData)); + end; + end; +end; + +procedure TCefBaseRefCountedOwn.DestroyOtherRefs; +begin + while HasAtLeastOneRef and not(HasOneRef) do + _Release; +end; + function TCefBaseRefCountedOwn.Wrap: Pointer; begin Result := FData; @@ -206,6 +259,22 @@ begin PCefBaseRefCounted(FData)^.add_ref(PCefBaseRefCounted(FData)); end; +function TCefBaseRefCountedOwn.HasOneRef : boolean; +begin + if (FData <> nil) and Assigned(PCefBaseRefCounted(FData)^.has_one_ref) then + Result := PCefBaseRefCounted(FData)^.has_one_ref(PCefBaseRefCounted(FData)) <> 0 + else + Result := False; +end; + +function TCefBaseRefCountedOwn.HasAtLeastOneRef : boolean; +begin + if (FData <> nil) and Assigned(PCefBaseRefCounted(FData)^.has_at_least_one_ref) then + Result := PCefBaseRefCounted(FData)^.has_at_least_one_ref(PCefBaseRefCounted(FData)) <> 0 + else + Result := False; +end; + // *********************************************** // ************ TCefBaseRefCountedRef ************ @@ -241,6 +310,26 @@ begin Result := (FData = aData); end; +function TCefBaseRefCountedRef.SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; +var + TempData : Pointer; +begin + Result := False; + + if (aBaseRefCounted <> nil) then + begin + TempData := aBaseRefCounted.Wrap; + + if (TempData <> nil) then + begin + Result := SameAs(TempData); + + if assigned(PCefBaseRefCounted(TempData)^.release) then + PCefBaseRefCounted(TempData)^.release(PCefBaseRefCounted(TempData)); + end; + end; +end; + class function TCefBaseRefCountedRef.UnWrap(data: Pointer): ICefBaseRefCounted; begin if (data <> nil) then @@ -262,6 +351,21 @@ begin end; end; +function TCefBaseRefCountedRef.HasOneRef : boolean; +begin + Result := (PCefBaseRefCounted(FData)^.has_one_ref(PCefBaseRefCounted(FData)) <> 0); +end; + +function TCefBaseRefCountedRef.HasAtLeastOneRef : boolean; +begin + Result := (PCefBaseRefCounted(FData)^.has_at_least_one_ref(PCefBaseRefCounted(FData)) <> 0); +end; + +procedure TCefBaseRefCountedRef.DestroyOtherRefs; +begin + // +end; + // ************************************************ // *********** TLoggingInterfacedObject *********** diff --git a/windows/src/ext/cef4delphi/source/uCEFBaseScopedWrapper.pas b/windows/src/ext/cef4delphi/source/uCEFBaseScopedWrapper.pas index 21ccb3fff4bce310d71aa80f9c1fa283833915aa..dbecf88a373bcc6899f046810e7096308c7cbf11 100644 --- a/windows/src/ext/cef4delphi/source/uCEFBaseScopedWrapper.pas +++ b/windows/src/ext/cef4delphi/source/uCEFBaseScopedWrapper.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFBaseScopedWrapper; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFBeforeDownloadCallback.pas b/windows/src/ext/cef4delphi/source/uCEFBeforeDownloadCallback.pas index ba427fe5403bfa9dd51e639dd00be1f24bb76fd7..7202f4450ca35d6ce18acc4322605fbc9f79f457 100644 --- a/windows/src/ext/cef4delphi/source/uCEFBeforeDownloadCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFBeforeDownloadCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFBeforeDownloadCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFBinaryValue.pas b/windows/src/ext/cef4delphi/source/uCEFBinaryValue.pas index 76a7fddf299f9027b3aa0270affcd8f026f07b98..399a3ff24724af615499f7b9d6d1296f8e62b2fb 100644 --- a/windows/src/ext/cef4delphi/source/uCEFBinaryValue.pas +++ b/windows/src/ext/cef4delphi/source/uCEFBinaryValue.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFBinaryValue; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFBitmapBitBuffer.pas b/windows/src/ext/cef4delphi/source/uCEFBitmapBitBuffer.pas new file mode 100644 index 0000000000000000000000000000000000000000..d9cb7d23f29045e351d200fb3d6ccc7b721bc9a6 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFBitmapBitBuffer.pas @@ -0,0 +1,198 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFBitmapBitBuffer; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils; + {$ELSE} + Classes, SysUtils; + {$ENDIF} + +type + TCEFBitmapBitBuffer = class + protected + FBuffer : pointer; + FImageWidth : integer; + FImageHeight : integer; + FBufferWidth : integer; + FBufferHeight : integer; + + function GetBufferScanlineSize : integer; + function GetScanlineSize : integer; + function GetBufferLength : integer; + function GetEmpty : boolean; + function GetScanline(y : integer) : PByte; + + procedure CreateBuffer; + procedure DestroyBuffer; + + public + constructor Create(aWidth, aHeight : integer); + destructor Destroy; override; + procedure UpdateSize(aWidth, aHeight : integer); + + property Width : integer read FImageWidth; + property Height : integer read FImageHeight; + property BufferLength : integer read GetBufferLength; + property Empty : boolean read GetEmpty; + property Scanline[y : integer] : PByte read GetScanline; + property ScanlineSize : integer read GetScanlineSize; + property BufferScanlineSize : integer read GetBufferScanlineSize; + property BufferBits : pointer read FBuffer; + end; + +implementation + +const + RGBQUAD_SIZE = 4; + BUFFER_MULTIPLIER = 1.1; + +constructor TCEFBitmapBitBuffer.Create(aWidth, aHeight : integer); +begin + inherited Create; + + FBuffer := nil; + FImageWidth := 0; + FImageHeight := 0; + FBufferWidth := 0; + FBufferHeight := 0; + + UpdateSize(aWidth, aHeight); +end; + +destructor TCEFBitmapBitBuffer.Destroy; +begin + DestroyBuffer; + + inherited Destroy; +end; + +procedure TCEFBitmapBitBuffer.DestroyBuffer; +begin + if (FBuffer <> nil) then + begin + FreeMem(FBuffer); + FBuffer := nil; + end; +end; + +function TCEFBitmapBitBuffer.GetScanlineSize : integer; +begin + Result := FImageWidth * RGBQUAD_SIZE; +end; + +function TCEFBitmapBitBuffer.GetBufferScanlineSize : integer; +begin + Result := FBufferWidth * RGBQUAD_SIZE; +end; + +function TCEFBitmapBitBuffer.GetBufferLength : integer; +begin + Result := FBufferHeight * BufferScanlineSize; +end; + +function TCEFBitmapBitBuffer.GetEmpty : boolean; +begin + Result := (BufferLength = 0) or (FBuffer = nil); +end; + +function TCEFBitmapBitBuffer.GetScanline(y : integer) : PByte; +begin + if (FBuffer = nil) or (y >= FImageHeight) then + Result := nil + else + begin + Result := PByte(FBuffer); + if (y > 0) then inc(Result, y * BufferScanlineSize); + end; +end; + +procedure TCEFBitmapBitBuffer.CreateBuffer; +var + TempLen : integer; +begin + TempLen := BufferLength; + + if (TempLen > 0) then + begin + GetMem(FBuffer, TempLen); + FillChar(FBuffer^, TempLen, $FF); + end; +end; + +procedure TCEFBitmapBitBuffer.UpdateSize(aWidth, aHeight : integer); +begin + if (aWidth > 0) and (aHeight > 0) then + begin + FImageWidth := aWidth; + FImageHeight := aHeight; + + if (FImageWidth > FBufferWidth) or + (FImageHeight > FBufferHeight) then + begin + FBufferWidth := round(FImageWidth * BUFFER_MULTIPLIER); + FBufferHeight := round(FImageHeight * BUFFER_MULTIPLIER); + + DestroyBuffer; + CreateBuffer; + end; + end + else + begin + FImageWidth := 0; + FImageHeight := 0; + FBufferWidth := 0; + FBufferHeight := 0; + + DestroyBuffer; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFBoxLayout.pas b/windows/src/ext/cef4delphi/source/uCEFBoxLayout.pas new file mode 100644 index 0000000000000000000000000000000000000000..18ab63e9813648720f1892741407930f85e3d773 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFBoxLayout.pas @@ -0,0 +1,96 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFBoxLayout; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFLayout; + +type + TCefBoxLayoutRef = class(TCefLayoutRef, ICefBoxLayout) + protected + procedure SetFlexForView(const view: ICefView; flex: Integer); + procedure ClearFlexForView(const view: ICefView); + + public + class function UnWrap(data: Pointer): ICefBoxLayout; + end; + +implementation + +uses + uCEFMiscFunctions; + +procedure TCefBoxLayoutRef.SetFlexForView(const view: ICefView; flex: Integer); +begin + PCefBoxLayout(FData)^.set_flex_for_view(PCefBoxLayout(FData), + CefGetData(view), + ord(flex)); +end; + +procedure TCefBoxLayoutRef.ClearFlexForView(const view: ICefView); +begin + PCefBoxLayout(FData)^.clear_flex_for_view(PCefBoxLayout(FData), + CefGetData(view)); +end; + +class function TCefBoxLayoutRef.UnWrap(data: Pointer): ICefBoxLayout; +begin + if (data <> nil) then + Result := Create(data) as ICefBoxLayout + else + Result := nil; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFBrowser.pas b/windows/src/ext/cef4delphi/source/uCEFBrowser.pas index 113a712ce5f8bea0ffff44ef78493eb80bb0f445..4b4a1637c7c80febfbc66f6e12a627b544ebe084 100644 --- a/windows/src/ext/cef4delphi/source/uCEFBrowser.pas +++ b/windows/src/ext/cef4delphi/source/uCEFBrowser.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFBrowser; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -81,7 +79,6 @@ type function GetFrameCount: NativeUInt; function GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean; function GetFrameNames(var aFrameNames : TStrings) : boolean; - function SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; public class function UnWrap(data: Pointer): ICefBrowser; @@ -107,39 +104,42 @@ type procedure Print; procedure PrintToPdf(const path: ustring; settings: PCefPdfPrintSettings; const callback: ICefPdfPrintCallback); procedure PrintToPdfProc(const path: ustring; settings: PCefPdfPrintSettings; const callback: TOnPdfPrintFinishedProc); - procedure Find(identifier: Integer; const searchText: ustring; forward, matchCase, findNext: Boolean); + procedure Find(identifier: Integer; const searchText: ustring; forward_, matchCase, findNext: Boolean); procedure StopFinding(clearSelection: Boolean); procedure ShowDevTools(const windowInfo: PCefWindowInfo; const client: ICefClient; const settings: PCefBrowserSettings; inspectElementAt: PCefPoint); procedure CloseDevTools; function HasDevTools: Boolean; + function SendDevToolsMessage(const message_: ustring): boolean; + function ExecuteDevToolsMethod(message_id: integer; const method: ustring; const params: ICefDictionaryValue): Integer; + function AddDevToolsMessageObserver(const observer: ICefDevToolsMessageObserver): ICefRegistration; procedure GetNavigationEntries(const visitor: ICefNavigationEntryVisitor; currentOnly: Boolean); procedure GetNavigationEntriesProc(const proc: TCefNavigationEntryVisitorProc; currentOnly: Boolean); - procedure SetMouseCursorChangeDisabled(disabled: Boolean); - function IsMouseCursorChangeDisabled: Boolean; procedure ReplaceMisspelling(const word: ustring); procedure AddWordToDictionary(const word: ustring); function IsWindowRenderingDisabled: Boolean; procedure WasResized; procedure NotifyScreenInfoChanged; procedure WasHidden(hidden: Boolean); - procedure Invalidate(kind: TCefPaintElementType); + procedure Invalidate(type_: TCefPaintElementType); + procedure SendExternalBeginFrame; procedure SendKeyEvent(const event: PCefKeyEvent); - procedure SendMouseClickEvent(const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); + procedure SendMouseClickEvent(const event: PCefMouseEvent; type_: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); procedure SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); procedure SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); + procedure SendTouchEvent(const event: PCefTouchEvent); procedure SendFocusEvent(aSetFocus: Boolean); procedure SendCaptureLostEvent; procedure NotifyMoveOrResizeStarted; function GetWindowlessFrameRate : Integer; procedure SetWindowlessFrameRate(frameRate: Integer); - procedure IMESetComposition(const text: ustring; underlinesCount : NativeUInt; const underlines : PCefCompositionUnderline; const replacement_range, selection_range : PCefRange); + procedure IMESetComposition(const text: ustring; const underlines : TCefCompositionUnderlineDynArray; const replacement_range, selection_range : PCefRange); procedure IMECommitText(const text: ustring; const replacement_range : PCefRange; relative_cursor_pos : integer); procedure IMEFinishComposingText(keep_selection : boolean); procedure IMECancelComposition; procedure DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); procedure DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); procedure DragTargetDragLeave; - procedure DragTargetDrop(event: PCefMouseEvent); + procedure DragTargetDrop(const event: PCefMouseEvent); procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); procedure DragSourceSystemDragEnded; function GetVisibleNavigationEntry : ICefNavigationEntry; @@ -147,6 +147,8 @@ type procedure SetAutoResizeEnabled(enabled: boolean; const min_size, max_size: PCefSize); function GetExtension : ICefExtension; function IsBackgroundHost : boolean; + procedure SetAudioMuted(mute: boolean); + function IsAudioMuted : boolean; public class function UnWrap(data: Pointer): ICefBrowserHost; @@ -157,7 +159,10 @@ implementation uses uCEFMiscFunctions, uCEFLibFunctions, uCEFDownloadImageCallBack, uCEFFrame, uCEFPDFPrintCallback, uCEFRunFileDialogCallback, uCEFRequestContext, uCEFNavigationEntryVisitor, uCEFNavigationEntry, - uCEFExtension, uCEFStringList; + uCEFExtension, uCEFStringList, uCEFRegistration; + + +// TCefBrowserRef function TCefBrowserRef.GetHost: ICefBrowserHost; begin @@ -239,11 +244,6 @@ begin end; end; -function TCefBrowserRef.SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; -begin - Result := PCefBrowser(FData)^.send_process_message(PCefBrowser(FData), targetProcess, CefGetData(ProcMessage)) <> 0; -end; - function TCefBrowserRef.GetMainFrame: ICefFrame; begin Result := TCefFrameRef.UnWrap(PCefBrowser(FData)^.get_main_frame(PCefBrowser(FData))) @@ -307,11 +307,12 @@ begin Result := nil; end; + // TCefBrowserHostRef procedure TCefBrowserHostRef.CloseDevTools; begin - PCefBrowserHost(FData)^.close_dev_tools(FData); + PCefBrowserHost(FData)^.close_dev_tools(PCefBrowserHost(FData)); end; procedure TCefBrowserHostRef.DownloadImage(const imageUrl : ustring; @@ -323,7 +324,12 @@ var url: TCefString; begin url := CefString(imageUrl); - PCefBrowserHost(FData)^.download_image(FData, @url, Ord(isFavicon), maxImageSize, Ord(bypassCache), CefGetData(callback)); + PCefBrowserHost(FData)^.download_image(PCefBrowserHost(FData), + @url, + Ord(isFavicon), + maxImageSize, + Ord(bypassCache), + CefGetData(callback)); end; procedure TCefBrowserHostRef.DownloadImageProc(const imageUrl : ustring; @@ -337,12 +343,12 @@ end; procedure TCefBrowserHostRef.DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); begin - PCefBrowserHost(FData)^.drag_source_ended_at(FData, x, y, op); + PCefBrowserHost(FData)^.drag_source_ended_at(PCefBrowserHost(FData), x, y, op); end; procedure TCefBrowserHostRef.DragSourceSystemDragEnded; begin - PCefBrowserHost(FData)^.drag_source_system_drag_ended(FData); + PCefBrowserHost(FData)^.drag_source_system_drag_ended(PCefBrowserHost(FData)); end; function TCefBrowserHostRef.GetVisibleNavigationEntry : ICefNavigationEntry; @@ -352,50 +358,60 @@ end; procedure TCefBrowserHostRef.SetAccessibilityState(accessibilityState: TCefState); begin - PCefBrowserHost(FData)^.set_accessibility_state(FData, accessibilityState); + PCefBrowserHost(FData)^.set_accessibility_state(PCefBrowserHost(FData), accessibilityState); end; procedure TCefBrowserHostRef.SetAutoResizeEnabled(enabled: boolean; const min_size, max_size: PCefSize); begin - PCefBrowserHost(FData)^.set_auto_resize_enabled(FData, Ord(enabled), min_size, max_size); + PCefBrowserHost(FData)^.set_auto_resize_enabled(PCefBrowserHost(FData), Ord(enabled), min_size, max_size); end; function TCefBrowserHostRef.GetExtension : ICefExtension; begin - Result := TCefExtensionRef.UnWrap(PCefBrowserHost(FData)^.get_extension(FData)); + Result := TCefExtensionRef.UnWrap(PCefBrowserHost(FData)^.get_extension(PCefBrowserHost(FData))); end; function TCefBrowserHostRef.IsBackgroundHost : boolean; begin - Result := PCefBrowserHost(FData)^.is_background_host(FData) <> 0; + Result := PCefBrowserHost(FData)^.is_background_host(PCefBrowserHost(FData)) <> 0; +end; + +procedure TCefBrowserHostRef.SetAudioMuted(mute: boolean); +begin + PCefBrowserHost(FData)^.set_audio_muted(PCefBrowserHost(FData), Ord(mute)); +end; + +function TCefBrowserHostRef.IsAudioMuted : boolean; +begin + Result := PCefBrowserHost(FData)^.is_audio_muted(PCefBrowserHost(FData)) <> 0; end; procedure TCefBrowserHostRef.DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); begin - PCefBrowserHost(FData)^.drag_target_drag_enter(FData, CefGetData(dragData), event, allowedOps); + PCefBrowserHost(FData)^.drag_target_drag_enter(PCefBrowserHost(FData), CefGetData(dragData), event, allowedOps); end; procedure TCefBrowserHostRef.DragTargetDragLeave; begin - PCefBrowserHost(FData)^.drag_target_drag_leave(FData); + PCefBrowserHost(FData)^.drag_target_drag_leave(PCefBrowserHost(FData)); end; procedure TCefBrowserHostRef.DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); begin - PCefBrowserHost(FData)^.drag_target_drag_over(FData, event, allowedOps); + PCefBrowserHost(FData)^.drag_target_drag_over(PCefBrowserHost(FData), event, allowedOps); end; -procedure TCefBrowserHostRef.DragTargetDrop(event: PCefMouseEvent); +procedure TCefBrowserHostRef.DragTargetDrop(const event: PCefMouseEvent); begin - PCefBrowserHost(FData)^.drag_target_drop(FData, event); + PCefBrowserHost(FData)^.drag_target_drop(PCefBrowserHost(FData), event); end; -procedure TCefBrowserHostRef.Find(identifier: Integer; const searchText: ustring; forward, matchCase, findNext: Boolean); +procedure TCefBrowserHostRef.Find(identifier: Integer; const searchText: ustring; forward_, matchCase, findNext: Boolean); var TempText : TCefString; begin TempText := CefString(searchText); - PCefBrowserHost(FData)^.find(FData, identifier, @TempText, Ord(forward), Ord(matchCase), Ord(findNext)); + PCefBrowserHost(FData)^.find(PCefBrowserHost(FData), identifier, @TempText, Ord(forward_), Ord(matchCase), Ord(findNext)); end; function TCefBrowserHostRef.GetBrowser: ICefBrowser; @@ -415,7 +431,7 @@ var str: TCefString; begin str := CefString(path); - PCefBrowserHost(FData)^.print_to_pdf(FData, @str, settings, CefGetData(callback)); + PCefBrowserHost(FData)^.print_to_pdf(PCefBrowserHost(FData), @str, settings, CefGetData(callback)); end; procedure TCefBrowserHostRef.PrintToPdfProc(const path : ustring; @@ -430,7 +446,7 @@ var str: TCefString; begin str := CefString(word); - PCefBrowserHost(FData)^.replace_misspelling(FData, @str); + PCefBrowserHost(FData)^.replace_misspelling(PCefBrowserHost(FData), @str); end; procedure TCefBrowserHostRef.RunFileDialog( mode : TCefFileDialogMode; @@ -477,7 +493,7 @@ var str: TCefString; begin str := CefString(word); - PCefBrowserHost(FData)^.add_word_to_dictionary(FData, @str); + PCefBrowserHost(FData)^.add_word_to_dictionary(PCefBrowserHost(FData), @str); end; procedure TCefBrowserHostRef.CloseBrowser(forceClose: Boolean); @@ -487,45 +503,45 @@ end; procedure TCefBrowserHostRef.SendCaptureLostEvent; begin - PCefBrowserHost(FData)^.send_capture_lost_event(FData); + PCefBrowserHost(FData)^.send_capture_lost_event(PCefBrowserHost(FData)); end; procedure TCefBrowserHostRef.SendFocusEvent(aSetFocus: Boolean); begin - PCefBrowserHost(FData)^.send_focus_event(FData, Ord(aSetFocus)); + PCefBrowserHost(FData)^.send_focus_event(PCefBrowserHost(FData), Ord(aSetFocus)); end; procedure TCefBrowserHostRef.SendKeyEvent(const event: PCefKeyEvent); begin - PCefBrowserHost(FData)^.send_key_event(FData, event); + PCefBrowserHost(FData)^.send_key_event(PCefBrowserHost(FData), event); end; procedure TCefBrowserHostRef.SendMouseClickEvent(const event : PCefMouseEvent; - kind : TCefMouseButtonType; + type_ : TCefMouseButtonType; mouseUp : Boolean; clickCount : Integer); begin - PCefBrowserHost(FData)^.send_mouse_click_event(FData, event, kind, Ord(mouseUp), clickCount); + PCefBrowserHost(FData)^.send_mouse_click_event(PCefBrowserHost(FData), event, type_, Ord(mouseUp), clickCount); end; procedure TCefBrowserHostRef.SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); begin - PCefBrowserHost(FData)^.send_mouse_move_event(FData, event, Ord(mouseLeave)); + PCefBrowserHost(FData)^.send_mouse_move_event(PCefBrowserHost(FData), event, Ord(mouseLeave)); end; procedure TCefBrowserHostRef.SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); begin - PCefBrowserHost(FData)^.send_mouse_wheel_event(FData, event, deltaX, deltaY); + PCefBrowserHost(FData)^.send_mouse_wheel_event(PCefBrowserHost(FData), event, deltaX, deltaY); end; -procedure TCefBrowserHostRef.SetFocus(focus: Boolean); +procedure TCefBrowserHostRef.SendTouchEvent(const event: PCefTouchEvent); begin - PCefBrowserHost(FData)^.set_focus(PCefBrowserHost(FData), Ord(focus)); + PCefBrowserHost(FData)^.send_touch_event(PCefBrowserHost(FData), event); end; -procedure TCefBrowserHostRef.SetMouseCursorChangeDisabled(disabled: Boolean); +procedure TCefBrowserHostRef.SetFocus(focus: Boolean); begin - PCefBrowserHost(FData)^.set_mouse_cursor_change_disabled(PCefBrowserHost(FData), Ord(disabled)); + PCefBrowserHost(FData)^.set_focus(PCefBrowserHost(FData), Ord(focus)); end; procedure TCefBrowserHostRef.SetWindowlessFrameRate(frameRate: Integer); @@ -550,12 +566,12 @@ end; function TCefBrowserHostRef.GetRequestContext: ICefRequestContext; begin - Result := TCefRequestContextRef.UnWrap(PCefBrowserHost(FData)^.get_request_context(FData)); + Result := TCefRequestContextRef.UnWrap(PCefBrowserHost(FData)^.get_request_context(PCefBrowserHost(FData))); end; procedure TCefBrowserHostRef.GetNavigationEntries(const visitor: ICefNavigationEntryVisitor; currentOnly: Boolean); begin - PCefBrowserHost(FData)^.get_navigation_entries(FData, CefGetData(visitor), Ord(currentOnly)); + PCefBrowserHost(FData)^.get_navigation_entries(PCefBrowserHost(FData), CefGetData(visitor), Ord(currentOnly)); end; procedure TCefBrowserHostRef.GetNavigationEntriesProc(const proc: TCefNavigationEntryVisitorProc; currentOnly: Boolean); @@ -569,15 +585,51 @@ begin end; procedure TCefBrowserHostRef.IMESetComposition(const text : ustring; - underlinesCount : NativeUInt; - const underlines : PCefCompositionUnderline; + const underlines : TCefCompositionUnderlineDynArray; const replacement_range : PCefRange; const selection_range : PCefRange); var - TempString : TCefString; + TempString : TCefString; + TempCount, i : NativeUInt; + TempUnderlines : PCefCompositionUnderline; + TempItem : PCefCompositionUnderline; begin - TempString := CefString(text); - PCefBrowserHost(FData)^.ime_set_composition(PCefBrowserHost(FData), @TempString, underlinesCount, underlines, replacement_range, selection_range); + TempCount := 0; + TempUnderlines := nil; + + try + TempString := CefString(text); + + if (underlines <> nil) then + begin + TempCount := length(underlines); + GetMem(TempUnderlines, TempCount * SizeOf(TCefCompositionUnderline)); + + TempItem := TempUnderlines; + i := 0; + + while (i < TempCount) do + begin + TempItem^.range := underlines[i].range; + TempItem^.color := underlines[i].color; + TempItem^.background_color := underlines[i].background_color; + TempItem^.thick := underlines[i].thick; + TempItem^.style := underlines[i].style; + + inc(i); + inc(TempItem); + end; + end; + + PCefBrowserHost(FData)^.ime_set_composition(PCefBrowserHost(FData), + @TempString, + TempCount, + TempUnderlines, + replacement_range, + selection_range); + finally + if (TempUnderlines <> nil) then FreeMem(TempUnderlines); + end; end; procedure TCefBrowserHostRef.IMECommitText(const text: ustring; const replacement_range : PCefRange; relative_cursor_pos : integer); @@ -600,27 +652,56 @@ end; function TCefBrowserHostRef.HasDevTools: Boolean; begin - Result := PCefBrowserHost(FData)^.has_dev_tools(FData) <> 0; + Result := PCefBrowserHost(FData)^.has_dev_tools(PCefBrowserHost(FData)) <> 0; +end; + +function TCefBrowserHostRef.SendDevToolsMessage(const message_: ustring): boolean; +var + TempMsg : TCefStringUtf8; + TempLen : integer; +begin + TempMsg.str := nil; + TempMsg.length := 0; + TempMsg.dtor := nil; + + TempLen := length(message_); + Result := (TempLen > 0) and + (cef_string_wide_to_utf8(PWideChar(@message_[1]), TempLen, @TempMsg) <> 0) and + (PCefBrowserHost(FData)^.send_dev_tools_message(PCefBrowserHost(FData), TempMsg.str, TempMsg.length) <> 0); +end; + +function TCefBrowserHostRef.ExecuteDevToolsMethod(message_id: integer; const method: ustring; const params: ICefDictionaryValue): Integer; +var + TempMethod : TCefString; +begin + TempMethod := CefString(method); + Result := PCefBrowserHost(FData)^.execute_dev_tools_method(PCefBrowserHost(FData), message_id, @TempMethod, CefGetData(params)); +end; + +function TCefBrowserHostRef.AddDevToolsMessageObserver(const observer: ICefDevToolsMessageObserver): ICefRegistration; +begin + Result := TCefRegistrationRef.UnWrap(PCefBrowserHost(FData)^.add_dev_tools_message_observer(PCefBrowserHost(FData), + CefGetData(observer))); end; function TCefBrowserHostRef.HasView: Boolean; begin - Result := PCefBrowserHost(FData)^.has_view(FData) <> 0; + Result := PCefBrowserHost(FData)^.has_view(PCefBrowserHost(FData)) <> 0; end; -procedure TCefBrowserHostRef.Invalidate(kind: TCefPaintElementType); +procedure TCefBrowserHostRef.Invalidate(type_: TCefPaintElementType); begin - PCefBrowserHost(FData)^.invalidate(FData, kind); + PCefBrowserHost(FData)^.invalidate(PCefBrowserHost(FData), type_); end; -function TCefBrowserHostRef.IsMouseCursorChangeDisabled: Boolean; +procedure TCefBrowserHostRef.SendExternalBeginFrame; begin - Result := PCefBrowserHost(FData)^.is_mouse_cursor_change_disabled(FData) <> 0 + PCefBrowserHost(FData)^.send_external_begin_frame(PCefBrowserHost(FData)); end; function TCefBrowserHostRef.IsWindowRenderingDisabled: Boolean; begin - Result := PCefBrowserHost(FData)^.is_window_rendering_disabled(FData) <> 0 + Result := PCefBrowserHost(FData)^.is_window_rendering_disabled(PCefBrowserHost(FData)) <> 0; end; procedure TCefBrowserHostRef.NotifyMoveOrResizeStarted; @@ -643,7 +724,11 @@ procedure TCefBrowserHostRef.ShowDevTools(const windowInfo : PCefWindowInf const settings : PCefBrowserSettings; inspectElementAt : PCefPoint); begin - PCefBrowserHost(FData)^.show_dev_tools(FData, windowInfo, CefGetData(client), settings, inspectElementAt); + PCefBrowserHost(FData)^.show_dev_tools(PCefBrowserHost(FData), + windowInfo, + CefGetData(client), + settings, + inspectElementAt); end; procedure TCefBrowserHostRef.StartDownload(const url: ustring); @@ -656,12 +741,12 @@ end; procedure TCefBrowserHostRef.StopFinding(clearSelection: Boolean); begin - PCefBrowserHost(FData)^.stop_finding(FData, Ord(clearSelection)); + PCefBrowserHost(FData)^.stop_finding(PCefBrowserHost(FData), Ord(clearSelection)); end; function TCefBrowserHostRef.TryCloseBrowser: Boolean; begin - Result := PCefBrowserHost(FData)^.try_close_browser(FData) <> 0; + Result := PCefBrowserHost(FData)^.try_close_browser(PCefBrowserHost(FData)) <> 0; end; class function TCefBrowserHostRef.UnWrap(data: Pointer): ICefBrowserHost; @@ -674,12 +759,12 @@ end; procedure TCefBrowserHostRef.WasHidden(hidden: Boolean); begin - PCefBrowserHost(FData)^.was_hidden(FData, Ord(hidden)); + PCefBrowserHost(FData)^.was_hidden(PCefBrowserHost(FData), Ord(hidden)); end; procedure TCefBrowserHostRef.WasResized; begin - PCefBrowserHost(FData)^.was_resized(FData); + PCefBrowserHost(FData)^.was_resized(PCefBrowserHost(FData)); end; diff --git a/windows/src/ext/cef4delphi/source/uCEFBrowserProcessHandler.pas b/windows/src/ext/cef4delphi/source/uCEFBrowserProcessHandler.pas index 3079bddd0a74d89e8583378b1932f2ea1b4287a9..8b8eaf1f3f11345d98bc9817283cd05deee10b1e 100644 --- a/windows/src/ext/cef4delphi/source/uCEFBrowserProcessHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFBrowserProcessHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,26 +41,32 @@ unit uCEFBrowserProcessHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} interface uses - uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplication; + {$IFDEF DELPHI16_UP} + System.Classes, + {$ELSE} + Classes, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplicationCore; type TCefBrowserProcessHandlerOwn = class(TCefBaseRefCountedOwn, ICefBrowserProcessHandler) protected + procedure GetCookieableSchemes(var schemes: TStringList; var include_defaults : boolean); virtual; abstract; procedure OnContextInitialized; virtual; abstract; procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); virtual; abstract; - procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); virtual; abstract; procedure GetPrintHandler(var aHandler : ICefPrintHandler); virtual; procedure OnScheduleMessagePumpWork(const delayMs: Int64); virtual; abstract; + procedure GetDefaultClient(var aClient : ICefClient); virtual; + + procedure RemoveReferences; virtual; abstract; public constructor Create; virtual; @@ -68,15 +74,20 @@ type TCefCustomBrowserProcessHandler = class(TCefBrowserProcessHandlerOwn) protected - FCefApp : TCefApplication; + FCefApp : TCefApplicationCore; + FPrintHandler : ICefPrintHandler; + procedure GetCookieableSchemes(var schemes: TStringList; var include_defaults : boolean); override; procedure OnContextInitialized; override; procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); override; - procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); override; + procedure GetPrintHandler(var aHandler : ICefPrintHandler); override; procedure OnScheduleMessagePumpWork(const delayMs: Int64); override; + procedure GetDefaultClient(var aClient : ICefClient); override; + + procedure RemoveReferences; override; public - constructor Create(const aCefApp : TCefApplication); reintroduce; + constructor Create(const aCefApp : TCefApplicationCore); reintroduce; destructor Destroy; override; end; @@ -88,38 +99,69 @@ uses {$ELSE} SysUtils, {$ENDIF} - uCEFMiscFunctions, uCEFLibFunctions, uCEFCommandLine, uCEFListValue, uCEFConstants; + uCEFMiscFunctions, uCEFLibFunctions, uCEFCommandLine, uCEFListValue, uCEFConstants, uCEFStringList, + uCEFPrintHandler; -procedure cef_browser_process_handler_on_context_initialized(self: PCefBrowserProcessHandler); stdcall; +procedure cef_browser_process_handler_get_cookieable_schemes(self : PCefBrowserProcessHandler; + schemes : TCefStringList; + include_defaults : PInteger); stdcall; var + TempSL : TStringList; + TempCefSL : ICefStringList; TempObject : TObject; + TempIncDef : boolean; begin - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then - TCefBrowserProcessHandlerOwn(TempObject).OnContextInitialized; + TempSL := nil; + + try + try + TempObject := CefGetObject(self); + + if (schemes <> nil) and (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then + begin + TempIncDef := (include_defaults^ <> 0); + TempSL := TStringList.Create; + TempCefSL := TCefStringListRef.Create(schemes); + TempCefSL.CopyToStrings(TempSL); + + TCefBrowserProcessHandlerOwn(TempObject).GetCookieableSchemes(TempSL, TempIncDef); + + TempCefSL.Clear; + TempCefSL.AddStrings(TempSL); + + include_defaults^ := ord(TempIncDef); + end; + except + on e : exception do + if CustomExceptionHandler('cef_browser_process_handler_get_cookieable_schemes', e) then raise; + end; + finally + if (TempSL <> nil) then FreeAndNil(TempSL); + TempCefSL := nil; + end; end; -procedure cef_browser_process_handler_on_before_child_process_launch(self : PCefBrowserProcessHandler; - command_line : PCefCommandLine); stdcall; +procedure cef_browser_process_handler_on_context_initialized(self: PCefBrowserProcessHandler); stdcall; var TempObject : TObject; begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then - TCefBrowserProcessHandlerOwn(TempObject).OnBeforeChildProcessLaunch(TCefCommandLineRef.UnWrap(command_line)); + if (TempObject <> nil) and + (TempObject is TCefBrowserProcessHandlerOwn) then + TCefBrowserProcessHandlerOwn(TempObject).OnContextInitialized; end; -procedure cef_browser_process_handler_on_render_process_thread_created(self : PCefBrowserProcessHandler; - extra_info : PCefListValue); stdcall; +procedure cef_browser_process_handler_on_before_child_process_launch(self : PCefBrowserProcessHandler; + command_line : PCefCommandLine); stdcall; var TempObject : TObject; begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then - TCefBrowserProcessHandlerOwn(TempObject).OnRenderProcessThreadCreated(TCefListValueRef.UnWrap(extra_info)); + if (TempObject <> nil) and + (TempObject is TCefBrowserProcessHandlerOwn) then + TCefBrowserProcessHandlerOwn(TempObject).OnBeforeChildProcessLaunch(TCefCommandLineRef.UnWrap(command_line)); end; function cef_browser_process_handler_get_print_handler(self: PCefBrowserProcessHandler): PCefPrintHandler; stdcall; @@ -130,8 +172,10 @@ begin Result := nil; TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefBrowserProcessHandlerOwn) then try + TempHandler := nil; TCefBrowserProcessHandlerOwn(TempObject).GetPrintHandler(TempHandler); if (TempHandler <> nil) then Result := TempHandler.Wrap; finally @@ -146,48 +190,99 @@ var begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefBrowserProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefBrowserProcessHandlerOwn) then TCefBrowserProcessHandlerOwn(TempObject).OnScheduleMessagePumpWork(delay_ms); end; +function cef_browser_process_handler_get_default_client(self: PCefBrowserProcessHandler): PCefClient; stdcall; +var + TempObject : TObject; + TempClient : ICefClient; +begin + Result := nil; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and + (TempObject is TCefBrowserProcessHandlerOwn) then + try + TempClient := nil; + TCefBrowserProcessHandlerOwn(TempObject).GetDefaultClient(TempClient); + if (TempClient <> nil) then Result := TempClient.Wrap; + finally + TempClient := nil; + end; +end; + constructor TCefBrowserProcessHandlerOwn.Create; begin inherited CreateData(SizeOf(TCefBrowserProcessHandler)); with PCefBrowserProcessHandler(FData)^ do begin + get_cookieable_schemes := {$IFDEF FPC}@{$ENDIF}cef_browser_process_handler_get_cookieable_schemes; on_context_initialized := {$IFDEF FPC}@{$ENDIF}cef_browser_process_handler_on_context_initialized; on_before_child_process_launch := {$IFDEF FPC}@{$ENDIF}cef_browser_process_handler_on_before_child_process_launch; - on_render_process_thread_created := {$IFDEF FPC}@{$ENDIF}cef_browser_process_handler_on_render_process_thread_created; get_print_handler := {$IFDEF FPC}@{$ENDIF}cef_browser_process_handler_get_print_handler; on_schedule_message_pump_work := {$IFDEF FPC}@{$ENDIF}cef_browser_process_handler_on_schedule_message_pump_work; + get_default_client := {$IFDEF FPC}@{$ENDIF}cef_browser_process_handler_get_default_client; end; end; procedure TCefBrowserProcessHandlerOwn.GetPrintHandler(var aHandler : ICefPrintHandler); begin - aHandler := nil; // only linux + aHandler := nil; +end; + +procedure TCefBrowserProcessHandlerOwn.GetDefaultClient(var aClient : ICefClient); +begin + aClient := nil; end; // TCefCustomBrowserProcessHandler -constructor TCefCustomBrowserProcessHandler.Create(const aCefApp : TCefApplication); +constructor TCefCustomBrowserProcessHandler.Create(const aCefApp : TCefApplicationCore); begin inherited Create; FCefApp := aCefApp; + + if (FCefApp <> nil) and FCefApp.MustCreatePrintHandler then + FPrintHandler := TCustomPrintHandler.Create(FCefApp) + else + FPrintHandler := nil; end; destructor TCefCustomBrowserProcessHandler.Destroy; begin - FCefApp := nil; + RemoveReferences; inherited Destroy; end; -procedure TCefCustomBrowserProcessHandler.OnContextInitialized; +procedure TCefCustomBrowserProcessHandler.RemoveReferences; +begin + if (FPrintHandler <> nil) then + FPrintHandler.RemoveReferences; + + FCefApp := nil; + FPrintHandler := nil; +end; + +procedure TCefCustomBrowserProcessHandler.GetCookieableSchemes(var schemes : TStringList; + var include_defaults : boolean); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_GetCookieableSchemes(schemes, include_defaults); + except + on e : exception do + if CustomExceptionHandler('TCefCustomBrowserProcessHandler.GetCookieableSchemes', e) then raise; + end; +end; + +procedure TCefCustomBrowserProcessHandler.OnContextInitialized; begin try if (FCefApp <> nil) then FCefApp.Internal_OnContextInitialized; @@ -206,15 +301,13 @@ begin if CustomExceptionHandler('TCefCustomBrowserProcessHandler.OnBeforeChildProcessLaunch', e) then raise; end; end; - -procedure TCefCustomBrowserProcessHandler.OnRenderProcessThreadCreated(const extraInfo: ICefListValue); -begin - try - if (FCefApp <> nil) then FCefApp.Internal_OnRenderProcessThreadCreated(extraInfo); - except - on e : exception do - if CustomExceptionHandler('TCefCustomBrowserProcessHandler.OnRenderProcessThreadCreated', e) then raise; - end; + +procedure TCefCustomBrowserProcessHandler.GetPrintHandler(var aHandler : ICefPrintHandler); +begin + if (FPrintHandler <> nil) then + aHandler := FPrintHandler + else + inherited GetPrintHandler(aHandler); end; procedure TCefCustomBrowserProcessHandler.OnScheduleMessagePumpWork(const delayMs: Int64); @@ -227,4 +320,14 @@ begin end; end; +procedure TCefCustomBrowserProcessHandler.GetDefaultClient(var aClient : ICefClient); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_GetDefaultClient(aClient); + except + on e : exception do + if CustomExceptionHandler('TCefCustomBrowserProcessHandler.GetDefaultClient', e) then raise; + end; +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFBrowserView.pas b/windows/src/ext/cef4delphi/source/uCEFBrowserView.pas new file mode 100644 index 0000000000000000000000000000000000000000..4caf5910d723c3cd15e9458c316039391de0d5bb --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFBrowserView.pas @@ -0,0 +1,139 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFBrowserView; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFView; + +type + TCefBrowserViewRef = class(TCefViewRef, ICefBrowserView) + protected + function GetBrowser : ICefBrowser; + procedure SetPreferAccelerators(prefer_accelerators: boolean); + + public + class function UnWrap(data: Pointer): ICefBrowserView; + class function CreateBrowserView(const client: ICefClient; const url: ustring; const settings: TCefBrowserSettings; const extra_info: ICefDictionaryValue; const request_context: ICefRequestContext; const delegate: ICefBrowserViewDelegate): ICefBrowserView; + class function GetForBrowser(const browser: ICefBrowser): ICefBrowserView; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFBrowser; + +function TCefBrowserViewRef.GetBrowser : ICefBrowser; +begin + Result := TCefBrowserRef.UnWrap(PCefBrowserView(FData)^.get_browser(PCefBrowserView(FData))); +end; + +procedure TCefBrowserViewRef.SetPreferAccelerators(prefer_accelerators: boolean); +begin + PCefBrowserView(FData)^.set_prefer_accelerators(PCefBrowserView(FData), + ord(prefer_accelerators)); +end; + +class function TCefBrowserViewRef.UnWrap(data: Pointer): ICefBrowserView; +begin + if (data <> nil) then + Result := Create(data) as ICefBrowserView + else + Result := nil; +end; + +class function TCefBrowserViewRef.CreateBrowserView(const client : ICefClient; + const url : ustring; + const settings : TCefBrowserSettings; + const extra_info : ICefDictionaryValue; + const request_context : ICefRequestContext; + const delegate : ICefBrowserViewDelegate): ICefBrowserView; + +var + TempURL : TCefString; + TempBrowserView : PCefBrowserView; +begin + Result := nil; + + if (client <> nil) and (delegate <> nil) then + begin + TempURL := CefString(url); + TempBrowserView := cef_browser_view_create(CefGetData(client), + @TempURL, + @settings, + CefGetData(extra_info), + CefGetData(request_context), + CefGetData(delegate)); + + if (TempBrowserView <> nil) then + Result := Create(TempBrowserView) as ICefBrowserView; + end; +end; + +class function TCefBrowserViewRef.GetForBrowser(const browser: ICefBrowser): ICefBrowserView; +var + TempBrowserView : PCefBrowserView; +begin + Result := nil; + + if (browser <> nil) then + begin + TempBrowserView := cef_browser_view_get_for_browser(CefGetData(browser)); + + if (TempBrowserView <> nil) then + Result := Create(TempBrowserView) as ICefBrowserView; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFBrowserViewComponent.pas b/windows/src/ext/cef4delphi/source/uCEFBrowserViewComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..86934331a1d6c3ce76186939389008933ff72ab6 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFBrowserViewComponent.pas @@ -0,0 +1,261 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFBrowserViewComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents, uCEFViewComponent; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFBrowserViewComponent = class(TCEFViewComponent, ICefBrowserViewDelegateEvents) + protected + FBrowserView : ICefBrowserView; + FBrowserViewDlg : ICefBrowserViewDelegate; + + // ICefBrowserViewDelegateEvents + FOnBrowserCreated : TOnBrowserCreatedEvent; + FOnBrowserDestroyed : TOnBrowserDestroyedEvent; + FOnGetDelegateForPopupBrowserView : TOnGetDelegateForPopupBrowserViewEvent; + FOnPopupBrowserViewCreated : TOnPopupBrowserViewCreatedEvent; + + procedure DestroyView; override; + procedure Initialize; override; + + function GetInitialized : boolean; override; + function GetAsView : ICefView; override; + function GetAsBrowserView : ICefBrowserView; override; + function GetBrowser : ICefBrowser; + + // ICefBrowserViewDelegateEvents + procedure doOnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); + procedure doOnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); + procedure doOnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); + procedure doOnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); + + public + function CreateBrowserView(const client: ICefClient; const url: ustring; const settings: TCefBrowserSettings; const extra_info: ICefDictionaryValue; const request_context: ICefRequestContext): boolean; + function GetForBrowser(const browser: ICefBrowser): boolean; + procedure SetPreferAccelerators(prefer_accelerators: boolean); + + property Browser : ICefBrowser read GetBrowser; + property BrowserView : ICefBrowserView read FBrowserView; + + published + property OnBrowserCreated : TOnBrowserCreatedEvent read FOnBrowserCreated write FOnBrowserCreated; + property OnBrowserDestroyed : TOnBrowserDestroyedEvent read FOnBrowserDestroyed write FOnBrowserDestroyed; + property OnGetDelegateForPopupBrowserView : TOnGetDelegateForPopupBrowserViewEvent read FOnGetDelegateForPopupBrowserView write FOnGetDelegateForPopupBrowserView; + property OnPopupBrowserViewCreated : TOnPopupBrowserViewCreatedEvent read FOnPopupBrowserViewCreated write FOnPopupBrowserViewCreated; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + uCEFBrowserView, uCEFBrowserViewDelegate, uCEFMiscFunctions; + +procedure TCEFBrowserViewComponent.Initialize; +begin + inherited Initialize; + + FBrowserView := nil; + FBrowserViewDlg := nil; + FOnBrowserCreated := nil; + FOnBrowserDestroyed := nil; + FOnGetDelegateForPopupBrowserView := nil; + FOnPopupBrowserViewCreated := nil; +end; + +procedure TCEFBrowserViewComponent.DestroyView; +begin + if (FBrowserViewDlg <> nil) then + begin + FBrowserViewDlg.DestroyOtherRefs; + FBrowserViewDlg := nil; + end; + + FBrowserView := nil; +end; + +function TCEFBrowserViewComponent.CreateBrowserView(const client : ICefClient; + const url : ustring; + const settings : TCefBrowserSettings; + const extra_info : ICefDictionaryValue; + const request_context : ICefRequestContext): boolean; +begin + Result := False; + + if CefCurrentlyOn(TID_UI) and (client <> nil) then + begin + if (FBrowserViewDlg = nil) then + FBrowserViewDlg := TCustomBrowserViewDelegate.Create(self); + + FBrowserView := TCefBrowserViewRef.CreateBrowserView(client, url, settings, extra_info, request_context, FBrowserViewDlg); + Result := (FBrowserView <> nil); + end; +end; + +function TCEFBrowserViewComponent.GetForBrowser(const browser: ICefBrowser): boolean; +begin + Result := False; + + if CefCurrentlyOn(TID_UI) and (browser <> nil) then + begin + FBrowserView := TCefBrowserViewRef.GetForBrowser(browser); + Result := (FBrowserView <> nil); + end; +end; + +function TCEFBrowserViewComponent.GetInitialized : boolean; +begin + Result := (FBrowserView <> nil); +end; + +function TCEFBrowserViewComponent.GetAsView : ICefView; +begin + Result := FBrowserView as ICefView; +end; + +function TCEFBrowserViewComponent.GetAsBrowserView : ICefBrowserView; +begin + Result := FBrowserView; +end; + +function TCEFBrowserViewComponent.GetBrowser : ICefBrowser; +begin + if Initialized then + Result := FBrowserView.GetBrowser + else + Result := nil; +end; + +procedure TCEFBrowserViewComponent.SetPreferAccelerators(prefer_accelerators: boolean); +begin + if Initialized then FBrowserView.SetPreferAccelerators(prefer_accelerators); +end; + +procedure TCEFBrowserViewComponent.doOnBrowserCreated(const browser_view : ICefBrowserView; + const browser : ICefBrowser); +begin + if assigned(FOnBrowserCreated) then + FOnBrowserCreated(self, browser_view, browser); +end; + +procedure TCEFBrowserViewComponent.doOnBrowserDestroyed(const browser_view : ICefBrowserView; + const browser : ICefBrowser); +begin + if assigned(FOnBrowserDestroyed) then + FOnBrowserDestroyed(self, browser_view, browser); +end; + +procedure TCEFBrowserViewComponent.doOnGetDelegateForPopupBrowserView(const browser_view : ICefBrowserView; + const settings : TCefBrowserSettings; + const client : ICefClient; + is_devtools : boolean; + var aResult : ICefBrowserViewDelegate); +begin + if assigned(FOnGetDelegateForPopupBrowserView) then + FOnGetDelegateForPopupBrowserView(self, browser_view, settings, client, is_devtools, aResult); +end; + +procedure TCEFBrowserViewComponent.doOnPopupBrowserViewCreated(const browser_view : ICefBrowserView; + const popup_browser_view : ICefBrowserView; + is_devtools : boolean; + var aResult : boolean); +begin + if assigned(FOnPopupBrowserViewCreated) then + FOnPopupBrowserViewCreated(self, browser_view, popup_browser_view, is_devtools, aResult); +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tcefbrowserviewcomponent.lrs} + RegisterComponents('Chromium Views Framework', [TCEFBrowserViewComponent]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFBrowserViewDelegate.pas b/windows/src/ext/cef4delphi/source/uCEFBrowserViewDelegate.pas new file mode 100644 index 0000000000000000000000000000000000000000..7ad572826ebf7db1cc793cf8fd540b73cc535a94 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFBrowserViewDelegate.pas @@ -0,0 +1,425 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFBrowserViewDelegate; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFViewDelegate; + +type + TCefBrowserViewDelegateRef = class(TCefViewDelegateRef, ICefBrowserViewDelegate) + protected + procedure OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); + procedure OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); + procedure OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); + procedure OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); + + public + class function UnWrap(data: Pointer): ICefBrowserViewDelegate; + end; + + TCefBrowserViewDelegateOwn = class(TCefViewDelegateOwn, ICefBrowserViewDelegate) + protected + procedure OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); virtual; + procedure OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); virtual; + procedure OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); virtual; + procedure OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); virtual; + + procedure InitializeCEFMethods; override; + + public + constructor Create; override; + end; + + TCustomBrowserViewDelegate = class(TCefBrowserViewDelegateOwn) + protected + FEvents : Pointer; + + // ICefViewDelegate + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); override; + procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); override; + procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); override; + procedure OnFocus(const view: ICefView); override; + procedure OnBlur(const view: ICefView); override; + + // ICefBrowserViewDelegate + procedure OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); override; + procedure OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); override; + procedure OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); override; + procedure OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); override; + + public + constructor Create(const events: ICefBrowserViewDelegateEvents); reintroduce; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFBrowserView, uCEFBrowser, uCEFClient; + + +// ************************************************************** +// **************** TCefBrowserViewDelegateRef ****************** +// ************************************************************** + +procedure TCefBrowserViewDelegateRef.OnBrowserCreated(const browser_view : ICefBrowserView; + const browser : ICefBrowser); +begin + PCefBrowserViewDelegate(FData)^.on_browser_created(PCefBrowserViewDelegate(FData), + CefGetData(browser_view), + CefGetData(browser)); +end; + +procedure TCefBrowserViewDelegateRef.OnBrowserDestroyed(const browser_view : ICefBrowserView; + const browser : ICefBrowser); +begin + PCefBrowserViewDelegate(FData)^.on_browser_destroyed(PCefBrowserViewDelegate(FData), + CefGetData(browser_view), + CefGetData(browser)); +end; + +procedure TCefBrowserViewDelegateRef.OnGetDelegateForPopupBrowserView(const browser_view : ICefBrowserView; + const settings : TCefBrowserSettings; + const client : ICefClient; + is_devtools : boolean; + var aResult : ICefBrowserViewDelegate); +begin + aResult := UnWrap((PCefBrowserViewDelegate(FData)^.get_delegate_for_popup_browser_view(PCefBrowserViewDelegate(FData), + CefGetData(browser_view), + @settings, + CefGetData(client), + ord(is_devtools)))); +end; + +procedure TCefBrowserViewDelegateRef.OnPopupBrowserViewCreated(const browser_view : ICefBrowserView; + const popup_browser_view : ICefBrowserView; + is_devtools : boolean; + var aResult : boolean); +begin + aResult := (PCefBrowserViewDelegate(FData)^.on_popup_browser_view_created(PCefBrowserViewDelegate(FData), + CefGetData(browser_view), + CefGetData(popup_browser_view), + ord(is_devtools)) <> 0); +end; + +class function TCefBrowserViewDelegateRef.UnWrap(data: Pointer): ICefBrowserViewDelegate; +begin + if (data <> nil) then + Result := Create(data) as ICefBrowserViewDelegate + else + Result := nil; +end; + + +// ************************************************************** +// **************** TCefBrowserViewDelegateOwn ****************** +// ************************************************************** + +procedure cef_browserview_delegate_on_browser_created(self : PCefBrowserViewDelegate; + browser_view : PCefBrowserView; + browser : PCefBrowser); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefBrowserViewDelegateOwn) then + TCefBrowserViewDelegateOwn(TempObject).OnBrowserCreated(TCefBrowserViewRef.UnWrap(browser_view), + TCefBrowserRef.UnWrap(browser)); +end; + +procedure cef_browserview_delegate_on_browser_destroyed(self : PCefBrowserViewDelegate; + browser_view : PCefBrowserView; + browser : PCefBrowser); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefBrowserViewDelegateOwn) then + TCefBrowserViewDelegateOwn(TempObject).OnBrowserDestroyed(TCefBrowserViewRef.UnWrap(browser_view), + TCefBrowserRef.UnWrap(browser)); +end; + +function cef_browserview_delegate_get_delegate_for_popup_browser_view( self : PCefBrowserViewDelegate; + browser_view : PCefBrowserView; + const settings : PCefBrowserSettings; + client : PCefClient; + is_devtools : Integer): PCefBrowserViewDelegate; stdcall; +var + TempObject : TObject; + TempDelegate : ICefBrowserViewDelegate; +begin + TempObject := CefGetObject(self); + TempDelegate := nil; + + if (TempObject <> nil) and (TempObject is TCefBrowserViewDelegateOwn) then + TCefBrowserViewDelegateOwn(TempObject).OnGetDelegateForPopupBrowserView(TCefBrowserViewRef.UnWrap(browser_view), + settings^, + TCefClientRef.UnWrap(client), + is_devtools <> 0, + TempDelegate); + + Result := CefGetData(TempDelegate); +end; + +function cef_browserview_delegate_on_popup_browser_view_created(self : PCefBrowserViewDelegate; + browser_view : PCefBrowserView; + popup_browser_view : PCefBrowserView; + is_devtools : Integer): Integer; stdcall; +var + TempObject : TObject; + TempResult : boolean; +begin + TempObject := CefGetObject(self); + TempResult := False; + + if (TempObject <> nil) and (TempObject is TCefBrowserViewDelegateOwn) then + TCefBrowserViewDelegateOwn(TempObject).OnPopupBrowserViewCreated(TCefBrowserViewRef.UnWrap(browser_view), + TCefBrowserViewRef.UnWrap(popup_browser_view), + is_devtools <> 0, + TempResult); + + Result := ord(TempResult); +end; + +constructor TCefBrowserViewDelegateOwn.Create; +begin + inherited CreateData(SizeOf(TCefBrowserViewDelegate)); + + InitializeCEFMethods; +end; + +procedure TCefBrowserViewDelegateOwn.InitializeCEFMethods; +begin + inherited InitializeCEFMethods; + + with PCefBrowserViewDelegate(FData)^ do + begin + on_browser_created := {$IFDEF FPC}@{$ENDIF}cef_browserview_delegate_on_browser_created; + on_browser_destroyed := {$IFDEF FPC}@{$ENDIF}cef_browserview_delegate_on_browser_destroyed; + get_delegate_for_popup_browser_view := {$IFDEF FPC}@{$ENDIF}cef_browserview_delegate_get_delegate_for_popup_browser_view; + on_popup_browser_view_created := {$IFDEF FPC}@{$ENDIF}cef_browserview_delegate_on_popup_browser_view_created; + end; +end; + +procedure TCefBrowserViewDelegateOwn.OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); +begin + // +end; + +procedure TCefBrowserViewDelegateOwn.OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); +begin + // +end; + +procedure TCefBrowserViewDelegateOwn.OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); +begin + // +end; + +procedure TCefBrowserViewDelegateOwn.OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); +begin + // +end; + + +// ************************************************************** +// **************** TCustomBrowserViewDelegate ****************** +// ************************************************************** + +constructor TCustomBrowserViewDelegate.Create(const events: ICefBrowserViewDelegateEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +procedure TCustomBrowserViewDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetPreferredSize', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetMinimumSize', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetMaximumSize', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetHeightForWidth', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnParentViewChanged', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnChildViewChanged(view, added, child); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnChildViewChanged', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnFocus(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnFocus(view); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnFocus', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnBlur(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnBlur(view); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnBlur', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnBrowserCreated(browser_view, browser); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnBrowserCreated', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnBrowserDestroyed(browser_view, browser); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnBrowserDestroyed', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnGetDelegateForPopupBrowserView(browser_view, settings, client, is_devtools, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetDelegateForPopupBrowserView', e) then raise; + end; +end; + +procedure TCustomBrowserViewDelegate.OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); +begin + try + if (FEvents <> nil) then + ICefBrowserViewDelegateEvents(FEvents).doOnPopupBrowserViewCreated(browser_view, popup_browser_view, is_devtools, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomBrowserViewDelegate.OnPopupBrowserViewCreated', e) then raise; + end; +end; + + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFBrowserWindow.pas b/windows/src/ext/cef4delphi/source/uCEFBrowserWindow.pas new file mode 100644 index 0000000000000000000000000000000000000000..9ffa3db11ce35ea3d85acfc0caa9cb24bc1e0c78 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFBrowserWindow.pas @@ -0,0 +1,739 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFBrowserWindow; + +{$mode objfpc}{$H+} +{$i cef.inc} + +interface + +uses + {$IFDEF FPC} + LResources, PropEdits, + {$ENDIF} + uCEFApplication, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces, uCEFChromium, + uCEFLinkedWinControlBase, uCEFBrowserViewComponent, + uCEFChromiumEvents, Forms, ExtCtrls, Controls, Classes, sysutils; + +type + + (* On cocoa closing a browser does not work, while the application is in any other event. + I.e. if the App is in a button-press event, then the browser will + only close once that event was finished. + *) + + { TEmbeddedChromium + + 1) TEmbeddedChromium keeps track of the browser while it is created. + This allows for CloseBrowser to function, even if the Browser object is not + yet known. + Also calls to "LoadUrl" are cached until the browser object is created. + + 2) TEmbeddedChromium adds InternalEvents that can be hooked by the + component that owns the TEmbeddedChromium. + This means the default published events are available to the end user. + Published events that should not be available are hidden via THiddenPropertyEditor + * Hidden event properties must not be assigned by any end user code. * + } + + TEmbeddedChromium = class(TChromium) + private type + TChromiumBrowserState = (csNoBrowser, csCreatingBrowser, csHasBrowser, csClosingBrowser, csCloseAfterCreate); + private + FInternalOnGotFocus: TOnGotFocus; + FState : TChromiumBrowserState; + FInternalOnBrowserClosed : TNotifyEvent; + FInternalOnBrowserCreated : TNotifyEvent; + + FLoadUrl, FFrameName : ustring; + function GetIsClosing: Boolean; + procedure SetInternalOnClose(AValue: TOnClose); + + protected + function GetHasBrowser : boolean; reintroduce; + + procedure doOnBeforeClose(const ABrowser: ICefBrowser); override; + procedure doOnAfterCreated(const ABrowser: ICefBrowser); override; + procedure doOnGotFocus(const Abrowser: ICefBrowser); override; + function MustCreateFocusHandler: boolean; override; + + procedure DoCreated(Data: PtrInt); + procedure DoOnClosed(Data: PtrInt); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + + function CreateBrowser(const aBrowserParent: TWinControl = nil; + const aWindowName: ustring = ''; const aContext: ICefRequestContext = + nil; const aExtraInfo: ICefDictionaryValue = nil): boolean; overload; override; + function CreateBrowser(aParentHandle: TCefWindowHandle; + aParentRect: TRect; const aWindowName: ustring = ''; + const aContext: ICefRequestContext = nil; + const aExtraInfo: ICefDictionaryValue = nil): boolean; overload; override; + procedure CreateBrowser(const aWindowName: ustring); overload; override; + function CreateBrowser(const aURL: ustring; + const aBrowserViewComp: TCEFBrowserViewComponent; + const aContext: ICefRequestContext = nil; + const aExtraInfo: ICefDictionaryValue = nil): boolean; overload; override; + + // CloseBrowser will work, even if the browser is still in creation, and Initialized is still false + procedure CloseBrowser(aForceClose: boolean); reintroduce; + + // LoadURL will work, even if the browser is still in creation, and Initialized is still false + procedure LoadURL(const aURL: ustring; const aFrameName: ustring = ''); overload; + + property HasBrowser: Boolean read GetHasBrowser; // Includes browser in creation + property IsClosing : Boolean read GetIsClosing; + + (* - Events for use by the Owning component ONLY + - Events are called in main thread + - OnBrowserCreated: the parent event may be called when procedure Initialized is still false. + - OnBrowserCreated: may not be called, if the CloseBrowser has already been called + *) + property InternalOnBrowserCreated : TNotifyEvent read FInternalOnBrowserCreated write FInternalOnBrowserCreated; + property InternalOnBrowserClosed : TNotifyEvent read FInternalOnBrowserClosed write FInternalOnBrowserClosed; + property InternalOnGotFocus : TOnGotFocus read FInternalOnGotFocus write FInternalOnGotFocus; + end; + + TBrowserWindow = class; + + { TChromiumWrapper } + + TChromiumWrapper = class + protected type + TWrapperState = (wsNone, wsWaitingForClose, wsSentCloseEventAfterWait, wsDestroyAfterWait); + protected + FChromium : TEmbeddedChromium; + FWrapperState : TWrapperState; + FBrowserWindow : TBrowserWindow; + + procedure DoOnAfterCreated(Sender: TObject); + procedure DoOnBeforeClose(Sender: TObject); + + procedure BrowserThread_OnClose(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction); + {$IFDEF FPC} + procedure BrowserThread_OnGotFocus(Sender: TObject; const browser: ICefBrowser); + {$ENDIF} + + procedure MaybeDestroy; + public + constructor Create(AOwner: TBrowserWindow); reintroduce; + destructor Destroy; override; + + function CreateBrowser: boolean; + procedure LoadURL(aURL: ustring); + procedure CloseBrowser(aForceClose: boolean); + function IsClosed: boolean; + (* WaitForBrowserClosed calls ProcessMessages. + It therefore is possible that the TBrowserWindow will be destroyed + when this method returns. + It is the callers responsibility to take any necessary precaution. + *) + procedure WaitForBrowserClosed; + + published + property Chromium: TEmbeddedChromium read FChromium; + end; + + { TBrowserWindow + + A simple "drop on the Form" component for an full embedded browser. + + The component handles most events required by CEF. + The only additions needed to be made by the User in their code are: + + * Implement TForm.OnCloseQuery + CEF must be able to destroy the browser, before the main form is closed. + (That is while the Form still has a Handle, and the event loop is still + running) + It is adviced to do the same for any other form (other than the main form). + + TForm.OnCloseQuery should call (for each TBrowserWindow) + TBrowserWindow.CloseBrowser(True); + The Form can be allowed to close by setting (checking for all BrowserWindows) + CanClose := BrowserWindow.IsClosed; + + On Windows and Linux it is also possible to Destroy the TBrowserWindow. + This will wait for the browser to close, and after that the form can be closed. + - However, this must be done in OnCloseQuery (or before). + - Once TForm.Destroy is called, it is to late. By that time the event loop + no longer runs. + + *** IMPORTANT: (MacOS) *** + On MacOs CloseBrowser() must be called, and the *event* must be awaited. + Neither destroying the component, nor waiting with App.ProcessMessages will + work. + On MacOS, CEF will not finish until the OnCloseQuery event returned to the + main event loop. (Hence ProcessMessage does not work). + The same is true for any action taken in OnClick or other event. + CEF always waits for any event to return to the main event loop. + See also the BrowserWindowEX example how that affect modal forms. + + * Implement TBrowserWindow.OnBrowserClosed + If TForm.OnCloseQuery called CloseBrowser, this callback can be used to + call Form.Close again (the callback should check if the browser was + closed by OnCloseQuery. + + * On Windows: + handle the WM_ENTERMENULOOP and WM_EXITMENULOOP, as shown in examples + + * Optional prevent pop-up windows by implementing + Chromium.BeforePopup + Chromium.OpenUrlFromTab + } + + TBrowserWindow = class(TCEFLinkedWinControlBase) + private + FChromiumWrapper : TChromiumWrapper; + + FOnBrowserClosed : TNotifyEvent; + FOnBrowserCreated : TNotifyEvent; + FTimer : TTimer; + + procedure DoCreateBrowser(Sender: TObject); + procedure DoCreateBrowserAfterContext(Sender: TObject); + function GetEmbeddedChromium: TEmbeddedChromium; + protected + function GetChromium: TChromium; override; + procedure DestroyHandle; override; + procedure RealizeBounds; override; + + procedure DoEnter; override; + procedure DoExit; override; + procedure DoOnCreated; + procedure DoOnClosed(Data: PtrInt); + procedure DoOnFocus(Data: PtrInt); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure CreateHandle; override; + + procedure CloseBrowser(aForceClose: boolean); + procedure WaitForBrowserClosed; + function IsClosed: boolean; + procedure LoadURL(aURL: ustring); + + published + property Chromium: TEmbeddedChromium read GetEmbeddedChromium; + + property OnBrowserCreated : TNotifyEvent read FOnBrowserCreated write FOnBrowserCreated; + (* OnBrowserClosed will not be called, if the TBrowserWindow is + destroyed/destroying before the browser is closed. + *) + property OnBrowserClosed : TNotifyEvent read FOnBrowserClosed write FOnBrowserClosed; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +implementation + +{ TEmbeddedChromium } + +function TEmbeddedChromium.GetIsClosing: Boolean; +begin + Result := FState in [csCloseAfterCreate, csClosingBrowser]; +end; + +procedure TEmbeddedChromium.SetInternalOnClose(AValue: TOnClose); +begin + inherited OnClose := AValue; +end; + +function TEmbeddedChromium.GetHasBrowser: boolean; +begin + Result := (FState <> csNoBrowser) or (inherited GetHasBrowser); +end; + +procedure TEmbeddedChromium.doOnBeforeClose(const ABrowser: ICefBrowser); +begin + inherited doOnBeforeClose(ABrowser); + + FState := csNoBrowser; + Application.QueueAsyncCall(@DoOnClosed, 0); +end; + +procedure TEmbeddedChromium.doOnAfterCreated(const ABrowser: ICefBrowser); +begin + inherited doOnAfterCreated(ABrowser); + (* We may still be in Chromium.CreateBrowserSync + In that case initialization will happen after this event, + but before the call to CreateBrowser returns + *) + Application.QueueAsyncCall(@DoCreated, 0); +end; + +procedure TEmbeddedChromium.doOnGotFocus(const Abrowser: ICefBrowser); +begin + inherited doOnGotFocus(Abrowser); + if Assigned(FInternalOnGotFocus) then + FInternalOnGotFocus(Self, Abrowser); +end; + +function TEmbeddedChromium.MustCreateFocusHandler: boolean; +begin + Result := assigned(FInternalOnGotFocus) or + inherited MustCreateFocusHandler; +end; + +procedure TEmbeddedChromium.DoCreated(Data: PtrInt); +var + u, f: ustring; +begin + // Any other state, means this is a late async call + case FState of + csCreatingBrowser: begin + FState := csHasBrowser; + if FLoadUrl <> '' then begin + u := FLoadUrl; + f := FFrameName; + LoadURL(u, f); + end; + + if (FInternalOnBrowserCreated <> nil) then + FInternalOnBrowserCreated(Self); + end; + csCloseAfterCreate: begin + FState := csHasBrowser; + CloseBrowser(True); + end; + end; +end; + +procedure TEmbeddedChromium.DoOnClosed(Data: PtrInt); +begin + if (FInternalOnBrowserClosed <> nil) then + FInternalOnBrowserClosed(Self); +end; + +constructor TEmbeddedChromium.Create(AOwner: TComponent); +begin + FState := csNoBrowser; + inherited Create(AOwner); + SetSubComponent(True); + Name := 'Chromium'; +end; + +destructor TEmbeddedChromium.Destroy; +begin + inherited Destroy; + Application.RemoveAsyncCalls(Self); +end; + +function TEmbeddedChromium.CreateBrowser(const aBrowserParent: TWinControl; + const aWindowName: ustring; const aContext: ICefRequestContext; + const aExtraInfo: ICefDictionaryValue): boolean; +begin + FState := csCreatingBrowser; + Result := inherited CreateBrowser(aBrowserParent, aWindowName, aContext, + aExtraInfo); + if Initialized then + DoCreated(0); +end; + +function TEmbeddedChromium.CreateBrowser(aParentHandle: TCefWindowHandle; + aParentRect: TRect; const aWindowName: ustring; + const aContext: ICefRequestContext; const aExtraInfo: ICefDictionaryValue): boolean; +begin + FState := csCreatingBrowser; + Result := inherited CreateBrowser(aParentHandle, aParentRect, aWindowName, + aContext, aExtraInfo); + if Initialized then + DoCreated(0); +end; + +procedure TEmbeddedChromium.CreateBrowser(const aWindowName: ustring); +begin + FState := csCreatingBrowser; + inherited CreateBrowser(aWindowName); + if Initialized then + DoCreated(0); +end; + +function TEmbeddedChromium.CreateBrowser(const aURL: ustring; + const aBrowserViewComp: TCEFBrowserViewComponent; + const aContext: ICefRequestContext; const aExtraInfo: ICefDictionaryValue + ): boolean; +begin + FState := csCreatingBrowser; + Result := inherited CreateBrowser(aURL, aBrowserViewComp, aContext, aExtraInfo); + if Initialized then + DoCreated(0); +end; + +procedure TEmbeddedChromium.CloseBrowser(aForceClose: boolean); +begin + if FState = csCreatingBrowser then begin + FState := csCloseAfterCreate; + exit; + end + else + if FState in [csHasBrowser] then + begin + FState := csClosingBrowser; + inherited CloseBrowser(aForceClose); + end; +end; + +procedure TEmbeddedChromium.LoadURL(const aURL: ustring; const aFrameName: ustring); +begin + FLoadUrl := ''; + FFrameName := ''; + if FState = csHasBrowser then + begin + inherited LoadURL(aURL, aFrameName); + end + else + begin + FLoadUrl := aURL; + FFrameName := aFrameName; + end; +end; + +{ TChromiumWrapper } + +procedure TChromiumWrapper.DoOnAfterCreated(Sender: TObject); +begin + if (FBrowserWindow <> nil) then + FBrowserWindow.DoOnCreated; +end; + +procedure TChromiumWrapper.BrowserThread_OnClose(Sender: TObject; + const browser: ICefBrowser; var aAction: TCefCloseBrowserAction); +begin + (* FBrowserWindow should always be <> nil + If FBrowserWindow is nil (MacOS) then the FBrowserWindow.Handle is destroyed too, + and CEF should call BeforeClose, without calling DoClose + *) + if (FBrowserWindow <> nil) and FBrowserWindow.DestroyChildWindow then + aAction := cbaDelay + else + aAction := cbaClose; +end; + +procedure TChromiumWrapper.DoOnBeforeClose(Sender: TObject); +begin + if (FBrowserWindow <> nil) then begin + if FWrapperState = wsWaitingForClose then + FWrapperState := wsSentCloseEventAfterWait + else + FBrowserWindow.DoOnClosed(0); + end; +end; + +procedure TChromiumWrapper.BrowserThread_OnGotFocus(Sender: TObject; + const browser: ICefBrowser); +begin + if (FBrowserWindow <> nil) then + Application.QueueAsyncCall(@FBrowserWindow.DoOnFocus, 0); +end; + +procedure TChromiumWrapper.MaybeDestroy; +begin + if FChromium.Owner <> nil then + FBrowserWindow.RemoveComponent(FChromium); + CloseBrowser(True); + FBrowserWindow := nil; + + if FWrapperState in [wsWaitingForClose, wsSentCloseEventAfterWait] then + FWrapperState := wsDestroyAfterWait; + + if not FChromium.HasBrowser then + Destroy; +end; + +constructor TChromiumWrapper.Create(AOwner: TBrowserWindow); +begin + FBrowserWindow := AOwner; + FWrapperState := wsNone; + + FChromium := TEmbeddedChromium.Create(AOwner); + if not(csDesigning in AOwner.ComponentState) then + begin + FChromium.OnClose := {$IFDEF FPC}@{$ENDIF}BrowserThread_OnClose; + FChromium.InternalOnBrowserClosed := {$IFDEF FPC}@{$ENDIF}DoOnBeforeClose; + FChromium.InternalOnBrowserCreated := {$IFDEF FPC}@{$ENDIF}DoOnAfterCreated; + {$IFDEF LINUX} + // This is a workaround for the CEF issue #2026. Read below for more info. + FChromium.InternalOnGotFocus := {$IFDEF FPC}@{$ENDIF}BrowserThread_OnGotFocus; + {$ENDIF} + end; + + inherited Create; +end; + +destructor TChromiumWrapper.Destroy; +begin + if FChromium.HasBrowser then + WaitForBrowserClosed; + + inherited Destroy; + FChromium.Destroy; + Application.RemoveAsyncCalls(Self); +end; + +function TChromiumWrapper.CreateBrowser: boolean; +begin + if FChromium.HasBrowser then + exit(False); + + Result := FChromium.CreateBrowser(FBrowserWindow, ''); +end; + +procedure TChromiumWrapper.LoadURL(aURL: ustring); +begin + FChromium.LoadURL(aURL); +end; + +procedure TChromiumWrapper.CloseBrowser(aForceClose: boolean); +begin + FChromium.CloseBrowser(aForceClose); +end; + +function TChromiumWrapper.IsClosed: boolean; +begin + Result := not FChromium.HasBrowser; +end; + +procedure TChromiumWrapper.WaitForBrowserClosed; +begin + if not FChromium.HasBrowser then + exit; + FChromium.CloseBrowser(True); + + FWrapperState := wsWaitingForClose; + while FChromium.HasBrowser do begin + Application.ProcessMessages; + if GlobalCEFApp.ExternalMessagePump then + GlobalCEFApp.DoMessageLoopWork; + sleep(5); + end; + + if (FBrowserWindow <> nil) and + (FWrapperState = wsSentCloseEventAfterWait) + then + Application.QueueAsyncCall(@FBrowserWindow.DoOnClosed, 0); + + if FWrapperState = wsDestroyAfterWait then + Destroy + else + FWrapperState := wsNone; +end; + +{ TBrowserWindow } + +procedure TBrowserWindow.DoCreateBrowser(Sender: TObject); +begin + if FTimer <> nil then + FTimer.Enabled := False; + + if FChromiumWrapper.Chromium.HasBrowser then begin + if not FChromiumWrapper.Chromium.IsClosing then begin + FreeAndNil(FTimer); + exit; + end + else begin + FChromiumWrapper.MaybeDestroy; + FChromiumWrapper := TChromiumWrapper.Create(Self); + end; + end; + + if FChromiumWrapper.CreateBrowser then begin + FreeAndNil(FTimer); + end + else begin + if GlobalCEFApp.ExternalMessagePump then + GlobalCEFApp.DoMessageLoopWork; + + if FTimer = nil then + FTimer := TTimer.Create(Self); + FTimer.OnTimer := @DoCreateBrowser; + FTimer.Interval := 100; + FTimer.Enabled := True; + end; +end; + +procedure TBrowserWindow.DoCreateBrowserAfterContext(Sender: TObject); +begin + {$IFnDEF WINDOWS} + FTimer := TTimer.Create(Self); + FTimer.Interval := 20; + FTimer.OnTimer := @DoCreateBrowser; + FTimer.Enabled := True; + {$ELSE} + DoCreateBrowser(nil); + {$ENDIF} +end; + +function TBrowserWindow.GetEmbeddedChromium: TEmbeddedChromium; +begin + Result := FChromiumWrapper.Chromium; +end; + +function TBrowserWindow.GetChromium: TChromium; +begin + Result := FChromiumWrapper.FChromium; +end; + +procedure TBrowserWindow.CreateHandle; +begin + inherited CreateHandle; + if not (csDesigning in ComponentState) then begin + (* On Windows we can create the browser immediately. + But at least on Linux, we need to wait + *) + + GlobalCEFApp.AddContextInitializedHandler(@DoCreateBrowserAfterContext); + end; +end; + +procedure TBrowserWindow.DestroyHandle; +begin + if FTimer <> nil then + FreeAndNil(FTimer); + + if (GlobalCEFApp = nil) or + (not FChromiumWrapper.Chromium.HasBrowser) or + (csDesigning in ComponentState) + then begin + inherited DestroyHandle; + exit; + end; + + {$IFDEF MACOSX} + inherited DestroyHandle; + FChromiumWrapper.CloseBrowser(True); + {$ELSE} + FChromiumWrapper.WaitForBrowserClosed; + inherited DestroyHandle; + {$ENDIF} +end; + +procedure TBrowserWindow.RealizeBounds; +begin + inherited RealizeBounds; + + if not (csDesigning in ComponentState) and HandleAllocated then + Chromium.NotifyMoveOrResizeStarted; +end; + +procedure TBrowserWindow.DoEnter; +begin + inherited DoEnter; + If not(csDesigning in ComponentState) then Chromium.SetFocus(True); +end; + +procedure TBrowserWindow.DoExit; +begin + inherited DoExit; + if not(csDesigning in ComponentState) then + Chromium.SendCaptureLostEvent; +end; + +procedure TBrowserWindow.DoOnCreated; +begin + {$IFDEF FPC}{$IFDEF LINUX} + Chromium.UpdateXWindowVisibility(Visible); + Chromium.UpdateBrowserSize(Left, Top, Width, Height); + {$ENDIF}{$ENDIF} + if Assigned(FOnBrowserCreated) then + FOnBrowserCreated(Self); +end; + +procedure TBrowserWindow.DoOnClosed(Data: PtrInt); +begin + if (not(csDestroying in ComponentState)) and + Assigned(FOnBrowserClosed) + then + FOnBrowserClosed(Self); +end; + +procedure TBrowserWindow.DoOnFocus(Data: PtrInt); +begin + SetFocus; +end; + +constructor TBrowserWindow.Create(AOwner: TComponent); +begin + FChromiumWrapper := TChromiumWrapper.Create(Self); + inherited Create(AOwner); + ControlStyle := ControlStyle + [csOwnedChildrenNotSelectable]; +end; + +destructor TBrowserWindow.Destroy; +begin + RemoveComponent(FChromiumWrapper.FChromium); + inherited Destroy; + FChromiumWrapper.MaybeDestroy; + Application.RemoveAsyncCalls(Self); +end; + +procedure TBrowserWindow.CloseBrowser(aForceClose: boolean); +begin + FChromiumWrapper.CloseBrowser(aForceClose); +end; + +procedure TBrowserWindow.WaitForBrowserClosed; +begin + FChromiumWrapper.WaitForBrowserClosed; +end; + +function TBrowserWindow.IsClosed: boolean; +begin + Result := FChromiumWrapper.IsClosed; +end; + +procedure TBrowserWindow.LoadURL(aURL: ustring); +begin + FChromiumWrapper.LoadURL(aURL); +end; + +{$IFDEF FPC} + +procedure Register; +begin + {$I res/TBrowserWindow.lrs} + RegisterComponents('Chromium', [TBrowserWindow]); + RegisterClass(TEmbeddedChromium); + RegisterPropertyEditor(TypeInfo(TOnClose), TEmbeddedChromium, 'OnClose', THiddenPropertyEditor); +end; +{$ENDIF} + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFBufferPanel.pas b/windows/src/ext/cef4delphi/source/uCEFBufferPanel.pas new file mode 100644 index 0000000000000000000000000000000000000000..34b50524b85f34572079a0cdc692b56cac34744c --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFBufferPanel.pas @@ -0,0 +1,1196 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFBufferPanel; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}Winapi.Windows, Winapi.Messages, Vcl.ExtCtrls, Vcl.Controls, Vcl.Graphics, WinApi.Imm, {$ENDIF} + System.Classes, System.SyncObjs, System.SysUtils, Vcl.Forms, + {$ELSE} + {$IFDEF MSWINDOWS}Windows, imm, {$ENDIF} Classes, Forms, Controls, Graphics, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, {$IFDEF MSWINDOWS}Win32Extra,{$ENDIF} + {$ELSE} + Messages, + {$ENDIF} + ExtCtrls, SyncObjs, SysUtils, + {$ENDIF} + {$IFDEF MSWINDOWS}uCEFOSRIMEHandler,{$ENDIF} uCEFConstants, uCEFTypes, uCEFBitmapBitBuffer; + +type + TOnIMECommitTextEvent = procedure(Sender: TObject; const aText : ustring; const replacement_range : PCefRange; relative_cursor_pos : integer) of object; + TOnIMESetCompositionEvent = procedure(Sender: TObject; const aText : ustring; const underlines : TCefCompositionUnderlineDynArray; const replacement_range, selection_range : TCefRange) of object; + {$IFDEF MSWINDOWS} + TOnHandledMessageEvent = procedure(Sender: TObject; var aMessage: TMessage; var aHandled : boolean) of object; + {$ENDIF} + + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TBufferPanel = class(TCustomPanel) + protected + FScanlineSize : integer; + FTransparent : boolean; + FOnPaintParentBkg : TNotifyEvent; + FForcedDeviceScaleFactor : single; + FDeviceScaleFactor : single; + FCopyOriginalBuffer : boolean; + FMustInitBuffer : boolean; + FBuffer : TBitmap; + FOrigBuffer : TCEFBitmapBitBuffer; + FOrigPopupBuffer : TCEFBitmapBitBuffer; + FOrigPopupScanlineSize : integer; + {$IFDEF MSWINDOWS} + FSyncObj : THandle; + FIMEHandler : TCEFOSRIMEHandler; + FOnIMECancelComposition : TNotifyEvent; + FOnIMECommitText : TOnIMECommitTextEvent; + FOnIMESetComposition : TOnIMESetCompositionEvent; + FOnCustomTouch : TOnHandledMessageEvent; + FOnPointerDown : TOnHandledMessageEvent; + FOnPointerUp : TOnHandledMessageEvent; + FOnPointerUpdate : TOnHandledMessageEvent; + {$ELSE} + FSyncObj : TCriticalSection; + {$ENDIF} + + procedure CreateSyncObj; + + procedure DestroySyncObj; + procedure DestroyBuffer; + + function GetBufferBits : pointer; + function GetBufferWidth : integer; + function GetBufferHeight : integer; + function GetOrigBufferWidth : integer; + function GetOrigBufferHeight : integer; + function GetScreenScale : single; virtual; + function GetRealScreenScale(var aResultScale : single) : boolean; virtual; + function GetOrigPopupBufferBits : pointer; + function GetOrigPopupBufferWidth : integer; + function GetOrigPopupBufferHeight : integer; + {$IFDEF MSWINDOWS} + function GetParentFormHandle : TCefWindowHandle; + function GetParentForm : TCustomForm; + {$ENDIF} + + procedure SetTransparent(aValue : boolean); + + function CopyBuffer : boolean; + function SaveBufferToFile(const aFilename : string) : boolean; + + procedure Paint; override; + {$IFDEF MSWINDOWS} + procedure CreateParams(var Params: TCreateParams); override; + procedure WndProc(var aMessage: TMessage); override; + procedure WMEraseBkgnd(var aMessage : TWMEraseBkgnd); message WM_ERASEBKGND; + procedure WMTouch(var aMessage: TMessage); message WM_TOUCH; + procedure WMPointerDown(var aMessage: TMessage); message WM_POINTERDOWN; + procedure WMPointerUpdate(var aMessage: TMessage); message WM_POINTERUPDATE; + procedure WMPointerUp(var aMessage: TMessage); message WM_POINTERUP; + procedure WMIMEStartComp(var aMessage: TMessage); + procedure WMIMEEndComp(var aMessage: TMessage); + procedure WMIMESetContext(var aMessage: TMessage); + procedure WMIMEComposition(var aMessage: TMessage); + + procedure DoOnIMECancelComposition; virtual; + procedure DoOnIMECommitText(const aText : ustring; const replacement_range : PCefRange; relative_cursor_pos : integer); virtual; + procedure DoOnIMESetComposition(const aText : ustring; const underlines : TCefCompositionUnderlineDynArray; const replacement_range, selection_range : TCefRange); virtual; + {$ENDIF} + + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure AfterConstruction; override; + function SaveToFile(const aFilename : string) : boolean; + function InvalidatePanel : boolean; + function BeginBufferDraw : boolean; + procedure EndBufferDraw; + procedure BufferDraw(x, y : integer; const aBitmap : TBitmap); overload; + procedure BufferDraw(const aBitmap : TBitmap; const aSrcRect, aDstRect : TRect); overload; + function UpdateBufferDimensions(aWidth, aHeight : integer) : boolean; + function UpdateOrigBufferDimensions(aWidth, aHeight : integer) : boolean; + function UpdateOrigPopupBufferDimensions(aWidth, aHeight : integer) : boolean; + procedure UpdateDeviceScaleFactor; + function BufferIsResized(aUseMutex : boolean = True) : boolean; + procedure CreateIMEHandler; + procedure ChangeCompositionRange(const selection_range : TCefRange; const character_bounds : TCefRectDynArray); + procedure DrawOrigPopupBuffer(const aSrcRect, aDstRect : TRect); + + property ScanlineSize : integer read FScanlineSize; + property BufferWidth : integer read GetBufferWidth; + property BufferHeight : integer read GetBufferHeight; + property BufferBits : pointer read GetBufferBits; + property ScreenScale : single read GetScreenScale; + property ForcedDeviceScaleFactor : single read FForcedDeviceScaleFactor write FForcedDeviceScaleFactor; + property MustInitBuffer : boolean read FMustInitBuffer write FMustInitBuffer; + + property Buffer : TBitmap read FBuffer; + property OrigBuffer : TCEFBitmapBitBuffer read FOrigBuffer; + property OrigBufferWidth : integer read GetOrigBufferWidth; + property OrigBufferHeight : integer read GetOrigBufferHeight; + property OrigPopupBuffer : TCEFBitmapBitBuffer read FOrigPopupBuffer; + property OrigPopupBufferWidth : integer read GetOrigPopupBufferWidth; + property OrigPopupBufferHeight : integer read GetOrigPopupBufferHeight; + property OrigPopupBufferBits : pointer read GetOrigPopupBufferBits; + property OrigPopupScanlineSize : integer read FOrigPopupScanlineSize; + + {$IFDEF MSWINDOWS} + property ParentFormHandle : TCefWindowHandle read GetParentFormHandle; + property ParentForm : TCustomForm read GetParentForm; + {$ENDIF} + + property DockManager; + property Canvas; + + published + {$IFDEF MSWINDOWS} + property OnIMECancelComposition : TNotifyEvent read FOnIMECancelComposition write FOnIMECancelComposition; + property OnIMECommitText : TOnIMECommitTextEvent read FOnIMECommitText write FOnIMECommitText; + property OnIMESetComposition : TOnIMESetCompositionEvent read FOnIMESetComposition write FOnIMESetComposition; + property OnCustomTouch : TOnHandledMessageEvent read FOnCustomTouch write FOnCustomTouch; + property OnPointerDown : TOnHandledMessageEvent read FOnPointerDown write FOnPointerDown; + property OnPointerUp : TOnHandledMessageEvent read FOnPointerUp write FOnPointerUp; + property OnPointerUpdate : TOnHandledMessageEvent read FOnPointerUpdate write FOnPointerUpdate; + {$ENDIF} + property OnPaintParentBkg : TNotifyEvent read FOnPaintParentBkg write FOnPaintParentBkg; + + property Transparent : boolean read FTransparent write SetTransparent default False; + property CopyOriginalBuffer : boolean read FCopyOriginalBuffer write FCopyOriginalBuffer default False; + + property Align; + property Alignment; + property Anchors; + property AutoSize; + {$IFDEF FPC} + property OnUTF8KeyPress; + {$ELSE} + property BevelEdges; + property BevelKind; + property Ctl3D; + property Locked; + property ParentBackground; + property ParentCtl3D; + property OnCanResize; + {$ENDIF} + property BevelInner; + property BevelOuter; + property BevelWidth; + property BiDiMode; + property BorderWidth; + property BorderStyle; + property Caption; + property Color; + property Constraints; + property UseDockManager default True; + property DockSite; + property DoubleBuffered; + property DragCursor; + property DragKind; + property DragMode; + property Enabled; + property FullRepaint; + property Font; + property ParentBiDiMode; + property ParentColor; + property ParentFont; + property ParentShowHint; + property PopupMenu; + property ShowHint; + property TabOrder; + property TabStop; + property Visible; + property OnClick; + property OnConstrainedResize; + property OnContextPopup; + property OnDockDrop; + property OnDockOver; + property OnDblClick; + property OnDragDrop; + property OnDragOver; + property OnEndDock; + property OnEndDrag; + property OnEnter; + property OnExit; + property OnGetSiteInfo; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + property OnMouseWheel; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnResize; + property OnStartDock; + property OnStartDrag; + property OnUnDock; + {$IFDEF DELPHI9_UP} + property VerticalAlignment; + property OnAlignInsertBefore; + property OnAlignPosition; + {$ENDIF} + {$IFDEF DELPHI10_UP} + property Padding; + property OnMouseActivate; + property OnMouseEnter; + property OnMouseLeave; + {$ENDIF} + {$IFDEF FPC} + property OnMouseEnter; + property OnMouseLeave; + {$ENDIF} + {$IFDEF DELPHI12_UP} + property ShowCaption; + property ParentDoubleBuffered; + {$ENDIF} + {$IFDEF DELPHI14_UP} + property Touch; + property OnGesture; + {$ENDIF} + {$IFDEF DELPHI17_UP} + property StyleElements; + {$ENDIF} + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.Math, + {$ELSE} + Math, + {$ENDIF} + uCEFMiscFunctions, uCEFApplicationCore; + +constructor TBufferPanel.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + FBuffer := nil; + FTransparent := False; + FOnPaintParentBkg := nil; + FScanlineSize := 0; + FCopyOriginalBuffer := False; + FOrigBuffer := nil; + FOrigPopupBuffer := nil; + FOrigPopupScanlineSize := 0; + FDeviceScaleFactor := 0; + + if (GlobalCEFApp <> nil) and (GlobalCEFApp.ForcedDeviceScaleFactor <> 0) then + FForcedDeviceScaleFactor := GlobalCEFApp.ForcedDeviceScaleFactor + else + FForcedDeviceScaleFactor := 0; + + {$IFDEF MSWINDOWS} + FSyncObj := 0; + FIMEHandler := nil; + FOnIMECancelComposition := nil; + FOnIMECommitText := nil; + FOnIMESetComposition := nil; + FOnCustomTouch := nil; + FOnPointerDown := nil; + FOnPointerUp := nil; + FOnPointerUpdate := nil; + FMustInitBuffer := False; + {$ELSE} + FSyncObj := nil; + FMustInitBuffer := True; + {$ENDIF} +end; + +destructor TBufferPanel.Destroy; +begin + DestroyBuffer; + DestroySyncObj; + + {$IFDEF MSWINDOWS} + if (FIMEHandler <> nil) then FreeAndNil(FIMEHandler); + {$ENDIF} + + inherited Destroy; +end; + +procedure TBufferPanel.AfterConstruction; +begin + inherited AfterConstruction; + + CreateSyncObj; + UpdateDeviceScaleFactor; + + {$IFDEF MSWINDOWS} + {$IFNDEF FPC} + ImeMode := imDontCare; + ImeName := ''; + {$ENDIF} + {$ENDIF} +end; + +procedure TBufferPanel.CreateIMEHandler; +begin + {$IFDEF MSWINDOWS} + if (FIMEHandler = nil) and HandleAllocated then + FIMEHandler := TCEFOSRIMEHandler.Create(Handle); + {$ENDIF} +end; + +procedure TBufferPanel.ChangeCompositionRange(const selection_range : TCefRange; + const character_bounds : TCefRectDynArray); +begin + {$IFDEF MSWINDOWS} + if (FIMEHandler <> nil) then + FIMEHandler.ChangeCompositionRange(selection_range, character_bounds); + {$ENDIF} +end; + +procedure TBufferPanel.DrawOrigPopupBuffer(const aSrcRect, aDstRect : TRect); +var + src_y, dst_y, TempWidth : integer; + src, dst : PByte; +begin + if (FOrigBuffer = nil) or (FOrigPopupBuffer = nil) then exit; + + src_y := aSrcRect.Top; + dst_y := aDstRect.Top; + + TempWidth := min(aSrcRect.Right - aSrcRect.Left + 1, + aDstRect.Right - aDstRect.Left + 1); + + if (aSrcRect.Left + TempWidth >= FOrigPopupBuffer.Width) then + TempWidth := FOrigPopupBuffer.Width - aSrcRect.Left; + + if (aDstRect.Left + TempWidth >= FOrigBuffer.Width) then + TempWidth := FOrigBuffer.Width - aDstRect.Left; + + while (src_y <= aSrcRect.Bottom) and (src_y < FOrigPopupBuffer.Height) and + (dst_y <= aDstRect.Bottom) and (dst_y < FOrigBuffer.Height) do + begin + src := FOrigPopupBuffer.ScanLine[src_y]; + dst := FOrigBuffer.ScanLine[dst_y]; + + if (aSrcRect.Left > 0) then + inc(src, aSrcRect.Left * SizeOf(TRGBQuad)); + + if (aDstRect.Left > 0) then + inc(dst, aDstRect.Left * SizeOf(TRGBQuad)); + + move(src^, dst^, TempWidth * SizeOf(TRGBQuad)); + + inc(src_y); + inc(dst_y); + end; +end; + +procedure TBufferPanel.CreateSyncObj; +begin + {$IFDEF MSWINDOWS} + FSyncObj := CreateMutex(nil, False, nil); + {$ELSE} + FSyncObj := TCriticalSection.Create; + {$ENDIF} +end; + +procedure TBufferPanel.DestroySyncObj; +begin + {$IFDEF MSWINDOWS} + if (FSyncObj <> 0) then + begin + CloseHandle(FSyncObj); + FSyncObj := 0; + end; + {$ELSE} + if (FSyncObj <> nil) then FreeAndNil(FSyncObj); + {$ENDIF} +end; + +procedure TBufferPanel.DestroyBuffer; +begin + if BeginBufferDraw then + begin + if (FBuffer <> nil) then FreeAndNil(FBuffer); + if (FOrigBuffer <> nil) then FreeAndNil(FOrigBuffer); + if (FOrigPopupBuffer <> nil) then FreeAndNil(FOrigPopupBuffer); + + EndBufferDraw; + end; +end; + +function TBufferPanel.SaveBufferToFile(const aFilename : string) : boolean; +begin + Result := False; + try + if (FBuffer <> nil) then + begin + FBuffer.SaveToFile(aFilename); + Result := True; + end; + except + on e : exception do + if CustomExceptionHandler('TBufferPanel.SaveBufferToFile', e) then raise; + end; +end; + +function TBufferPanel.SaveToFile(const aFilename : string) : boolean; +begin + Result := False; + + if BeginBufferDraw then + begin + Result := SaveBufferToFile(aFilename); + EndBufferDraw; + end; +end; + +function TBufferPanel.InvalidatePanel : boolean; +begin + {$IFDEF MSWINDOWS} + Result := HandleAllocated and PostMessage(Handle, CM_INVALIDATE, 0, 0); + {$ELSE} + Result := True; + TThread.Queue(nil, @Invalidate); + {$ENDIF} +end; + +function TBufferPanel.BeginBufferDraw : boolean; +begin + {$IFDEF MSWINDOWS} + Result := (FSyncObj <> 0) and (WaitForSingleObject(FSyncObj, 5000) = WAIT_OBJECT_0); + {$ELSE} + if (FSyncObj <> nil) then + begin + FSyncObj.Acquire; + Result := True; + end + else + Result := False; + {$ENDIF} +end; + +procedure TBufferPanel.EndBufferDraw; +begin + {$IFDEF MSWINDOWS} + if (FSyncObj <> 0) then ReleaseMutex(FSyncObj); + {$ELSE} + if (FSyncObj <> nil) then FSyncObj.Release; + {$ENDIF} +end; + +function TBufferPanel.CopyBuffer : boolean; +var + {$IFDEF MSWINDOWS} + TempFunction : TBlendFunction; + {$ENDIF} + y : integer; + src, dst : pointer; +begin + Result := False; + + if BeginBufferDraw then + try + if FCopyOriginalBuffer then + begin + if (FBuffer = nil) then + begin + FBuffer := TBitmap.Create; + FBuffer.PixelFormat := pf32bit; + FBuffer.HandleType := bmDIB; + FBuffer.Width := 1001; + FBuffer.Height := 600; + + if FMustInitBuffer then + begin + FBuffer.Canvas.Brush.Color := clWhite; + FBuffer.Canvas.FillRect(rect(0, 0, FBuffer.Width, FBuffer.Height)); + end; + end; + + if (FOrigBuffer <> nil) and not(FOrigBuffer.Empty) then + begin + if (FBuffer.Width <> FOrigBuffer.Width) or + (FBuffer.Height <> FOrigBuffer.Height) then + begin + FBuffer.Width := FOrigBuffer.Width; + FBuffer.Height := FOrigBuffer.Height; + + if FMustInitBuffer then + begin + FBuffer.Canvas.Brush.Color := clWhite; + FBuffer.Canvas.FillRect(rect(0, 0, FBuffer.Width, FBuffer.Height)); + end; + end; + + try + {$IFDEF FPC} + FBuffer.BeginUpdate; + {$ENDIF} + y := 0; + while (y < FBuffer.Height) do + begin + src := FOrigBuffer.ScanLine[y]; + dst := FBuffer.ScanLine[y]; + move(src^, dst^, FOrigBuffer.ScanLineSize); + inc(y); + end; + finally + {$IFDEF FPC} + FBuffer.EndUpdate; + {$ENDIF} + end; + end; + end; + + if (FBuffer <> nil) and (FBuffer.Width <> 0) and (FBuffer.Height <> 0) then + begin + {$IFDEF MSWINDOWS} + if FTransparent then + begin + // TODO : To avoid flickering we should be using another bitmap + // for the background image. We should blend "FBuffer" with the + // "background bitmap" and then blit the result to the canvas. + + if assigned(FOnPaintParentBkg) then FOnPaintParentBkg(self); + + TempFunction.BlendOp := AC_SRC_OVER; + TempFunction.BlendFlags := 0; + TempFunction.SourceConstantAlpha := 255; + TempFunction.AlphaFormat := AC_SRC_ALPHA; + + Result := AlphaBlend(Canvas.Handle, 0, 0, Width, Height, + FBuffer.Canvas.Handle, 0, 0, FBuffer.Width, FBuffer.Height, + TempFunction); + end + else + Result := BitBlt(Canvas.Handle, 0, 0, Width, Height, + FBuffer.Canvas.Handle, 0, 0, + SrcCopy); + {$ELSE} + try + Canvas.Lock; + Canvas.Draw(0, 0, FBuffer); + Result := True; + finally + Canvas.Unlock; + end; + {$ENDIF} + end; + finally + EndBufferDraw; + end; +end; + +procedure TBufferPanel.Paint; +begin + if csDesigning in ComponentState then + begin + Canvas.Font.Assign(Font); + Canvas.Brush.Color := Color; + Canvas.Brush.Style := bsSolid; + Canvas.Pen.Style := psDash; + + Canvas.Rectangle(0, 0, Width, Height); + end + else + if not(CopyBuffer) and not(FTransparent) then + begin + Canvas.Brush.Color := Color; + Canvas.Brush.Style := bsSolid; + Canvas.FillRect(rect(0, 0, Width, Height)); + end; + + {$IFDEF FPC} + if assigned(OnPaint) then OnPaint(Self); + {$ENDIF} +end; + +{$IFDEF MSWINDOWS} +procedure TBufferPanel.CreateParams(var Params: TCreateParams); +begin + inherited CreateParams(Params); + + if FTransparent then + Params.ExStyle := Params.ExStyle and not WS_EX_TRANSPARENT; +end; + +procedure TBufferPanel.WndProc(var aMessage: TMessage); +begin + case aMessage.Msg of + WM_IME_STARTCOMPOSITION : WMIMEStartComp(aMessage); + WM_IME_COMPOSITION : WMIMEComposition(aMessage); + + WM_IME_ENDCOMPOSITION : + begin + WMIMEEndComp(aMessage); + inherited WndProc(aMessage); + end; + + WM_IME_SETCONTEXT : + begin + aMessage.LParam := aMessage.LParam and not(ISC_SHOWUICOMPOSITIONWINDOW); + inherited WndProc(aMessage); + WMIMESetContext(aMessage); + end; + + else inherited WndProc(aMessage); + end; +end; + +procedure TBufferPanel.WMEraseBkgnd(var aMessage : TWMEraseBkgnd); +begin + aMessage.Result := 1; +end; + +procedure TBufferPanel.WMTouch(var aMessage: TMessage); +var + TempHandled : boolean; +begin + TempHandled := False; + {$IFDEF MSWINDOWS} + if assigned(FOnCustomTouch) then FOnCustomTouch(self, aMessage, TempHandled); + {$ENDIF} + if not(TempHandled) then inherited; +end; + +procedure TBufferPanel.WMPointerDown(var aMessage: TMessage); +var + TempHandled : boolean; +begin + TempHandled := False; + {$IFDEF MSWINDOWS} + if assigned(FOnPointerDown) then FOnPointerDown(self, aMessage, TempHandled); + {$ENDIF} + if not(TempHandled) then inherited; +end; + +procedure TBufferPanel.WMPointerUpdate(var aMessage: TMessage); +var + TempHandled : boolean; +begin + TempHandled := False; + {$IFDEF MSWINDOWS} + if assigned(FOnPointerUpdate) then FOnPointerUpdate(self, aMessage, TempHandled); + {$ENDIF} + if not(TempHandled) then inherited; +end; + +procedure TBufferPanel.WMPointerUp(var aMessage: TMessage); +var + TempHandled : boolean; +begin + TempHandled := False; + {$IFDEF MSWINDOWS} + if assigned(FOnPointerUp) then FOnPointerUp(self, aMessage, TempHandled); + {$ENDIF} + if not(TempHandled) then inherited; +end; + +procedure TBufferPanel.WMIMEStartComp(var aMessage: TMessage); +begin + if (FIMEHandler <> nil) then + begin + {$IFNDEF FPC} + FInImeComposition := False; + {$ENDIF} + + FIMEHandler.CreateImeWindow; + FIMEHandler.MoveImeWindow; + FIMEHandler.ResetComposition; + end; +end; + +procedure TBufferPanel.WMIMEEndComp(var aMessage: TMessage); +begin + DoOnIMECancelComposition; + + if (FIMEHandler <> nil) then + begin + FIMEHandler.ResetComposition; + FIMEHandler.DestroyImeWindow; + end; +end; + +procedure TBufferPanel.WMIMESetContext(var aMessage: TMessage); +begin + if (FIMEHandler <> nil) then + begin + FIMEHandler.CreateImeWindow; + FIMEHandler.MoveImeWindow; + end; +end; + +procedure TBufferPanel.WMIMEComposition(var aMessage: TMessage); +var + TempText : ustring; + TempRange : TCefRange; + TempCompStart : integer; + TempUnderlines : TCefCompositionUnderlineDynArray; + TempSelection : TCefRange; +begin + TempText := ''; + TempCompStart := 0; + TempUnderlines := nil; + + try + if (FIMEHandler <> nil) then + begin + if FIMEHandler.GetResult(aMessage.LParam, TempText) then + begin + if assigned(FOnIMECommitText) then + begin + TempRange.from := high(Integer); + TempRange.to_ := high(Integer); + + DoOnIMECommitText(TempText, @TempRange, 0); + end; + + FIMEHandler.ResetComposition; + end; + + if FIMEHandler.GetComposition(aMessage.LParam, TempText, TempUnderlines, TempCompStart) then + begin + if assigned(FOnIMESetComposition) then + begin + TempRange.from := high(Integer); + TempRange.to_ := high(Integer); + + TempSelection.from := TempCompStart; + TempSelection.to_ := TempCompStart + length(TempText); + + DoOnIMESetComposition(TempText, TempUnderlines, TempRange, TempSelection); + end; + + FIMEHandler.UpdateCaretPosition(pred(TempCompStart)); + end + else + begin + DoOnIMECancelComposition; + + FIMEHandler.ResetComposition; + FIMEHandler.DestroyImeWindow; + end; + end; + finally + if (TempUnderlines <> nil) then + begin + Finalize(TempUnderlines); + TempUnderlines := nil; + end; + end; +end; + +procedure TBufferPanel.DoOnIMECancelComposition; +begin + if assigned(FOnIMECancelComposition) then + FOnIMECancelComposition(Self); +end; + +procedure TBufferPanel.DoOnIMECommitText(const aText: ustring; + const replacement_range: PCefRange; relative_cursor_pos: integer); +begin + if assigned(FOnIMECommitText) then + FOnIMECommitText(Self, aText, replacement_range, relative_cursor_pos); +end; + +procedure TBufferPanel.DoOnIMESetComposition(const aText: ustring; + const underlines: TCefCompositionUnderlineDynArray; const replacement_range, + selection_range: TCefRange); +begin + if assigned(FOnIMESetComposition) then + FOnIMESetComposition(Self, aText, underlines, replacement_range, selection_range); +end; +{$ENDIF} + +function TBufferPanel.GetBufferBits : pointer; +begin + if (FBuffer <> nil) and (FBuffer.Height <> 0) then + Result := FBuffer.Scanline[pred(FBuffer.Height)] + else + Result := nil; +end; + +function TBufferPanel.GetBufferWidth : integer; +begin + if (FBuffer <> nil) then + Result := FBuffer.Width + else + Result := 0; +end; + +function TBufferPanel.GetBufferHeight : integer; +begin + if (FBuffer <> nil) then + Result := FBuffer.Height + else + Result := 0; +end; + +function TBufferPanel.GetOrigBufferWidth : integer; +begin + if (FOrigBuffer <> nil) then + Result := FOrigBuffer.Width + else + Result := 0; +end; + +function TBufferPanel.GetOrigBufferHeight : integer; +begin + if (FOrigBuffer <> nil) then + Result := FOrigBuffer.Height + else + Result := 0; +end; + +function TBufferPanel.GetOrigPopupBufferBits : pointer; +begin + if (FOrigPopupBuffer <> nil) then + Result := FOrigPopupBuffer.BufferBits + else + Result := nil; +end; + +function TBufferPanel.GetOrigPopupBufferWidth : integer; +begin + if (FOrigPopupBuffer <> nil) then + Result := FOrigPopupBuffer.Width + else + Result := 0; +end; + +function TBufferPanel.GetOrigPopupBufferHeight : integer; +begin + if (FOrigPopupBuffer <> nil) then + Result := FOrigPopupBuffer.Height + else + Result := 0; +end; + +procedure TBufferPanel.UpdateDeviceScaleFactor; +var + TempScale : single; +begin + if GetRealScreenScale(TempScale) then + FDeviceScaleFactor := TempScale; +end; + +function TBufferPanel.GetRealScreenScale(var aResultScale : single) : boolean; + {$IFDEF MSWINDOWS} +var + TempHandle : TCefWindowHandle; + TempDC : HDC; + TempDPI : UINT; + {$ELSE} + {$IFDEF LINUX} + {$IFDEF FPC} +var + TempForm : TCustomForm; + TempMonitor : TMonitor; + {$ENDIF} + {$ENDIF} + {$ENDIF} +begin + Result := False; + aResultScale := 1; + + {$IFDEF MSWINDOWS} + TempHandle := ParentFormHandle; + + if (TempHandle <> 0) then + begin + Result := True; + + if RunningWindows10OrNewer and GetDPIForHandle(TempHandle, TempDPI) then + aResultScale := TempDPI / USER_DEFAULT_SCREEN_DPI + else + begin + TempDC := GetWindowDC(TempHandle); + aResultScale := GetDeviceCaps(TempDC, LOGPIXELSX) / USER_DEFAULT_SCREEN_DPI; + ReleaseDC(TempHandle, TempDC); + end; + end; + {$ENDIF} + + {$IFDEF LINUX} + {$IFDEF FPC} + TempForm := GetParentForm(self, True); + + if (TempForm <> nil) then + begin + TempMonitor := TempForm.Monitor; + + if (TempMonitor <> nil) and (TempMonitor.PixelsPerInch > 0) then + begin + aResultScale := TempMonitor.PixelsPerInch / USER_DEFAULT_SCREEN_DPI; + Result := True; + end; + end; + {$ELSE} + // TODO: Get the screen scale in FMXLinux + {$ENDIF} + {$ENDIF} + + {$IFDEF MACOSX} + {$IFDEF FPC} + // TODO: Get the screen scale in Lazarus/FPC + {$ELSE} + // TODO: Get the screen scale in FMX + {$ENDIF} + {$ENDIF} +end; + +function TBufferPanel.GetScreenScale : single; +begin + if (FForcedDeviceScaleFactor <> 0) then + Result := FForcedDeviceScaleFactor + else + if (FDeviceScaleFactor <> 0) then + Result := FDeviceScaleFactor + else + if (GlobalCEFApp <> nil) then + Result := GlobalCEFApp.DeviceScaleFactor + else + Result := 1; +end; + +{$IFDEF MSWINDOWS} +function TBufferPanel.GetParentForm : TCustomForm; +var + TempComp : TComponent; +begin + Result := nil; + TempComp := Owner; + + while (TempComp <> nil) do + if (TempComp is TCustomForm) then + begin + Result := TCustomForm(TempComp); + exit; + end + else + TempComp := TempComp.owner; +end; + +function TBufferPanel.GetParentFormHandle : TCefWindowHandle; +var + TempForm : TCustomForm; +begin + Result := 0; + TempForm := GetParentForm; + + if (TempForm <> nil) then + Result := TempForm.Handle + else + if (Application <> nil) and + (Application.MainForm <> nil) then + Result := Application.MainForm.Handle; +end; +{$ENDIF} + +procedure TBufferPanel.SetTransparent(aValue : boolean); +begin + if (FTransparent <> aValue) then + begin + FTransparent := aValue; + + {$IFDEF MSWINDOWS} + RecreateWnd{$IFDEF FPC}(self){$ENDIF}; + {$ENDIF} + end; +end; + +procedure TBufferPanel.BufferDraw(x, y : integer; const aBitmap : TBitmap); +begin + if (FBuffer <> nil) then FBuffer.Canvas.Draw(x, y, aBitmap); +end; + +procedure TBufferPanel.BufferDraw(const aBitmap : TBitmap; const aSrcRect, aDstRect : TRect); +begin + if (FBuffer <> nil) and (aBitmap <> nil) then + begin + FBuffer.Canvas.Lock; + aBitmap.Canvas.Lock; + FBuffer.Canvas.CopyRect(aDstRect, aBitmap.Canvas, aSrcRect); + aBitmap.Canvas.UnLock; + FBuffer.Canvas.UnLock; + end; +end; + +function TBufferPanel.UpdateBufferDimensions(aWidth, aHeight : integer) : boolean; +begin + Result := False; + + if (FBuffer = nil) then + begin + FBuffer := TBitmap.Create; + FBuffer.PixelFormat := pf32bit; + FBuffer.HandleType := bmDIB; + FBuffer.Width := aWidth; + FBuffer.Height := aHeight; + FScanlineSize := aWidth * SizeOf(TRGBQuad); + + if FMustInitBuffer then + begin + FBuffer.Canvas.Brush.Color := clWhite; + FBuffer.Canvas.FillRect(rect(0, 0, FBuffer.Width, FBuffer.Height)); + end; + + Result := True; + end + else + if (FBuffer.Width <> aWidth) or + (FBuffer.Height <> aHeight) then + begin + FBuffer.Width := aWidth; + FBuffer.Height := aHeight; + FScanlineSize := aWidth * SizeOf(TRGBQuad); + + if FMustInitBuffer then + begin + FBuffer.Canvas.Brush.Color := clWhite; + FBuffer.Canvas.FillRect(rect(0, 0, FBuffer.Width, FBuffer.Height)); + end; + + Result := True; + end; +end; + +function TBufferPanel.UpdateOrigBufferDimensions(aWidth, aHeight : integer) : boolean; +begin + Result := False; + + if (FOrigBuffer = nil) then + begin + FOrigBuffer := TCEFBitmapBitBuffer.Create(aWidth, aHeight); + FScanlineSize := FOrigBuffer.ScanlineSize; + Result := True; + end + else + if (FOrigBuffer.Width <> aWidth) or + (FOrigBuffer.Height <> aHeight) then + begin + FOrigBuffer.UpdateSize(aWidth, aHeight); + FScanlineSize := FOrigBuffer.ScanlineSize; + Result := True; + end; +end; + +function TBufferPanel.UpdateOrigPopupBufferDimensions(aWidth, aHeight : integer) : boolean; +begin + Result := False; + + if (FOrigPopupBuffer = nil) then + begin + FOrigPopupBuffer := TCEFBitmapBitBuffer.Create(aWidth, aHeight); + FOrigPopupScanlineSize := FOrigPopupBuffer.ScanlineSize; + Result := True; + end + else + if (FOrigPopupBuffer.Width <> aWidth) or + (FOrigPopupBuffer.Height <> aHeight) then + begin + FOrigPopupBuffer.UpdateSize(aWidth, aHeight); + FOrigPopupScanlineSize := FOrigPopupBuffer.ScanlineSize; + Result := True; + end; +end; + +function TBufferPanel.BufferIsResized(aUseMutex : boolean) : boolean; +var + TempDevWidth, TempLogWidth, TempDevHeight, TempLogHeight : integer; + TempScale : single; +begin + Result := False; + if (GlobalCEFApp = nil) then exit; + + if not(aUseMutex) or BeginBufferDraw then + begin + TempScale := ScreenScale; + + if (TempScale = 1) then + begin + if FCopyOriginalBuffer then + Result := (FOrigBuffer <> nil) and + (FOrigBuffer.Width = Width) and + (FOrigBuffer.Height = Height) + else + Result := (FBuffer <> nil) and + (FBuffer.Width = Width) and + (FBuffer.Height = Height); + end + else + begin + // CEF and Chromium use 'floor' to round the float values in Device <-> Logical unit conversions + // and Delphi uses MulDiv, which uses the bankers rounding, to resize the components in high DPI mode. + // This is the cause of slight differences in size between the buffer and the panel in some occasions. + + TempLogWidth := DeviceToLogical(Width, TempScale); + TempLogHeight := DeviceToLogical(Height, TempScale); + + TempDevWidth := LogicalToDevice(TempLogWidth, TempScale); + TempDevHeight := LogicalToDevice(TempLogHeight, TempScale); + + if FCopyOriginalBuffer then + Result := (FOrigBuffer <> nil) and + (FOrigBuffer.Width = TempDevWidth) and + (FOrigBuffer.Height = TempDevHeight) + else + Result := (FBuffer <> nil) and + (FBuffer.Width = TempDevWidth) and + (FBuffer.Height = TempDevHeight); + end; + + if aUseMutex then EndBufferDraw; + end; +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tbufferpanel.lrs} + RegisterComponents('Chromium', [TBufferPanel]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFButton.pas b/windows/src/ext/cef4delphi/source/uCEFButton.pas new file mode 100644 index 0000000000000000000000000000000000000000..cdb34c45631be96da819dd0d0a1099428395060c --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFButton.pas @@ -0,0 +1,123 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFButton; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFView; + +type + TCefButtonRef = class(TCefViewRef, ICefButton) + protected + function AsLabelButton : ICefLabelButton; + procedure SetState(state_: TCefButtonState); + function GetState : TCefButtonState; + procedure SetInkDropEnabled(enabled_: boolean); + procedure SetTooltipText(const tooltip_text: ustring); + procedure SetAccessibleName(const name: ustring); + + public + class function UnWrap(data: Pointer): ICefButton; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFLabelButton; + +function TCefButtonRef.AsLabelButton : ICefLabelButton; +begin + Result := TCefLabelButtonRef.UnWrap(PCefButton(FData)^.as_label_button(PCefButton(FData))); +end; + +procedure TCefButtonRef.SetState(state_: TCefButtonState); +begin + PCefButton(FData)^.set_state(PCefButton(FData), state_); +end; + +function TCefButtonRef.GetState : TCefButtonState; +begin + Result := PCefButton(FData)^.get_state(PCefButton(FData)); +end; + +procedure TCefButtonRef.SetInkDropEnabled(enabled_: boolean); +begin + PCefButton(FData)^.set_ink_drop_enabled(PCefButton(FData), ord(enabled_)); +end; + +procedure TCefButtonRef.SetTooltipText(const tooltip_text: ustring); +var + TempText : TCefString; +begin + TempText := CefString(tooltip_text); + PCefButton(FData)^.set_tooltip_text(PCefButton(FData), @TempText); +end; + +procedure TCefButtonRef.SetAccessibleName(const name: ustring); +var + TempName : TCefString; +begin + TempName := CefString(name); + PCefButton(FData)^.set_accessible_name(PCefButton(FData), @TempName); +end; + +class function TCefButtonRef.UnWrap(data: Pointer): ICefButton; +begin + if (data <> nil) then + Result := Create(data) as ICefButton + else + Result := nil; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFButtonComponent.pas b/windows/src/ext/cef4delphi/source/uCEFButtonComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..913546d09826ac0c4ba25d8eb1de77ad852f49cf --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFButtonComponent.pas @@ -0,0 +1,206 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFButtonComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents, uCEFViewComponent; + +type + TCEFButtonComponent = class(TCEFViewComponent, ICefButtonDelegateEvents) + protected + FButton : ICefButton; + + // ICefButtonDelegateEvents + FOnButtonPressed : TOnButtonPressedEvent; + FOnButtonStateChanged : TOnButtonStateChangedEvent; + + procedure DestroyView; override; + procedure Initialize; override; + + function GetInitialized : boolean; override; + function GetAsView : ICefView; override; + function GetState : TCefButtonState; + function GetAsButton : ICefButton; override; + function GetAsLabelButton : ICefLabelButton; virtual; + + procedure SetState(state_: TCefButtonState); + + // ICefButtonDelegateEvents + procedure doOnButtonPressed(const button: ICefButton); + procedure doOnButtonStateChanged(const button: ICefButton); + + public + procedure SetInkDropEnabled(enabled_: boolean); + procedure SetTooltipText(const tooltip_text: ustring); + procedure SetAccessibleName(const name_: ustring); + + property AsLabelButton : ICefLabelButton read GetAsLabelButton; + property State : TCefButtonState read GetState write SetState; + + published + property OnButtonPressed : TOnButtonPressedEvent read FOnButtonPressed write FOnButtonPressed; + property OnButtonStateChanged : TOnButtonStateChangedEvent read FOnButtonStateChanged write FOnButtonStateChanged; + end; + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + uCEFButtonDelegate; + +procedure TCEFButtonComponent.Initialize; +begin + inherited Initialize; + + FButton := nil; + FOnButtonPressed := nil; + FOnButtonStateChanged := nil; +end; + +procedure TCEFButtonComponent.DestroyView; +begin + FButton := nil; +end; + +function TCEFButtonComponent.GetInitialized : boolean; +begin + Result := (FButton <> nil); +end; + +function TCEFButtonComponent.GetAsView : ICefView; +begin + Result := FButton as ICefView; +end; + +function TCEFButtonComponent.GetAsButton : ICefButton; +begin + Result := FButton; +end; + +function TCEFButtonComponent.GetAsLabelButton : ICefLabelButton; +begin + Result := nil; +end; + +procedure TCEFButtonComponent.doOnButtonPressed(const button: ICefButton); +begin + if assigned(FOnButtonPressed) then + FOnButtonPressed(self, button); +end; + +procedure TCEFButtonComponent.doOnButtonStateChanged(const button: ICefButton); +begin + if assigned(FOnButtonStateChanged) then + FOnButtonStateChanged(self, button); +end; + +procedure TCEFButtonComponent.SetState(state_: TCefButtonState); +begin + if Initialized then AsButton.SetState(state_); +end; + +function TCEFButtonComponent.GetState : TCefButtonState; +begin + if Initialized then + Result := AsButton.GetState + else + Result := CEF_BUTTON_STATE_NORMAL; +end; + +procedure TCEFButtonComponent.SetInkDropEnabled(enabled_: boolean); +begin + if Initialized then AsButton.SetInkDropEnabled(enabled_); +end; + +procedure TCEFButtonComponent.SetTooltipText(const tooltip_text: ustring); +begin + if Initialized then AsButton.SetTooltipText(tooltip_text); +end; + +procedure TCEFButtonComponent.SetAccessibleName(const name_: ustring); +begin + if Initialized then AsButton.SetAccessibleName(name_); +end; + + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFButtonDelegate.pas b/windows/src/ext/cef4delphi/source/uCEFButtonDelegate.pas new file mode 100644 index 0000000000000000000000000000000000000000..199734603e5c1a5be1a38c9634bb809ebe0492f8 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFButtonDelegate.pas @@ -0,0 +1,306 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFButtonDelegate; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFViewDelegate; + +type + TCefButtonDelegateRef = class(TCefViewDelegateRef, ICefButtonDelegate) + protected + procedure OnButtonPressed(const button: ICefButton); + procedure OnButtonStateChanged(const button: ICefButton); + + public + class function UnWrap(data: Pointer): ICefButtonDelegate; + end; + + TCefButtonDelegateOwn = class(TCefViewDelegateOwn, ICefButtonDelegate) + protected + procedure OnButtonPressed(const button: ICefButton); virtual; + procedure OnButtonStateChanged(const button: ICefButton); virtual; + + procedure InitializeCEFMethods; override; + public + constructor Create; override; + end; + + TCustomButtonDelegate = class(TCefButtonDelegateOwn) + protected + FEvents : Pointer; + + // ICefViewDelegate + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); override; + procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); override; + procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); override; + procedure OnFocus(const view: ICefView); override; + procedure OnBlur(const view: ICefView); override; + + // ICefButtonDelegate + procedure OnButtonPressed(const button: ICefButton); override; + procedure OnButtonStateChanged(const button: ICefButton); override; + + public + constructor Create(const events: ICefButtonDelegateEvents); reintroduce; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFButton; + + +// ************************************************************** +// ****************** TCefButtonDelegateRef ********************* +// ************************************************************** + +procedure TCefButtonDelegateRef.OnButtonPressed(const button: ICefButton); +begin + PCefButtonDelegate(FData)^.on_button_pressed(PCefButtonDelegate(FData), + CefGetData(button)); +end; + +procedure TCefButtonDelegateRef.OnButtonStateChanged(const button: ICefButton); +begin + PCefButtonDelegate(FData)^.on_button_state_changed(PCefButtonDelegate(FData), + CefGetData(button)); +end; + +class function TCefButtonDelegateRef.UnWrap(data: Pointer): ICefButtonDelegate; +begin + if (data <> nil) then + Result := Create(data) as ICefButtonDelegate + else + Result := nil; +end; + +// ************************************************************** +// ****************** TCefButtonDelegateOwn ********************* +// ************************************************************** + +procedure cef_button_delegate_on_button_pressed(self: PCefButtonDelegate; button: PCefButton); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefButtonDelegateOwn) then + TCefButtonDelegateOwn(TempObject).OnButtonPressed(TCefButtonRef.UnWrap(button)); +end; + +procedure cef_button_delegate_on_button_state_changed(self: PCefButtonDelegate; button: PCefButton); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefButtonDelegateOwn) then + TCefButtonDelegateOwn(TempObject).OnButtonStateChanged(TCefButtonRef.UnWrap(button)); +end; + + +constructor TCefButtonDelegateOwn.Create; +begin + inherited CreateData(SizeOf(TCefButtonDelegate)); + + InitializeCEFMethods; +end; + +procedure TCefButtonDelegateOwn.InitializeCEFMethods; +begin + inherited InitializeCEFMethods; + + with PCefButtonDelegate(FData)^ do + begin + on_button_pressed := {$IFDEF FPC}@{$ENDIF}cef_button_delegate_on_button_pressed; + on_button_state_changed := {$IFDEF FPC}@{$ENDIF}cef_button_delegate_on_button_state_changed; + end; +end; + +procedure TCefButtonDelegateOwn.OnButtonPressed(const button: ICefButton); +begin + // +end; + +procedure TCefButtonDelegateOwn.OnButtonStateChanged(const button: ICefButton); +begin + // +end; + +// ************************************************************** +// ****************** TCustomButtonDelegate ********************* +// ************************************************************** + +constructor TCustomButtonDelegate.Create(const events: ICefButtonDelegateEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +procedure TCustomButtonDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnGetPreferredSize', e) then raise; + end; +end; + +procedure TCustomButtonDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnGetMinimumSize', e) then raise; + end; +end; + +procedure TCustomButtonDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnGetMaximumSize', e) then raise; + end; +end; + +procedure TCustomButtonDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnGetHeightForWidth', e) then raise; + end; +end; + +procedure TCustomButtonDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnParentViewChanged', e) then raise; + end; +end; + +procedure TCustomButtonDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnChildViewChanged(view, added, child); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnChildViewChanged', e) then raise; + end; +end; + +procedure TCustomButtonDelegate.OnFocus(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnFocus(view); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnFocus', e) then raise; + end; +end; + +procedure TCustomButtonDelegate.OnBlur(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnBlur(view); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnBlur', e) then raise; + end; +end; + +procedure TCustomButtonDelegate.OnButtonPressed(const button: ICefButton); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnButtonPressed(button); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnButtonPressed', e) then raise; + end; +end; + +procedure TCustomButtonDelegate.OnButtonStateChanged(const button: ICefButton); +begin + try + if (FEvents <> nil) then + ICefButtonDelegateEvents(FEvents).doOnButtonStateChanged(button); + except + on e : exception do + if CustomExceptionHandler('TCustomButtonDelegate.OnButtonStateChanged', e) then raise; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFCallback.pas b/windows/src/ext/cef4delphi/source/uCEFCallback.pas index 4e59eb3c1c747bcdf0fd0b63f7ae8903d3f55b2b..53da3f0573f1da5781b2835fa1f5f3c6c7b71213 100644 --- a/windows/src/ext/cef4delphi/source/uCEFCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFChromium.pas b/windows/src/ext/cef4delphi/source/uCEFChromium.pas index f4c14062a36cf3b45d193d8f1c5acb75dd2b7859..775d89766b7507acceba88f56bf90f11ba2ddcd7 100644 --- a/windows/src/ext/cef4delphi/source/uCEFChromium.pas +++ b/windows/src/ext/cef4delphi/source/uCEFChromium.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,3655 +41,135 @@ unit uCEFChromium; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} - -{$I cef.inc} - -interface - -uses - {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, WinApi.ActiveX,{$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics, Vcl.Forms, - {$ELSE} - {$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} Classes, Forms, Controls, Graphics, - {$IFDEF FPC} - LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, - {$ELSE} - Messages, - {$ENDIF} - {$ENDIF} - uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFMiscFunctions, uCEFClient, - uCEFConstants, uCEFTask, uCEFDomVisitor, uCEFChromiumEvents, - {$IFNDEF FPC}uCEFDragAndDropMgr,{$ENDIF} - uCEFChromiumOptions, uCEFChromiumFontOptions, uCEFPDFPrintOptions; - -type - TChromium = class(TComponent, IChromiumEvents) - protected - FCompHandle : HWND; - FHandler : ICefClient; - FBrowser : ICefBrowser; - FBrowserId : Integer; - FDefaultUrl : ustring; - FOptions : TChromiumOptions; - FFontOptions : TChromiumFontOptions; - FPDFPrintOptions : TPDFPrintOptions; - FDefaultEncoding : ustring; - FProxyType : integer; - FProxyScheme : TCefProxyScheme; - FProxyServer : ustring; - FProxyPort : integer; - FProxyUsername : ustring; - FProxyPassword : ustring; - FProxyScriptURL : ustring; - FProxyByPassList : ustring; - FUpdatePreferences : boolean; - FCustomHeaderName : ustring; - FCustomHeaderValue : ustring; - FAddCustomHeader : boolean; - FDoNotTrack : boolean; - FSendReferrer : boolean; - FHyperlinkAuditing : boolean; - FRunAllFlashInAllowMode : boolean; - FAllowOutdatedPlugins : boolean; - FAlwaysAuthorizePlugins : boolean; - FCookiePrefs : integer; - FImagesPrefs : integer; - FZoomStep : byte; - FPrefsFileName : string; - FIsOSR : boolean; - FInitialized : boolean; - FClosing : boolean; - FWindowInfo : TCefWindowInfo; - FBrowserSettings : TCefBrowserSettings; - FDevWindowInfo : TCefWindowInfo; - FDevBrowserSettings : TCefBrowserSettings; - FDragOperations : TCefDragOperations; - {$IFNDEF FPC} - FDragDropManager : TCEFDragAndDropMgr; - {$ENDIF} - FDropTargetCtrl : TWinControl; - FDragAndDropInitialized : boolean; - FWebRTCIPHandlingPolicy : TCefWebRTCHandlingPolicy; - FWebRTCMultipleRoutes : TCefState; - FWebRTCNonProxiedUDP : TCefState; - {$IFNDEF FPC} - FOldBrowserCompWndPrc : TFNWndProc; - FOldWidgetCompWndPrc : TFNWndProc; - FOldRenderCompWndPrc : TFNWndProc; - FBrowserCompStub : Pointer; - FWidgetCompStub : Pointer; - FRenderCompStub : Pointer; - {$ENDIF} - FBrowserCompHWND : THandle; - FWidgetCompHWND : THandle; - FRenderCompHWND : THandle; - - // ICefClient - FOnProcessMessageReceived : TOnProcessMessageReceived; - - // ICefLoadHandler - FOnLoadStart : TOnLoadStart; - FOnLoadEnd : TOnLoadEnd; - FOnLoadError : TOnLoadError; - FOnLoadingStateChange : TOnLoadingStateChange; - - // ICefFocusHandler - FOnTakeFocus : TOnTakeFocus; - FOnSetFocus : TOnSetFocus; - FOnGotFocus : TOnGotFocus; - - // ICefContextMenuHandler - FOnBeforeContextMenu : TOnBeforeContextMenu; - FOnRunContextMenu : TOnRunContextMenu; - FOnContextMenuCommand : TOnContextMenuCommand; - FOnContextMenuDismissed : TOnContextMenuDismissed; - - // ICefKeyboardHandler - FOnPreKeyEvent : TOnPreKeyEvent; - FOnKeyEvent : TOnKeyEvent; - - // ICefDisplayHandler - FOnAddressChange : TOnAddressChange; - FOnTitleChange : TOnTitleChange; - FOnFavIconUrlChange : TOnFavIconUrlChange; - FOnFullScreenModeChange : TOnFullScreenModeChange; - FOnTooltip : TOnTooltip; - FOnStatusMessage : TOnStatusMessage; - FOnConsoleMessage : TOnConsoleMessage; - FOnAutoResize : TOnAutoResize; - FOnLoadingProgressChange : TOnLoadingProgressChange; - - // ICefDownloadHandler - FOnBeforeDownload : TOnBeforeDownload; - FOnDownloadUpdated : TOnDownloadUpdated; - - // ICefJsDialogHandler - FOnJsdialog : TOnJsdialog; - FOnBeforeUnloadDialog : TOnBeforeUnloadDialog; - FOnResetDialogState : TOnResetDialogState; - FOnDialogClosed : TOnDialogClosed; - - // ICefLifeSpanHandler - FOnBeforePopup : TOnBeforePopup; - FOnAfterCreated : TOnAfterCreated; - FOnBeforeClose : TOnBeforeClose; - FOnClose : TOnClose; - - // ICefRequestHandler - FOnBeforeBrowse : TOnBeforeBrowse; - FOnOpenUrlFromTab : TOnOpenUrlFromTab; - FOnBeforeResourceLoad : TOnBeforeResourceLoad; - FOnGetResourceHandler : TOnGetResourceHandler; - FOnResourceRedirect : TOnResourceRedirect; - FOnResourceResponse : TOnResourceResponse; - FOnGetResourceResponseFilter : TOnGetResourceResponseFilter; - FOnResourceLoadComplete : TOnResourceLoadComplete; - FOnGetAuthCredentials : TOnGetAuthCredentials; - FOnCanGetCookies : TOnCanGetCookies; - FOnCanSetCookie : TOnCanSetCookie; - FOnQuotaRequest : TOnQuotaRequest; - FOnProtocolExecution : TOnProtocolExecution; - FOnCertificateError : TOnCertificateError; - FOnSelectClientCertificate : TOnSelectClientCertificate; - FOnPluginCrashed : TOnPluginCrashed; - FOnRenderViewReady : TOnRenderViewReady; - FOnRenderProcessTerminated : TOnRenderProcessTerminated; - - // ICefDialogHandler - FOnFileDialog : TOnFileDialog; - - // ICefRenderHandler - FOnGetAccessibilityHandler : TOnGetAccessibilityHandler; - FOnGetRootScreenRect : TOnGetRootScreenRect; - FOnGetViewRect : TOnGetViewRect; - FOnGetScreenPoint : TOnGetScreenPoint; - FOnGetScreenInfo : TOnGetScreenInfo; - FOnPopupShow : TOnPopupShow; - FOnPopupSize : TOnPopupSize; - FOnPaint : TOnPaint; - FOnCursorChange : TOnCursorChange; - FOnStartDragging : TOnStartDragging; - FOnUpdateDragCursor : TOnUpdateDragCursor; - FOnScrollOffsetChanged : TOnScrollOffsetChanged; - FOnIMECompositionRangeChanged : TOnIMECompositionRangeChanged; - FOnTextSelectionChanged : TOnTextSelectionChanged; - - // ICefDragHandler - FOnDragEnter : TOnDragEnter; - FOnDraggableRegionsChanged : TOnDraggableRegionsChanged; - - // ICefFindHandler - FOnFindResult : TOnFindResult; - - // Custom - FOnTextResultAvailable : TOnTextResultAvailableEvent; - FOnPdfPrintFinished : TOnPdfPrintFinishedEvent; - FOnPrefsAvailable : TOnPrefsAvailableEvent; - FOnCookiesDeleted : TOnCookiesDeletedEvent; - FOnResolvedHostAvailable : TOnResolvedIPsAvailableEvent; - {$IFNDEF FPC} - FOnBrowserCompMsg : TOnCompMsgEvent; - FOnWidgetCompMsg : TOnCompMsgEvent; - FOnRenderCompMsg : TOnCompMsgEvent; - {$ENDIF} - - function GetIsLoading : boolean; - function GetMultithreadApp : boolean; - function GetHasDocument : boolean; - function GetHasView : boolean; - function GetHasDevTools : boolean; - function GetHasClientHandler : boolean; - function GetHasBrowser : boolean; - function GetCanGoBack : boolean; - function GetCanGoForward : boolean; - function GetDocumentURL : ustring; - function GetZoomLevel : double; - function GetZoomPct : double; - function GetIsPopUp : boolean; - function GetWindowHandle : THandle; - function GetWindowlessFrameRate : integer; - function GetFrameIsFocused : boolean; - function GetInitialized : boolean; - function GetVisibleNavigationEntry : ICefNavigationEntry; - function GetHasValidMainFrame : boolean; - function GetFrameCount : NativeUInt; - function GetRequestContextCache : ustring; - function GetRequestContextIsGlobal : boolean; - - procedure SetDoNotTrack(aValue : boolean); - procedure SetSendReferrer(aValue : boolean); - procedure SetHyperlinkAuditing(aValue : boolean); - procedure SetRunAllFlashInAllowMode(aValue : boolean); - procedure SetAllowOutdatedPlugins(aValue : boolean); - procedure SetAlwaysAuthorizePlugins(aValue : boolean); - procedure SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); - procedure SetWebRTCMultipleRoutes(aValue : TCefState); - procedure SetWebRTCNonProxiedUDP(aValue : TCefState); - procedure SetCookiePrefs(aValue : integer); - procedure SetImagesPrefs(aValue : integer); - procedure SetProxyType(aValue : integer); - procedure SetProxyScheme(aValue : TCefProxyScheme); - procedure SetProxyServer(const aValue : ustring); - procedure SetProxyPort(aValue : integer); - procedure SetProxyUsername(const aValue : ustring); - procedure SetProxyPassword(const aValue : ustring); - procedure SetProxyScriptURL(const aValue : ustring); - procedure SetProxyByPassList(const aValue : ustring); - procedure SetCustomHeaderName(const aValue : ustring); - procedure SetCustomHeaderValue(const aValue : ustring); - procedure SetZoomLevel(const aValue : double); - procedure SetZoomPct(const aValue : double); - procedure SetZoomStep(aValue : byte); - procedure SetWindowlessFrameRate(aValue : integer); - - - function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aContext : ICefRequestContext): boolean; - function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aContext : ICefRequestContext): Boolean; - - procedure DestroyClientHandler; - - procedure ClearBrowserReference; - - procedure InitializeEvents; - procedure InitializeSettings(var aSettings : TCefBrowserSettings); - - procedure GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : ustring); - - function UpdateProxyPrefs(const aBrowser: ICefBrowser) : boolean; - function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : boolean) : boolean; overload; - function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : integer) : boolean; overload; - function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; const aValue : double) : boolean; overload; - function UpdatePreference(const aBrowser: ICefBrowser; const aName, aValue : ustring) : boolean; overload; - - procedure HandleDictionary(const aDict : ICefDictionaryValue; var aResultSL : TStringList; const aRoot : string); - procedure HandleNull(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleBool(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleInteger(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleDouble(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleString(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleBinary(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - - function MustCreateLoadHandler : boolean; virtual; - function MustCreateFocusHandler : boolean; virtual; - function MustCreateContextMenuHandler : boolean; virtual; - function MustCreateDialogHandler : boolean; virtual; - function MustCreateKeyboardHandler : boolean; virtual; - function MustCreateDisplayHandler : boolean; virtual; - function MustCreateDownloadHandler : boolean; virtual; - function MustCreateJsDialogHandler : boolean; virtual; - function MustCreateDragHandler : boolean; virtual; - function MustCreateFindHandler : boolean; virtual; - - procedure PrefsAvailableMsg(var aMessage : TMessage); - function GetParentForm : TCustomForm; - procedure ApplyZoomStep; - procedure DelayedDragging; - function SendCompMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean; - procedure ToMouseEvent(grfKeyState : Longint; pt : TPoint; var aMouseEvent : TCefMouseEvent); - - procedure FreeAndNilStub(var aStub : pointer); - procedure CreateStub(const aMethod : TWndMethod; var aStub : Pointer); - procedure WndProc(var aMessage: TMessage); - {$IFNDEF FPC} - procedure BrowserCompWndProc(var aMessage: TMessage); - procedure WidgetCompWndProc(var aMessage: TMessage); - procedure RenderCompWndProc(var aMessage: TMessage); - {$ENDIF} - - procedure DragDropManager_OnDragEnter(Sender: TObject; const aDragData : ICefDragData; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); - procedure DragDropManager_OnDragOver(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); - procedure DragDropManager_OnDragLeave(Sender: TObject); - procedure DragDropManager_OnDrop(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); - - // IChromiumEvents - procedure GetSettings(var aSettings : TCefBrowserSettings); - - // ICefClient - function doOnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual; - - // ICefLoadHandler - procedure doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); 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; - procedure doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); virtual; - - // ICefFocusHandler - procedure doOnTakeFocus(const browser: ICefBrowser; next: Boolean); virtual; - function doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; virtual; - procedure doOnGotFocus(const browser: ICefBrowser); virtual; - - // ICefContextMenuHandler - procedure doOnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); virtual; - function doRunContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel; const callback: ICefRunContextMenuCallback): Boolean; 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; - - // ICefKeyboardHandler - 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; - - // ICefDisplayHandler - procedure doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); virtual; - procedure doOnTitleChange(const browser: ICefBrowser; const title: ustring); virtual; - procedure doOnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); virtual; - procedure doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); virtual; - function doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; virtual; - procedure doOnStatusMessage(const browser: ICefBrowser; const value: ustring); virtual; - function doOnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const aMessage, source: ustring; line: Integer): Boolean; virtual; - function doOnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; virtual; - procedure doOnLoadingProgressChange(const browser: ICefBrowser; const progress: double); virtual; - - // ICefDownloadHandler - 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; - - // ICefJsDialogHandler - function doOnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const 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; - procedure doOnDialogClosed(const browser: ICefBrowser); virtual; - - // ICefLifeSpanHandler - function doOnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const 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 doOnClose(const browser: ICefBrowser): Boolean; virtual; - - // ICefRequestHandler - function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; virtual; - function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; virtual; - function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; virtual; - function doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; virtual; - procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); virtual; - function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; virtual; - function doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; virtual; - procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); 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 doCanGetCookies(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): boolean; virtual; - function doCanSetCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie : PCefCookie): boolean; virtual; - function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; virtual; - procedure doOnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); virtual; - function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; virtual; - function doOnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; virtual; - procedure doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); virtual; - procedure doOnRenderViewReady(const browser: ICefBrowser); virtual; - procedure doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); virtual; - - // ICefDialogHandler - function doOnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; virtual; - - // ICefRenderHandler - procedure doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); virtual; - function doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; - function doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; - function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; virtual; - function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; virtual; - procedure doOnPopupShow(const browser: ICefBrowser; show: Boolean); virtual; - procedure doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); virtual; - procedure doOnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); virtual; - procedure doOnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); virtual; - function doOnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; virtual; - procedure doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); virtual; - procedure doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); virtual; - procedure doOnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); virtual; - procedure doOnTextSelectionChanged(const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange); virtual; - - // ICefDragHandler - function doOnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; virtual; - procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); virtual; - - // ICefFindHandler - procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual; - - // Custom - procedure doCookiesDeleted(numDeleted : integer); virtual; - procedure doPdfPrintFinished(aResultOK : boolean); virtual; - procedure doTextResultAvailable(const aText : ustring); virtual; - procedure doUpdatePreferences(const aBrowser: ICefBrowser); virtual; - procedure doUpdateOwnPreferences; virtual; - function doSavePreferences : boolean; virtual; - procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); virtual; - - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure AfterConstruction; override; - procedure BeforeDestruction; override; - function CreateClientHandler(aIsOSR : boolean) : boolean; overload; - function CreateClientHandler(var aClient : ICefClient; aIsOSR : boolean = True) : boolean; overload; - procedure CloseBrowser(aForceClose : boolean); - function ShareRequestContext(var aContext : ICefRequestContext; const aHandler : ICefRequestContextHandler = nil) : boolean; - procedure InitializeDragAndDrop(const aDropTargetCtrl : TWinControl); - procedure ShutdownDragAndDrop; - function CreateBrowser(const aBrowserParent : TWinControl = nil; const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aCookiesPath : ustring = ''; aPersistSessionCookies : boolean = False) : boolean; overload; virtual; - function CreateBrowser(aParentHandle : HWND; aParentRect : TRect; const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aCookiesPath : ustring = ''; aPersistSessionCookies : boolean = False) : boolean; overload; virtual; - - procedure LoadURL(const aURL : ustring; const aFrameName : ustring = ''); overload; - procedure LoadURL(const aURL : ustring; const aFrame : ICefFrame); overload; - procedure LoadURL(const aURL : ustring; const aFrameIdentifier : int64); overload; - procedure LoadString(const aString : ustring; const aURL : ustring = ''); - procedure LoadRequest(const aRequest: ICefRequest); - - procedure GoBack; - procedure GoForward; - procedure Reload; - procedure ReloadIgnoreCache; - procedure StopLoad; - procedure StartDownload(const aURL : ustring); - - procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer); - function DeleteCookies(const url : ustring = ''; const cookieName : ustring = '') : boolean; - procedure RetrieveHTML(const aFrameName : ustring = ''); overload; - procedure RetrieveHTML(const aFrame : ICefFrame); overload; - procedure RetrieveHTML(const aFrameIdentifier : int64); overload; - procedure RetrieveText(const aFrameName : ustring = ''); overload; - procedure RetrieveText(const aFrame : ICefFrame); overload; - procedure RetrieveText(const aFrameIdentifier : int64); overload; - function GetFrameNames(var aFrameNames : TStrings) : boolean; - function GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean; - procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameName : ustring = ''; aStartLine : integer = 0); overload; - procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrame : ICefFrame; aStartLine : integer = 0); overload; - procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameIdentifier : int64; aStartLine : integer = 0); overload; - procedure UpdatePreferences; - procedure SavePreferences(const aFileName : string); - function SetNewBrowserParent(aNewParentHwnd : HWND) : boolean; - procedure ResolveHost(const aURL : ustring); - function TakeSnapshot(var aBitmap : TBitmap) : boolean; - function IsSameBrowser(const aBrowser : ICefBrowser) : boolean; - - procedure ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl); - procedure CloseDevTools(const aDevTools : TWinControl = nil); - - procedure Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); - procedure StopFinding(aClearSelection : Boolean); - - procedure Print; - procedure PrintToPDF(const aFilePath, aTitle, aURL : ustring); - - procedure ClipboardCopy; - procedure ClipboardPaste; - procedure ClipboardCut; - procedure ClipboardUndo; - procedure ClipboardRedo; - procedure ClipboardDel; - procedure SelectAll; - - procedure IncZoomStep; - procedure DecZoomStep; - procedure ResetZoomStep; - - procedure MoveFormTo(const x, y: Integer); - procedure MoveFormBy(const x, y: Integer); - procedure ResizeFormWidthTo(const x : Integer); - procedure ResizeFormHeightTo(const y : Integer); - procedure SetFormLeftTo(const x : Integer); - procedure SetFormTopTo(const y : Integer); - - procedure WasResized; - procedure WasHidden(hidden: Boolean); - procedure NotifyScreenInfoChanged; - procedure NotifyMoveOrResizeStarted; - procedure Invalidate(kind: TCefPaintElementType = PET_VIEW); - procedure SendKeyEvent(const event: PCefKeyEvent); - procedure SendMouseClickEvent(const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); - procedure SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); - procedure SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); - procedure SendFocusEvent(setFocus: Boolean); - procedure SendCaptureLostEvent; - function SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; - procedure SetFocus(focus: Boolean); - procedure SetAccessibilityState(accessibilityState: TCefState); - - procedure DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); - procedure DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); - procedure DragTargetDragLeave; - procedure DragTargetDrop(event: PCefMouseEvent); - procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); - procedure DragSourceSystemDragEnded; - - - property DefaultUrl : ustring read FDefaultUrl write FDefaultUrl; - property Options : TChromiumOptions read FOptions write FOptions; - property FontOptions : TChromiumFontOptions read FFontOptions write FFontOptions; - property PDFPrintOptions : TPDFPrintOptions read FPDFPrintOptions write FPDFPrintOptions; - property DefaultEncoding : ustring read FDefaultEncoding write FDefaultEncoding; - property BrowserId : integer read FBrowserId; - property Browser : ICefBrowser read FBrowser; - property CefClient : ICefClient read FHandler; - property CefWindowInfo : TCefWindowInfo read FWindowInfo; - property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; - property MultithreadApp : boolean read GetMultithreadApp; - property IsLoading : boolean read GetIsLoading; - property HasDocument : boolean read GetHasDocument; - property HasView : boolean read GetHasView; - property HasDevTools : boolean read GetHasDevTools; - property HasClientHandler : boolean read GetHasClientHandler; - property HasBrowser : boolean read GetHasBrowser; - property CanGoBack : boolean read GetCanGoBack; - property CanGoForward : boolean read GetCanGoForward; - property IsPopUp : boolean read GetIsPopUp; - property WindowHandle : THandle read GetWindowHandle; - property BrowserHandle : THandle read FBrowserCompHWND; - property WidgetHandle : THandle read FWidgetCompHWND; - property RenderHandle : THandle read FRenderCompHWND; - property FrameIsFocused : boolean read GetFrameIsFocused; - property Initialized : boolean read GetInitialized; - property RequestContextCache : ustring read GetRequestContextCache; - property RequestContextIsGlobal : boolean read GetRequestContextIsGlobal; - property CookiePrefs : integer read FCookiePrefs write SetCookiePrefs; - property ImagesPrefs : integer read FImagesPrefs write SetImagesPrefs; - property DocumentURL : ustring read GetDocumentURL; - property ZoomLevel : double read GetZoomLevel write SetZoomLevel; - property ZoomPct : double read GetZoomPct write SetZoomPct; - property ZoomStep : byte read FZoomStep write SetZoomStep; - property WindowlessFrameRate : integer read GetWindowlessFrameRate write SetWindowlessFrameRate; - property CustomHeaderName : ustring read FCustomHeaderName write SetCustomHeaderName; - property CustomHeaderValue : ustring read FCustomHeaderValue write SetCustomHeaderValue; - property DoNotTrack : boolean read FDoNotTrack write SetDoNotTrack; - property SendReferrer : boolean read FSendReferrer write SetSendReferrer; - property HyperlinkAuditing : boolean read FHyperlinkAuditing write SetHyperlinkAuditing; - property RunAllFlashInAllowMode : boolean read FRunAllFlashInAllowMode write SetRunAllFlashInAllowMode; - property AllowOutdatedPlugins : boolean read FAllowOutdatedPlugins write SetAllowOutdatedPlugins; - property AlwaysAuthorizePlugins : boolean read FAlwaysAuthorizePlugins write SetAlwaysAuthorizePlugins; - property HasValidMainFrame : boolean read GetHasValidMainFrame; - property FrameCount : NativeUInt read GetFrameCount; - property DragOperations : TCefDragOperations read FDragOperations write FDragOperations; - - property WebRTCIPHandlingPolicy : TCefWebRTCHandlingPolicy read FWebRTCIPHandlingPolicy write SetWebRTCIPHandlingPolicy; - property WebRTCMultipleRoutes : TCefState read FWebRTCMultipleRoutes write SetWebRTCMultipleRoutes; - property WebRTCNonproxiedUDP : TCefState read FWebRTCNonProxiedUDP write SetWebRTCNonProxiedUDP; - - property ProxyType : integer read FProxyType write SetProxyType; - property ProxyScheme : TCefProxyScheme read FProxyScheme write SetProxyScheme; - property ProxyServer : ustring read FProxyServer write SetProxyServer; - property ProxyPort : integer read FProxyPort write SetProxyPort; - property ProxyUsername : ustring read FProxyUsername write SetProxyUsername; - property ProxyPassword : ustring read FProxyPassword write SetProxyPassword; - property ProxyScriptURL : ustring read FProxyScriptURL write SetProxyScriptURL; - property ProxyByPassList : ustring read FProxyByPassList write SetProxyByPassList; - - published - property OnTextResultAvailable : TOnTextResultAvailableEvent read FOnTextResultAvailable write FOnTextResultAvailable; - property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished; - property OnPrefsAvailable : TOnPrefsAvailableEvent read FOnPrefsAvailable write FOnPrefsAvailable; - property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted; - property OnResolvedHostAvailable : TOnResolvedIPsAvailableEvent read FOnResolvedHostAvailable write FOnResolvedHostAvailable; - {$IFNDEF FPC} - property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg; - property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg; - property OnRenderCompMsg : TOnCompMsgEvent read FOnRenderCompMsg write FOnRenderCompMsg; - {$ENDIF} - - // ICefClient - property OnProcessMessageReceived : TOnProcessMessageReceived read FOnProcessMessageReceived write FOnProcessMessageReceived; - - // ICefLoadHandler - property OnLoadStart : TOnLoadStart read FOnLoadStart write FOnLoadStart; - property OnLoadEnd : TOnLoadEnd read FOnLoadEnd write FOnLoadEnd; - property OnLoadError : TOnLoadError read FOnLoadError write FOnLoadError; - property OnLoadingStateChange : TOnLoadingStateChange read FOnLoadingStateChange write FOnLoadingStateChange; - - // ICefFocusHandler - property OnTakeFocus : TOnTakeFocus read FOnTakeFocus write FOnTakeFocus; - property OnSetFocus : TOnSetFocus read FOnSetFocus write FOnSetFocus; - property OnGotFocus : TOnGotFocus read FOnGotFocus write FOnGotFocus; - - // ICefContextMenuHandler - property OnBeforeContextMenu : TOnBeforeContextMenu read FOnBeforeContextMenu write FOnBeforeContextMenu; - property OnRunContextMenu : TOnRunContextMenu read FOnRunContextMenu write FOnRunContextMenu; - property OnContextMenuCommand : TOnContextMenuCommand read FOnContextMenuCommand write FOnContextMenuCommand; - property OnContextMenuDismissed : TOnContextMenuDismissed read FOnContextMenuDismissed write FOnContextMenuDismissed; - - // ICefKeyboardHandler - property OnPreKeyEvent : TOnPreKeyEvent read FOnPreKeyEvent write FOnPreKeyEvent; - property OnKeyEvent : TOnKeyEvent read FOnKeyEvent write FOnKeyEvent; - - // ICefDisplayHandler - property OnAddressChange : TOnAddressChange read FOnAddressChange write FOnAddressChange; - property OnTitleChange : TOnTitleChange read FOnTitleChange write FOnTitleChange; - property OnFavIconUrlChange : TOnFavIconUrlChange read FOnFavIconUrlChange write FOnFavIconUrlChange; - property OnFullScreenModeChange : TOnFullScreenModeChange read FOnFullScreenModeChange write FOnFullScreenModeChange; - property OnTooltip : TOnTooltip read FOnTooltip write FOnTooltip; - property OnStatusMessage : TOnStatusMessage read FOnStatusMessage write FOnStatusMessage; - property OnConsoleMessage : TOnConsoleMessage read FOnConsoleMessage write FOnConsoleMessage; - property OnAutoResize : TOnAutoResize read FOnAutoResize write FOnAutoResize; - property OnLoadingProgressChange : TOnLoadingProgressChange read FOnLoadingProgressChange write FOnLoadingProgressChange; - - // ICefDownloadHandler - property OnBeforeDownload : TOnBeforeDownload read FOnBeforeDownload write FOnBeforeDownload; - property OnDownloadUpdated : TOnDownloadUpdated read FOnDownloadUpdated write FOnDownloadUpdated; - - // ICefJsDialogHandler - property OnJsdialog : TOnJsdialog read FOnJsdialog write FOnJsdialog; - property OnBeforeUnloadDialog : TOnBeforeUnloadDialog read FOnBeforeUnloadDialog write FOnBeforeUnloadDialog; - property OnResetDialogState : TOnResetDialogState read FOnResetDialogState write FOnResetDialogState; - property OnDialogClosed : TOnDialogClosed read FOnDialogClosed write FOnDialogClosed; - - // ICefLifeSpanHandler - property OnBeforePopup : TOnBeforePopup read FOnBeforePopup write FOnBeforePopup; - property OnAfterCreated : TOnAfterCreated read FOnAfterCreated write FOnAfterCreated; - property OnBeforeClose : TOnBeforeClose read FOnBeforeClose write FOnBeforeClose; - property OnClose : TOnClose read FOnClose write FOnClose; - - // ICefRequestHandler - property OnBeforeBrowse : TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse; - property OnOpenUrlFromTab : TOnOpenUrlFromTab read FOnOpenUrlFromTab write FOnOpenUrlFromTab; - property OnBeforeResourceLoad : TOnBeforeResourceLoad read FOnBeforeResourceLoad write FOnBeforeResourceLoad; - property OnGetResourceHandler : TOnGetResourceHandler read FOnGetResourceHandler write FOnGetResourceHandler; - property OnResourceRedirect : TOnResourceRedirect read FOnResourceRedirect write FOnResourceRedirect; - property OnResourceResponse : TOnResourceResponse read FOnResourceResponse write FOnResourceResponse; - property OnGetResourceResponseFilter : TOnGetResourceResponseFilter read FOnGetResourceResponseFilter write FOnGetResourceResponseFilter; - property OnResourceLoadComplete : TOnResourceLoadComplete read FOnResourceLoadComplete write FOnResourceLoadComplete; - property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials; - property OnCanGetCookies : TOnCanGetCookies read FOnCanGetCookies write FOnCanGetCookies; - property OnCanSetCookie : TOnCanSetCookie read FOnCanSetCookie write FOnCanSetCookie; - property OnQuotaRequest : TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest; - property OnProtocolExecution : TOnProtocolExecution read FOnProtocolExecution write FOnProtocolExecution; - property OnCertificateError : TOnCertificateError read FOnCertificateError write FOnCertificateError; - property OnSelectClientCertificate : TOnSelectClientCertificate read FOnSelectClientCertificate write FOnSelectClientCertificate; - property OnPluginCrashed : TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed; - property OnRenderViewReady : TOnRenderViewReady read FOnRenderViewReady write FOnRenderViewReady; - property OnRenderProcessTerminated : TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated; - - // ICefDialogHandler - property OnFileDialog : TOnFileDialog read FOnFileDialog write FOnFileDialog; - - // ICefRenderHandler - property OnGetAccessibilityHandler : TOnGetAccessibilityHandler read FOnGetAccessibilityHandler write FOnGetAccessibilityHandler; - 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 OnStartDragging : TOnStartDragging read FOnStartDragging write FOnStartDragging; - property OnUpdateDragCursor : TOnUpdateDragCursor read FOnUpdateDragCursor write FOnUpdateDragCursor; - property OnScrollOffsetChanged : TOnScrollOffsetChanged read FOnScrollOffsetChanged write FOnScrollOffsetChanged; - property OnIMECompositionRangeChanged : TOnIMECompositionRangeChanged read FOnIMECompositionRangeChanged write FOnIMECompositionRangeChanged; - property OnTextSelectionChanged : TOnTextSelectionChanged read FOnTextSelectionChanged write FOnTextSelectionChanged; - - // ICefDragHandler - property OnDragEnter : TOnDragEnter read FOnDragEnter write FOnDragEnter; - property OnDraggableRegionsChanged : TOnDraggableRegionsChanged read FOnDraggableRegionsChanged write FOnDraggableRegionsChanged; - - // ICefFindHandler - property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult; - - end; - -{$IFDEF FPC} -procedure Register; -{$ENDIF} - -implementation - -uses - {$IFDEF DELPHI16_UP} - System.SysUtils, System.Math, - {$ELSE} - SysUtils, Math, - {$ENDIF} - uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame, - uCEFApplication, uCEFProcessMessage, uCEFRequestContext, {$IFNDEF FPC}uOLEDragAndDrop,{$ENDIF} - uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor; - -constructor TChromium.Create(AOwner: TComponent); -begin - FBrowser := nil; - FBrowserId := 0; - FCompHandle := 0; - FClosing := False; - FInitialized := False; - FIsOSR := False; - FDefaultUrl := 'about:blank'; - FHandler := nil; - FOptions := nil; - FFontOptions := nil; - FDefaultEncoding := ''; - FPDFPrintOptions := nil; - FUpdatePreferences := False; - FCustomHeaderName := ''; - FCustomHeaderValue := ''; - FPrefsFileName := ''; - FAddCustomHeader := False; - FDoNotTrack := True; - FSendReferrer := True; - FHyperlinkAuditing := False; - FRunAllFlashInAllowMode := False; - FAllowOutdatedPlugins := False; - FAlwaysAuthorizePlugins := False; - FCookiePrefs := CEF_CONTENT_SETTING_ALLOW; - FImagesPrefs := CEF_CONTENT_SETTING_ALLOW; - FZoomStep := ZOOM_STEP_DEF; - {$IFNDEF FPC} - FOldBrowserCompWndPrc := nil; - FOldWidgetCompWndPrc := nil; - FOldRenderCompWndPrc := nil; - FBrowserCompStub := nil; - FWidgetCompStub := nil; - FRenderCompStub := nil; - {$ENDIF} - FBrowserCompHWND := 0; - FWidgetCompHWND := 0; - FRenderCompHWND := 0; - - FDragOperations := DRAG_OPERATION_NONE; - {$IFNDEF FPC} - FDragDropManager := nil; - {$ENDIF} - FDropTargetCtrl := nil; - FDragAndDropInitialized := False; - - FWebRTCIPHandlingPolicy := hpDefault; - FWebRTCMultipleRoutes := STATE_DEFAULT; - FWebRTCNonProxiedUDP := STATE_DEFAULT; - - FProxyType := CEF_PROXYTYPE_DIRECT; - FProxyScheme := psHTTP; - FProxyServer := ''; - FProxyPort := 80; - FProxyUsername := ''; - FProxyPassword := ''; - FProxyScriptURL := ''; - FProxyByPassList := ''; - - FillChar(FWindowInfo, SizeOf(TCefWindowInfo), 0); - FillChar(FDevWindowInfo, SizeOf(TCefWindowInfo), 0); - - InitializeSettings(FBrowserSettings); - InitializeSettings(FDevBrowserSettings); - - InitializeEvents; - - inherited Create(AOwner); -end; - -destructor TChromium.Destroy; -begin - try - try - {$IFNDEF FPC} - if (FDragDropManager <> nil) then FreeAndNil(FDragDropManager); - {$ENDIF} - - if (FCompHandle <> 0) then - begin - DeallocateHWnd(FCompHandle); - FCompHandle := 0; - end; - - ClearBrowserReference; - - if (FFontOptions <> nil) then FreeAndNil(FFontOptions); - if (FOptions <> nil) then FreeAndNil(FOptions); - if (FPDFPrintOptions <> nil) then FreeAndNil(FPDFPrintOptions); - except - on e : exception do - if CustomExceptionHandler('TChromium.Destroy', e) then raise; - end; - finally - inherited Destroy; - end; -end; - -procedure TChromium.BeforeDestruction; -begin - {$IFNDEF FPC} - if (FBrowserCompHWND <> 0) and (FOldBrowserCompWndPrc <> nil) then - begin - SetWindowLongPtr(FBrowserCompHWND, GWL_WNDPROC, NativeInt(FOldBrowserCompWndPrc)); - FreeAndNilStub(FBrowserCompStub); - FOldBrowserCompWndPrc := nil; - end; - - if (FWidgetCompHWND <> 0) and (FOldWidgetCompWndPrc <> nil) then - begin - SetWindowLongPtr(FWidgetCompHWND, GWL_WNDPROC, NativeInt(FOldWidgetCompWndPrc)); - FreeAndNilStub(FWidgetCompStub); - FOldWidgetCompWndPrc := nil; - end; - - if (FRenderCompHWND <> 0) and (FOldRenderCompWndPrc <> nil) then - begin - SetWindowLongPtr(FRenderCompHWND, GWL_WNDPROC, NativeInt(FOldRenderCompWndPrc)); - FreeAndNilStub(FRenderCompStub); - FOldRenderCompWndPrc := nil; - end; - {$ENDIF} - - DestroyClientHandler; - - inherited BeforeDestruction; -end; - -procedure TChromium.ClearBrowserReference; -begin - FBrowser := nil; - FBrowserId := 0; -end; - -procedure TChromium.CreateStub(const aMethod : TWndMethod; var aStub : Pointer); -begin - if (aStub = nil) then aStub := MakeObjectInstance(aMethod); -end; - -procedure TChromium.FreeAndNilStub(var aStub : pointer); -begin - if (aStub <> nil) then - begin - FreeObjectInstance(aStub); - aStub := nil; - end; -end; - -procedure TChromium.DestroyClientHandler; -begin - try - if (FHandler <> nil) then - begin - FHandler.RemoveReferences; - FHandler := nil; - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.DestroyClientHandler', e) then raise; - end; -end; - -procedure TChromium.AfterConstruction; -{$IFDEF FPC} -var - TempWndMethod : TWndMethod; -{$ENDIF} -begin - inherited AfterConstruction; - - try - if not(csDesigning in ComponentState) then - begin - {$IFDEF FPC} - TempWndMethod := @WndProc; - FCompHandle := AllocateHWnd(TempWndMethod); - {$ELSE} - FCompHandle := AllocateHWnd(WndProc); - {$ENDIF} - FOptions := TChromiumOptions.Create; - FFontOptions := TChromiumFontOptions.Create; - FPDFPrintOptions := TPDFPrintOptions.Create; - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.AfterConstruction', e) then raise; - end; -end; - -function TChromium.CreateClientHandler(aIsOSR : boolean) : boolean; -begin - Result := False; - - try - if (FHandler = nil) then - begin - FIsOSR := aIsOsr; - FHandler := TCustomClientHandler.Create(Self, - MustCreateLoadHandler, - MustCreateFocusHandler, - MustCreateContextMenuHandler, - MustCreateDialogHandler, - MustCreateKeyboardHandler, - MustCreateDisplayHandler, - MustCreateDownloadHandler, - MustCreateJsDialogHandler, - True, - FIsOSR, // Create the Render Handler in OSR mode only - True, - MustCreateDragHandler, - MustCreateFindHandler); - - Result := True; - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.CreateClientHandler', e) then raise; - end; -end; - -function TChromium.CreateClientHandler(var aClient : ICefClient; aIsOSR : boolean) : boolean; -begin - if CreateClientHandler(aIsOSR) then - begin - aClient := FHandler; - Result := True; - end - else - Result := False; -end; - -procedure TChromium.InitializeEvents; -begin - // ICefClient - FOnProcessMessageReceived := nil; - - // ICefLoadHandler - FOnLoadStart := nil; - FOnLoadEnd := nil; - FOnLoadError := nil; - FOnLoadingStateChange := nil; - - // ICefFocusHandler - FOnTakeFocus := nil; - FOnSetFocus := nil; - FOnGotFocus := nil; - - // ICefContextMenuHandler - FOnBeforeContextMenu := nil; - FOnRunContextMenu := nil; - FOnContextMenuCommand := nil; - FOnContextMenuDismissed := nil; - - // ICefKeyboardHandler - FOnPreKeyEvent := nil; - FOnKeyEvent := nil; - - // ICefDisplayHandler - FOnAddressChange := nil; - FOnTitleChange := nil; - FOnFavIconUrlChange := nil; - FOnFullScreenModeChange := nil; - FOnTooltip := nil; - FOnStatusMessage := nil; - FOnConsoleMessage := nil; - FOnAutoResize := nil; - FOnLoadingProgressChange := nil; - - // ICefDownloadHandler - FOnBeforeDownload := nil; - FOnDownloadUpdated := nil; - - // ICefJsDialogHandler - FOnJsdialog := nil; - FOnBeforeUnloadDialog := nil; - FOnResetDialogState := nil; - FOnDialogClosed := nil; - - // ICefLifeSpanHandler - FOnBeforePopup := nil; - FOnAfterCreated := nil; - FOnBeforeClose := nil; - FOnClose := nil; - - // ICefRequestHandler - FOnBeforeBrowse := nil; - FOnOpenUrlFromTab := nil; - FOnBeforeResourceLoad := nil; - FOnGetResourceHandler := nil; - FOnResourceRedirect := nil; - FOnResourceResponse := nil; - FOnGetResourceResponseFilter := nil; - FOnResourceLoadComplete := nil; - FOnGetAuthCredentials := nil; - FOnCanGetCookies := nil; - FOnCanSetCookie := nil; - FOnQuotaRequest := nil; - FOnProtocolExecution := nil; - FOnCertificateError := nil; - FOnSelectClientCertificate := nil; - FOnPluginCrashed := nil; - FOnRenderViewReady := nil; - FOnRenderProcessTerminated := nil; - - // ICefDialogHandler - FOnFileDialog := nil; - - // ICefRenderHandler - FOnGetAccessibilityHandler := nil; - FOnGetRootScreenRect := nil; - FOnGetViewRect := nil; - FOnGetScreenPoint := nil; - FOnGetScreenInfo := nil; - FOnPopupShow := nil; - FOnPopupSize := nil; - FOnPaint := nil; - FOnCursorChange := nil; - FOnStartDragging := nil; - FOnUpdateDragCursor := nil; - FOnScrollOffsetChanged := nil; - FOnIMECompositionRangeChanged := nil; - FOnTextSelectionChanged := nil; - - // ICefDragHandler - FOnDragEnter := nil; - FOnDraggableRegionsChanged := nil; - - // ICefFindHandler - FOnFindResult := nil; - - // Custom - FOnTextResultAvailable := nil; - FOnPdfPrintFinished := nil; - FOnPrefsAvailable := nil; - FOnCookiesDeleted := nil; - FOnResolvedHostAvailable := nil; - {$IFNDEF FPC} - FOnBrowserCompMsg := nil; - FOnWidgetCompMsg := nil; - FOnRenderCompMsg := nil; - {$ENDIF} -end; - -function TChromium.CreateBrowser(const aBrowserParent : TWinControl; - const aWindowName : ustring; - const aContext : ICefRequestContext; - const aCookiesPath : ustring; - aPersistSessionCookies : boolean) : boolean; -var - TempHandle : HWND; - TempRect : TRect; -begin - if (aBrowserParent <> nil) then - begin - TempHandle := aBrowserParent.Handle; - TempRect := aBrowserParent.ClientRect; - end - else - begin - TempHandle := 0; - TempRect := rect(0, 0, 0, 0); - end; - - Result := CreateBrowser(TempHandle, TempRect, aWindowName, aContext, aCookiesPath, aPersistSessionCookies); -end; - -function TChromium.CreateBrowser( aParentHandle : HWND; - aParentRect : TRect; - const aWindowName : ustring; - const aContext : ICefRequestContext; - const aCookiesPath : ustring; - aPersistSessionCookies : boolean) : boolean; -var - TempCookieManager : ICefCookieManager; -begin - Result := False; - - try - // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser - // even if you use a custom request context. - // If you create a browser in the initialization of your app, make sure you call this - // function when GlobalCEFApp.GlobalContextInitialized is TRUE. - // Use the GlobalCEFApp.OnContextInitialized event to know when - // GlobalCEFApp.GlobalContextInitialized is set to TRUE. - - if not(csDesigning in ComponentState) and - not(FClosing) and - (FBrowser = nil) and - (FBrowserId = 0) and - (GlobalCEFApp <> nil) and - GlobalCEFApp.GlobalContextInitialized and - CreateClientHandler(aParentHandle = 0) then - begin - GetSettings(FBrowserSettings); - - if FIsOSR then - WindowInfoAsWindowless(FWindowInfo, FCompHandle, aWindowName) - else - WindowInfoAsChild(FWindowInfo, aParentHandle, aParentRect, aWindowName); - - - if (aContext <> nil) and (length(aCookiesPath) > 0) then - begin - TempCookieManager := aContext.GetDefaultCookieManager(nil); - - if (TempCookieManager = nil) or - not(TempCookieManager.SetStoragePath(aCookiesPath, aPersistSessionCookies, nil)) then - OutputDebugMessage('TChromium.CreateBrowser error : cookies cannot be accessed'); - end; - - - if GlobalCEFApp.MultiThreadedMessageLoop then - Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aContext) - else - Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aContext); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.CreateBrowser', e) then raise; - end; -end; - -procedure TChromium.InitializeDragAndDrop(const aDropTargetCtrl : TWinControl); -var - TempDropTarget : IDropTarget; -begin - {$IFNDEF FPC} - if FIsOSR and - not(FDragAndDropInitialized) and - (FDragDropManager = nil) and - (aDropTargetCtrl <> nil) then - begin - FDropTargetCtrl := aDropTargetCtrl; - - FDragDropManager := TCEFDragAndDropMgr.Create; - FDragDropManager.OnDragEnter := DragDropManager_OnDragEnter; - FDragDropManager.OnDragOver := DragDropManager_OnDragOver; - FDragDropManager.OnDragLeave := DragDropManager_OnDragLeave; - FDragDropManager.OnDrop := DragDropManager_OnDrop; - - TempDropTarget := TOLEDropTarget.Create(FDragDropManager); - - RegisterDragDrop(FDropTargetCtrl.Handle, TempDropTarget); - - FDragAndDropInitialized := True; - end; - {$ENDIF} -end; - -function TChromium.ShareRequestContext(var aContext : ICefRequestContext; - const aHandler : ICefRequestContextHandler) : boolean; -begin - Result := False; - aContext := nil; - - if Initialized then - begin - aContext := TCefRequestContextRef.Shared(FBrowser.Host.RequestContext, aHandler); - Result := (aContext <> nil); - end; -end; - -procedure TChromium.ShutdownDragAndDrop; -begin - if FDragAndDropInitialized and (FDropTargetCtrl <> nil) then - begin - RevokeDragDrop(FDropTargetCtrl.Handle); - FDragAndDropInitialized := False; - end; -end; - -procedure TChromium.ToMouseEvent(grfKeyState : Longint; pt : TPoint; var aMouseEvent : TCefMouseEvent); -begin - if (FDropTargetCtrl <> nil) then - begin - pt := FDropTargetCtrl.ScreenToClient(pt); - aMouseEvent.x := pt.x; - aMouseEvent.y := pt.y; - aMouseEvent.modifiers := GetCefMouseModifiers(grfKeyState); - end; -end; - -procedure TChromium.DragDropManager_OnDragEnter(Sender: TObject; const aDragData : ICefDragData; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); -var - TempMouseEvent : TCefMouseEvent; - TempAllowedOps : TCefDragOperations; -begin - if (GlobalCEFApp <> nil) then - begin - ToMouseEvent(grfKeyState, pt, TempMouseEvent); - DropEffectToDragOperation(dwEffect, TempAllowedOps); - DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor); - - DragTargetDragEnter(aDragData, @TempMouseEvent, TempAllowedOps); - DragTargetDragOver(@TempMouseEvent, TempAllowedOps); - - DragOperationToDropEffect(FDragOperations, dwEffect); - end; -end; - -procedure TChromium.DragDropManager_OnDragOver(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); -var - TempMouseEvent : TCefMouseEvent; - TempAllowedOps : TCefDragOperations; -begin - if (GlobalCEFApp <> nil) then - begin - ToMouseEvent(grfKeyState, pt, TempMouseEvent); - DropEffectToDragOperation(dwEffect, TempAllowedOps); - DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor); - - DragTargetDragOver(@TempMouseEvent, TempAllowedOps); - - DragOperationToDropEffect(FDragOperations, dwEffect); - end; -end; - -procedure TChromium.DragDropManager_OnDragLeave(Sender: TObject); -begin - DragTargetDragLeave; -end; - -procedure TChromium.DragDropManager_OnDrop(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); -var - TempMouseEvent : TCefMouseEvent; - TempAllowedOps : TCefDragOperations; -begin - if (GlobalCEFApp <> nil) then - begin - ToMouseEvent(grfKeyState, pt, TempMouseEvent); - DropEffectToDragOperation(dwEffect, TempAllowedOps); - DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor); - - DragTargetDragOver(@TempMouseEvent, TempAllowedOps); - DragTargetDrop(@TempMouseEvent); - - DragOperationToDropEffect(FDragOperations, dwEffect); - end; -end; - -procedure TChromium.CloseBrowser(aForceClose : boolean); -begin - if Initialized then FBrowser.Host.CloseBrowser(aForceClose); -end; - -function TChromium.CreateBrowserHost(aWindowInfo : PCefWindowInfo; - const aURL : ustring; - const aSettings : PCefBrowserSettings; - const aContext : ICefRequestContext): boolean; -var - TempURL : TCefString; -begin - TempURL := CefString(aURL); - Result := cef_browser_host_create_browser(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aContext)) <> 0; -end; - -function TChromium.CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; - const aURL : ustring; - const aSettings : PCefBrowserSettings; - const aContext : ICefRequestContext): boolean; -var - TempURL : TCefString; -begin - TempURL := CefString(aURL); - FBrowser := TCefBrowserRef.UnWrap(cef_browser_host_create_browser_sync(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aContext))); - - if (FBrowser <> nil) then - begin - FBrowserId := FBrowser.Identifier; - FInitialized := (FBrowserId <> 0); - Result := FInitialized; - end - else - Result := False; -end; - -procedure TChromium.Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); -begin - if Initialized then FBrowser.Host.Find(aIdentifier, aSearchText, aForward, aMatchCase, aFindNext); -end; - -procedure TChromium.StopFinding(aClearSelection : Boolean); -begin - if Initialized then FBrowser.Host.StopFinding(aClearSelection); -end; - -procedure TChromium.Print; -begin - if Initialized then FBrowser.Host.Print; -end; - -procedure TChromium.PrintToPDF(const aFilePath, aTitle, aURL : ustring); -var - TempSettings : TCefPdfPrintSettings; - TempCallback : ICefPdfPrintCallback; -begin - if Initialized then - begin - GetPrintPDFSettings(TempSettings, aTitle, aURL); - TempCallback := TCefCustomPDFPrintCallBack.Create(self); - FBrowser.Host.PrintToPdf(aFilePath, @TempSettings, TempCallback); - end; -end; - -procedure TChromium.ClipboardCopy; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Copy; - end; -end; - -procedure TChromium.ClipboardPaste; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Paste; - end; -end; - -procedure TChromium.ClipboardCut; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Cut; - end; -end; - -procedure TChromium.ClipboardUndo; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Undo; - end; -end; - -procedure TChromium.ClipboardRedo; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Redo; - end; -end; - -procedure TChromium.ClipboardDel; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Del; - end; -end; - -procedure TChromium.SelectAll; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.SelectAll; - end; -end; - -procedure TChromium.GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : ustring); -begin - if (FPDFPrintOptions <> nil) then - begin - aSettings.header_footer_title := CefString(aTitle); - aSettings.header_footer_url := CefString(aURL); - aSettings.page_width := FPDFPrintOptions.page_width; - aSettings.page_height := FPDFPrintOptions.page_height; - aSettings.scale_factor := FPDFPrintOptions.scale_factor; - aSettings.margin_top := FPDFPrintOptions.margin_top; - aSettings.margin_right := FPDFPrintOptions.margin_right; - aSettings.margin_bottom := FPDFPrintOptions.margin_bottom; - aSettings.margin_left := FPDFPrintOptions.margin_left; - aSettings.margin_type := FPDFPrintOptions.margin_type; - aSettings.header_footer_enabled := FPDFPrintOptions.header_footer_enabled; - aSettings.selection_only := FPDFPrintOptions.selection_only; - aSettings.landscape := FPDFPrintOptions.landscape; - aSettings.backgrounds_enabled := FPDFPrintOptions.backgrounds_enabled; - end; -end; - -procedure TChromium.GetSettings(var aSettings : TCefBrowserSettings); -begin - if (FFontOptions <> nil) and (FOptions <> nil) then - begin - aSettings.size := SizeOf(TCefBrowserSettings); - aSettings.windowless_frame_rate := FOptions.WindowlessFrameRate; - aSettings.standard_font_family := CefString(FFontOptions.StandardFontFamily); - aSettings.fixed_font_family := CefString(FFontOptions.FixedFontFamily); - aSettings.serif_font_family := CefString(FFontOptions.SerifFontFamily); - aSettings.sans_serif_font_family := CefString(FFontOptions.SansSerifFontFamily); - aSettings.cursive_font_family := CefString(FFontOptions.CursiveFontFamily); - aSettings.fantasy_font_family := CefString(FFontOptions.FantasyFontFamily); - aSettings.default_font_size := FFontOptions.DefaultFontSize; - aSettings.default_fixed_font_size := FFontOptions.DefaultFixedFontSize; - aSettings.minimum_font_size := FFontOptions.MinimumFontSize; - aSettings.minimum_logical_font_size := FFontOptions.MinimumLogicalFontSize; - aSettings.remote_fonts := FFontOptions.RemoteFonts; - aSettings.default_encoding := CefString(DefaultEncoding); - aSettings.javascript := FOptions.Javascript; - aSettings.javascript_close_windows := FOptions.JavascriptCloseWindows; - aSettings.javascript_access_clipboard := FOptions.JavascriptAccessClipboard; - aSettings.javascript_dom_paste := FOptions.JavascriptDomPaste; - aSettings.plugins := FOptions.Plugins; - aSettings.universal_access_from_file_urls := FOptions.UniversalAccessFromFileUrls; - aSettings.file_access_from_file_urls := FOptions.FileAccessFromFileUrls; - aSettings.web_security := FOptions.WebSecurity; - aSettings.image_loading := FOptions.ImageLoading; - aSettings.image_shrink_standalone_to_fit := FOptions.ImageShrinkStandaloneToFit; - aSettings.text_area_resize := FOptions.TextAreaResize; - aSettings.tab_to_links := FOptions.TabToLinks; - aSettings.local_storage := FOptions.LocalStorage; - aSettings.databases := FOptions.Databases; - aSettings.application_cache := FOptions.ApplicationCache; - aSettings.webgl := FOptions.Webgl; - aSettings.background_color := FOptions.BackgroundColor; - aSettings.accept_language_list := CefString(FOptions.AcceptLanguageList); - end; -end; - -procedure TChromium.InitializeSettings(var aSettings : TCefBrowserSettings); -begin - aSettings.size := SizeOf(TCefBrowserSettings); - aSettings.windowless_frame_rate := 30; - aSettings.standard_font_family := CefString(''); - aSettings.fixed_font_family := CefString(''); - aSettings.serif_font_family := CefString(''); - aSettings.sans_serif_font_family := CefString(''); - aSettings.cursive_font_family := CefString(''); - aSettings.fantasy_font_family := CefString(''); - aSettings.default_font_size := 0; - aSettings.default_fixed_font_size := 0; - aSettings.minimum_font_size := 0; - aSettings.minimum_logical_font_size := 0; - aSettings.remote_fonts := STATE_DEFAULT; - aSettings.default_encoding := CefString(''); - aSettings.javascript := STATE_DEFAULT; - aSettings.javascript_close_windows := STATE_DEFAULT; - aSettings.javascript_access_clipboard := STATE_DEFAULT; - aSettings.javascript_dom_paste := STATE_DEFAULT; - aSettings.plugins := STATE_DEFAULT; - aSettings.universal_access_from_file_urls := STATE_DEFAULT; - aSettings.file_access_from_file_urls := STATE_DEFAULT; - aSettings.web_security := STATE_DEFAULT; - aSettings.image_loading := STATE_DEFAULT; - aSettings.image_shrink_standalone_to_fit := STATE_DEFAULT; - aSettings.text_area_resize := STATE_DEFAULT; - aSettings.tab_to_links := STATE_DEFAULT; - aSettings.local_storage := STATE_DEFAULT; - aSettings.databases := STATE_DEFAULT; - aSettings.application_cache := STATE_DEFAULT; - aSettings.webgl := STATE_DEFAULT; - aSettings.background_color := 0; - aSettings.accept_language_list := CefString(''); -end; - -// Leave aFrameName empty to load the URL in the main frame -procedure TChromium.LoadURL(const aURL : ustring; const aFrameName : ustring = ''); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - if (length(aFrameName) > 0) then - TempFrame := FBrowser.GetFrame(aFrameName) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.LoadUrl(aURL); - end; -end; - -procedure TChromium.LoadURL(const aURL : ustring; const aFrame : ICefFrame); -begin - if Initialized and (aFrame <> nil) then aFrame.LoadUrl(aURL); -end; - -procedure TChromium.LoadURL(const aURL : ustring; const aFrameIdentifier : int64); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - if (aFrameIdentifier <> 0) then - TempFrame := FBrowser.GetFrameByident(aFrameIdentifier) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.LoadUrl(aURL); - end; -end; - -procedure TChromium.LoadString(const aString : ustring; const aURL : ustring); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then TempFrame.LoadString(aString, aURL); - end; -end; - -procedure TChromium.LoadRequest(const aRequest: ICefRequest); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then TempFrame.LoadRequest(aRequest); - end; -end; - -procedure TChromium.GoBack; -begin - if Initialized and CanGoBack then FBrowser.GoBack; -end; - -procedure TChromium.GoForward; -begin - if Initialized and CanGoForward then FBrowser.GoForward; -end; - -procedure TChromium.Reload; -begin - if Initialized then FBrowser.Reload; -end; - -procedure TChromium.ReloadIgnoreCache; -begin - if Initialized then FBrowser.ReloadIgnoreCache; -end; - -procedure TChromium.StopLoad; -begin - if Initialized then FBrowser.StopLoad; -end; - -procedure TChromium.StartDownload(const aURL : ustring); -begin - if Initialized then FBrowser.Host.StartDownload(aURL); -end; - -function TChromium.GetIsLoading : boolean; -begin - Result := Initialized and FBrowser.IsLoading; -end; - -function TChromium.GetMultithreadApp : boolean; -begin - Result := (GlobalCEFApp <> nil) and GlobalCEFApp.MultiThreadedMessageLoop; -end; - -function TChromium.GetHasDocument : boolean; -begin - Result := Initialized and FBrowser.HasDocument; -end; - -function TChromium.GetHasView : boolean; -begin - Result := Initialized and FBrowser.Host.HasView; -end; - -function TChromium.GetHasDevTools : boolean; -begin - Result := Initialized and FBrowser.Host.HasDevTools; -end; - -function TChromium.GetHasClientHandler : boolean; -begin - Result := (FHandler <> nil); -end; - -function TChromium.GetHasBrowser : boolean; -begin - Result := (FBrowser <> nil); -end; - -function TChromium.GetWindowHandle : THandle; -begin - if Initialized then - Result := FBrowser.Host.WindowHandle - else - Result := 0; -end; - -function TChromium.GetFrameIsFocused : boolean; -begin - Result := Initialized and (FBrowser.FocusedFrame <> nil); -end; - -function TChromium.GetWindowlessFrameRate : integer; -begin - if Initialized then - Result := FBrowser.Host.GetWindowlessFrameRate - else - Result := 0; -end; - -function TChromium.GetVisibleNavigationEntry : ICefNavigationEntry; -begin - if Initialized then - Result := FBrowser.Host.VisibleNavigationEntry - else - Result := nil; -end; - -function TChromium.GetHasValidMainFrame : boolean; -begin - Result := Initialized and (FBrowser.MainFrame <> nil) and FBrowser.MainFrame.IsValid; -end; - -function TChromium.GetFrameCount : NativeUInt; -begin - if Initialized then - Result := FBrowser.GetFrameCount - else - Result := 0; -end; - -function TChromium.GetRequestContextCache : ustring; -begin - if Initialized then - Result := FBrowser.host.RequestContext.CachePath - else - if (GlobalCEFApp <> nil) then - Result := GlobalCEFApp.cache - else - Result := ''; -end; - -function TChromium.GetRequestContextIsGlobal : boolean; -begin - Result := Initialized and FBrowser.host.RequestContext.IsGlobal; -end; - -procedure TChromium.SetWindowlessFrameRate(aValue : integer); -begin - if Initialized then FBrowser.Host.SetWindowlessFrameRate(aValue); -end; - -function TChromium.GetCanGoBack : boolean; -begin - Result := Initialized and FBrowser.CanGoBack; -end; - -function TChromium.GetCanGoForward : boolean; -begin - Result := Initialized and FBrowser.CanGoForward; -end; - -function TChromium.GetIsPopUp : boolean; -begin - Result := Initialized and FBrowser.IsPopUp; -end; - -function TChromium.GetInitialized : boolean; -begin - Result := FInitialized and not(FClosing) and (FBrowser <> nil); -end; - -function TChromium.GetDocumentURL : ustring; -var - TempFrame : ICefFrame; -begin - Result := ''; - - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then Result := TempFrame.URL; - end; -end; - -function TChromium.GetZoomLevel : double; -begin - Result := 0; - - if Initialized then Result := FBrowser.Host.ZoomLevel; -end; - -procedure TChromium.SetZoomLevel(const aValue : double); -begin - if Initialized then FBrowser.Host.ZoomLevel := aValue; -end; - -function TChromium.GetZoomPct : double; -begin - Result := power(1.2, ZoomLevel) * 100; -end; - -procedure TChromium.SetZoomPct(const aValue : double); -begin - if Initialized and (aValue > 0) then ZoomLevel := LogN(1.2, aValue / 100); -end; - -procedure TChromium.ApplyZoomStep; -begin - case FZoomStep of - ZOOM_STEP_25 : ZoomPct := 25; - ZOOM_STEP_33 : ZoomPct := 33; - ZOOM_STEP_50 : ZoomPct := 50; - ZOOM_STEP_67 : ZoomPct := 67; - ZOOM_STEP_75 : ZoomPct := 75; - ZOOM_STEP_90 : ZoomPct := 90; - ZOOM_STEP_100 : ZoomPct := 100; - ZOOM_STEP_110 : ZoomPct := 110; - ZOOM_STEP_125 : ZoomPct := 125; - ZOOM_STEP_150 : ZoomPct := 150; - ZOOM_STEP_175 : ZoomPct := 175; - ZOOM_STEP_200 : ZoomPct := 200; - ZOOM_STEP_250 : ZoomPct := 250; - ZOOM_STEP_300 : ZoomPct := 300; - ZOOM_STEP_400 : ZoomPct := 400; - ZOOM_STEP_500 : ZoomPct := 500; - end; -end; - -procedure TChromium.SetZoomStep(aValue : byte); -begin - if Initialized and (aValue in [ZOOM_STEP_MIN..ZOOM_STEP_MAX]) then - begin - FZoomStep := aValue; - ApplyZoomStep; - end; -end; - -procedure TChromium.IncZoomStep; -begin - if Initialized and (FZoomStep < ZOOM_STEP_MAX) then - begin - inc(FZoomStep); - ApplyZoomStep; - end; -end; - -procedure TChromium.DecZoomStep; -begin - if Initialized and (FZoomStep > ZOOM_STEP_MIN) then - begin - dec(FZoomStep); - ApplyZoomStep; - end; -end; - -procedure TChromium.ResetZoomStep; -begin - ZoomStep := ZOOM_STEP_DEF; -end; - -procedure TChromium.SetDoNotTrack(aValue : boolean); -begin - if (FDoNotTrack <> aValue) then - begin - FDoNotTrack := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetSendReferrer(aValue : boolean); -begin - if (FSendReferrer <> aValue) then - begin - FSendReferrer := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetHyperlinkAuditing(aValue : boolean); -begin - if (FHyperlinkAuditing <> aValue) then - begin - FHyperlinkAuditing := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetRunAllFlashInAllowMode(aValue : boolean); -begin - if (FRunAllFlashInAllowMode <> aValue) then - begin - FRunAllFlashInAllowMode := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetAllowOutdatedPlugins(aValue : boolean); -begin - if (FAllowOutdatedPlugins <> aValue) then - begin - FAllowOutdatedPlugins := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetAlwaysAuthorizePlugins(aValue : boolean); -begin - if (FAlwaysAuthorizePlugins <> aValue) then - begin - FAlwaysAuthorizePlugins := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); -begin - if (FWebRTCIPHandlingPolicy <> aValue) then - begin - FWebRTCIPHandlingPolicy := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetWebRTCMultipleRoutes(aValue : TCefState); -begin - if (FWebRTCMultipleRoutes <> aValue) then - begin - FWebRTCMultipleRoutes := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetWebRTCNonProxiedUDP(aValue : TCefState); -begin - if (FWebRTCNonProxiedUDP <> aValue) then - begin - FWebRTCNonProxiedUDP := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetCookiePrefs(aValue : integer); -begin - if (FCookiePrefs <> aValue) then - begin - FCookiePrefs := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetImagesPrefs(aValue : integer); -begin - if (FImagesPrefs <> aValue) then - begin - FImagesPrefs := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyType(aValue : integer); -begin - if (FProxyType <> aValue) then - begin - FProxyType := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyScheme(aValue : TCefProxyScheme); -begin - if (FProxyScheme <> aValue) then - begin - FProxyScheme := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyServer(const aValue : ustring); -begin - if (FProxyServer <> aValue) then - begin - FProxyServer := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyPort(aValue : integer); -begin - if (FProxyPort <> aValue) then - begin - FProxyPort := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyUsername(const aValue : ustring); -begin - if (FProxyUsername <> aValue) then - begin - FProxyUsername := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyPassword(const aValue : ustring); -begin - if (FProxyPassword <> aValue) then - begin - FProxyPassword := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyScriptURL(const aValue : ustring); -begin - if (FProxyScriptURL <> aValue) then - begin - FProxyScriptURL := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetProxyByPassList(const aValue : ustring); -begin - if (FProxyByPassList <> aValue) then - begin - FProxyByPassList := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TChromium.SetCustomHeaderName(const aValue : ustring); -begin - if (FCustomHeaderName <> aValue) then - begin - FCustomHeaderName := aValue; - FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); - end; -end; - -procedure TChromium.SetCustomHeaderValue(const aValue : ustring); -begin - if (FCustomHeaderValue <> aValue) then - begin - FCustomHeaderValue := aValue; - FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); - end; -end; - -function TChromium.DeleteCookies(const url, cookieName: ustring) : boolean; -var - TempManager : ICefCookieManager; - TempCallback : ICefDeleteCookiesCallback; -begin - Result := False; - - if Initialized and (FBrowser.Host <> nil) and (FBrowser.Host.RequestContext <> nil) then - begin - TempManager := FBrowser.Host.RequestContext.GetDefaultCookieManager(nil); - - if (TempManager <> nil) then - begin - TempCallback := TCefCustomDeleteCookiesCallback.Create(self); - Result := TempManager.DeleteCookies(url, cookieName, TempCallback); - end; - end; -end; - -// Leave aFrameName empty to get the HTML source from the main frame -procedure TChromium.RetrieveHTML(const aFrameName : ustring); -var - TempFrame : ICefFrame; - TempVisitor : ICefStringVisitor; -begin - if Initialized then - begin - if (length(aFrameName) > 0) then - TempFrame := FBrowser.GetFrame(aFrameName) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - TempFrame.GetSource(TempVisitor); - end; - end; -end; - -procedure TChromium.RetrieveHTML(const aFrame : ICefFrame); -var - TempVisitor : ICefStringVisitor; -begin - if Initialized and (aFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - aFrame.GetSource(TempVisitor); - end; -end; - -procedure TChromium.RetrieveHTML(const aFrameIdentifier : int64); -var - TempFrame : ICefFrame; - TempVisitor : ICefStringVisitor; -begin - if Initialized then - begin - if (aFrameIdentifier <> 0) then - TempFrame := FBrowser.GetFrameByident(aFrameIdentifier) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - TempFrame.GetSource(TempVisitor); - end; - end; -end; - -// Leave aFrameName empty to get the HTML source from the main frame -procedure TChromium.RetrieveText(const aFrameName : ustring); -var - TempFrame : ICefFrame; - TempVisitor : ICefStringVisitor; -begin - if Initialized then - begin - if (length(aFrameName) > 0) then - TempFrame := FBrowser.GetFrame(aFrameName) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - TempFrame.GetText(TempVisitor); - end; - end; -end; - -procedure TChromium.RetrieveText(const aFrame : ICefFrame); -var - TempVisitor : ICefStringVisitor; -begin - if Initialized and (aFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - aFrame.GetText(TempVisitor); - end; -end; - -procedure TChromium.RetrieveText(const aFrameIdentifier : int64); -var - TempFrame : ICefFrame; - TempVisitor : ICefStringVisitor; -begin - if Initialized then - begin - if (aFrameIdentifier <> 0) then - TempFrame := FBrowser.GetFrameByident(aFrameIdentifier) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - TempFrame.GetText(TempVisitor); - end; - end; -end; - -function TChromium.GetFrameNames(var aFrameNames : TStrings) : boolean; -begin - Result := Initialized and FBrowser.GetFrameNames(aFrameNames); -end; - -function TChromium.GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean; -begin - Result := Initialized and FBrowser.GetFrameIdentifiers(aFrameCount, aFrameIdentifierArray); -end; - -procedure TChromium.UpdatePreferences; -var - TempTask: ICefTask; -begin - if Initialized then - begin - TempTask := TCefUpdatePrefsTask.Create(self); - CefPostTask(TID_UI, TempTask); - end; -end; - -procedure TChromium.SavePreferences(const aFileName : string); -var - TempTask: ICefTask; -begin - if Initialized and (length(aFileName) > 0) then - begin - FPrefsFileName := aFileName; - TempTask := TCefSavePrefsTask.Create(self); - CefPostTask(TID_UI, TempTask); - end; -end; - -function TChromium.SetNewBrowserParent(aNewParentHwnd : HWND) : boolean; -var - TempHandle : HWND; -begin - Result := False; - - if Initialized then - begin - TempHandle := FBrowser.Host.WindowHandle; - Result := (TempHandle <> 0) and (SetParent(TempHandle, aNewParentHwnd) <> 0); - end; -end; - -procedure TChromium.ResolveHost(const aURL : ustring); -var - TempCallback : ICefResolveCallback; -begin - // Results will be received in the OnResolvedHostAvailable event of this class - if Initialized and (length(aURL) > 0) then - begin - TempCallback := TCefCustomResolveCallback.Create(self); - FBrowser.Host.RequestContext.ResolveHost(aURL, TempCallback); - end; -end; - -function TChromium.TakeSnapshot(var aBitmap : TBitmap) : boolean; -var - TempHWND : HWND; - TempDC : HDC; - TempRect : TRect; - TempWidth : Integer; - TempHeight : Integer; -begin - Result := False; - - if not(FIsOSR) then - begin - TempHWND := GetWindowHandle; - - if (TempHWND <> 0) then - begin - {$IFDEF DELPHI16_UP}Winapi.{$ENDIF}Windows.GetClientRect(TempHWND, TempRect); - - TempDC := GetDC(TempHWND); - TempWidth := TempRect.Right - TempRect.Left; - TempHeight := TempRect.Bottom - TempRect.Top; - - if (aBitmap <> nil) then FreeAndNil(aBitmap); - - aBitmap := TBitmap.Create; - aBitmap.Height := TempHeight; - aBitmap.Width := TempWidth; - - Result := BitBlt(aBitmap.Canvas.Handle, 0, 0, TempWidth, TempHeight, - TempDC, 0, 0, SRCCOPY); - - ReleaseDC(TempHWND, TempDC); - end; - end; -end; - -function TChromium.IsSameBrowser(const aBrowser : ICefBrowser) : boolean; -begin - Result := Initialized and (aBrowser <> nil) and FBrowser.IsSame(aBrowser); -end; - -procedure TChromium.SimulateMouseWheel(aDeltaX, aDeltaY : integer); -var - TempEvent : TCefMouseEvent; -begin - if Initialized then - begin - TempEvent.x := 0; - TempEvent.y := 0; - TempEvent.modifiers := EVENTFLAG_NONE; - FBrowser.Host.SendMouseWheelEvent(@TempEvent, aDeltaX, aDeltaY); - end; -end; - -procedure TChromium.doUpdatePreferences(const aBrowser: ICefBrowser); -begin - FUpdatePreferences := False; - - UpdateProxyPrefs(aBrowser); - UpdatePreference(aBrowser, 'enable_do_not_track', FDoNotTrack); - UpdatePreference(aBrowser, 'enable_referrers', FSendReferrer); - UpdatePreference(aBrowser, 'enable_a_ping', FHyperlinkAuditing); - UpdatePreference(aBrowser, 'plugins.run_all_flash_in_allow_mode', FRunAllFlashInAllowMode); - UpdatePreference(aBrowser, 'plugins.allow_outdated', FAllowOutdatedPlugins); - UpdatePreference(aBrowser, 'plugins.always_authorize', FAlwaysAuthorizePlugins); - - if FRunAllFlashInAllowMode then - UpdatePreference(aBrowser, 'profile.default_content_setting_values.plugins', 1); - - case FWebRTCIPHandlingPolicy of - hpDefaultPublicAndPrivateInterfaces : - UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'default_public_and_private_interfaces'); - - hpDefaultPublicInterfaceOnly : - UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'default_public_interface_only'); - - hpDisableNonProxiedUDP : - UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'disable_non_proxied_udp'); - end; - - if (FWebRTCMultipleRoutes <> STATE_DEFAULT) then - UpdatePreference(aBrowser, 'webrtc.multiple_routes_enabled', (FWebRTCMultipleRoutes = STATE_ENABLED)); - - if (FWebRTCNonProxiedUDP <> STATE_DEFAULT) then - UpdatePreference(aBrowser, 'webrtc.nonproxied_udp_enabled', (FWebRTCNonProxiedUDP = STATE_ENABLED)); -end; - -procedure TChromium.doUpdateOwnPreferences; -begin - if Initialized then doUpdatePreferences(FBrowser); -end; - -function TChromium.UpdateProxyPrefs(const aBrowser: ICefBrowser) : boolean; -var - TempError : ustring; - TempProxy : ICefValue; - TempValue : ICefValue; - TempDict : ICefDictionaryValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference('proxy') then - begin - TempProxy := TCefValueRef.New; - TempValue := TCefValueRef.New; - TempDict := TCefDictionaryValueRef.New; - - case FProxyType of - CEF_PROXYTYPE_AUTODETECT : - begin - TempValue.SetString('auto_detect'); - TempDict.SetValue('mode', TempValue); - end; - - CEF_PROXYTYPE_SYSTEM : - begin - TempValue.SetString('system'); - TempDict.SetValue('mode', TempValue); - end; - - CEF_PROXYTYPE_FIXED_SERVERS : - begin - TempValue.SetString('fixed_servers'); - TempDict.SetValue('mode', TempValue); - - case FProxyScheme of - psSOCKS4 : TempDict.SetString('server', 'socks4://' + FProxyServer + ':' + inttostr(FProxyPort)); - psSOCKS5 : TempDict.SetString('server', 'socks5://' + FProxyServer + ':' + inttostr(FProxyPort)); - else TempDict.SetString('server', FProxyServer + ':' + inttostr(FProxyPort)); - end; - - if (length(FProxyByPassList) > 0) then TempDict.SetString('bypass_list', FProxyByPassList); - end; - - CEF_PROXYTYPE_PAC_SCRIPT : - begin - TempValue.SetString('pac_script'); - TempDict.SetValue('mode', TempValue); - TempDict.SetString('pac_url', FProxyScriptURL); - end; - - else // CEF_PROXYTYPE_DIRECT - begin - TempValue.SetString('direct'); - TempDict.SetValue('mode', TempValue); - end; - end; - - Result := TempProxy.SetDictionary(TempDict) and - aBrowser.Host.RequestContext.SetPreference('proxy', TempProxy, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdateProxyPrefs error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdateProxyPrefs', e) then raise; - end; -end; - -function TChromium.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : boolean) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - - if aValue then - TempValue.SetBool(1) - else - TempValue.SetBool(0); - - Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; - end; -end; - -function TChromium.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : integer) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - TempValue.SetInt(aValue); - Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; - end; -end; - -function TChromium.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; const aValue : double) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - TempValue.SetDouble(aValue); - Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; - end; -end; - -function TChromium.UpdatePreference(const aBrowser: ICefBrowser; const aName, aValue : ustring) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - TempValue.SetString(aValue); - Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.UpdatePreference', e) then raise; - end; -end; - -procedure TChromium.HandleNull(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : -null-') - else - aResultSL.Add('-null-'); -end; - -procedure TChromium.HandleBool(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + BoolToStr(aValue.GetBool, true)) - else - aResultSL.Add(BoolToStr(aValue.GetBool, true)); -end; - -procedure TChromium.HandleInteger(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + IntToStr(aValue.GetInt)) - else - aResultSL.Add(IntToStr(aValue.GetInt)); -end; - -procedure TChromium.HandleDouble(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + FloatToStr(aValue.GetDouble)) - else - aResultSL.Add(FloatToStr(aValue.GetDouble)); -end; - -procedure TChromium.HandleString(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + aValue.GetString) - else - aResultSL.Add(aValue.GetString); -end; - -procedure TChromium.HandleBinary(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : -binary-') - else - aResultSL.Add('-binary-'); -end; - -procedure TChromium.HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey, TempResult : string; - i, j : integer; - TempList : ICefListValue; - TempValue : ICefValue; - TempSL : TStringList; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - TempList := aValue.GetList; - TempSL := TStringList.Create; - - i := 0; - j := TempList.GetSize; - - TempResult := '(' + inttostr(j) + '){'; - - while (i < j) do - begin - TempValue := TempList.GetValue(i); - - case TempValue.GetType of - VTYPE_NULL : TempResult := TempResult + '-null-,'; - VTYPE_BOOL : TempResult := TempResult + BoolToStr(aValue.GetBool, true) + ','; - VTYPE_INT : TempResult := TempResult + IntToStr(aValue.GetInt) + ','; - VTYPE_DOUBLE : TempResult := TempResult + FloatToStr(aValue.GetDouble) + ','; - VTYPE_STRING : TempResult := TempResult + aValue.GetString + ','; - VTYPE_BINARY : TempResult := TempResult + '-binary-,'; - VTYPE_DICTIONARY : - begin - TempSL.Clear; - HandleDictionary(TempValue.GetDictionary, TempSL, ''); - TempResult := TempResult + TempSL.CommaText + ','; - end; - - VTYPE_LIST : - begin - TempSL.Clear; - HandleList(TempValue, TempSL, '', ''); - TempResult := TempResult + TempSL.CommaText + ','; - end; - - else TempResult := TempResult + '-invalid-,'; - end; - - inc(i); - end; - - i := length(TempResult); - if (i > 0) and (TempResult[i] = ',') then TempResult := copy(TempResult, 1, pred(i)); - TempResult := TempResult + '}'; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + TempResult) - else - aResultSL.Add(TempResult); - - TempSL.Free; -end; - -procedure TChromium.HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : -invalid-') - else - aResultSL.Add('-invalid-'); -end; - -procedure TChromium.HandleDictionary(const aDict : ICefDictionaryValue; var aResultSL : TStringList; const aRoot : string); -var - TempKeys : TStringList; - i, j : integer; - TempValue : ICefValue; - TempNewKey : string; -begin - TempKeys := nil; - - try - try - if (aDict <> nil) then - begin - TempKeys := TStringList.Create; - aDict.GetKeys(TempKeys); - - i := 0; - j := TempKeys.Count; - - while (i < j) do - begin - TempValue := aDict.GetValue(TempKeys[i]); - - case TempValue.GetType of - VTYPE_NULL : HandleNull(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_BOOL : HandleBool(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_INT : HandleInteger(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_DOUBLE : HandleDouble(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_STRING : HandleString(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_BINARY : HandleBinary(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_LIST : HandleList(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_DICTIONARY : - begin - if (length(aRoot) > 0) then - TempNewKey := aRoot + '.' + TempKeys[i] - else - TempNewKey := TempKeys[i]; - - HandleDictionary(TempValue.GetDictionary, aResultSL, TempNewKey); - end; - - else - HandleInvalid(TempValue, aResultSL, aRoot, TempKeys[i]); - end; - - inc(i); - end; - - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.HandleDictionary', e) then raise; - end; - finally - if (TempKeys <> nil) then TempKeys.Free; - end; -end; - -function TChromium.doSavePreferences : boolean; -var - TempDict : ICefDictionaryValue; - TempPrefs : TStringList; -begin - Result := False; - TempPrefs := nil; - - try - try - if Initialized then - begin - TempPrefs := TStringList.Create; - TempDict := FBrowser.Host.RequestContext.GetAllPreferences(True); - HandleDictionary(TempDict, TempPrefs, ''); - TempPrefs.SaveToFile(FPrefsFileName); - Result := True; - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.Internal_SavePreferences', e) then raise; - end; - finally - SendCompMessage(CEF_PREFERENCES_SAVED, Ord(Result)); - if (TempPrefs <> nil) then FreeAndNil(TempPrefs); - end; -end; - -procedure TChromium.doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); -begin - if assigned(FOnResolvedHostAvailable) then FOnResolvedHostAvailable(self, result, resolvedIps); -end; - -function TChromium.MustCreateLoadHandler : boolean; -begin - Result := assigned(FOnLoadStart) or - assigned(FOnLoadEnd) or - assigned(FOnLoadError) or - assigned(FOnLoadingStateChange); -end; - -function TChromium.MustCreateFocusHandler : boolean; -begin - Result := assigned(FOnTakeFocus) or - assigned(FOnSetFocus) or - assigned(FOnGotFocus); -end; - -function TChromium.MustCreateContextMenuHandler : boolean; -begin - Result := assigned(FOnBeforeContextMenu) or - assigned(FOnRunContextMenu) or - assigned(FOnContextMenuCommand) or - assigned(FOnContextMenuDismissed); -end; - -function TChromium.MustCreateDialogHandler : boolean; -begin - Result := assigned(FOnFileDialog); -end; - -function TChromium.MustCreateKeyboardHandler : boolean; -begin - Result := assigned(FOnPreKeyEvent) or - assigned(FOnKeyEvent); -end; - -function TChromium.MustCreateDisplayHandler : boolean; -begin - Result := assigned(FOnAddressChange) or - assigned(FOnTitleChange) or - assigned(FOnFavIconUrlChange) or - assigned(FOnFullScreenModeChange) or - assigned(FOnTooltip) or - assigned(FOnStatusMessage) or - assigned(FOnConsoleMessage) or - assigned(FOnAutoResize) or - assigned(FOnLoadingProgressChange); -end; - -function TChromium.MustCreateDownloadHandler : boolean; -begin - Result := assigned(FOnBeforeDownload) or - assigned(FOnDownloadUpdated); -end; - -function TChromium.MustCreateJsDialogHandler : boolean; -begin - Result := assigned(FOnJsdialog) or - assigned(FOnBeforeUnloadDialog) or - assigned(FOnResetDialogState) or - assigned(FOnDialogClosed); -end; - -function TChromium.MustCreateDragHandler : boolean; -begin - Result := assigned(FOnDragEnter) or - assigned(FOnDraggableRegionsChanged); -end; - -function TChromium.MustCreateFindHandler : boolean; -begin - Result := assigned(FOnFindResult); -end; - -procedure TChromium.PrefsAvailableMsg(var aMessage : TMessage); -begin - if assigned(FOnPrefsAvailable) then FOnPrefsAvailable(self, (aMessage.WParam <> 0)); -end; - -function TChromium.SendCompMessage(aMsg : cardinal; wParam : cardinal; lParam : integer) : boolean; -begin - Result := (FCompHandle <> 0) and PostMessage(FCompHandle, aMsg, wParam, lParam); -end; - -procedure TChromium.doTextResultAvailable(const aText : ustring); -begin - if assigned(FOnTextResultAvailable) then FOnTextResultAvailable(self, aText); -end; - -procedure TChromium.ExecuteJavaScript(const aCode, aScriptURL, aFrameName : ustring; aStartLine : integer); -var - TempFrame : ICefFrame; -begin - try - if Initialized then - begin - if (length(aFrameName) > 0) then - TempFrame := FBrowser.GetFrame(aFrameName) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - TempFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.ExecuteJavaScript', e) then raise; - end; -end; - -procedure TChromium.ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrame : ICefFrame; aStartLine : integer); -begin - try - if Initialized and (aFrame <> nil) then - aFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); - except - on e : exception do - if CustomExceptionHandler('TChromium.ExecuteJavaScript', e) then raise; - end; -end; - -procedure TChromium.ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameIdentifier : int64; aStartLine : integer = 0); -var - TempFrame : ICefFrame; -begin - try - if Initialized then - begin - if (aFrameIdentifier <> 0) then - TempFrame := FBrowser.GetFrameByident(aFrameIdentifier) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - TempFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); - end; - except - on e : exception do - if CustomExceptionHandler('TChromium.ExecuteJavaScript', e) then raise; - end; -end; - -procedure TChromium.doCookiesDeleted(numDeleted : integer); -begin - if assigned(FOnCookiesDeleted) then FOnCookiesDeleted(self, numDeleted); -end; - -procedure TChromium.doPdfPrintFinished(aResultOK : boolean); -begin - if assigned(FOnPdfPrintFinished) then FOnPdfPrintFinished(self, aResultOK); -end; - -procedure TChromium.ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl); -var - TempPoint : TCefPoint; -begin - if not(Initialized) or HasDevTools then Exit; - - InitializeSettings(FDevBrowserSettings); - - if (aDevTools <> nil) then - WindowInfoAsChild(FDevWindowInfo, aDevTools.Handle, aDevTools.ClientRect, aDevTools.Name) - else - WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME); - - - if (inspectElementAt.x <> low(integer)) and - (inspectElementAt.y <> low(integer)) then - begin - TempPoint.x := inspectElementAt.x; - TempPoint.y := inspectElementAt.y; - - FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, @TempPoint); - end - else - FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, nil); -end; - -procedure TChromium.CloseDevTools(const aDevTools : TWinControl); -begin - if Initialized then - begin - if (aDevTools <> nil) then - begin - {$IFDEF DELPHI16_UP} - WinApi.Windows.SetParent(GetWindow(aDevTools.Handle, GW_CHILD), 0); - {$ELSE} - Windows.SetParent(GetWindow(aDevTools.Handle, GW_CHILD), 0); - {$ENDIF} - end; - - if (FBrowser <> nil) then FBrowser.Host.CloseDevTools; - end; -end; - -procedure TChromium.WndProc(var aMessage: TMessage); -begin - case aMessage.Msg of - CEF_PREFERENCES_SAVED : PrefsAvailableMsg(aMessage); - CEF_STARTDRAGGING : DelayedDragging; - - else aMessage.Result := DefWindowProc(FCompHandle, aMessage.Msg, aMessage.WParam, aMessage.LParam); - end; -end; - -{$IFNDEF FPC} -procedure TChromium.BrowserCompWndProc(var aMessage: TMessage); -var - TempHandled : boolean; -begin - try - TempHandled := False; - - if assigned(FOnBrowserCompMsg) then - FOnBrowserCompMsg(aMessage, TempHandled); - - if not(TempHandled) and - (FOldBrowserCompWndPrc <> nil) and - (FBrowserCompHWND <> 0) then - aMessage.Result := CallWindowProc(FOldBrowserCompWndPrc, - FBrowserCompHWND, - aMessage.Msg, - aMessage.wParam, - aMessage.lParam); - except - on e : exception do - if CustomExceptionHandler('TChromium.BrowserCompWndProc', e) then raise; - end; -end; - -procedure TChromium.WidgetCompWndProc(var aMessage: TMessage); -var - TempHandled : boolean; -begin - try - TempHandled := False; - - if assigned(FOnWidgetCompMsg) then - FOnWidgetCompMsg(aMessage, TempHandled); - - if not(TempHandled) and - (FOldWidgetCompWndPrc <> nil) and - (FWidgetCompHWND <> 0) then - aMessage.Result := CallWindowProc(FOldWidgetCompWndPrc, - FWidgetCompHWND, - aMessage.Msg, - aMessage.wParam, - aMessage.lParam); - except - on e : exception do - if CustomExceptionHandler('TChromium.WidgetCompWndProc', e) then raise; - end; -end; - -procedure TChromium.RenderCompWndProc(var aMessage: TMessage); -var - TempHandled : boolean; -begin - try - TempHandled := False; - - if assigned(FOnRenderCompMsg) then - FOnRenderCompMsg(aMessage, TempHandled); - - if not(TempHandled) and - (FOldRenderCompWndPrc <> nil) and - (FRenderCompHWND <> 0) then - aMessage.Result := CallWindowProc(FOldRenderCompWndPrc, - FRenderCompHWND, - aMessage.Msg, - aMessage.wParam, - aMessage.lParam); - except - on e : exception do - if CustomExceptionHandler('TChromium.RenderCompWndProc', e) then raise; - end; -end; -{$ENDIF} - -function TChromium.doOnClose(const browser: ICefBrowser): Boolean; -begin - Result := False; - - if (browser <> nil) and (FBrowserId = browser.Identifier) then FClosing := True; - - if Assigned(FOnClose) then FOnClose(Self, browser, Result); -end; - -procedure TChromium.doOnBeforeClose(const browser: ICefBrowser); -begin - if (browser <> nil) and (FBrowserId = browser.Identifier) then - begin - FInitialized := False; - ClearBrowserReference; - DestroyClientHandler; - end; - - if Assigned(FOnBeforeClose) then FOnBeforeClose(Self, browser); -end; - -procedure TChromium.doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); -begin - if Assigned(FOnAddressChange) then FOnAddressChange(Self, browser, frame, url); -end; - -procedure TChromium.doOnAfterCreated(const browser: ICefBrowser); -begin - if MultithreadApp and (FBrowser = nil) and (browser <> nil) then - begin - FBrowser := browser; - FBrowserId := browser.Identifier; - FInitialized := (FBrowserId <> 0); - end; - - doUpdatePreferences(browser); - - if Assigned(FOnAfterCreated) then FOnAfterCreated(Self, browser); -end; - -function TChromium.doOnBeforeBrowse(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - user_gesture : Boolean; - isRedirect : Boolean): Boolean; -begin - Result := False; - - if FUpdatePreferences then doUpdatePreferences(browser); - - if Assigned(FOnBeforeBrowse) then FOnBeforeBrowse(Self, browser, frame, request, user_gesture, isRedirect, Result); -end; - -procedure TChromium.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 TChromium.doRunContextMenu(const browser : ICefBrowser; - const frame : ICefFrame; - const params : ICefContextMenuParams; - const model : ICefMenuModel; - const callback : ICefRunContextMenuCallback): Boolean; -begin - Result := False; - - if Assigned(FOnRunContextMenu) then FOnRunContextMenu(Self, browser, frame, params, model, callback, Result); -end; - -procedure TChromium.doOnBeforeDownload(const browser : ICefBrowser; - const downloadItem : ICefDownloadItem; - const suggestedName : ustring; - const callback : ICefBeforeDownloadCallback); -begin - if Assigned(FOnBeforeDownload) then FOnBeforeDownload(Self, browser, downloadItem, suggestedName, callback); -end; - -function TChromium.doOnBeforePopup(const browser : ICefBrowser; - const frame : ICefFrame; - const targetUrl : ustring; - const targetFrameName : ustring; - targetDisposition : TCefWindowOpenDisposition; - userGesture : Boolean; - const 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, - targetDisposition, userGesture, popupFeatures, windowInfo, client, - settings, noJavascriptAccess, Result); -end; - -function TChromium.doOnBeforeResourceLoad(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const callback : ICefRequestCallback): TCefReturnValue; -var - TempHeaderMap : ICefStringMultimap; -begin - if FAddCustomHeader then - try - TempHeaderMap := TCefStringMultimapOwn.Create; - request.GetHeaderMap(TempHeaderMap); - TempHeaderMap.Append(FCustomHeaderName, FCustomHeaderValue); - request.SetHeaderMap(TempHeaderMap); - finally - TempHeaderMap := nil; - end; - - if not(FSendReferrer) then request.SetReferrer('', REFERRER_POLICY_NO_REFERRER); - - Result := RV_CONTINUE; - - if Assigned(FOnBeforeResourceLoad) then FOnBeforeResourceLoad(Self, browser, frame, request, callback, Result); -end; - -function TChromium.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; - -function TChromium.doOnCertificateError(const browser : ICefBrowser; - certError : TCefErrorcode; - const requestUrl : ustring; - const sslInfo : ICefSslInfo; - const callback : ICefRequestCallback): Boolean; -begin - Result := False; - - if Assigned(FOnCertificateError) then - FOnCertificateError(Self, browser, certError, requestUrl, sslInfo, callback, Result); -end; - -function TChromium.doOnConsoleMessage(const browser : ICefBrowser; - level : TCefLogSeverity; - const aMessage : ustring; - const source : ustring; - line : Integer): Boolean; -begin - Result := False; - - if Assigned(FOnConsoleMessage) then FOnConsoleMessage(Self, browser, level, aMessage, source, line, Result); -end; - -function TChromium.doOnAutoResize(const browser : ICefBrowser; - const new_size : PCefSize): Boolean; -begin - Result := False; - - if Assigned(FOnAutoResize) then FOnAutoResize(Self, browser, new_size, Result); -end; - -procedure TChromium.doOnLoadingProgressChange(const browser: ICefBrowser; const progress: double); -begin - if assigned(FOnLoadingProgressChange) then FOnLoadingProgressChange(self, browser, progress); -end; - -function TChromium.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 TChromium.doOnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); -begin - if Assigned(FOnContextMenuDismissed) then FOnContextMenuDismissed(Self, browser, frame); -end; - -procedure TChromium.doOnCursorChange(const browser : ICefBrowser; - cursor : TCefCursorHandle; - cursorType : TCefCursorType; - const customCursorInfo : PCefCursorInfo); -begin - if assigned(FOnCursorChange) then FOnCursorChange(self, browser, cursor, cursorType, customCursorInfo); -end; - -procedure TChromium.doOnDialogClosed(const browser: ICefBrowser); -begin - if Assigned(FOnDialogClosed) then FOnDialogClosed(Self, browser); -end; - -procedure TChromium.doOnDownloadUpdated(const browser : ICefBrowser; - const downloadItem : ICefDownloadItem; - const callback : ICefDownloadItemCallback); -begin - if Assigned(FOnDownloadUpdated) then FOnDownloadUpdated(Self, browser, downloadItem, callback); -end; - -function TChromium.doOnDragEnter(const browser : ICefBrowser; - const dragData : ICefDragData; - mask : TCefDragOperations): Boolean; -begin - Result := False; - - if Assigned(FOnDragEnter) then FOnDragEnter(Self, browser, dragData, mask, Result); -end; - -procedure TChromium.doOnDraggableRegionsChanged(const browser : ICefBrowser; - regionsCount : NativeUInt; - regions : PCefDraggableRegionArray); -begin - if Assigned(FOnDraggableRegionsChanged) then FOnDraggableRegionsChanged(Self, browser, regionsCount, regions); -end; - -procedure TChromium.doOnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); -begin - if Assigned(FOnFavIconUrlChange) then FOnFavIconUrlChange(Self, browser, iconUrls); -end; - -function TChromium.doOnFileDialog(const browser : ICefBrowser; - mode : TCefFileDialogMode; - const title : ustring; - const defaultFilePath : ustring; - const acceptFilters : TStrings; - selectedAcceptFilter : Integer; - const callback : ICefFileDialogCallback): Boolean; -begin - Result := False; - - if Assigned(FOnFileDialog) then - FOnFileDialog(Self, browser, mode, title, defaultFilePath, acceptFilters, - selectedAcceptFilter, callback, Result); -end; - -procedure TChromium.doOnFindResult(const browser : ICefBrowser; - identifier : integer; - count : Integer; - const selectionRect : PCefRect; - activeMatchOrdinal : Integer; - finalUpdate : Boolean); -begin - if Assigned(FOnFindResult) then - FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate); -end; - -procedure TChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); -begin - if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen); -end; - -function TChromium.doOnGetAuthCredentials(const browser : ICefBrowser; - const frame : ICefFrame; - isProxy : Boolean; - const host : ustring; - port : Integer; - const realm : ustring; - const scheme : ustring; - const callback : ICefAuthCallback): Boolean; -begin - Result := False; - - if isProxy then - begin - if (FProxyType = CEF_PROXYTYPE_FIXED_SERVERS) and (callback <> nil) then - begin - Result := True; - callback.cont(FProxyUsername, FProxyPassword); - end; - end - else - if (frame <> nil) and frame.IsMain and Assigned(FOnGetAuthCredentials) then - FOnGetAuthCredentials(Self, browser, frame, isProxy, host, port, realm, scheme, callback, Result); -end; - -function TChromium.doCanGetCookies(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest): boolean; -begin - Result := True; - - if assigned(FOnCanGetCookies) then FOnCanGetCookies(self, browser, frame, request, Result); -end; - -function TChromium.doCanSetCookie(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const cookie : PCefCookie): boolean; -begin - Result := True; - - if assigned(FOnCanSetCookie) then FOnCanSetCookie(self, browser, frame, request, cookie, Result); -end; - -function TChromium.doOnGetResourceHandler(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest): ICefResourceHandler; -begin - Result := nil; - - if Assigned(FOnGetResourceHandler) then - FOnGetResourceHandler(Self, browser, frame, request, Result); -end; - -procedure TChromium.doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); -begin - if assigned(FOnGetAccessibilityHandler) then FOnGetAccessibilityHandler(Self, aAccessibilityHandler); -end; - -function TChromium.doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; -begin - Result := False; - - if Assigned(FOnGetRootScreenRect) then FOnGetRootScreenRect(Self, browser, rect, Result); -end; +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} -function TChromium.doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; -begin - Result := False; - - if Assigned(FOnGetScreenInfo) then FOnGetScreenInfo(Self, browser, screenInfo, Result); -end; - -function TChromium.doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; -begin - Result := False; - - if Assigned(FOnGetScreenPoint) then FOnGetScreenPoint(Self, browser, viewX, viewY, screenX, screenY, Result); -end; - -function TChromium.doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; -begin - Result := False; - - if Assigned(FOnGetViewRect) then FOnGetViewRect(Self, browser, rect, Result); -end; - -procedure TChromium.doOnGotFocus(const browser: ICefBrowser); -begin - if Assigned(FOnGotFocus) then FOnGotFocus(Self, browser) -end; - -function TChromium.doOnJsdialog(const browser : ICefBrowser; - const originUrl : ustring; - dialogType : TCefJsDialogType; - const messageText : ustring; - const defaultPromptText : ustring; - const callback : ICefJsDialogCallback; - out suppressMessage : Boolean): Boolean; -begin - Result := False; - - if not(Initialized) then - suppressMessage := True - else - begin - suppressMessage := False; - - if Assigned(FOnJsdialog) then - FOnJsdialog(Self, browser, originUrl, dialogType, messageText, - defaultPromptText, callback, suppressMessage, Result); - end; -end; - -function TChromium.doOnKeyEvent(const browser : ICefBrowser; - const event : PCefKeyEvent; - osEvent : TCefEventHandle): Boolean; -begin - Result := False; - - if Assigned(FOnKeyEvent) then FOnKeyEvent(Self, browser, event, osEvent, Result); -end; - -procedure TChromium.doOnLoadEnd(const browser : ICefBrowser; - const frame : ICefFrame; - httpStatusCode : Integer); -begin - if Assigned(FOnLoadEnd) then FOnLoadEnd(Self, browser, frame, httpStatusCode); -end; - -procedure TChromium.doOnLoadError(const browser : ICefBrowser; - const frame : ICefFrame; - errorCode : TCefErrorCode; - const errorText : ustring; - const failedUrl : ustring); -begin - if Assigned(FOnLoadError) then FOnLoadError(Self, browser, frame, errorCode, errorText, failedUrl); -end; - -procedure TChromium.doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); -begin - if Assigned(FOnLoadingStateChange) then FOnLoadingStateChange(Self, browser, isLoading, canGoBack, canGoForward); -end; - -procedure TChromium.doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); -begin - if Assigned(FOnLoadStart) then FOnLoadStart(Self, browser, frame, transitionType); -end; - -function TChromium.doOnOpenUrlFromTab(const browser : ICefBrowser; - const frame : ICefFrame; - const targetUrl : ustring; - targetDisposition : TCefWindowOpenDisposition; - userGesture : Boolean): Boolean; -begin - Result := False; - - if Assigned(FOnOpenUrlFromTab) then - FOnOpenUrlFromTab(Self, browser, frame, targetUrl, targetDisposition, userGesture, Result); -end; - -procedure TChromium.doOnPaint(const browser : ICefBrowser; - kind : TCefPaintElementType; - dirtyRectsCount : NativeUInt; - const dirtyRects : PCefRectArray; - const buffer : Pointer; - width : Integer; - height : Integer); -begin - if Assigned(FOnPaint) then FOnPaint(Self, browser, kind, dirtyRectsCount, dirtyRects, buffer, width, height); -end; - -function TChromium.doOnSelectClientCertificate(const browser : ICefBrowser; - isProxy : boolean; - const host : ustring; - port : integer; - certificatesCount : NativeUInt; - const certificates : TCefX509CertificateArray; - const callback : ICefSelectClientCertificateCallback): boolean; -begin - Result := False; - - if assigned(FOnSelectClientCertificate) then - FOnSelectClientCertificate(self, browser, isProxy, host, port, certificatesCount, certificates, callback, Result); -end; - -procedure TChromium.doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); -begin - if Assigned(FOnPluginCrashed) then FOnPluginCrashed(Self, browser, pluginPath); -end; - -procedure TChromium.doOnPopupShow(const browser: ICefBrowser; show: Boolean); -begin - if assigned(FOnPopupShow) then FOnPopupShow(self, browser, show); -end; +{$I cef.inc} -procedure TChromium.doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); -begin - if assigned(FOnPopupSize) then FOnPopupSize(self, browser, rect); -end; +interface -function TChromium.doOnPreKeyEvent(const browser : ICefBrowser; - const event : PCefKeyEvent; - osEvent : TCefEventHandle; - out isKeyboardShortcut : Boolean): Boolean; -begin - Result := False; +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics, Vcl.Forms, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Controls, Graphics, Forms, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, + {$ELSE} + Messages, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFChromiumCore; - if Assigned(FOnPreKeyEvent) then FOnPreKeyEvent(Self, browser, event, osEvent, isKeyboardShortcut, Result); -end; +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TChromium = class(TChromiumCore) + protected + function GetParentFormHandle : TCefWindowHandle; override; + function GetParentForm : TCustomForm; + procedure InitializeDevToolsWindowInfo(aDevTools : TWinControl); virtual; + public + {$IFDEF MSWINDOWS} + procedure InitializeDragAndDrop(const aDropTargetCtrl : TWinControl); + {$ENDIF MSWINDOWS} + + procedure ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl = nil); + procedure CloseDevTools(const aDevTools : TWinControl = nil); + + procedure MoveFormTo(const x, y: Integer); + procedure MoveFormBy(const x, y: Integer); + procedure ResizeFormWidthTo(const x : Integer); + procedure ResizeFormHeightTo(const y : Integer); + procedure SetFormLeftTo(const x : Integer); + procedure SetFormTopTo(const y : Integer); + + function CreateBrowser(const aBrowserParent : TWinControl = nil; const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aExtraInfo : ICefDictionaryValue = nil) : boolean; overload; virtual; + function SaveAsBitmapStream(var aStream : TStream) : boolean; + function TakeSnapshot(var aBitmap : TBitmap) : boolean; + end; -function TChromium.doOnProcessMessageReceived(const browser : ICefBrowser; - sourceProcess : TCefProcessId; - const aMessage : ICefProcessMessage): Boolean; -begin - Result := False; +{$IFDEF FPC} +procedure Register; +{$ENDIF} - if Assigned(FOnProcessMessageReceived) then - FOnProcessMessageReceived(Self, browser, sourceProcess, aMessage, Result); -end; +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* -procedure TChromium.doOnProtocolExecution(const browser : ICefBrowser; - const url : ustring; - out allowOsExecution : Boolean); -begin - if Assigned(FOnProtocolExecution) then FOnProtocolExecution(Self, browser, url, allowOsExecution); -end; +implementation -function TChromium.doOnQuotaRequest(const browser : ICefBrowser; - const originUrl : ustring; - newSize : Int64; - const callback : ICefRequestCallback): Boolean; -begin - Result := False; +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, System.Math, + {$ELSE} + SysUtils, Math, + {$ENDIF} + uCEFMiscFunctions; - if Assigned(FOnQuotaRequest) then FOnQuotaRequest(Self, browser, originUrl, newSize, callback, Result); -end; +{ TChromium } -procedure TChromium.doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); +{$IFDEF MSWINDOWS} +procedure TChromium.InitializeDragAndDrop(const aDropTargetCtrl: TWinControl); begin - if Assigned(FOnRenderProcessTerminated) then FOnRenderProcessTerminated(Self, browser, status); + if (aDropTargetCtrl <> nil) then + inherited InitializeDragAndDrop(aDropTargetCtrl.Handle); end; +{$ENDIF MSWINDOWS} -procedure TChromium.doOnRenderViewReady(const browser: ICefBrowser); +procedure TChromium.InitializeDevToolsWindowInfo(aDevTools: TWinControl); +var + TempHandle : TCefWindowHandle; begin - if (browser <> nil) and - (browser.Host <> nil) and - (browser.Identifier = FBrowserId) then + if (aDevTools <> nil) then + DefaultInitializeDevToolsWindowInfo(aDevTools.Handle, aDevTools.ClientRect, aDevTools.Name) + else begin - FBrowserCompHWND := browser.Host.WindowHandle; - - if (FBrowserCompHWND <> 0) then - FWidgetCompHWND := FindWindowEx(FBrowserCompHWND, 0, 'Chrome_WidgetWin_0', ''); - - if (FWidgetCompHWND <> 0) then - FRenderCompHWND := FindWindowEx(FWidgetCompHWND, 0, 'Chrome_RenderWidgetHostHWND', 'Chrome Legacy Window'); - - {$IFNDEF FPC} - if assigned(FOnBrowserCompMsg) and (FBrowserCompHWND <> 0) and (FOldBrowserCompWndPrc = nil) then - begin - CreateStub(BrowserCompWndProc, FBrowserCompStub); - FOldBrowserCompWndPrc := TFNWndProc(SetWindowLongPtr(FBrowserCompHWND, - GWL_WNDPROC, - NativeInt(FBrowserCompStub))); - end; - - if assigned(FOnWidgetCompMsg) and (FWidgetCompHWND <> 0) and (FOldWidgetCompWndPrc = nil) then - begin - CreateStub(WidgetCompWndProc, FWidgetCompStub); - FOldWidgetCompWndPrc := TFNWndProc(SetWindowLongPtr(FWidgetCompHWND, - GWL_WNDPROC, - NativeInt(FWidgetCompStub))); - end; - - if assigned(FOnRenderCompMsg) and (FRenderCompHWND <> 0) and (FOldRenderCompWndPrc = nil) then - begin - CreateStub(RenderCompWndProc, FRenderCompStub); - FOldRenderCompWndPrc := TFNWndProc(SetWindowLongPtr(FRenderCompHWND, - GWL_WNDPROC, - NativeInt(FRenderCompStub))); - end; - {$ENDIF} + InitializeWindowHandle(TempHandle); + DefaultInitializeDevToolsWindowInfo(TempHandle, Rect(0, 0, 0, 0), ''); end; - - if Assigned(FOnRenderViewReady) then FOnRenderViewReady(Self, browser); -end; - -procedure TChromium.doOnResetDialogState(const browser: ICefBrowser); -begin - if Assigned(FOnResetDialogState) then FOnResetDialogState(Self, browser); -end; - -procedure TChromium.doOnResourceRedirect(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - var newUrl : ustring); -begin - if Assigned(FOnResourceRedirect) then FOnResourceRedirect(Self, browser, frame, request, response, newUrl); -end; - -function TChromium.doOnResourceResponse(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse): Boolean; -begin - Result := False; - - if Assigned(FOnResourceResponse) then FOnResourceResponse(Self, browser, frame, request, response, Result); -end; -function TChromium.doOnGetResourceResponseFilter(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse) : ICefResponseFilter; -begin - Result := nil; - - if Assigned(FOnGetResourceResponseFilter) then - FOnGetResourceResponseFilter(self, browser, frame, request, response, Result); -end; - -procedure TChromium.doOnResourceLoadComplete(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - status : TCefUrlRequestStatus; - receivedContentLength : Int64); -begin - if Assigned(FOnResourceLoadComplete) then - FOnResourceLoadComplete(self, browser, frame, request, response, status, receivedContentLength); -end; - -procedure TChromium.doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); -begin - if Assigned(FOnScrollOffsetChanged) then FOnScrollOffsetChanged(Self, browser, x, y); -end; - -procedure TChromium.doOnIMECompositionRangeChanged(const browser : ICefBrowser; - const selected_range : PCefRange; - character_boundsCount : NativeUInt; - const character_bounds : PCefRect); -begin - if assigned(FOnIMECompositionRangeChanged) then - FOnIMECompositionRangeChanged(self, browser, selected_range, character_boundsCount, character_bounds); -end; - -procedure TChromium.doOnTextSelectionChanged(const browser : ICefBrowser; - const selected_text : ustring; - const selected_range : PCefRange); -begin - if assigned(FOnTextSelectionChanged) then - FOnTextSelectionChanged(self, browser, selected_text, selected_range); -end; - -function TChromium.doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; -begin - Result := False; - - if Assigned(FOnSetFocus) then FOnSetFocus(Self, browser, source, Result); end; -function TChromium.doOnStartDragging(const browser : ICefBrowser; - const dragData : ICefDragData; - allowedOps : TCefDragOperations; - x : integer; - y : Integer): Boolean; +procedure TChromium.ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl); begin - Result := False; - {$IFNDEF FPC} - if FDragAndDropInitialized and - FDragDropManager.CloneDragData(dragData, allowedOps) then + if Initialized then begin - Result := True; - SendCompMessage(CEF_STARTDRAGGING); + InitializeDevToolsWindowInfo(aDevTools); + inherited ShowDevTools(inspectElementAt, @FDevWindowInfo); end; - - if Assigned(FOnStartDragging) then FOnStartDragging(Self, browser, dragData, allowedOps, x, y, Result); - {$ENDIF} end; -procedure TChromium.DelayedDragging; -var - TempOperation : TCefDragOperation; - TempPoint : TPoint; +procedure TChromium.CloseDevTools(const aDevTools : TWinControl); begin - {$IFNDEF FPC} - if FDragAndDropInitialized and (FDropTargetCtrl <> nil) and (GlobalCEFApp <> nil) then + if Initialized then begin - FDragOperations := DRAG_OPERATION_NONE; - TempOperation := FDragDropManager.StartDragging; - FDragOperations := DRAG_OPERATION_NONE; - - GetCursorPos(TempPoint); - TempPoint := FDropTargetCtrl.ScreenToClient(TempPoint); - DeviceToLogical(TempPoint, GlobalCEFApp.DeviceScaleFactor); - - DragSourceEndedAt(TempPoint.x, TempPoint.y, TempOperation); - DragSourceSystemDragEnded; + if (aDevTools <> nil) then + inherited CloseDevTools(aDevTools.Handle) + else + inherited CloseDevTools(0); end; - {$ENDIF} -end; - -procedure TChromium.doOnStatusMessage(const browser: ICefBrowser; const value: ustring); -begin - if Assigned(FOnStatusMessage) then FOnStatusMessage(Self, browser, value); -end; - -procedure TChromium.doOnTakeFocus(const browser: ICefBrowser; next: Boolean); -begin - if Assigned(FOnTakeFocus) then FOnTakeFocus(Self, browser, next); -end; - -procedure TChromium.doOnTitleChange(const browser: ICefBrowser; const title: ustring); -begin - if Assigned(FOnTitleChange) then FOnTitleChange(Self, browser, title); -end; - -function TChromium.doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; -begin - Result := False; - - if Assigned(FOnTooltip) then FOnTooltip(Self, browser, text, Result); -end; - -procedure TChromium.doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); -begin - if FDragAndDropInitialized then FDragOperations := operation; - - if Assigned(FOnUpdateDragCursor) then FOnUpdateDragCursor(Self, browser, operation); end; function TChromium.GetParentForm : TCustomForm; @@ -3709,6 +189,22 @@ begin TempComp := TempComp.owner; end; +function TChromium.GetParentFormHandle : TCefWindowHandle; +var + TempForm : TCustomForm; +begin + Result := inherited GetParentFormHandle; + TempForm := GetParentForm; + + if (TempForm <> nil) and TempForm.HandleAllocated then + Result := TempForm.Handle + else + if (Application <> nil) and + (Application.MainForm <> nil) and + Application.MainForm.HandleAllocated then + Result := Application.MainForm.Handle; +end; + procedure TChromium.MoveFormTo(const x, y: Integer); var TempForm : TCustomForm; @@ -3795,116 +291,91 @@ begin TempForm.Top := min(max(y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); end; -procedure TChromium.WasResized; -begin - if Initialized then FBrowser.Host.WasResized; -end; - -procedure TChromium.WasHidden(hidden: Boolean); -begin - if Initialized then FBrowser.Host.WasHidden(hidden); -end; - -procedure TChromium.NotifyScreenInfoChanged; -begin - if Initialized then FBrowser.Host.NotifyScreenInfoChanged; -end; - -procedure TChromium.NotifyMoveOrResizeStarted; -begin - if Initialized then FBrowser.Host.NotifyMoveOrResizeStarted; -end; - -procedure TChromium.Invalidate(kind: TCefPaintElementType); +function TChromium.CreateBrowser(const aBrowserParent : TWinControl; + const aWindowName : ustring; + const aContext : ICefRequestContext; + const aExtraInfo : ICefDictionaryValue) : boolean; +var + TempHandle : TCefWindowHandle; + TempRect : TRect; begin - if Initialized then + if (aBrowserParent <> nil) then begin - if FIsOSR then - FBrowser.Host.Invalidate(kind) - else - if (RenderHandle <> 0) then - InvalidateRect(RenderHandle, nil, False) - else - InvalidateRect(WindowHandle, nil, False); + TempHandle := aBrowserParent.Handle; + TempRect := aBrowserParent.ClientRect; + end + else + begin + InitializeWindowHandle(TempHandle); + TempRect := rect(0, 0, 0, 0); end; -end; - -procedure TChromium.SendKeyEvent(const event: PCefKeyEvent); -begin - if Initialized then FBrowser.Host.SendKeyEvent(event); -end; - -procedure TChromium.SendMouseClickEvent(const event : PCefMouseEvent; - kind : TCefMouseButtonType; - mouseUp : Boolean; - clickCount : Integer); -begin - if Initialized then FBrowser.Host.SendMouseClickEvent(event, kind, mouseUp, clickCount); -end; -procedure TChromium.SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); -begin - if Initialized then FBrowser.Host.SendMouseMoveEvent(event, mouseLeave); -end; - -procedure TChromium.SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); -begin - if Initialized then FBrowser.Host.SendMouseWheelEvent(event, deltaX, deltaY); + Result := inherited CreateBrowser(TempHandle, TempRect, aWindowName, aContext, aExtraInfo); end; -procedure TChromium.SendFocusEvent(setFocus: Boolean); +function TChromium.SaveAsBitmapStream(var aStream : TStream) : boolean; +{$IFDEF MSWINDOWS} +var + TempDC : HDC; + TempRect : TRect; +{$ENDIF} begin - if Initialized then FBrowser.Host.SendFocusEvent(setFocus); -end; + Result := False; -procedure TChromium.SendCaptureLostEvent; -begin - if Initialized then FBrowser.Host.SendCaptureLostEvent; -end; + {$IFDEF MSWINDOWS} + if not(FIsOSR) and (FRenderCompHWND <> 0) and (aStream <> nil) then + begin + TempDC := GetDC(FRenderCompHWND); -procedure TChromium.SetFocus(focus: Boolean); -begin - if Initialized then FBrowser.Host.SetFocus(focus); + if (TempDC <> 0) then + try + GetClientRect(FRenderCompHWND, TempRect); + Result := CopyDCToBitmapStream(TempDC, TempRect, aStream); + finally + ReleaseDC(FRenderCompHWND, TempDC); + end; + end; + {$ENDIF} end; -procedure TChromium.SetAccessibilityState(accessibilityState: TCefState); +function TChromium.TakeSnapshot(var aBitmap : TBitmap) : boolean; +{$IFDEF MSWINDOWS} +var + TempDC : HDC; + TempRect : TRect; + TempWidth : Integer; + TempHeight : Integer; +{$ENDIF} begin - if Initialized then FBrowser.Host.SetAccessibilityState(accessibilityState); -end; + Result := False; -function TChromium.SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; -begin - Result := Initialized and FBrowser.SendProcessMessage(targetProcess, ProcMessage); -end; + {$IFDEF MSWINDOWS} + if not(FIsOSR) and (FRenderCompHWND <> 0) then + begin + GetClientRect(FRenderCompHWND, TempRect); -procedure TChromium.DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); -begin - if Initialized then FBrowser.Host.DragTargetDragEnter(dragData, event, allowedOps); -end; + TempWidth := TempRect.Right - TempRect.Left; + TempHeight := TempRect.Bottom - TempRect.Top; -procedure TChromium.DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); -begin - if Initialized then FBrowser.Host.DragTargetDragOver(event, allowedOps); -end; + if (TempWidth <= 0) or (TempHeight <= 0) then exit; -procedure TChromium.DragTargetDragLeave; -begin - if Initialized then FBrowser.Host.DragTargetDragLeave; -end; + if (aBitmap <> nil) then FreeAndNil(aBitmap); -procedure TChromium.DragTargetDrop(event: PCefMouseEvent); -begin - if Initialized then FBrowser.Host.DragTargetDrop(event); -end; + aBitmap := TBitmap.Create; + aBitmap.Height := TempHeight; + aBitmap.Width := TempWidth; -procedure TChromium.DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); -begin - if Initialized then FBrowser.Host.DragSourceEndedAt(x, y, op); -end; + TempDC := GetDC(FRenderCompHWND); -procedure TChromium.DragSourceSystemDragEnded; -begin - if Initialized then FBrowser.Host.DragSourceSystemDragEnded; + if (TempDC <> 0) then + try + Result := BitBlt(aBitmap.Canvas.Handle, 0, 0, TempWidth, TempHeight, + TempDC, 0, 0, SRCCOPY); + finally + ReleaseDC(FRenderCompHWND, TempDC); + end; + end; + {$ENDIF} end; {$IFDEF FPC} diff --git a/windows/src/ext/cef4delphi/source/uCEFChromiumCore.pas b/windows/src/ext/cef4delphi/source/uCEFChromiumCore.pas new file mode 100644 index 0000000000000000000000000000000000000000..c63f163c4f6cb238a8592c71907f6a56bae3ffa3 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFChromiumCore.pas @@ -0,0 +1,7000 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFChromiumCore; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, WinApi.ActiveX, WinApi.CommCtrl,{$ENDIF} + System.Classes, System.SyncObjs, System.Types, + {$ELSE} + {$IFDEF MSWINDOWS}Windows, ActiveX, CommCtrl,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, + {$IFDEF LINUX}xlib,{$ENDIF} + {$ELSE} + Messages, + {$ENDIF} + SyncObjs, + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFMiscFunctions, uCEFClient, + uCEFConstants, uCEFTask, uCEFDomVisitor, uCEFChromiumEvents, + {$IFDEF MSWINDOWS}uCEFDragAndDropMgr,{$ENDIF} + {$IFDEF LINUX}uCEFLinuxTypes,{$ENDIF} + uCEFChromiumOptions, uCEFChromiumFontOptions, uCEFPDFPrintOptions, + uCEFBrowserViewComponent; + +type + TBrowserInfoList = class; + + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TChromiumCore = class(TComponent, IChromiumEvents) + protected + {$IFDEF MSWINDOWS} + FCompHandle : HWND; + {$ENDIF} + FHandler : ICefClient; + FBrowsersCS : TCriticalSection; + FBrowsers : TBrowserInfoList; + FBrowserId : integer; + FMultiBrowserMode : boolean; + FReqContextHandler : ICefRequestContextHandler; + FResourceRequestHandler : ICefResourceRequestHandler; + FMediaObserver : ICefMediaObserver; + FMediaObserverReg : ICefRegistration; + FDevToolsMsgObserver : ICefDevToolsMessageObserver; + FDevToolsMsgObserverReg : ICefRegistration; + FExtensionHandler : ICefExtensionHandler; + FDefaultUrl : ustring; + FOptions : TChromiumOptions; + FFontOptions : TChromiumFontOptions; + FPDFPrintOptions : TPDFPrintOptions; + FDefaultEncoding : ustring; + FProxyType : integer; + FProxyScheme : TCefProxyScheme; + FProxyServer : ustring; + FProxyPort : integer; + FProxyUsername : ustring; + FProxyPassword : ustring; + FProxyScriptURL : ustring; + FProxyByPassList : ustring; + FMaxConnectionsPerProxy : integer; + FUpdatePreferences : boolean; + FCustomHeaderName : ustring; + FCustomHeaderValue : ustring; + FAddCustomHeader : boolean; + FDoNotTrack : boolean; + FSendReferrer : boolean; + FHyperlinkAuditing : boolean; + FAllowOutdatedPlugins : boolean; + FAlwaysAuthorizePlugins : boolean; + FSpellChecking : boolean; + FSpellCheckerDicts : ustring; + FZoomStep : byte; + FZoomStepCS : TCriticalSection; + FPrefsFileName : string; + FIsOSR : boolean; + FSafeSearch : boolean; + FOffline : boolean; + FYouTubeRestrict : integer; + FPrintingEnabled : boolean; + FWindowInfo : TCefWindowInfo; + FBrowserSettings : TCefBrowserSettings; + FDevWindowInfo : TCefWindowInfo; + FDevBrowserSettings : TCefBrowserSettings; + FDragOperations : TCefDragOperations; + {$IFDEF MSWINDOWS} + FDragDropManager : TCEFDragAndDropMgr; + FDropTargetWnd : HWND; + {$ENDIF} + FDragAndDropInitialized : boolean; + FWebRTCIPHandlingPolicy : TCefWebRTCHandlingPolicy; + FWebRTCMultipleRoutes : TCefState; + FWebRTCNonProxiedUDP : TCefState; + FAcceptLanguageList : ustring; + FAcceptCookies : TCefCookiePref; + FBlock3rdPartyCookies : boolean; + FDefaultWindowInfoExStyle : DWORD; + FNetworkPredictions : TCefNetworkPredictionOptions; + FQuicAllowed : boolean; + FJavascriptEnabled : boolean; + FLoadImagesAutomatically : boolean; + + {$IFDEF LINUX} + FXDisplay : PXDisplay; + {$ENDIF} + + {$IFDEF MSWINDOWS} + FOldBrowserCompWndPrc : TFNWndProc; + FOldWidgetCompWndPrc : TFNWndProc; + FOldRenderCompWndPrc : TFNWndProc; + FBrowserCompStub : Pointer; + FWidgetCompStub : Pointer; + FRenderCompStub : Pointer; + FBrowserCompHWND : THandle; + FWidgetCompHWND : THandle; + FRenderCompHWND : THandle; + {$ENDIF} + + // ICefClient + FOnProcessMessageReceived : TOnProcessMessageReceived; + + // ICefLoadHandler + FOnLoadStart : TOnLoadStart; + FOnLoadEnd : TOnLoadEnd; + FOnLoadError : TOnLoadError; + FOnLoadingStateChange : TOnLoadingStateChange; + + // ICefFocusHandler + FOnTakeFocus : TOnTakeFocus; + FOnSetFocus : TOnSetFocus; + FOnGotFocus : TOnGotFocus; + + // ICefContextMenuHandler + FOnBeforeContextMenu : TOnBeforeContextMenu; + FOnRunContextMenu : TOnRunContextMenu; + FOnContextMenuCommand : TOnContextMenuCommand; + FOnContextMenuDismissed : TOnContextMenuDismissed; + + // ICefKeyboardHandler + FOnPreKeyEvent : TOnPreKeyEvent; + FOnKeyEvent : TOnKeyEvent; + + // ICefDisplayHandler + FOnAddressChange : TOnAddressChange; + FOnTitleChange : TOnTitleChange; + FOnFavIconUrlChange : TOnFavIconUrlChange; + FOnFullScreenModeChange : TOnFullScreenModeChange; + FOnTooltip : TOnTooltip; + FOnStatusMessage : TOnStatusMessage; + FOnConsoleMessage : TOnConsoleMessage; + FOnAutoResize : TOnAutoResize; + FOnLoadingProgressChange : TOnLoadingProgressChange; + FOnCursorChange : TOnCursorChange; + + // ICefDownloadHandler + FOnBeforeDownload : TOnBeforeDownload; + FOnDownloadUpdated : TOnDownloadUpdated; + + // ICefJsDialogHandler + FOnJsdialog : TOnJsdialog; + FOnBeforeUnloadDialog : TOnBeforeUnloadDialog; + FOnResetDialogState : TOnResetDialogState; + FOnDialogClosed : TOnDialogClosed; + + // ICefLifeSpanHandler + FOnBeforePopup : TOnBeforePopup; + FOnAfterCreated : TOnAfterCreated; + FOnBeforeClose : TOnBeforeClose; + FOnClose : TOnClose; + + // ICefRequestHandler + FOnBeforeBrowse : TOnBeforeBrowse; + FOnOpenUrlFromTab : TOnOpenUrlFromTab; + FOnGetAuthCredentials : TOnGetAuthCredentials; + FOnQuotaRequest : TOnQuotaRequest; + FOnCertificateError : TOnCertificateError; + FOnSelectClientCertificate : TOnSelectClientCertificate; + FOnPluginCrashed : TOnPluginCrashed; + FOnRenderViewReady : TOnRenderViewReady; + FOnRenderProcessTerminated : TOnRenderProcessTerminated; + FOnGetResourceRequestHandler_ReqHdlr : TOnGetResourceRequestHandler; + FOnDocumentAvailableInMainFrame : TOnDocumentAvailableInMainFrame; + + // ICefResourceRequestHandler + FOnBeforeResourceLoad : TOnBeforeResourceLoad; + FOnGetResourceHandler : TOnGetResourceHandler; + FOnResourceRedirect : TOnResourceRedirect; + FOnResourceResponse : TOnResourceResponse; + FOnGetResourceResponseFilter : TOnGetResourceResponseFilter; + FOnResourceLoadComplete : TOnResourceLoadComplete; + FOnProtocolExecution : TOnProtocolExecution; + + // ICefCookieAccessFilter + FOnCanSendCookie : TOnCanSendCookie; + FOnCanSaveCookie : TOnCanSaveCookie; + + // ICefDialogHandler + FOnFileDialog : TOnFileDialog; + + // ICefRenderHandler + FOnGetAccessibilityHandler : TOnGetAccessibilityHandler; + FOnGetRootScreenRect : TOnGetRootScreenRect; + FOnGetViewRect : TOnGetViewRect; + FOnGetScreenPoint : TOnGetScreenPoint; + FOnGetScreenInfo : TOnGetScreenInfo; + FOnPopupShow : TOnPopupShow; + FOnPopupSize : TOnPopupSize; + FOnPaint : TOnPaint; + FOnAcceleratedPaint : TOnAcceleratedPaint; + FOnStartDragging : TOnStartDragging; + FOnUpdateDragCursor : TOnUpdateDragCursor; + FOnScrollOffsetChanged : TOnScrollOffsetChanged; + FOnIMECompositionRangeChanged : TOnIMECompositionRangeChanged; + FOnTextSelectionChanged : TOnTextSelectionChanged; + FOnVirtualKeyboardRequested : TOnVirtualKeyboardRequested; + + // ICefDragHandler + FOnDragEnter : TOnDragEnter; + FOnDraggableRegionsChanged : TOnDraggableRegionsChanged; + + // ICefFindHandler + FOnFindResult : TOnFindResult; + + // ICefRequestContextHandler + FOnRequestContextInitialized : TOnRequestContextInitialized; + FOnBeforePluginLoad : TOnBeforePluginLoad; + FOnGetResourceRequestHandler_ReqCtxHdlr : TOnGetResourceRequestHandler; + + // ICefMediaObserver + FOnSinks : TOnSinksEvent; + FOnRoutes : TOnRoutesEvent; + FOnRouteStateChanged : TOnRouteStateChangedEvent; + FOnRouteMessageReceived : TOnRouteMessageReceivedEvent; + + // ICefAudioHandler + FOnGetAudioParameters : TOnGetAudioParametersEvent; + FOnAudioStreamStarted : TOnAudioStreamStartedEvent; + FOnAudioStreamPacket : TOnAudioStreamPacketEvent; + FOnAudioStreamStopped : TOnAudioStreamStoppedEvent; + FOnAudioStreamError : TOnAudioStreamErrorEvent; + + // ICefDevToolsMessageObserver + FOnDevToolsMessage : TOnDevToolsMessageEvent; + FOnDevToolsRawMessage : TOnDevToolsRawMessageEvent; + FOnDevToolsMethodResult : TOnDevToolsMethodResultEvent; + FOnDevToolsMethodRawResult : TOnDevToolsMethodRawResultEvent; + FOnDevToolsEvent : TOnDevToolsEventEvent; + FOnDevToolsRawEvent : TOnDevToolsEventRawEvent; + FOnDevToolsAgentAttached : TOnDevToolsAgentAttachedEvent; + FOnDevToolsAgentDetached : TOnDevToolsAgentDetachedEvent; + + // ICefExtensionHandler + FOnExtensionLoadFailed : TOnExtensionLoadFailedEvent; + FOnExtensionLoaded : TOnExtensionLoadedEvent; + FOnExtensionUnloaded : TOnExtensionUnloadedEvent; + FOnExtensionBeforeBackgroundBrowser : TOnBeforeBackgroundBrowserEvent; + FOnExtensionBeforeBrowser : TOnBeforeBrowserEvent; + FOnExtensionGetActiveBrowser : TOnGetActiveBrowserEvent; + FOnExtensionCanAccessBrowser : TOnCanAccessBrowserEvent; + FOnExtensionGetExtensionResource : TOnGetExtensionResourceEvent; + + // Custom + FOnTextResultAvailable : TOnTextResultAvailableEvent; + FOnPdfPrintFinished : TOnPdfPrintFinishedEvent; + FOnPrefsAvailable : TOnPrefsAvailableEvent; + FOnCookiesDeleted : TOnCookiesDeletedEvent; + FOnResolvedHostAvailable : TOnResolvedIPsAvailableEvent; + FOnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent; + FOnDownloadImageFinished : TOnDownloadImageFinishedEvent; + FOnCookiesFlushed : TNotifyEvent; + FOnCertificateExceptionsCleared : TNotifyEvent; + FOnHttpAuthCredentialsCleared : TNotifyEvent; + FOnAllConnectionsClosed : TNotifyEvent; + FOnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread; + FOnCookiesVisited : TOnCookiesVisited; + FOnCookieVisitorDestroyed : TOnCookieVisitorDestroyed; + FOnCookieSet : TOnCookieSet; + FOnZoomPctAvailable : TOnZoomPctAvailable; + FOnMediaRouteCreateFinished : TOnMediaRouteCreateFinishedEvent; + FOnMediaSinkDeviceInfo : TOnMediaSinkDeviceInfoEvent; + {$IFDEF MSWINDOWS} + FOnBrowserCompMsg : TOnCompMsgEvent; + FOnWidgetCompMsg : TOnCompMsgEvent; + FOnRenderCompMsg : TOnCompMsgEvent; + {$ENDIF} + + function GetIsLoading : boolean; + function GetMultithreadApp : boolean; + function GetHasDocument : boolean; + function GetHasView : boolean; + function GetHasDevTools : boolean; + function GetHasClientHandler : boolean; + function GetHasBrowser : boolean; + function GetCanGoBack : boolean; + function GetCanGoForward : boolean; + function GetDocumentURL : ustring; + function GetZoomLevel : double; + function GetZoomPct : double; + function GetZoomStep : byte; + function GetIsPopUp : boolean; + function GetWindowHandle : TCefWindowHandle; + function GetOpenerWindowHandle : TCefWindowHandle; + function GetWindowlessFrameRate : integer; + function GetFrameIsFocused : boolean; + function GetInitialized : boolean; + function GetVisibleNavigationEntry : ICefNavigationEntry; + function GetHasValidMainFrame : boolean; + function GetFrameCount : NativeUInt; + function GetRequestContextCache : ustring; + function GetRequestContextIsGlobal : boolean; + function GetAudioMuted : boolean; + function GetParentFormHandle : TCefWindowHandle; virtual; + function GetRequestContext : ICefRequestContext; + function GetMediaRouter : ICefMediaRouter; + function GetBrowser : ICefBrowser; + function GetBrowserId : integer; + function GetBrowserById(aID : integer) : ICefBrowser; + function GetBrowserCount : integer; + function GetBrowserIdByIndex(aIndex : integer) : integer; + {$IFDEF LINUX} + function GetXDisplay : PXDisplay; + {$ENDIF} + + procedure SetDoNotTrack(aValue : boolean); + procedure SetSendReferrer(aValue : boolean); + procedure SetHyperlinkAuditing(aValue : boolean); + procedure SetAllowOutdatedPlugins(aValue : boolean); + procedure SetAlwaysAuthorizePlugins(aValue : boolean); + procedure SetSpellChecking(aValue : boolean); + procedure SetSpellCheckerDicts(const aValue : ustring); + procedure SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); + procedure SetWebRTCMultipleRoutes(aValue : TCefState); + procedure SetWebRTCNonProxiedUDP(aValue : TCefState); + procedure SetProxyType(aValue : integer); + procedure SetProxyScheme(aValue : TCefProxyScheme); + procedure SetProxyServer(const aValue : ustring); + procedure SetProxyPort(aValue : integer); + procedure SetProxyUsername(const aValue : ustring); + procedure SetProxyPassword(const aValue : ustring); + procedure SetProxyScriptURL(const aValue : ustring); + procedure SetProxyByPassList(const aValue : ustring); + procedure SetMaxConnectionsPerProxy(const aValue : integer); + procedure SetCustomHeaderName(const aValue : ustring); + procedure SetCustomHeaderValue(const aValue : ustring); + procedure SetZoomLevel(const aValue : double); + procedure SetZoomPct(const aValue : double); + procedure SetZoomStep(aValue : byte); + procedure SetWindowlessFrameRate(aValue : integer); + procedure SetAudioMuted(aValue : boolean); + procedure SetSafeSearch(aValue : boolean); + procedure SetOffline(aValue : boolean); + procedure SetYouTubeRestrict(aValue : integer); + procedure SetPrintingEnabled(aValue : boolean); + procedure SetAcceptLanguageList(const aValue : ustring); + procedure SetAcceptCookies(const aValue : TCefCookiePref); + procedure SetBlock3rdPartyCookies(const aValue : boolean); + procedure SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized); + procedure SetOnBeforePluginLoad(const aValue : TOnBeforePluginLoad); + procedure SetMultiBrowserMode(aValue : boolean); + procedure SetNetworkPredictions(aValue : TCefNetworkPredictionOptions); + procedure SetQuicAllowed(aValue : boolean); + procedure SetJavascriptEnabled(aValue : boolean); + procedure SetLoadImagesAutomatically(aValue : boolean); + + function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean; + function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): Boolean; + + procedure DestroyAllBrowsers; + procedure DestroyClientHandler; + procedure DestroyReqContextHandler; + procedure DestroyResourceRequestHandler; + procedure DestroyMediaObserver; + procedure DestroyDevToolsMsgObserver; + procedure DestroyExtensionHandler; + procedure DestroyAllHandlersAndObservers; + + procedure CreateReqContextHandler; + procedure CreateResourceRequestHandler; + procedure CreateMediaObserver; + procedure CreateDevToolsMsgObserver; + procedure CreateExtensionHandler; + + procedure InitializeEvents; + procedure InitializeSettings(var aSettings : TCefBrowserSettings); + + procedure GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : ustring); + + function UpdateProxyPrefs(const aBrowser: ICefBrowser) : boolean; + function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : boolean) : boolean; overload; + function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : integer) : boolean; overload; + function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; const aValue : double) : boolean; overload; + function UpdatePreference(const aBrowser: ICefBrowser; const aName, aValue : ustring) : boolean; overload; + function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; const aValue : TStringList) : boolean; overload; + function UpdateStringListPref(const aBrowser: ICefBrowser; const aName, aValue : ustring) : boolean; + + function ExecuteUpdateZoomStepTask(aInc : boolean) : boolean; + function ExecuteUpdateZoomPctTask(aInc : boolean) : boolean; + function ExecuteReadZoomTask : boolean; + function ExecuteSetZoomPctTask(const aValue : double) : boolean; + function ExecuteSetZoomLevelTask(const aValue : double) : boolean; + function ExecuteSetZoomStepTask(aValue : byte) : boolean; + function ExecuteBrowserNavigationTask(aTask : TCefBrowserNavigation) : boolean; + + procedure UpdateHostZoomLevel(const aValue : double); + procedure UpdateHostZoomPct(const aValue : double); + + procedure DelayedDragging; + procedure InitializeWindowInfo(aParentHandle : TCefWindowHandle; aParentRect : TRect; const aWindowName : ustring); virtual; + procedure DefaultInitializeDevToolsWindowInfo(aDevToolsWnd: TCefWindowHandle; const aClientRect: TRect; const aWindowName: ustring); + + function AddBrowser(const aBrowser : ICefBrowser) : boolean; + function RemoveBrowser(const aBrowser : ICefBrowser) : boolean; + procedure SetBrowserIsClosing(aID : integer); + + {$IFDEF MSWINDOWS} + procedure PrefsAvailableMsg(aResultOK : boolean); + function SendCompMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean; + procedure ToMouseEvent(grfKeyState : Longint; pt : TPoint; var aMouseEvent : TCefMouseEvent); + procedure WndProc(var aMessage: TMessage); + procedure CreateStub(const aMethod : TWndMethod; var aStub : Pointer); + procedure FreeAndNilStub(var aStub : pointer); + function InstallCompWndProc(aWnd: THandle; aStub: Pointer): TFNWndProc; + procedure RestoreCompWndProc(var aOldWnd: THandle; aNewWnd: THandle; var aProc: TFNWndProc); + procedure CallOldCompWndProc(aProc: TFNWndProc; aWnd: THandle; var aMessage: TMessage); + procedure BrowserCompWndProc(var aMessage: TMessage); + procedure WidgetCompWndProc(var aMessage: TMessage); + procedure RenderCompWndProc(var aMessage: TMessage); + procedure RestoreOldCompWndProc; + function CopyDCToBitmapStream(aSrcDC : HDC; const aSrcRect : TRect; var aStream : TStream) : boolean; + {$ENDIF} + + procedure DragDropManager_OnDragEnter(Sender: TObject; const aDragData : ICefDragData; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); + procedure DragDropManager_OnDragOver(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); + procedure DragDropManager_OnDragLeave(Sender: TObject); + procedure DragDropManager_OnDrop(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); + + // IChromiumEvents + procedure GetSettings(var aSettings : TCefBrowserSettings); + + // ICefClient + function doOnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual; + + // ICefLoadHandler + procedure doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); 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; + procedure doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); virtual; + + // ICefFocusHandler + procedure doOnTakeFocus(const browser: ICefBrowser; next: Boolean); virtual; + function doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; virtual; + procedure doOnGotFocus(const browser: ICefBrowser); virtual; + + // ICefContextMenuHandler + procedure doOnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); virtual; + function doRunContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel; const callback: ICefRunContextMenuCallback): Boolean; 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; + + // ICefKeyboardHandler + 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; + + // ICefDisplayHandler + procedure doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); virtual; + procedure doOnTitleChange(const browser: ICefBrowser; const title: ustring); virtual; + procedure doOnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); virtual; + procedure doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); virtual; + function doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; virtual; + procedure doOnStatusMessage(const browser: ICefBrowser; const value: ustring); virtual; + function doOnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const aMessage, source: ustring; line: Integer): Boolean; virtual; + function doOnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; virtual; + procedure doOnLoadingProgressChange(const browser: ICefBrowser; const progress: double); virtual; + procedure doOnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); virtual; + + // ICefDownloadHandler + 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; + + // ICefJsDialogHandler + function doOnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const 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; + procedure doOnDialogClosed(const browser: ICefBrowser); virtual; + + // ICefLifeSpanHandler + function doOnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean): Boolean; virtual; + procedure doOnAfterCreated(const browser: ICefBrowser); virtual; + procedure doOnBeforeClose(const browser: ICefBrowser); virtual; + function doOnClose(const browser: ICefBrowser): Boolean; virtual; + + // ICefRequestHandler + function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; virtual; + function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; virtual; + procedure doGetResourceRequestHandler_ReqHdlr(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); virtual; + function doOnGetAuthCredentials(const browser: ICefBrowser; const originUrl: ustring; 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: ICefRequestCallback): Boolean; virtual; + function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; virtual; + function doOnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; virtual; + procedure doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); virtual; + procedure doOnRenderViewReady(const browser: ICefBrowser); virtual; + procedure doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); virtual; + procedure doOnDocumentAvailableInMainFrame(const browser: ICefBrowser); virtual; + + // ICefResourceRequestHandler + function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; virtual; + procedure doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aResourceHandler : ICefResourceHandler); virtual; + procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); virtual; + function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; virtual; + procedure doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var aResponseFilter: ICefResponseFilter); virtual; + procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); virtual; + procedure doOnProtocolExecution(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var allowOsExecution: Boolean); virtual; + + // ICefCookieAccessFilter + function doCanSendCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie: PCefCookie): boolean; virtual; + function doCanSaveCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; const cookie: PCefCookie): boolean; virtual; + + // ICefDialogHandler + function doOnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; virtual; + + // ICefRenderHandler + procedure doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); virtual; + function doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; + procedure doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect); virtual; + function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; virtual; + function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; virtual; + procedure doOnPopupShow(const browser: ICefBrowser; show: Boolean); virtual; + procedure doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); virtual; + procedure doOnPaint(const browser: ICefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); virtual; + procedure doOnAcceleratedPaint(const browser: ICefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; shared_handle: Pointer); virtual; + function doOnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; virtual; + procedure doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); virtual; + procedure doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); virtual; + procedure doOnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); virtual; + procedure doOnTextSelectionChanged(const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange); virtual; + procedure doOnVirtualKeyboardRequested(const browser: ICefBrowser; input_mode: TCefTextInpuMode); virtual; + + // ICefDragHandler + function doOnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; virtual; + procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; const frame: ICefFrame; regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); virtual; + + // ICefFindHandler + procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual; + + // ICefRequestContextHandler + procedure doOnRequestContextInitialized(const request_context: ICefRequestContext); virtual; + function doOnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; virtual; + procedure doGetResourceRequestHandler_ReqCtxHdlr(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); virtual; + + // ICefMediaObserver + procedure doOnSinks(const sinks: TCefMediaSinkArray); virtual; + procedure doOnRoutes(const routes: TCefMediaRouteArray); virtual; + procedure doOnRouteStateChanged(const route: ICefMediaRoute; state: TCefMediaRouteConnectionState); virtual; + procedure doOnRouteMessageReceived(const route: ICefMediaRoute; const message_: ustring); virtual; + + // ICefAudioHandler + procedure doOnGetAudioParameters(const browser: ICefBrowser; var params: TCefAudioParameters; var aResult: boolean); virtual; + procedure doOnAudioStreamStarted(const browser: ICefBrowser; const params: TCefAudioParameters; channels: integer); virtual; + procedure doOnAudioStreamPacket(const browser: ICefBrowser; const data : PPSingle; frames: integer; pts: int64); virtual; + procedure doOnAudioStreamStopped(const browser: ICefBrowser); virtual; + procedure doOnAudioStreamError(const browser: ICefBrowser; const message_: ustring); virtual; + + // ICefDevToolsMessageObserver + procedure doOnDevToolsMessage(const browser: ICefBrowser; const message_: Pointer; message_size: NativeUInt; var aHandled: boolean); virtual; + procedure doOnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: Pointer; result_size: NativeUInt); virtual; + procedure doOnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: Pointer; params_size: NativeUInt); virtual; + procedure doOnDevToolsAgentAttached(const browser: ICefBrowser); virtual; + procedure doOnDevToolsAgentDetached(const browser: ICefBrowser); virtual; + + // ICefExtensionHandler + procedure doOnExtensionLoadFailed(result: TCefErrorcode); + procedure doOnExtensionLoaded(const extension: ICefExtension); + procedure doOnExtensionUnloaded(const extension: ICefExtension); + function doOnExtensionBeforeBackgroundBrowser(const extension: ICefExtension; const url: ustring; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; + function doOnExtensionBeforeBrowser(const extension: ICefExtension; const browser, active_browser: ICefBrowser; index: Integer; const url: ustring; active: boolean; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; + procedure doOnExtensionGetActiveBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; var aRsltBrowser: ICefBrowser); + function doOnExtensionCanAccessBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; const target_browser: ICefBrowser): boolean; + function doOnExtensionGetExtensionResource(const extension: ICefExtension; const browser: ICefBrowser; const file_: ustring; const callback: ICefGetExtensionResourceCallback): boolean; + + // Custom + procedure doCookiesDeleted(numDeleted : integer); virtual; + procedure doPdfPrintFinished(aResultOK : boolean); virtual; + procedure doTextResultAvailable(const aText : ustring); virtual; + procedure doUpdatePreferences(const aBrowser: ICefBrowser); virtual; + procedure doUpdateOwnPreferences; virtual; + function doSavePreferences : boolean; virtual; + procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); virtual; + function doNavigationVisitorResultAvailable(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer) : boolean; virtual; + procedure doDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); virtual; + procedure doOnCookiesStoreFlushed; virtual; + procedure doCertificateExceptionsCleared; virtual; + procedure doHttpAuthCredentialsCleared; virtual; + procedure doAllConnectionsClosed; virtual; + procedure doOnExecuteTaskOnCefThread(aTaskID : cardinal); virtual; + procedure doOnCookiesVisited(const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; same_site : TCefCookieSameSite; priority : TCefCookiePriority; var aDeleteCookie, aResult : Boolean); virtual; + procedure doOnCookieVisitorDestroyed(aID : integer); virtual; + procedure doOnCookieSet(aSuccess : boolean; aID : integer); virtual; + procedure doUpdateZoomStep(aInc : boolean); virtual; + procedure doUpdateZoomPct(aInc : boolean); virtual; + procedure doReadZoom; virtual; + procedure doSetZoomLevel(const aValue : double); virtual; + procedure doSetZoomPct(const aValue : double); virtual; + procedure doSetZoomStep(aValue : byte); virtual; + procedure doMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); virtual; + procedure doOnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); virtual; + procedure doBrowserNavigation(aTask : TCefBrowserNavigation); virtual; + function MustCreateAudioHandler : boolean; virtual; + function MustCreateDevToolsMessageObserver : boolean; virtual; + function MustCreateLoadHandler : boolean; virtual; + function MustCreateFocusHandler : boolean; virtual; + function MustCreateContextMenuHandler : boolean; virtual; + function MustCreateDialogHandler : boolean; virtual; + function MustCreateKeyboardHandler : boolean; virtual; + function MustCreateDisplayHandler : boolean; virtual; + function MustCreateDownloadHandler : boolean; virtual; + function MustCreateJsDialogHandler : boolean; virtual; + function MustCreateLifeSpanHandler : boolean; virtual; + function MustCreateRenderHandler : boolean; virtual; + function MustCreateRequestHandler : boolean; virtual; + function MustCreateDragHandler : boolean; virtual; + function MustCreateFindHandler : boolean; virtual; + function MustCreateResourceRequestHandler : boolean; virtual; + function MustCreateCookieAccessFilter : boolean; virtual; + function MustCreateRequestContextHandler : boolean; virtual; + function MustCreateMediaObserver : boolean; virtual; + function MustCreateExtensionHandler : boolean; virtual; + + property ParentFormHandle : TCefWindowHandle read GetParentFormHandle; + + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure AfterConstruction; override; + function CreateClientHandler(aIsOSR : boolean = True) : boolean; overload; + function CreateClientHandler(var aClient : ICefClient; aIsOSR : boolean = True) : boolean; overload; + procedure CloseBrowser(aForceClose : boolean); + procedure CloseAllBrowsers; + function TryCloseBrowser : boolean; + function SelectBrowser(aID : integer) : boolean; + function IndexOfBrowserID(aID : integer) : integer; + function ShareRequestContext(var aContext : ICefRequestContext; const aHandler : ICefRequestContextHandler = nil) : boolean; + {$IFDEF MSWINDOWS} + procedure InitializeDragAndDrop(const aDropTargetWnd : HWND); + procedure ShutdownDragAndDrop; + function SetNewBrowserParent(aNewParentHwnd : HWND) : boolean; + {$ENDIF MSWINDOWS} + + function CreateBrowser(aParentHandle : TCefWindowHandle; aParentRect : TRect; const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aExtraInfo : ICefDictionaryValue = nil) : boolean; overload; virtual; + function CreateBrowser(const aURL : ustring; const aBrowserViewComp : TCEFBrowserViewComponent; const aContext : ICefRequestContext = nil; const aExtraInfo : ICefDictionaryValue = nil) : boolean; overload; virtual; + procedure CreateBrowser(const aWindowName : ustring); overload; virtual; + + procedure LoadURL(const aURL : ustring; const aFrameName : ustring = ''); overload; + procedure LoadURL(const aURL : ustring; const aFrame : ICefFrame); overload; + procedure LoadURL(const aURL : ustring; const aFrameIdentifier : int64); overload; + procedure LoadString(const aHTML : ustring; const aFrameName : ustring = ''); overload; + procedure LoadString(const aHTML : ustring; const aFrame : ICefFrame); overload; + procedure LoadString(const aHTML : ustring; const aFrameIdentifier : int64); overload; + procedure LoadResource(const aStream : TCustomMemoryStream; const aMimeType, aCharset : string; const aFrameName : ustring = ''); overload; + procedure LoadResource(const aStream : TCustomMemoryStream; const aMimeType, aCharset : string; const aFrame : ICefFrame); overload; + procedure LoadResource(const aStream : TCustomMemoryStream; const aMimeType, aCharset : string; const aFrameIdentifier : int64); overload; + procedure LoadRequest(const aRequest: ICefRequest); + + procedure GoBack; + procedure GoForward; + procedure Reload; + procedure ReloadIgnoreCache; + procedure StopLoad; + procedure StartDownload(const aURL : ustring); + procedure DownloadImage(const imageUrl: ustring; isFavicon: Boolean; maxImageSize: cardinal; bypassCache: Boolean); + + procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer); + function ClearCertificateExceptions(aClearImmediately : boolean = True) : boolean; + function ClearHttpAuthCredentials(aClearImmediately : boolean = True) : boolean; + function CloseAllConnections(aCloseImmediately : boolean = True) : boolean; + procedure RetrieveHTML(const aFrameName : ustring = ''); overload; + procedure RetrieveHTML(const aFrame : ICefFrame); overload; + procedure RetrieveHTML(const aFrameIdentifier : int64); overload; + procedure RetrieveText(const aFrameName : ustring = ''); overload; + procedure RetrieveText(const aFrame : ICefFrame); overload; + procedure RetrieveText(const aFrameIdentifier : int64); overload; + procedure GetNavigationEntries(currentOnly: Boolean); + function GetFrameNames(var aFrameNames : TStrings) : boolean; + function GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean; + procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameName : ustring = ''; aStartLine : integer = 0); overload; + procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrame : ICefFrame; aStartLine : integer = 0); overload; + procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameIdentifier : int64; aStartLine : integer = 0); overload; + procedure UpdatePreferences; + procedure SavePreferences(const aFileName : string); + procedure ResolveHost(const aURL : ustring); + function IsSameBrowser(const aBrowser : ICefBrowser) : boolean; + function ExecuteTaskOnCefThread(aCefThreadId : TCefThreadId; aTaskID : cardinal; aDelayMs : Int64 = 0) : boolean; + procedure SetUserAgentOverride(const aUserAgent : ustring; const aAcceptLanguage : ustring = ''; const aPlatform : ustring = ''); + procedure ClearDataForOrigin(const aOrigin : ustring; aStorageTypes : TCefClearDataStorageTypes = cdstAll); + procedure ClearCache; + + function DeleteCookies(const url : ustring = ''; const cookieName : ustring = ''; aDeleteImmediately : boolean = False) : boolean; + function VisitAllCookies(aID : integer = 0) : boolean; + function VisitURLCookies(const url : ustring; includeHttpOnly : boolean = False; aID : integer = 0) : boolean; + function SetCookie(const url, name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; same_site : TCefCookieSameSite; priority : TCefCookiePriority; aSetImmediately : boolean = True; aID : integer = 0): Boolean; + function FlushCookieStore(aFlushImmediately : boolean = True) : boolean; + procedure UpdateSupportedSchemes(const aSchemes : TStrings; aIncludeDefaults : boolean = True); + + procedure ShowDevTools(const inspectElementAt: TPoint; aWindowInfo: PCefWindowInfo); + procedure CloseDevTools; overload; + procedure CloseDevTools(const aDevToolsWnd : TCefWindowHandle); overload; + function SendDevToolsMessage(const message_: ustring): boolean; + function ExecuteDevToolsMethod(message_id: integer; const method: ustring; const params: ICefDictionaryValue): Integer; + function AddDevToolsMessageObserver(const observer: ICefDevToolsMessageObserver): ICefRegistration; + + procedure Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); + procedure StopFinding(aClearSelection : Boolean); + + procedure Print; + procedure PrintToPDF(const aFilePath, aTitle, aURL : ustring); + + procedure ClipboardCopy; + procedure ClipboardPaste; + procedure ClipboardCut; + procedure ClipboardUndo; + procedure ClipboardRedo; + procedure ClipboardDel; + procedure SelectAll; + + procedure IncZoomStep; + procedure DecZoomStep; + procedure IncZoomPct; + procedure DecZoomPct; + procedure ResetZoomStep; + procedure ResetZoomLevel; + procedure ResetZoomPct; + procedure ReadZoom; + + procedure WasResized; + procedure WasHidden(hidden: Boolean); + procedure NotifyScreenInfoChanged; + procedure NotifyMoveOrResizeStarted; + procedure Invalidate(type_: TCefPaintElementType = PET_VIEW); + procedure SendExternalBeginFrame; + procedure SendKeyEvent(const event: PCefKeyEvent); + procedure SendMouseClickEvent(const event: PCefMouseEvent; type_: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); + procedure SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); + procedure SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); + procedure SendTouchEvent(const event: PCefTouchEvent); + procedure SendFocusEvent(setFocus: Boolean); + procedure SendCaptureLostEvent; + + procedure SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage; const aFrameName : ustring = ''); overload; + procedure SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage; const aFrame : ICefFrame); overload; + procedure SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage; const aFrameIdentifier : int64); overload; + + function CreateUrlRequest(const request: ICefRequest; const client: ICefUrlrequestClient; const aFrameName : ustring = ''): ICefUrlRequest; overload; + function CreateUrlRequest(const request: ICefRequest; const client: ICefUrlrequestClient; const aFrame : ICefFrame): ICefUrlRequest; overload; + function CreateUrlRequest(const request: ICefRequest; const client: ICefUrlrequestClient; const aFrameIdentifier : int64): ICefUrlRequest; overload; + + procedure SetFocus(focus: Boolean); + procedure SetAccessibilityState(accessibilityState: TCefState); + + procedure DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); + procedure DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); + procedure DragTargetDragLeave; + procedure DragTargetDrop(const event: PCefMouseEvent); + procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); + procedure DragSourceSystemDragEnded; + + procedure IMESetComposition(const text: ustring; const underlines : TCefCompositionUnderlineDynArray; const replacement_range, selection_range : PCefRange); + procedure IMECommitText(const text: ustring; const replacement_range : PCefRange; relative_cursor_pos : integer); + procedure IMEFinishComposingText(keep_selection : boolean); + procedure IMECancelComposition; + + procedure ReplaceMisspelling(const aWord : ustring); + procedure AddWordToDictionary(const aWord : ustring); + + {$IFDEF LINUX} + procedure UpdateBrowserSize(aLeft, aTop, aWidth, aHeight : integer); + procedure UpdateXWindowVisibility(aVisible : boolean); + {$ENDIF} + + // ICefMediaRouter methods + function AddObserver(const observer: ICefMediaObserver): ICefRegistration; + function GetSource(const urn: ustring): ICefMediaSource; + procedure NotifyCurrentSinks; + procedure NotifyCurrentRoutes; + procedure CreateRoute(const source: ICefMediaSource; const sink: ICefMediaSink); + procedure GetDeviceInfo(const aMediaSink: ICefMediaSink); + + // ICefRequestContext methods for extensions + function LoadExtension(const root_directory: ustring; const manifest: ICefDictionaryValue = nil; const handler: ICefExtensionHandler = nil; const requestContext : ICefRequestContext = nil) : boolean; + function DidLoadExtension(const extension_id: ustring): boolean; + function HasExtension(const extension_id: ustring): boolean; + function GetExtensions(const extension_ids: TStringList): boolean; + function GetExtension(const extension_id: ustring): ICefExtension; + + property DefaultUrl : ustring read FDefaultUrl write FDefaultUrl; + property Options : TChromiumOptions read FOptions write FOptions; + property FontOptions : TChromiumFontOptions read FFontOptions write FFontOptions; + property PDFPrintOptions : TPDFPrintOptions read FPDFPrintOptions write FPDFPrintOptions; + property DefaultEncoding : ustring read FDefaultEncoding write FDefaultEncoding; + property BrowserId : integer read GetBrowserId; + property Browser : ICefBrowser read GetBrowser; + property BrowserById[id : integer] : ICefBrowser read GetBrowserById; + property BrowserCount : integer read GetBrowserCount; + property BrowserIdByIndex[i : integer] : integer read GetBrowserIdByIndex; + property CefClient : ICefClient read FHandler; + property ReqContextHandler : ICefRequestContextHandler read FReqContextHandler; + property ResourceRequestHandler : ICefResourceRequestHandler read FResourceRequestHandler; + property CefWindowInfo : TCefWindowInfo read FWindowInfo; + property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; + property RequestContext : ICefRequestContext read GetRequestContext; + property MediaRouter : ICefMediaRouter read GetMediaRouter; + property MediaObserver : ICefMediaObserver read FMediaObserver; + property MediaObserverReg : ICefRegistration read FMediaObserverReg; + property DevToolsMsgObserver : ICefDevToolsMessageObserver read FDevToolsMsgObserver; + property DevToolsMsgObserverReg : ICefRegistration read FDevToolsMsgObserverReg; + property ExtensionHandler : ICefExtensionHandler read FExtensionHandler; + property MultithreadApp : boolean read GetMultithreadApp; + property IsLoading : boolean read GetIsLoading; + property HasDocument : boolean read GetHasDocument; + property HasView : boolean read GetHasView; + property HasDevTools : boolean read GetHasDevTools; + property HasClientHandler : boolean read GetHasClientHandler; + property HasBrowser : boolean read GetHasBrowser; + property CanGoBack : boolean read GetCanGoBack; + property CanGoForward : boolean read GetCanGoForward; + property IsPopUp : boolean read GetIsPopUp; + property WindowHandle : TCefWindowHandle read GetWindowHandle; + property OpenerWindowHandle : TCefWindowHandle read GetOpenerWindowHandle; + {$IFDEF MSWINDOWS} + property BrowserHandle : THandle read FBrowserCompHWND; + property WidgetHandle : THandle read FWidgetCompHWND; + property RenderHandle : THandle read FRenderCompHWND; + {$ENDIF} + property FrameIsFocused : boolean read GetFrameIsFocused; + property Initialized : boolean read GetInitialized; + property RequestContextCache : ustring read GetRequestContextCache; + property RequestContextIsGlobal : boolean read GetRequestContextIsGlobal; + property DocumentURL : ustring read GetDocumentURL; + property ZoomLevel : double read GetZoomLevel write SetZoomLevel; + property ZoomPct : double read GetZoomPct write SetZoomPct; + property ZoomStep : byte read GetZoomStep write SetZoomStep; + property WindowlessFrameRate : integer read GetWindowlessFrameRate write SetWindowlessFrameRate; + property CustomHeaderName : ustring read FCustomHeaderName write SetCustomHeaderName; + property CustomHeaderValue : ustring read FCustomHeaderValue write SetCustomHeaderValue; + property DoNotTrack : boolean read FDoNotTrack write SetDoNotTrack; + property SendReferrer : boolean read FSendReferrer write SetSendReferrer; + property HyperlinkAuditing : boolean read FHyperlinkAuditing write SetHyperlinkAuditing; + property AllowOutdatedPlugins : boolean read FAllowOutdatedPlugins write SetAllowOutdatedPlugins; + property AlwaysAuthorizePlugins : boolean read FAlwaysAuthorizePlugins write SetAlwaysAuthorizePlugins; + property SpellChecking : boolean read FSpellChecking write SetSpellChecking; + property SpellCheckerDicts : ustring read FSpellCheckerDicts write SetSpellCheckerDicts; + property HasValidMainFrame : boolean read GetHasValidMainFrame; + property FrameCount : NativeUInt read GetFrameCount; + property DragOperations : TCefDragOperations read FDragOperations write FDragOperations; + property AudioMuted : boolean read GetAudioMuted write SetAudioMuted; + property SafeSearch : boolean read FSafeSearch write SetSafeSearch; + property YouTubeRestrict : integer read FYouTubeRestrict write SetYouTubeRestrict; + property PrintingEnabled : boolean read FPrintingEnabled write SetPrintingEnabled; + property AcceptLanguageList : ustring read FAcceptLanguageList write SetAcceptLanguageList; + property AcceptCookies : TCefCookiePref read FAcceptCookies write SetAcceptCookies; + property Block3rdPartyCookies : boolean read FBlock3rdPartyCookies write SetBlock3rdPartyCookies; + property MultiBrowserMode : boolean read FMultiBrowserMode write SetMultiBrowserMode; + property DefaultWindowInfoExStyle : DWORD read FDefaultWindowInfoExStyle write FDefaultWindowInfoExStyle; + property Offline : boolean read FOffline write SetOffline; + property NetworkPredictions : TCefNetworkPredictionOptions read FNetworkPredictions write SetNetworkPredictions; + property QuicAllowed : boolean read FQuicAllowed write SetQuicAllowed; + property JavascriptEnabled : boolean read FJavascriptEnabled write SetJavascriptEnabled; + property LoadImagesAutomatically : boolean read FLoadImagesAutomatically write SetLoadImagesAutomatically; + {$IFDEF LINUX} + property XDisplay : PXDisplay read GetXDisplay; + {$ENDIF} + + property WebRTCIPHandlingPolicy : TCefWebRTCHandlingPolicy read FWebRTCIPHandlingPolicy write SetWebRTCIPHandlingPolicy; + property WebRTCMultipleRoutes : TCefState read FWebRTCMultipleRoutes write SetWebRTCMultipleRoutes; + property WebRTCNonproxiedUDP : TCefState read FWebRTCNonProxiedUDP write SetWebRTCNonProxiedUDP; + + property ProxyType : integer read FProxyType write SetProxyType; + property ProxyScheme : TCefProxyScheme read FProxyScheme write SetProxyScheme; + property ProxyServer : ustring read FProxyServer write SetProxyServer; + property ProxyPort : integer read FProxyPort write SetProxyPort; + property ProxyUsername : ustring read FProxyUsername write SetProxyUsername; + property ProxyPassword : ustring read FProxyPassword write SetProxyPassword; + property ProxyScriptURL : ustring read FProxyScriptURL write SetProxyScriptURL; + property ProxyByPassList : ustring read FProxyByPassList write SetProxyByPassList; + property MaxConnectionsPerProxy : integer read FMaxConnectionsPerProxy write SetMaxConnectionsPerProxy; + + published + property OnTextResultAvailable : TOnTextResultAvailableEvent read FOnTextResultAvailable write FOnTextResultAvailable; + property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished; + property OnPrefsAvailable : TOnPrefsAvailableEvent read FOnPrefsAvailable write FOnPrefsAvailable; + property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted; + property OnResolvedHostAvailable : TOnResolvedIPsAvailableEvent read FOnResolvedHostAvailable write FOnResolvedHostAvailable; + property OnNavigationVisitorResultAvailable : TOnNavigationVisitorResultAvailableEvent read FOnNavigationVisitorResultAvailable write FOnNavigationVisitorResultAvailable; + property OnDownloadImageFinished : TOnDownloadImageFinishedEvent read FOnDownloadImageFinished write FOnDownloadImageFinished; + property OnCookiesFlushed : TNotifyEvent read FOnCookiesFlushed write FOnCookiesFlushed; + property OnCertificateExceptionsCleared : TNotifyEvent read FOnCertificateExceptionsCleared write FOnCertificateExceptionsCleared; + property OnHttpAuthCredentialsCleared : TNotifyEvent read FOnHttpAuthCredentialsCleared write FOnHttpAuthCredentialsCleared; + property OnAllConnectionsClosed : TNotifyEvent read FOnAllConnectionsClosed write FOnAllConnectionsClosed; + property OnExecuteTaskOnCefThread : TOnExecuteTaskOnCefThread read FOnExecuteTaskOnCefThread write FOnExecuteTaskOnCefThread; + property OnCookiesVisited : TOnCookiesVisited read FOnCookiesVisited write FOnCookiesVisited; + property OnCookieVisitorDestroyed : TOnCookieVisitorDestroyed read FOnCookieVisitorDestroyed write FOnCookieVisitorDestroyed; + property OnCookieSet : TOnCookieSet read FOnCookieSet write FOnCookieSet; + property OnZoomPctAvailable : TOnZoomPctAvailable read FOnZoomPctAvailable write FOnZoomPctAvailable; + property OnMediaRouteCreateFinished : TOnMediaRouteCreateFinishedEvent read FOnMediaRouteCreateFinished write FOnMediaRouteCreateFinished; + property OnMediaSinkDeviceInfo : TOnMediaSinkDeviceInfoEvent read FOnMediaSinkDeviceInfo write FOnMediaSinkDeviceInfo; + {$IFDEF MSWINDOWS} + property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg; + property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg; + property OnRenderCompMsg : TOnCompMsgEvent read FOnRenderCompMsg write FOnRenderCompMsg; + {$ENDIF} + + // ICefClient + property OnProcessMessageReceived : TOnProcessMessageReceived read FOnProcessMessageReceived write FOnProcessMessageReceived; + + // ICefLoadHandler + property OnLoadStart : TOnLoadStart read FOnLoadStart write FOnLoadStart; + property OnLoadEnd : TOnLoadEnd read FOnLoadEnd write FOnLoadEnd; + property OnLoadError : TOnLoadError read FOnLoadError write FOnLoadError; + property OnLoadingStateChange : TOnLoadingStateChange read FOnLoadingStateChange write FOnLoadingStateChange; + + // ICefFocusHandler + property OnTakeFocus : TOnTakeFocus read FOnTakeFocus write FOnTakeFocus; + property OnSetFocus : TOnSetFocus read FOnSetFocus write FOnSetFocus; + property OnGotFocus : TOnGotFocus read FOnGotFocus write FOnGotFocus; + + // ICefContextMenuHandler + property OnBeforeContextMenu : TOnBeforeContextMenu read FOnBeforeContextMenu write FOnBeforeContextMenu; + property OnRunContextMenu : TOnRunContextMenu read FOnRunContextMenu write FOnRunContextMenu; + property OnContextMenuCommand : TOnContextMenuCommand read FOnContextMenuCommand write FOnContextMenuCommand; + property OnContextMenuDismissed : TOnContextMenuDismissed read FOnContextMenuDismissed write FOnContextMenuDismissed; + + // ICefKeyboardHandler + property OnPreKeyEvent : TOnPreKeyEvent read FOnPreKeyEvent write FOnPreKeyEvent; + property OnKeyEvent : TOnKeyEvent read FOnKeyEvent write FOnKeyEvent; + + // ICefDisplayHandler + property OnAddressChange : TOnAddressChange read FOnAddressChange write FOnAddressChange; + property OnTitleChange : TOnTitleChange read FOnTitleChange write FOnTitleChange; + property OnFavIconUrlChange : TOnFavIconUrlChange read FOnFavIconUrlChange write FOnFavIconUrlChange; + property OnFullScreenModeChange : TOnFullScreenModeChange read FOnFullScreenModeChange write FOnFullScreenModeChange; + property OnTooltip : TOnTooltip read FOnTooltip write FOnTooltip; + property OnStatusMessage : TOnStatusMessage read FOnStatusMessage write FOnStatusMessage; + property OnConsoleMessage : TOnConsoleMessage read FOnConsoleMessage write FOnConsoleMessage; + property OnAutoResize : TOnAutoResize read FOnAutoResize write FOnAutoResize; + property OnLoadingProgressChange : TOnLoadingProgressChange read FOnLoadingProgressChange write FOnLoadingProgressChange; + property OnCursorChange : TOnCursorChange read FOnCursorChange write FOnCursorChange; + + // ICefDownloadHandler + property OnBeforeDownload : TOnBeforeDownload read FOnBeforeDownload write FOnBeforeDownload; + property OnDownloadUpdated : TOnDownloadUpdated read FOnDownloadUpdated write FOnDownloadUpdated; + + // ICefJsDialogHandler + property OnJsdialog : TOnJsdialog read FOnJsdialog write FOnJsdialog; + property OnBeforeUnloadDialog : TOnBeforeUnloadDialog read FOnBeforeUnloadDialog write FOnBeforeUnloadDialog; + property OnResetDialogState : TOnResetDialogState read FOnResetDialogState write FOnResetDialogState; + property OnDialogClosed : TOnDialogClosed read FOnDialogClosed write FOnDialogClosed; + + // ICefLifeSpanHandler + property OnBeforePopup : TOnBeforePopup read FOnBeforePopup write FOnBeforePopup; + property OnAfterCreated : TOnAfterCreated read FOnAfterCreated write FOnAfterCreated; + property OnBeforeClose : TOnBeforeClose read FOnBeforeClose write FOnBeforeClose; + property OnClose : TOnClose read FOnClose write FOnClose; + + // ICefRequestHandler + property OnBeforeBrowse : TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse; + property OnOpenUrlFromTab : TOnOpenUrlFromTab read FOnOpenUrlFromTab write FOnOpenUrlFromTab; + property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials; + property OnQuotaRequest : TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest; + property OnCertificateError : TOnCertificateError read FOnCertificateError write FOnCertificateError; + property OnSelectClientCertificate : TOnSelectClientCertificate read FOnSelectClientCertificate write FOnSelectClientCertificate; + property OnPluginCrashed : TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed; + property OnRenderViewReady : TOnRenderViewReady read FOnRenderViewReady write FOnRenderViewReady; + property OnRenderProcessTerminated : TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated; + property OnGetResourceRequestHandler_ReqHdlr : TOnGetResourceRequestHandler read FOnGetResourceRequestHandler_ReqHdlr write FOnGetResourceRequestHandler_ReqHdlr; + property OnDocumentAvailableInMainFrame : TOnDocumentAvailableInMainFrame read FOnDocumentAvailableInMainFrame write FOnDocumentAvailableInMainFrame; + + // ICefResourceRequestHandler + property OnBeforeResourceLoad : TOnBeforeResourceLoad read FOnBeforeResourceLoad write FOnBeforeResourceLoad; + property OnGetResourceHandler : TOnGetResourceHandler read FOnGetResourceHandler write FOnGetResourceHandler; + property OnResourceRedirect : TOnResourceRedirect read FOnResourceRedirect write FOnResourceRedirect; + property OnResourceResponse : TOnResourceResponse read FOnResourceResponse write FOnResourceResponse; + property OnGetResourceResponseFilter : TOnGetResourceResponseFilter read FOnGetResourceResponseFilter write FOnGetResourceResponseFilter; + property OnResourceLoadComplete : TOnResourceLoadComplete read FOnResourceLoadComplete write FOnResourceLoadComplete; + property OnProtocolExecution : TOnProtocolExecution read FOnProtocolExecution write FOnProtocolExecution; + + // ICefCookieAccessFilter + property OnCanSendCookie : TOnCanSendCookie read FOnCanSendCookie write FOnCanSendCookie; + property OnCanSaveCookie : TOnCanSaveCookie read FOnCanSaveCookie write FOnCanSaveCookie; + + // ICefDialogHandler + property OnFileDialog : TOnFileDialog read FOnFileDialog write FOnFileDialog; + + // ICefRenderHandler + property OnGetAccessibilityHandler : TOnGetAccessibilityHandler read FOnGetAccessibilityHandler write FOnGetAccessibilityHandler; + 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 OnAcceleratedPaint : TOnAcceleratedPaint read FOnAcceleratedPaint write FOnAcceleratedPaint; + property OnStartDragging : TOnStartDragging read FOnStartDragging write FOnStartDragging; + property OnUpdateDragCursor : TOnUpdateDragCursor read FOnUpdateDragCursor write FOnUpdateDragCursor; + property OnScrollOffsetChanged : TOnScrollOffsetChanged read FOnScrollOffsetChanged write FOnScrollOffsetChanged; + property OnIMECompositionRangeChanged : TOnIMECompositionRangeChanged read FOnIMECompositionRangeChanged write FOnIMECompositionRangeChanged; + property OnTextSelectionChanged : TOnTextSelectionChanged read FOnTextSelectionChanged write FOnTextSelectionChanged; + property OnVirtualKeyboardRequested : TOnVirtualKeyboardRequested read FOnVirtualKeyboardRequested write FOnVirtualKeyboardRequested; + + // ICefDragHandler + property OnDragEnter : TOnDragEnter read FOnDragEnter write FOnDragEnter; + property OnDraggableRegionsChanged : TOnDraggableRegionsChanged read FOnDraggableRegionsChanged write FOnDraggableRegionsChanged; + + // ICefFindHandler + property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult; + + // ICefRequestContextHandler + property OnRequestContextInitialized : TOnRequestContextInitialized read FOnRequestContextInitialized write SetOnRequestContextInitialized; + property OnBeforePluginLoad : TOnBeforePluginLoad read FOnBeforePluginLoad write SetOnBeforePluginLoad; + property OnGetResourceRequestHandler_ReqCtxHdlr : TOnGetResourceRequestHandler read FOnGetResourceRequestHandler_ReqCtxHdlr write FOnGetResourceRequestHandler_ReqCtxHdlr; + + // ICefMediaObserver + property OnSinks : TOnSinksEvent read FOnSinks write FOnSinks; + property OnRoutes : TOnRoutesEvent read FOnRoutes write FOnRoutes; + property OnRouteStateChanged : TOnRouteStateChangedEvent read FOnRouteStateChanged write FOnRouteStateChanged; + property OnRouteMessageReceived : TOnRouteMessageReceivedEvent read FOnRouteMessageReceived write FOnRouteMessageReceived; + + // ICefAudioHandler + property OnGetAudioParameters : TOnGetAudioParametersEvent read FOnGetAudioParameters write FOnGetAudioParameters; + property OnAudioStreamStarted : TOnAudioStreamStartedEvent read FOnAudioStreamStarted write FOnAudioStreamStarted; + property OnAudioStreamPacket : TOnAudioStreamPacketEvent read FOnAudioStreamPacket write FOnAudioStreamPacket; + property OnAudioStreamStopped : TOnAudioStreamStoppedEvent read FOnAudioStreamStopped write FOnAudioStreamStopped; + property OnAudioStreamError : TOnAudioStreamErrorEvent read FOnAudioStreamError write FOnAudioStreamError; + + // ICefDevToolsMessageObserver + property OnDevToolsMessage : TOnDevToolsMessageEvent read FOnDevToolsMessage write FOnDevToolsMessage; + property OnDevToolsRawMessage : TOnDevToolsRawMessageEvent read FOnDevToolsRawMessage write FOnDevToolsRawMessage; + property OnDevToolsMethodResult : TOnDevToolsMethodResultEvent read FOnDevToolsMethodResult write FOnDevToolsMethodResult; + property OnDevToolsMethodRawResult : TOnDevToolsMethodRawResultEvent read FOnDevToolsMethodRawResult write FOnDevToolsMethodRawResult; + property OnDevToolsEvent : TOnDevToolsEventEvent read FOnDevToolsEvent write FOnDevToolsEvent; + property OnDevToolsRawEvent : TOnDevToolsEventRawEvent read FOnDevToolsRawEvent write FOnDevToolsRawEvent; + property OnDevToolsAgentAttached : TOnDevToolsAgentAttachedEvent read FOnDevToolsAgentAttached write FOnDevToolsAgentAttached; + property OnDevToolsAgentDetached : TOnDevToolsAgentDetachedEvent read FOnDevToolsAgentDetached write FOnDevToolsAgentDetached; + + // ICefExtensionHandler + property OnExtensionLoadFailed : TOnExtensionLoadFailedEvent read FOnExtensionLoadFailed write FOnExtensionLoadFailed; + property OnExtensionLoaded : TOnExtensionLoadedEvent read FOnExtensionLoaded write FOnExtensionLoaded; + property OnExtensionUnloaded : TOnExtensionUnloadedEvent read FOnExtensionUnloaded write FOnExtensionUnloaded; + property OnExtensionBeforeBackgroundBrowser : TOnBeforeBackgroundBrowserEvent read FOnExtensionBeforeBackgroundBrowser write FOnExtensionBeforeBackgroundBrowser; + property OnExtensionBeforeBrowser : TOnBeforeBrowserEvent read FOnExtensionBeforeBrowser write FOnExtensionBeforeBrowser; + property OnExtensionGetActiveBrowser : TOnGetActiveBrowserEvent read FOnExtensionGetActiveBrowser write FOnExtensionGetActiveBrowser; + property OnExtensionCanAccessBrowser : TOnCanAccessBrowserEvent read FOnExtensionCanAccessBrowser write FOnExtensionCanAccessBrowser; + property OnExtensionGetExtensionResource : TOnGetExtensionResourceEvent read FOnExtensionGetExtensionResource write FOnExtensionGetExtensionResource; + end; + + TBrowserInfo = class + protected + FBrowser : ICefBrowser; + FIsClosing : boolean; + FID : integer; + + public + constructor Create(const aBrowser : ICefBrowser); reintroduce; + destructor Destroy; override; + + property Browser : ICefBrowser read FBrowser; + property ID : integer read FID; + property IsClosing : boolean read FIsClosing write FIsClosing; + end; + + TBrowserInfoList = class(TList) + protected + procedure SetBrowserIsClosing(aID : integer; aValue : boolean); + + function GetBrowserIsClosing(aID : integer) : boolean; + function GetBrowser(aID : integer) : ICefBrowser; + function GetFirstBrowser : ICefBrowser; + function GetFirstID : integer; + + public + destructor Destroy; override; + function AddBrowser(const aBrowser : ICefBrowser) : boolean; + function RemoveBrowser(const aBrowser : ICefBrowser) : boolean; + function SearchBrowser(aID : integer) : integer; + procedure FreeAndClearAllItems; + procedure CloseAllBrowsers; + + property BrowserIsClosing[aID : integer] : boolean read GetBrowserIsClosing write SetBrowserIsClosing; + property Browser[aID : integer] : ICefBrowser read GetBrowser; + property FirstBrowser : ICefBrowser read GetFirstBrowser; + property FirstID : integer read GetFirstID; + end; + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, System.Math, + {$ELSE} + SysUtils, Math, {$IFDEF FPC}{$IFDEF LINUX}x, xatom, gdk2x, gtk2,{$ENDIF}{$ENDIF} + {$ENDIF} + uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame, + uCEFApplicationCore, uCEFProcessMessage, uCEFRequestContext, + {$IFDEF MSWINDOWS}uCEFOLEDragAndDrop,{$ENDIF} + uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, + uCEFStringVisitor, uCEFListValue, uCEFNavigationEntryVisitor, + uCEFDownloadImageCallBack, uCEFCookieManager, uCEFRequestContextHandler, + uCEFCookieVisitor, uCEFSetCookieCallback, uCEFResourceRequestHandler, + uCEFMediaObserver, uCEFMediaRouteCreateCallback ,uCEFDevToolsMessageObserver, + uCEFMediaSinkDeviceInfoCallback, uCEFJson, uCEFExtensionHandler; + +constructor TChromiumCore.Create(AOwner: TComponent); +begin + FBrowsersCS := nil; + FBrowsers := nil; + FBrowserId := 0; + FMultiBrowserMode := False; + {$IFDEF MSWINDOWS} + FCompHandle := 0; + {$ENDIF} + FIsOSR := False; + FDefaultUrl := 'about:blank'; + FHandler := nil; + FReqContextHandler := nil; + FResourceRequestHandler := nil; + FMediaObserver := nil; + FMediaObserverReg := nil; + FDevToolsMsgObserver := nil; + FDevToolsMsgObserverReg := nil; + FExtensionHandler := nil; + FOptions := nil; + FFontOptions := nil; + FDefaultEncoding := ''; + FPDFPrintOptions := nil; + FUpdatePreferences := False; + FCustomHeaderName := ''; + FCustomHeaderValue := ''; + FPrefsFileName := ''; + FAddCustomHeader := False; + FDoNotTrack := True; + FSendReferrer := True; + FAllowOutdatedPlugins := False; + FAlwaysAuthorizePlugins := False; + FSpellChecking := True; + FSpellCheckerDicts := ''; + FZoomStep := ZOOM_STEP_DEF; + FZoomStepCS := nil; + FSafeSearch := False; + FYouTubeRestrict := YOUTUBE_RESTRICT_OFF; + FPrintingEnabled := True; + FAcceptLanguageList := ''; + FAcceptCookies := cpAllow; + FBlock3rdPartyCookies := False; + FOffline := False; + FNetworkPredictions := CEF_NETWORK_PREDICTION_WIFI_ONLY; + FQuicAllowed := True; + FJavascriptEnabled := True; + FLoadImagesAutomatically := True; + {$IFDEF LINUX} + FXDisplay := nil; + {$ENDIF} + + if (GlobalCEFApp <> nil) then + FHyperlinkAuditing := GlobalCEFApp.HyperlinkAuditing + else + FHyperlinkAuditing := True; + + // + // Some focus issues in CEF seem to be fixed when you use WS_EX_NOACTIVATE in + // FDefaultWindowInfoExStyle to initialize the browser with that ExStyle but + // it may cause side effects. Read these links for more information : + // https://www.briskbard.com/forum/viewtopic.php?f=10&t=723 + // https://bitbucket.org/chromiumembedded/cef/issues/1856/branch-2526-cef-activates-browser-window + // + // It's necessary to set this property before the CreateBrowser call. + // + FDefaultWindowInfoExStyle := 0; + //FDefaultWindowInfoExStyle := WS_EX_NOACTIVATE; + + {$IFDEF MSWINDOWS} + FOldBrowserCompWndPrc := nil; + FOldWidgetCompWndPrc := nil; + FOldRenderCompWndPrc := nil; + FBrowserCompStub := nil; + FWidgetCompStub := nil; + FRenderCompStub := nil; + FBrowserCompHWND := 0; + FWidgetCompHWND := 0; + FRenderCompHWND := 0; + {$ENDIF MSWINDOWS} + + FDragOperations := DRAG_OPERATION_NONE; + {$IFDEF MSWINDOWS} + FDragDropManager := nil; + FDropTargetWnd := 0; + {$ENDIF MSWINDOWS} + FDragAndDropInitialized := False; + + FWebRTCIPHandlingPolicy := hpDefault; + FWebRTCMultipleRoutes := STATE_DEFAULT; + FWebRTCNonProxiedUDP := STATE_DEFAULT; + + FProxyType := CEF_PROXYTYPE_SYSTEM; + FProxyScheme := psHTTP; + FProxyServer := ''; + FProxyPort := 80; + FProxyUsername := ''; + FProxyPassword := ''; + FProxyScriptURL := ''; + FProxyByPassList := ''; + FMaxConnectionsPerProxy := CEF_MAX_CONNECTIONS_PER_PROXY_DEFAULT_VALUE; + + FillChar(FWindowInfo, SizeOf(TCefWindowInfo), 0); + FillChar(FDevWindowInfo, SizeOf(TCefWindowInfo), 0); + + InitializeSettings(FBrowserSettings); + InitializeSettings(FDevBrowserSettings); + + InitializeEvents; + + inherited Create(AOwner); +end; + +destructor TChromiumCore.Destroy; +begin + try + try + {$IFDEF MSWINDOWS} + RestoreOldCompWndProc; + DestroyAllHandlersAndObservers; + + if (FDragDropManager <> nil) then FreeAndNil(FDragDropManager); + + if (FCompHandle <> 0) then + begin + DeallocateHWnd(FCompHandle); + FCompHandle := 0; + end; + {$ENDIF MSWINDOWS} + + DestroyAllBrowsers; + + if (FFontOptions <> nil) then FreeAndNil(FFontOptions); + if (FOptions <> nil) then FreeAndNil(FOptions); + if (FPDFPrintOptions <> nil) then FreeAndNil(FPDFPrintOptions); + if (FZoomStepCS <> nil) then FreeAndNil(FZoomStepCS); + if (FBrowsersCS <> nil) then FreeAndNil(FBrowsersCS); + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.Destroy', e) then raise; + end; + finally + inherited Destroy; + end; +end; + +procedure TChromiumCore.DestroyAllBrowsers; +begin + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + if (FBrowsers <> nil) then FreeAndNil(FBrowsers); + finally + FBrowsersCS.Release; + end; +end; + +{$IFDEF MSWINDOWS} +{$IFNDEF FPC} +// Windows XP and newer (older Delphi version < XE don't have them and newer +// require a call to InitCommonControl what isn't necessary. +{type + SUBCLASSPROC = function(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM; + uIdSubclass: UINT_PTR; dwRefData: DWORD_PTR): LRESULT; stdcall; + TSubClassProc = SUBCLASSPROC; + +function SetWindowSubclass(hWnd: HWND; pfnSubclass: SUBCLASSPROC; uIdSubclass: UINT_PTR; dwRefData: DWORD_PTR): BOOL; stdcall; + external comctl32 name 'SetWindowSubclass'; +//function GetWindowSubclass(hWnd: HWND; pfnSubclass: SUBCLASSPROC; uIdSubclass: UINT_PTR; var pdwRefData: DWORD_PTR): BOOL; stdcall; +// external comctl32 name 'GetWindowSubclass'; +function RemoveWindowSubclass(hWnd: HWND; pfnSubclass: SUBCLASSPROC; uIdSubclass: UINT_PTR): BOOL; stdcall; + external comctl32 name 'RemoveWindowSubclass'; +function DefSubclassProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; + external comctl32 name 'DefSubclassProc'; + +// We stick with the original implementation because the WndProc stub is a lot +// faster than the WindowSubClass stub that uses the slow GetProp(hWnd). Which +// is extremly slow in Windows 10 1809 and newer. +} + +procedure TChromiumCore.CreateStub(const aMethod : TWndMethod; var aStub : Pointer); +begin + if (aStub = nil) then aStub := MakeObjectInstance(aMethod); +end; + +procedure TChromiumCore.FreeAndNilStub(var aStub : pointer); +begin + if (aStub <> nil) then + begin + FreeObjectInstance(aStub); + aStub := nil; + end; +end; + +function TChromiumCore.InstallCompWndProc(aWnd: THandle; aStub: Pointer): TFNWndProc; +begin + Result := TFNWndProc(SetWindowLongPtr(aWnd, GWLP_WNDPROC, NativeInt(aStub))); +end; + +procedure TChromiumCore.RestoreCompWndProc(var aOldWnd: THandle; aNewWnd: THandle; var aProc: TFNWndProc); +begin + if (aOldWnd <> 0) and (aOldWnd <> aNewWnd) and (aProc <> nil) then + begin + SetWindowLongPtr(aOldWnd, GWLP_WNDPROC, NativeInt(aProc)); + aProc := nil; + aOldWnd := 0; + end; +end; + +procedure TChromiumCore.CallOldCompWndProc(aProc: TFNWndProc; aWnd: THandle; var aMessage: TMessage); +begin + if (aProc <> nil) and (aWnd <> 0) then + aMessage.Result := CallWindowProc(aProc, aWnd, aMessage.Msg, aMessage.wParam, aMessage.lParam); +end; + +{$ELSE} + +procedure TChromiumCore.CreateStub(const aMethod : TWndMethod; var aStub : Pointer); +begin + if (aStub = nil) then + begin + GetMem(aStub, SizeOf(TWndMethod)); + TWndMethod(aStub^) := aMethod; + end; +end; + +procedure TChromiumCore.FreeAndNilStub(var aStub : pointer); +begin + if (aStub <> nil) then + begin + FreeMem(aStub); + aStub := nil; + end; +end; + +function CompSubClassProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM; + uIdSubclass: UINT_PTR; dwRefData: DWORD_PTR): LRESULT; stdcall; +var + m: TWndMethod; + Msg: TMessage; +begin + Msg.msg := uMsg; + Msg.wParam := wparam; + Msg.lParam := lParam; + Msg.Result := 0; + + m := TWndMethod(Pointer(dwRefData)^); + m(Msg); + Result := Msg.Result; +end; + +function TChromiumCore.InstallCompWndProc(aWnd: THandle; aStub: Pointer): TFNWndProc; +begin + Result := nil; + if (aWnd <> 0) and (aStub <> nil) then + begin + SetWindowSubclass(aWnd, @CompSubClassProc, 1, NativeInt(aStub)); + Result := TFNWndProc(1); // IdSubClass + end; +end; + +procedure TChromiumCore.RestoreCompWndProc(var aOldWnd: THandle; aNewWnd: THandle; var aProc: TFNWndProc); +begin + if (aOldWnd <> 0) and (aOldWnd <> aNewWnd) and (aProc <> nil) then + begin + RemoveWindowSubclass(aOldWnd, @CompSubClassProc, 1); + aProc := nil; + aOldWnd := 0; + end; +end; + +procedure TChromiumCore.CallOldCompWndProc(aProc: TFNWndProc; aWnd: THandle; var aMessage: TMessage); +begin + if (aProc <> nil) and (aWnd <> 0) then + aMessage.Result := DefSubclassProc(aWnd, aMessage.Msg, aMessage.wParam, aMessage.lParam); +end; +{$ENDIF} +{$ENDIF} + +procedure TChromiumCore.DestroyClientHandler; +begin + try + if (FHandler <> nil) then + begin + FHandler.RemoveReferences; + FHandler := nil; + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.DestroyClientHandler', e) then raise; + end; +end; + +procedure TChromiumCore.DestroyReqContextHandler; +begin + try + if (FReqContextHandler <> nil) then + begin + FReqContextHandler.RemoveReferences; + FReqContextHandler := nil; + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.DestroyReqContextHandler', e) then raise; + end; +end; + +procedure TChromiumCore.DestroyResourceRequestHandler; +begin + try + if (FResourceRequestHandler <> nil) then + begin + FResourceRequestHandler.RemoveReferences; + FResourceRequestHandler := nil; + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.DestroyResourceRequestHandler', e) then raise; + end; +end; + +procedure TChromiumCore.DestroyMediaObserver; +begin + FMediaObserverReg := nil; + FMediaObserver := nil; +end; + +procedure TChromiumCore.DestroyDevToolsMsgObserver; +begin + FDevToolsMsgObserverReg := nil; + FDevToolsMsgObserver := nil; +end; + +procedure TChromiumCore.DestroyExtensionHandler; +begin + try + if (FExtensionHandler <> nil) then + begin + FExtensionHandler.RemoveReferences; + FExtensionHandler := nil; + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.DestroyExtensionHandler', e) then raise; + end; +end; + +procedure TChromiumCore.DestroyAllHandlersAndObservers; +begin + DestroyExtensionHandler; + DestroyDevToolsMsgObserver; + DestroyMediaObserver; + DestroyResourceRequestHandler; + DestroyReqContextHandler; + DestroyClientHandler; +end; + +procedure TChromiumCore.CreateReqContextHandler; +begin + if MustCreateRequestContextHandler and + (FReqContextHandler = nil) then + FReqContextHandler := TCustomRequestContextHandler.Create(self); +end; + +procedure TChromiumCore.CreateMediaObserver; +begin + if MustCreateMediaObserver and + (FMediaObserver = nil) then + FMediaObserver := TCustomMediaObserver.Create(self); +end; + +procedure TChromiumCore.CreateDevToolsMsgObserver; +begin + if MustCreateDevToolsMessageObserver and + (FDevToolsMsgObserver = nil) then + FDevToolsMsgObserver := TCustomDevToolsMessageObserver.Create(self); +end; + +procedure TChromiumCore.CreateExtensionHandler; +begin + if MustCreateExtensionHandler and + (FExtensionHandler = nil) then + FExtensionHandler := TCustomExtensionHandler.Create(self); +end; + +procedure TChromiumCore.CreateResourceRequestHandler; +begin + if MustCreateResourceRequestHandler and + (FResourceRequestHandler = nil) then + FResourceRequestHandler := TCustomResourceRequestHandler.Create(self); +end; + +procedure TChromiumCore.AfterConstruction; +begin + inherited AfterConstruction; + + try + if not(csDesigning in ComponentState) then + begin + {$IFDEF MSWINDOWS} + FCompHandle := AllocateHWnd({$IFDEF FPC}@{$ENDIF}WndProc); + {$ENDIF} + FBrowsers := TBrowserInfoList.Create; + FOptions := TChromiumOptions.Create; + FFontOptions := TChromiumFontOptions.Create; + FPDFPrintOptions := TPDFPrintOptions.Create; + FZoomStepCS := TCriticalSection.Create; + FBrowsersCS := TCriticalSection.Create; + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.AfterConstruction', e) then raise; + end; +end; + +function TChromiumCore.CreateClientHandler(aIsOSR : boolean) : boolean; +begin + Result := False; + + try + if (FHandler = nil) then + begin + FIsOSR := aIsOsr; + FHandler := TCustomClientHandler.Create(Self); + Result := True; + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.CreateClientHandler', e) then raise; + end; +end; + +function TChromiumCore.CreateClientHandler(var aClient : ICefClient; aIsOSR : boolean) : boolean; +begin + if CreateClientHandler(aIsOSR) then + begin + CreateResourceRequestHandler; + CreateMediaObserver; + CreateDevToolsMsgObserver; + CreateExtensionHandler; + + aClient := FHandler; + Result := True; + end + else + Result := False; +end; + +procedure TChromiumCore.InitializeEvents; +begin + // ICefClient + FOnProcessMessageReceived := nil; + + // ICefLoadHandler + FOnLoadStart := nil; + FOnLoadEnd := nil; + FOnLoadError := nil; + FOnLoadingStateChange := nil; + + // ICefFocusHandler + FOnTakeFocus := nil; + FOnSetFocus := nil; + FOnGotFocus := nil; + + // ICefContextMenuHandler + FOnBeforeContextMenu := nil; + FOnRunContextMenu := nil; + FOnContextMenuCommand := nil; + FOnContextMenuDismissed := nil; + + // ICefKeyboardHandler + FOnPreKeyEvent := nil; + FOnKeyEvent := nil; + + // ICefDisplayHandler + FOnAddressChange := nil; + FOnTitleChange := nil; + FOnFavIconUrlChange := nil; + FOnFullScreenModeChange := nil; + FOnTooltip := nil; + FOnStatusMessage := nil; + FOnConsoleMessage := nil; + FOnAutoResize := nil; + FOnLoadingProgressChange := nil; + FOnCursorChange := nil; + + // ICefDownloadHandler + FOnBeforeDownload := nil; + FOnDownloadUpdated := nil; + + // ICefJsDialogHandler + FOnJsdialog := nil; + FOnBeforeUnloadDialog := nil; + FOnResetDialogState := nil; + FOnDialogClosed := nil; + + // ICefLifeSpanHandler + FOnBeforePopup := nil; + FOnAfterCreated := nil; + FOnBeforeClose := nil; + FOnClose := nil; + + // ICefRequestHandler + FOnBeforeBrowse := nil; + FOnOpenUrlFromTab := nil; + FOnGetAuthCredentials := nil; + FOnQuotaRequest := nil; + FOnCertificateError := nil; + FOnSelectClientCertificate := nil; + FOnPluginCrashed := nil; + FOnRenderViewReady := nil; + FOnRenderProcessTerminated := nil; + FOnGetResourceRequestHandler_ReqHdlr := nil; + FOnDocumentAvailableInMainFrame := nil; + + // ICefResourceRequestHandler + FOnBeforeResourceLoad := nil; + FOnGetResourceHandler := nil; + FOnResourceRedirect := nil; + FOnResourceResponse := nil; + FOnGetResourceResponseFilter := nil; + FOnResourceLoadComplete := nil; + FOnProtocolExecution := nil; + + // ICefCookieAccessFilter + FOnCanSendCookie := nil; + FOnCanSaveCookie := nil; + + // ICefDialogHandler + FOnFileDialog := nil; + + // ICefRenderHandler + FOnGetAccessibilityHandler := nil; + FOnGetRootScreenRect := nil; + FOnGetViewRect := nil; + FOnGetScreenPoint := nil; + FOnGetScreenInfo := nil; + FOnPopupShow := nil; + FOnPopupSize := nil; + FOnPaint := nil; + FOnAcceleratedPaint := nil; + FOnStartDragging := nil; + FOnUpdateDragCursor := nil; + FOnScrollOffsetChanged := nil; + FOnIMECompositionRangeChanged := nil; + FOnTextSelectionChanged := nil; + FOnVirtualKeyboardRequested := nil; + + // ICefDragHandler + FOnDragEnter := nil; + FOnDraggableRegionsChanged := nil; + + // ICefFindHandler + FOnFindResult := nil; + + // ICefRequestContextHandler + FOnRequestContextInitialized := nil; + FOnBeforePluginLoad := nil; + FOnGetResourceRequestHandler_ReqCtxHdlr := nil; + + // ICefMediaObserver + FOnSinks := nil; + FOnRoutes := nil; + FOnRouteStateChanged := nil; + FOnRouteMessageReceived := nil; + + // ICefAudioHandler + FOnGetAudioParameters := nil; + FOnAudioStreamStarted := nil; + FOnAudioStreamPacket := nil; + FOnAudioStreamStopped := nil; + FOnAudioStreamError := nil; + + // ICefDevToolsMessageObserver + FOnDevToolsMessage := nil; + FOnDevToolsRawMessage := nil; + FOnDevToolsMethodResult := nil; + FOnDevToolsMethodRawResult := nil; + FOnDevToolsEvent := nil; + FOnDevToolsRawEvent := nil; + FOnDevToolsAgentAttached := nil; + FOnDevToolsAgentDetached := nil; + + // ICefExtensionHandler + FOnExtensionLoadFailed := nil; + FOnExtensionLoaded := nil; + FOnExtensionUnloaded := nil; + FOnExtensionBeforeBackgroundBrowser := nil; + FOnExtensionBeforeBrowser := nil; + FOnExtensionGetActiveBrowser := nil; + FOnExtensionCanAccessBrowser := nil; + FOnExtensionGetExtensionResource := nil; + + // Custom + FOnTextResultAvailable := nil; + FOnPdfPrintFinished := nil; + FOnPrefsAvailable := nil; + FOnCookiesDeleted := nil; + FOnResolvedHostAvailable := nil; + FOnNavigationVisitorResultAvailable := nil; + FOnDownloadImageFinished := nil; + FOnCookiesFlushed := nil; + FOnCertificateExceptionsCleared := nil; + FOnHttpAuthCredentialsCleared := nil; + FOnAllConnectionsClosed := nil; + FOnExecuteTaskOnCefThread := nil; + FOnCookiesVisited := nil; + FOnCookieVisitorDestroyed := nil; + FOnCookieSet := nil; + FOnZoomPctAvailable := nil; + FOnMediaRouteCreateFinished := nil; + FOnMediaSinkDeviceInfo := nil; + + {$IFDEF MSWINDOWS} + FOnBrowserCompMsg := nil; + FOnWidgetCompMsg := nil; + FOnRenderCompMsg := nil; + {$ENDIF} +end; + +function TChromiumCore.CreateBrowser( aParentHandle : TCefWindowHandle; + aParentRect : TRect; + const aWindowName : ustring; + const aContext : ICefRequestContext; + const aExtraInfo : ICefDictionaryValue) : boolean; +var + TempNewContext, TempGlobalContext : ICefRequestContext; +begin + Result := False; + TempNewContext := nil; + + try + try + // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser + // even if you use a custom request context. + // If you create a browser in the initialization of your app, make sure you call this + // function when GlobalCEFApp.GlobalContextInitialized is TRUE. + // Use the GlobalCEFApp.OnContextInitialized event to know when + // GlobalCEFApp.GlobalContextInitialized is set to TRUE. + + if not(csDesigning in ComponentState) and + (BrowserId = 0) and + (GlobalCEFApp <> nil) and + GlobalCEFApp.GlobalContextInitialized and + CreateClientHandler(not(ValidCefWindowHandle(aParentHandle))) then + begin + GetSettings(FBrowserSettings); + InitializeWindowInfo(aParentHandle, aParentRect, aWindowName); + CreateResourceRequestHandler; + CreateMediaObserver; + CreateDevToolsMsgObserver; + CreateExtensionHandler; + + if (aContext = nil) then + begin + CreateReqContextHandler; + + if (FReqContextHandler <> nil) then + begin + TempGlobalContext := TCefRequestContextRef.Global(); + TempNewContext := TCefRequestContextRef.Shared(TempGlobalContext, FReqContextHandler); + end; + end + else + TempNewContext := aContext; + + if GlobalCEFApp.MultiThreadedMessageLoop then + Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, TempNewContext) + else + Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aExtraInfo, TempNewContext); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.CreateBrowser', e) then raise; + end; + finally + TempGlobalContext := nil; + TempNewContext := nil; + end; +end; + +function TChromiumCore.CreateBrowser(const aURL : ustring; + const aBrowserViewComp : TCEFBrowserViewComponent; + const aContext : ICefRequestContext; + const aExtraInfo : ICefDictionaryValue) : boolean; +var + TempNewContext, TempGlobalContext : ICefRequestContext; +begin + Result := False; + + try + try + // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser + // even if you use a custom request context. + // If you create a browser in the initialization of your app, make sure you call this + // function when GlobalCEFApp.GlobalContextInitialized is TRUE. + // Use the GlobalCEFApp.OnContextInitialized event to know when + // GlobalCEFApp.GlobalContextInitialized is set to TRUE. + + if not(csDesigning in ComponentState) and + (BrowserId = 0) and + (aBrowserViewComp <> nil) and + (GlobalCEFApp <> nil) and + GlobalCEFApp.GlobalContextInitialized and + CreateClientHandler(False) then + begin + GetSettings(FBrowserSettings); + CreateResourceRequestHandler; + CreateMediaObserver; + CreateDevToolsMsgObserver; + CreateExtensionHandler; + + if (aContext = nil) then + begin + CreateReqContextHandler; + + if (FReqContextHandler <> nil) then + begin + TempGlobalContext := TCefRequestContextRef.Global(); + TempNewContext := TCefRequestContextRef.Shared(TempGlobalContext, FReqContextHandler); + end; + end + else + TempNewContext := aContext; + + Result := aBrowserViewComp.CreateBrowserView(FHandler, aURL, FBrowserSettings, aExtraInfo, TempNewContext); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.CreateBrowser', e) then raise; + end; + finally + TempGlobalContext := nil; + TempNewContext := nil; + end; +end; + +procedure TChromiumCore.CreateBrowser(const aWindowName : ustring); +var + TempHandle : TCefWindowHandle; +begin + try + // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser + // even if you use a custom request context. + // If you create a browser in the initialization of your app, make sure you call this + // function when GlobalCEFApp.GlobalContextInitialized is TRUE. + // Use the GlobalCEFApp.OnContextInitialized event to know when + // GlobalCEFApp.GlobalContextInitialized is set to TRUE. + if (BrowserId = 0) and + (GlobalCEFApp <> nil) and + GlobalCEFApp.GlobalContextInitialized and + CreateClientHandler(False) then + begin + GetSettings(FBrowserSettings); + InitializeWindowHandle(TempHandle); + WindowInfoAsPopUp(FWindowInfo, TempHandle, aWindowName); + CreateResourceRequestHandler; + CreateMediaObserver; + CreateDevToolsMsgObserver; + CreateExtensionHandler; + CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, nil, nil); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.CreateBrowser', e) then raise; + end; +end; + +procedure TChromiumCore.InitializeWindowInfo( aParentHandle : TCefWindowHandle; + aParentRect : TRect; + const aWindowName : ustring); +begin + {$IFDEF MSWINDOWS} + if FIsOSR then + WindowInfoAsWindowless(FWindowInfo, ParentFormHandle, aWindowName) + else + WindowInfoAsChild(FWindowInfo, aParentHandle, aParentRect, aWindowName, FDefaultWindowInfoExStyle); + {$ELSE} + if FIsOSR then + WindowInfoAsWindowless(FWindowInfo, aParentHandle) + else + WindowInfoAsChild(FWindowInfo, aParentHandle, aParentRect); + {$ENDIF} +end; + +procedure TChromiumCore.DefaultInitializeDevToolsWindowInfo( aDevToolsWnd : TCefWindowHandle; + const aClientRect : TRect; + const aWindowName : ustring); +begin + if (ValidCefWindowHandle(aDevToolsWnd)) then + {$IFDEF MSWINDOWS} + WindowInfoAsChild(FDevWindowInfo, aDevToolsWnd, aClientRect, aWindowName) + else + WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME); + {$ELSE} + WindowInfoAsChild(FDevWindowInfo, aDevToolsWnd, aClientRect) + else + // WindowInfoAsPopUp only exists for Windows. The Linux version of cefclient + // calls WindowInfoAsChild with aParent set to NULL to create a popup window. + WindowInfoAsPopUp(FDevWindowInfo, aDevToolsWnd); + {$ENDIF} +end; + +function TChromiumCore.ShareRequestContext(var aContext : ICefRequestContext; + const aHandler : ICefRequestContextHandler) : boolean; +begin + Result := False; + aContext := nil; + + if Initialized then + begin + aContext := TCefRequestContextRef.Shared(Browser.Host.RequestContext, aHandler); + Result := (aContext <> nil); + end; +end; + +{$IFDEF MSWINDOWS} +procedure TChromiumCore.InitializeDragAndDrop(const aDropTargetWnd : HWND); +var + TempDropTarget : IDropTarget; +begin + if FIsOSR and + not(FDragAndDropInitialized) and + (FDragDropManager = nil) and + (aDropTargetWnd <> 0) then + begin + FDropTargetWnd := aDropTargetWnd; + + FDragDropManager := TCEFDragAndDropMgr.Create; + FDragDropManager.OnDragEnter := {$IFDEF FPC}@{$ENDIF}DragDropManager_OnDragEnter; + FDragDropManager.OnDragOver := {$IFDEF FPC}@{$ENDIF}DragDropManager_OnDragOver; + FDragDropManager.OnDragLeave := {$IFDEF FPC}@{$ENDIF}DragDropManager_OnDragLeave; + FDragDropManager.OnDrop := {$IFDEF FPC}@{$ENDIF}DragDropManager_OnDrop; + + TempDropTarget := TOLEDropTarget.Create(FDragDropManager); + + RegisterDragDrop(FDropTargetWnd, TempDropTarget); + + FDragAndDropInitialized := True; + end; +end; + +procedure TChromiumCore.ShutdownDragAndDrop; +begin + if FDragAndDropInitialized and (FDropTargetWnd <> 0) then + begin + RevokeDragDrop(FDropTargetWnd); + FDragAndDropInitialized := False; + end; +end; + +procedure TChromiumCore.ToMouseEvent(grfKeyState : Longint; pt : TPoint; var aMouseEvent : TCefMouseEvent); +begin + if (FDropTargetWnd <> 0) then + begin + MapWindowPoints(0, FDropTargetWnd, pt, 1); + aMouseEvent.x := pt.x; + aMouseEvent.y := pt.y; + aMouseEvent.modifiers := GetCefMouseModifiers(grfKeyState); + end; +end; +{$ENDIF} + +procedure TChromiumCore.DragDropManager_OnDragEnter(Sender: TObject; const aDragData : ICefDragData; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); +{$IFDEF MSWINDOWS} +var + TempMouseEvent : TCefMouseEvent; + TempAllowedOps : TCefDragOperations; +{$ENDIF} +begin + if (GlobalCEFApp <> nil) then + begin + {$IFDEF MSWINDOWS} + ToMouseEvent(grfKeyState, pt, TempMouseEvent); + DropEffectToDragOperation(dwEffect, TempAllowedOps); + DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor); + + DragTargetDragEnter(aDragData, @TempMouseEvent, TempAllowedOps); + DragTargetDragOver(@TempMouseEvent, TempAllowedOps); + + DragOperationToDropEffect(FDragOperations, dwEffect); + {$ENDIF} + end; +end; + +procedure TChromiumCore.DragDropManager_OnDragOver(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); +{$IFDEF MSWINDOWS} +var + TempMouseEvent : TCefMouseEvent; + TempAllowedOps : TCefDragOperations; +{$ENDIF} +begin + if (GlobalCEFApp <> nil) then + begin + {$IFDEF MSWINDOWS} + ToMouseEvent(grfKeyState, pt, TempMouseEvent); + DropEffectToDragOperation(dwEffect, TempAllowedOps); + DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor); + + DragTargetDragOver(@TempMouseEvent, TempAllowedOps); + + DragOperationToDropEffect(FDragOperations, dwEffect); + {$ENDIF} + end; +end; + +procedure TChromiumCore.DragDropManager_OnDragLeave(Sender: TObject); +begin + DragTargetDragLeave; +end; + +procedure TChromiumCore.DragDropManager_OnDrop(Sender: TObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint); +{$IFDEF MSWINDOWS} +var + TempMouseEvent : TCefMouseEvent; + TempAllowedOps : TCefDragOperations; +{$ENDIF} +begin + if (GlobalCEFApp <> nil) then + begin + {$IFDEF MSWINDOWS} + ToMouseEvent(grfKeyState, pt, TempMouseEvent); + DropEffectToDragOperation(dwEffect, TempAllowedOps); + DeviceToLogical(TempMouseEvent, GlobalCEFApp.DeviceScaleFactor); + + DragTargetDragOver(@TempMouseEvent, TempAllowedOps); + DragTargetDrop(@TempMouseEvent); + + DragOperationToDropEffect(FDragOperations, dwEffect); + {$ENDIF} + end; +end; + +procedure TChromiumCore.CloseBrowser(aForceClose : boolean); +begin + if Initialized then + Browser.Host.CloseBrowser(aForceClose); +end; + +procedure TChromiumCore.CloseAllBrowsers; +begin + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + if (FBrowsers <> nil) then FBrowsers.CloseAllBrowsers; + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.TryCloseBrowser : boolean; +begin + if Initialized then + Result := Browser.Host.TryCloseBrowser + else + Result := True; +end; + +function TChromiumCore.CreateBrowserHost( aWindowInfo : PCefWindowInfo; + const aURL : ustring; + const aSettings : PCefBrowserSettings; + const aExtraInfo : ICefDictionaryValue; + const aContext : ICefRequestContext): boolean; +var + TempURL : TCefString; +begin + TempURL := CefString(aURL); + Result := cef_browser_host_create_browser(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aExtraInfo), CefGetData(aContext)) <> 0; +end; + +function TChromiumCore.CreateBrowserHostSync( aWindowInfo : PCefWindowInfo; + const aURL : ustring; + const aSettings : PCefBrowserSettings; + const aExtraInfo : ICefDictionaryValue; + const aContext : ICefRequestContext): boolean; +var + TempURL : TCefString; + TempBrowser : ICefBrowser; +begin + TempURL := CefString(aURL); + TempBrowser := TCefBrowserRef.UnWrap(cef_browser_host_create_browser_sync(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aExtraInfo), CefGetData(aContext))); + Result := AddBrowser(TempBrowser); +end; + +procedure TChromiumCore.Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); +begin + if Initialized then + Browser.Host.Find(aIdentifier, aSearchText, aForward, aMatchCase, aFindNext); +end; + +procedure TChromiumCore.StopFinding(aClearSelection : Boolean); +begin + if Initialized then + Browser.Host.StopFinding(aClearSelection); +end; + +procedure TChromiumCore.Print; +begin + if Initialized then + Browser.Host.Print; +end; + +procedure TChromiumCore.PrintToPDF(const aFilePath, aTitle, aURL : ustring); +var + TempSettings : TCefPdfPrintSettings; + TempCallback : ICefPdfPrintCallback; +begin + if Initialized then + begin + GetPrintPDFSettings(TempSettings, aTitle, aURL); + TempCallback := TCefCustomPDFPrintCallBack.Create(self); + Browser.Host.PrintToPdf(aFilePath, @TempSettings, TempCallback); + end; +end; + +procedure TChromiumCore.ClipboardCopy; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := Browser.FocusedFrame; + if (TempFrame = nil) then TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.Copy; + end; +end; + +procedure TChromiumCore.ClipboardPaste; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := Browser.FocusedFrame; + if (TempFrame = nil) then TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.Paste; + end; +end; + +procedure TChromiumCore.ClipboardCut; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := Browser.FocusedFrame; + if (TempFrame = nil) then TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.Cut; + end; +end; + +procedure TChromiumCore.ClipboardUndo; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := Browser.FocusedFrame; + if (TempFrame = nil) then TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.Undo; + end; +end; + +procedure TChromiumCore.ClipboardRedo; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := Browser.FocusedFrame; + if (TempFrame = nil) then TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.Redo; + end; +end; + +procedure TChromiumCore.ClipboardDel; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := Browser.FocusedFrame; + if (TempFrame = nil) then TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.Del; + end; +end; + +procedure TChromiumCore.SelectAll; +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := Browser.FocusedFrame; + if (TempFrame = nil) then TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.SelectAll; + end; +end; + +procedure TChromiumCore.GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : ustring); +begin + if (FPDFPrintOptions <> nil) then + begin + aSettings.header_footer_title := CefString(aTitle); + aSettings.header_footer_url := CefString(aURL); + aSettings.page_width := FPDFPrintOptions.page_width; + aSettings.page_height := FPDFPrintOptions.page_height; + aSettings.scale_factor := FPDFPrintOptions.scale_factor; + aSettings.margin_top := FPDFPrintOptions.margin_top; + aSettings.margin_right := FPDFPrintOptions.margin_right; + aSettings.margin_bottom := FPDFPrintOptions.margin_bottom; + aSettings.margin_left := FPDFPrintOptions.margin_left; + aSettings.margin_type := FPDFPrintOptions.margin_type; + aSettings.header_footer_enabled := Ord(FPDFPrintOptions.header_footer_enabled); + aSettings.selection_only := Ord(FPDFPrintOptions.selection_only); + aSettings.landscape := Ord(FPDFPrintOptions.landscape); + aSettings.backgrounds_enabled := Ord(FPDFPrintOptions.backgrounds_enabled); + end; +end; + +procedure TChromiumCore.GetSettings(var aSettings : TCefBrowserSettings); +begin + if (FFontOptions <> nil) and (FOptions <> nil) then + begin + aSettings.size := SizeOf(TCefBrowserSettings); + aSettings.windowless_frame_rate := FOptions.WindowlessFrameRate; + aSettings.standard_font_family := CefString(FFontOptions.StandardFontFamily); + aSettings.fixed_font_family := CefString(FFontOptions.FixedFontFamily); + aSettings.serif_font_family := CefString(FFontOptions.SerifFontFamily); + aSettings.sans_serif_font_family := CefString(FFontOptions.SansSerifFontFamily); + aSettings.cursive_font_family := CefString(FFontOptions.CursiveFontFamily); + aSettings.fantasy_font_family := CefString(FFontOptions.FantasyFontFamily); + aSettings.default_font_size := FFontOptions.DefaultFontSize; + aSettings.default_fixed_font_size := FFontOptions.DefaultFixedFontSize; + aSettings.minimum_font_size := FFontOptions.MinimumFontSize; + aSettings.minimum_logical_font_size := FFontOptions.MinimumLogicalFontSize; + aSettings.remote_fonts := FFontOptions.RemoteFonts; + aSettings.default_encoding := CefString(DefaultEncoding); + aSettings.javascript := FOptions.Javascript; + aSettings.javascript_close_windows := FOptions.JavascriptCloseWindows; + aSettings.javascript_access_clipboard := FOptions.JavascriptAccessClipboard; + aSettings.javascript_dom_paste := FOptions.JavascriptDomPaste; + aSettings.plugins := FOptions.Plugins; + aSettings.universal_access_from_file_urls := FOptions.UniversalAccessFromFileUrls; + aSettings.file_access_from_file_urls := FOptions.FileAccessFromFileUrls; + aSettings.web_security := FOptions.WebSecurity; + aSettings.image_loading := FOptions.ImageLoading; + aSettings.image_shrink_standalone_to_fit := FOptions.ImageShrinkStandaloneToFit; + aSettings.text_area_resize := FOptions.TextAreaResize; + aSettings.tab_to_links := FOptions.TabToLinks; + aSettings.local_storage := FOptions.LocalStorage; + aSettings.databases := FOptions.Databases; + aSettings.application_cache := FOptions.ApplicationCache; + aSettings.webgl := FOptions.Webgl; + aSettings.background_color := FOptions.BackgroundColor; + aSettings.accept_language_list := CefString(FOptions.AcceptLanguageList); + end; +end; + +procedure TChromiumCore.InitializeSettings(var aSettings : TCefBrowserSettings); +begin + aSettings.size := SizeOf(TCefBrowserSettings); + aSettings.windowless_frame_rate := 30; + aSettings.standard_font_family := CefString(''); + aSettings.fixed_font_family := CefString(''); + aSettings.serif_font_family := CefString(''); + aSettings.sans_serif_font_family := CefString(''); + aSettings.cursive_font_family := CefString(''); + aSettings.fantasy_font_family := CefString(''); + aSettings.default_font_size := 0; + aSettings.default_fixed_font_size := 0; + aSettings.minimum_font_size := 0; + aSettings.minimum_logical_font_size := 0; + aSettings.remote_fonts := STATE_DEFAULT; + aSettings.default_encoding := CefString(''); + aSettings.javascript := STATE_DEFAULT; + aSettings.javascript_close_windows := STATE_DEFAULT; + aSettings.javascript_access_clipboard := STATE_DEFAULT; + aSettings.javascript_dom_paste := STATE_DEFAULT; + aSettings.plugins := STATE_DEFAULT; + aSettings.universal_access_from_file_urls := STATE_DEFAULT; + aSettings.file_access_from_file_urls := STATE_DEFAULT; + aSettings.web_security := STATE_DEFAULT; + aSettings.image_loading := STATE_DEFAULT; + aSettings.image_shrink_standalone_to_fit := STATE_DEFAULT; + aSettings.text_area_resize := STATE_DEFAULT; + aSettings.tab_to_links := STATE_DEFAULT; + aSettings.local_storage := STATE_DEFAULT; + aSettings.databases := STATE_DEFAULT; + aSettings.application_cache := STATE_DEFAULT; + aSettings.webgl := STATE_DEFAULT; + aSettings.background_color := 0; + aSettings.accept_language_list := CefString(''); +end; + +// Leave aFrameName empty to load the URL in the main frame +procedure TChromiumCore.LoadURL(const aURL : ustring; const aFrameName : ustring); +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + if (length(aFrameName) > 0) then + TempFrame := Browser.GetFrame(aFrameName) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.LoadUrl(aURL); + end; +end; + +procedure TChromiumCore.LoadURL(const aURL : ustring; const aFrame : ICefFrame); +begin + if Initialized and (aFrame <> nil) and aFrame.IsValid then + aFrame.LoadUrl(aURL); +end; + +procedure TChromiumCore.LoadURL(const aURL : ustring; const aFrameIdentifier : int64); +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + if (aFrameIdentifier <> 0) then + TempFrame := Browser.GetFrameByident(aFrameIdentifier) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.LoadUrl(aURL); + end; +end; + +// Leave aFrameName empty to load the URL in the main frame +procedure TChromiumCore.LoadString(const aHTML : ustring; const aFrameName : ustring); +var + TempFrame : ICefFrame; +begin + if Initialized and (length(aHTML) > 0) then + begin + if (length(aFrameName) > 0) then + TempFrame := Browser.GetFrame(aFrameName) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + TempFrame.LoadUrl(CefGetDataURI(aHTML, 'text/html')); + end; +end; + +procedure TChromiumCore.LoadString(const aHTML : ustring; const aFrame : ICefFrame); +begin + if Initialized and (length(aHTML) > 0) and (aFrame <> nil) and aFrame.IsValid then + aFrame.LoadUrl(CefGetDataURI(aHTML, 'text/html')); +end; + +procedure TChromiumCore.LoadString(const aHTML : ustring; const aFrameIdentifier : int64); +var + TempFrame : ICefFrame; +begin + if Initialized and (length(aHTML) > 0) then + begin + if (aFrameIdentifier <> 0) then + TempFrame := Browser.GetFrameByident(aFrameIdentifier) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + TempFrame.LoadUrl(CefGetDataURI(aHTML, 'text/html')); + end; +end; + +// Leave aFrameName empty to load the URL in the main frame +procedure TChromiumCore.LoadResource(const aStream : TCustomMemoryStream; const aMimeType, aCharset : string; const aFrameName : ustring); +var + TempFrame : ICefFrame; +begin + if Initialized and (aStream <> nil) and (aStream.Size > 0) then + begin + if (length(aFrameName) > 0) then + TempFrame := Browser.GetFrame(aFrameName) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + TempFrame.LoadUrl(CefGetDataURI(aStream.Memory, aStream.Size, aMimeType, aCharset)); + end; +end; + +procedure TChromiumCore.LoadResource(const aStream : TCustomMemoryStream; const aMimeType, aCharset : string; const aFrame : ICefFrame); +begin + if Initialized and (aStream <> nil) and (aStream.Size > 0) and (aFrame <> nil) and aFrame.IsValid then + aFrame.LoadUrl(CefGetDataURI(aStream.Memory, aStream.Size, aMimeType, aCharset)); +end; + +procedure TChromiumCore.LoadResource(const aStream : TCustomMemoryStream; const aMimeType, aCharset : string; const aFrameIdentifier : int64); +var + TempFrame : ICefFrame; +begin + if Initialized and (aStream <> nil) and (aStream.Size > 0) then + begin + if (aFrameIdentifier <> 0) then + TempFrame := Browser.GetFrameByident(aFrameIdentifier) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + TempFrame.LoadUrl(CefGetDataURI(aStream.Memory, aStream.Size, aMimeType, aCharset)); + end; +end; + +// WARNING: This function will fail with "bad IPC message" reason +// INVALID_INITIATOR_ORIGIN (213) unless you first navigate to the request +// origin using some other mechanism (LoadURL, link click, etc). +procedure TChromiumCore.LoadRequest(const aRequest: ICefRequest); +var + TempFrame : ICefFrame; +begin + if Initialized then + begin + TempFrame := Browser.MainFrame; + if (TempFrame <> nil) and TempFrame.IsValid then TempFrame.LoadRequest(aRequest); + end; +end; + +function TChromiumCore.ExecuteBrowserNavigationTask(aTask : TCefBrowserNavigation) : boolean; +var + TempTask : ICefTask; +begin + Result := False; + + try + if Initialized then + begin + TempTask := TCefBrowserNavigationTask.Create(self, aTask); + Result := CefPostTask(TID_UI, TempTask); + end; + finally + TempTask := nil; + end; +end; + +procedure TChromiumCore.GoBack; +begin + ExecuteBrowserNavigationTask(bnBack); +end; + +procedure TChromiumCore.GoForward; +begin + ExecuteBrowserNavigationTask(bnForward); +end; + +procedure TChromiumCore.Reload; +begin + ExecuteBrowserNavigationTask(bnReload); +end; + +procedure TChromiumCore.ReloadIgnoreCache; +begin + ExecuteBrowserNavigationTask(bnReloadIgnoreCache); +end; + +procedure TChromiumCore.StopLoad; +begin + ExecuteBrowserNavigationTask(bnStopLoad); +end; + +procedure TChromiumCore.StartDownload(const aURL : ustring); +begin + if Initialized then + Browser.Host.StartDownload(aURL); +end; + +// Use the OnDownloadImageFinished event to receive the image +procedure TChromiumCore.DownloadImage(const imageUrl : ustring; + isFavicon : boolean; + maxImageSize : cardinal; + bypassCache : boolean); +var + TempCallback : ICefDownloadImageCallback; +begin + try + if Initialized then + begin + TempCallback := TCefCustomDownloadImageCallback.Create(self); + Browser.Host.DownloadImage(imageUrl, isFavicon, maxImageSize, bypassCache, TempCallback); + end; + finally + TempCallback := nil; + end; +end; + +function TChromiumCore.GetIsLoading : boolean; +begin + Result := Initialized and Browser.IsLoading; +end; + +function TChromiumCore.GetMultithreadApp : boolean; +begin + Result := (GlobalCEFApp <> nil) and GlobalCEFApp.MultiThreadedMessageLoop; +end; + +function TChromiumCore.GetHasDocument : boolean; +begin + Result := Initialized and Browser.HasDocument; +end; + +function TChromiumCore.GetHasView : boolean; +begin + Result := Initialized and Browser.Host.HasView; +end; + +function TChromiumCore.GetHasDevTools : boolean; +begin + Result := Initialized and Browser.Host.HasDevTools; +end; + +function TChromiumCore.GetHasClientHandler : boolean; +begin + Result := (FHandler <> nil); +end; + +function TChromiumCore.GetHasBrowser : boolean; +begin + Result := (Browser <> nil); +end; + +function TChromiumCore.GetWindowHandle : TCefWindowHandle; +begin + InitializeWindowHandle(Result); + + if Initialized then + Result := Browser.Host.WindowHandle; +end; + +function TChromiumCore.GetOpenerWindowHandle : TCefWindowHandle; +begin + InitializeWindowHandle(Result); + + if Initialized then + Result := Browser.Host.OpenerWindowHandle; +end; + +function TChromiumCore.GetFrameIsFocused : boolean; +begin + Result := Initialized and (Browser.FocusedFrame <> nil); +end; + +function TChromiumCore.GetWindowlessFrameRate : integer; +begin + if Initialized then + Result := Browser.Host.GetWindowlessFrameRate + else + Result := 0; +end; + +function TChromiumCore.GetVisibleNavigationEntry : ICefNavigationEntry; +begin + if Initialized then + Result := Browser.Host.VisibleNavigationEntry + else + Result := nil; +end; + +function TChromiumCore.GetBrowser : ICefBrowser; +begin + Result := nil; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + + if (FBrowsers <> nil) then + begin + if FMultiBrowserMode then + Result := FBrowsers.Browser[FBrowserId] + else + Result := FBrowsers.FirstBrowser; + end; + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.GetBrowserId : integer; +begin + Result := 0; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + Result := FBrowserId; + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.GetBrowserById(aID : integer) : ICefBrowser; +begin + Result := nil; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + if (FBrowsers <> nil) then + Result := FBrowsers.Browser[aID]; + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.GetBrowserCount : integer; +begin + Result := 0; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + if (FBrowsers <> nil) then + Result := FBrowsers.Count; + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.GetBrowserIdByIndex(aIndex : integer) : integer; +begin + Result := 0; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + if (FBrowsers <> nil) and (aIndex >= 0) and (aIndex < FBrowsers.Count) then + Result := TBrowserInfo(FBrowsers[aIndex]).ID; + finally + FBrowsersCS.Release; + end; +end; + +{$IFDEF LINUX} +function TChromiumCore.GetXDisplay : PXDisplay; +{$IFDEF FPC} +var + TempParent : TCefWindowHandle; +{$ENDIF} +begin + if (FXDisplay = nil) then + begin + {$IFDEF FPC} + TempParent := ParentFormHandle; + + if ValidCefWindowHandle(TempParent) and + (PGtkWidget(TempParent)^.Window <> nil) then + FXDisplay := GDK_WINDOW_XDISPLAY(PGtkWidget(TempParent)^.Window); + {$ENDIF} + + // GlobalCEFApp.XDisplay can only be called in the CEF UI thread. + if (FXDisplay = nil) and (GlobalCEFApp <> nil) then + FXDisplay := GlobalCEFApp.XDisplay; + end; + + Result := FXDisplay; +end; +{$ENDIF} + +function TChromiumCore.GetHasValidMainFrame : boolean; +begin + Result := Initialized and (Browser.MainFrame <> nil) and Browser.MainFrame.IsValid; +end; + +function TChromiumCore.GetFrameCount : NativeUInt; +begin + if Initialized then + Result := Browser.GetFrameCount + else + Result := 0; +end; + +function TChromiumCore.GetRequestContextCache : ustring; +begin + if Initialized then + Result := Browser.host.RequestContext.CachePath + else + if (GlobalCEFApp <> nil) then + Result := GlobalCEFApp.cache + else + Result := ''; +end; + +function TChromiumCore.GetRequestContextIsGlobal : boolean; +begin + Result := Initialized and Browser.host.RequestContext.IsGlobal; +end; + +function TChromiumCore.GetAudioMuted : boolean; +begin + Result := Initialized and Browser.host.IsAudioMuted; +end; + +function TChromiumCore.GetParentFormHandle : TCefWindowHandle; +begin + InitializeWindowHandle(Result); +end; + +procedure TChromiumCore.SetMultiBrowserMode(aValue : boolean); +begin + if not(Initialized) then FMultiBrowserMode := aValue; +end; + +procedure TChromiumCore.SetNetworkPredictions(aValue : TCefNetworkPredictionOptions); +begin + if (FNetworkPredictions <> aValue) then + begin + FNetworkPredictions := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetQuicAllowed(aValue : boolean); +begin + if (FQuicAllowed <> aValue) then + begin + FQuicAllowed := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetJavascriptEnabled(aValue : boolean); +begin + if (FJavascriptEnabled <> aValue) then + begin + FJavascriptEnabled := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetLoadImagesAutomatically(aValue : boolean); +begin + if (FLoadImagesAutomatically <> aValue) then + begin + FLoadImagesAutomatically := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetAudioMuted(aValue : boolean); +begin + if Initialized then + Browser.Host.SetAudioMuted(aValue); +end; + +procedure TChromiumCore.SetWindowlessFrameRate(aValue : integer); +begin + if Initialized then + Browser.Host.SetWindowlessFrameRate(aValue); +end; + +function TChromiumCore.GetCanGoBack : boolean; +begin + Result := Initialized and Browser.CanGoBack; +end; + +function TChromiumCore.GetCanGoForward : boolean; +begin + Result := Initialized and Browser.CanGoForward; +end; + +function TChromiumCore.GetIsPopUp : boolean; +begin + Result := Initialized and Browser.IsPopUp; +end; + +function TChromiumCore.GetInitialized : boolean; +begin + Result := False; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + Result := (FBrowserId <> 0) and (FBrowsers <> nil) and not(FBrowsers.BrowserIsClosing[FBrowserId]); + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.GetDocumentURL : ustring; +var + TempFrame : ICefFrame; +begin + Result := ''; + + if Initialized then + begin + TempFrame := Browser.MainFrame; + if (TempFrame <> nil) and TempFrame.IsValid then Result := TempFrame.URL; + end; +end; + +function TChromiumCore.GetZoomLevel : double; +begin + if Initialized then + Result := Browser.Host.ZoomLevel + else + Result := 0; +end; + +function TChromiumCore.GetZoomPct : double; +begin + Result := power(1.2, ZoomLevel) * 100; +end; + +function TChromiumCore.GetZoomStep : byte; +begin + Result := ZOOM_STEP_DEF; + + if (FZoomStepCS <> nil) then + try + FZoomStepCS.Acquire; + Result := FZoomStep; + finally + FZoomStepCS.Release; + end; +end; + +procedure TChromiumCore.SetZoomLevel(const aValue : double); +begin + if CefCurrentlyOn(TID_UI) then + doSetZoomLevel(aValue) + else + ExecuteSetZoomLevelTask(aValue); +end; + +procedure TChromiumCore.SetZoomPct(const aValue : double); +begin + if CefCurrentlyOn(TID_UI) then + doSetZoomPct(aValue) + else + ExecuteSetZoomPctTask(aValue); +end; + +procedure TChromiumCore.SetZoomStep(aValue : byte); +begin + if CefCurrentlyOn(TID_UI) then + doSetZoomStep(aValue) + else + ExecuteSetZoomStepTask(aValue); +end; + +// Increments the Zoom Step value and triggers the TChromium.OnZoomPctAvailable event with the new value +procedure TChromiumCore.IncZoomStep; +begin + if CefCurrentlyOn(TID_UI) then + doUpdateZoomStep(True) + else + ExecuteUpdateZoomStepTask(True); +end; + +// Decrements the Zoom Step value and triggers the TChromium.OnZoomPctAvailable event with the new value +procedure TChromiumCore.DecZoomStep; +begin + if CefCurrentlyOn(TID_UI) then + doUpdateZoomStep(False) + else + ExecuteUpdateZoomStepTask(False); +end; + +// Increments the Zoom Percent value and triggers the TChromium.OnZoomPctAvailable event with the new value +procedure TChromiumCore.IncZoomPct; +begin + if CefCurrentlyOn(TID_UI) then + doUpdateZoomPct(True) + else + ExecuteUpdateZoomPctTask(True); +end; + +// Decrements the Zoom Percent value and triggers the TChromium.OnZoomPctAvailable event with the new value +procedure TChromiumCore.DecZoomPct; +begin + if CefCurrentlyOn(TID_UI) then + doUpdateZoomPct(False) + else + ExecuteUpdateZoomPctTask(False); +end; + +// Sets the Zoom Step to the default value and triggers the TChromium.OnZoomPctAvailable event +procedure TChromiumCore.ResetZoomStep; +begin + ZoomStep := ZOOM_STEP_DEF; +end; + +// Sets the Zoom Level to the default value and triggers the TChromium.OnZoomPctAvailable event +procedure TChromiumCore.ResetZoomLevel; +begin + ZoomLevel := 0; +end; + +// Sets the Zoom Percent to the default value and triggers the TChromium.OnZoomPctAvailable event +procedure TChromiumCore.ResetZoomPct; +begin + ZoomPct := ZoomStepValues[ZOOM_STEP_DEF]; +end; + +// Triggers the TChromium.OnZoomPctAvailable event with the current Zoom Percent value +procedure TChromiumCore.ReadZoom; +begin + if CefCurrentlyOn(TID_UI) then + doReadZoom + else + ExecuteReadZoomTask; +end; + +function TChromiumCore.ExecuteUpdateZoomStepTask(aInc : boolean) : boolean; +var + TempTask : ICefTask; +begin + Result := False; + + try + if Initialized then + begin + TempTask := TCefUpdateZoomStepTask.Create(self, aInc); + Result := CefPostTask(TID_UI, TempTask); + end; + finally + TempTask := nil; + end; +end; + +function TChromiumCore.ExecuteUpdateZoomPctTask(aInc : boolean) : boolean; +var + TempTask : ICefTask; +begin + Result := False; + + try + if Initialized then + begin + TempTask := TCefUpdateZoomPctTask.Create(self, aInc); + Result := CefPostTask(TID_UI, TempTask); + end; + finally + TempTask := nil; + end; +end; + +function TChromiumCore.ExecuteReadZoomTask : boolean; +var + TempTask : ICefTask; +begin + Result := False; + + try + if Initialized then + begin + TempTask := TCefReadZoomTask.Create(self); + Result := CefPostTask(TID_UI, TempTask); + end; + finally + TempTask := nil; + end; +end; + +function TChromiumCore.ExecuteSetZoomPctTask(const aValue : double) : boolean; +var + TempTask : ICefTask; +begin + Result := False; + + try + if Initialized then + begin + TempTask := TCefSetZoomPctTask.Create(self, aValue); + Result := CefPostTask(TID_UI, TempTask); + end; + finally + TempTask := nil; + end; +end; + +function TChromiumCore.ExecuteSetZoomLevelTask(const aValue : double) : boolean; +var + TempTask : ICefTask; +begin + Result := False; + + try + if Initialized then + begin + TempTask := TCefSetZoomLevelTask.Create(self, aValue); + Result := CefPostTask(TID_UI, TempTask); + end; + finally + TempTask := nil; + end; +end; + +function TChromiumCore.ExecuteSetZoomStepTask(aValue : byte) : boolean; +var + TempTask : ICefTask; +begin + Result := False; + + try + if Initialized then + begin + TempTask := TCefSetZoomStepTask.Create(self, aValue); + Result := CefPostTask(TID_UI, TempTask); + end; + finally + TempTask := nil; + end; +end; + +procedure TChromiumCore.SetDoNotTrack(aValue : boolean); +begin + if (FDoNotTrack <> aValue) then + begin + FDoNotTrack := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetSendReferrer(aValue : boolean); +begin + if (FSendReferrer <> aValue) then + begin + FSendReferrer := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetHyperlinkAuditing(aValue : boolean); +begin + if (FHyperlinkAuditing <> aValue) then + begin + FHyperlinkAuditing := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetAllowOutdatedPlugins(aValue : boolean); +begin + if (FAllowOutdatedPlugins <> aValue) then + begin + FAllowOutdatedPlugins := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetAlwaysAuthorizePlugins(aValue : boolean); +begin + if (FAlwaysAuthorizePlugins <> aValue) then + begin + FAlwaysAuthorizePlugins := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetSpellChecking(aValue : boolean); +begin + if (FSpellChecking <> aValue) then + begin + FSpellChecking := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetSpellCheckerDicts(const aValue : ustring); +begin + if (FSpellCheckerDicts <> aValue) then + begin + FSpellCheckerDicts := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetSafeSearch(aValue : boolean); +begin + if (FSafeSearch <> aValue) then + begin + FSafeSearch := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetOffline(aValue : boolean); +var + TempParams : ICefDictionaryValue; +begin + if (FOffline <> aValue) then + try + FOffline := aValue; + + TempParams := TCefDictionaryValueRef.New; + TempParams.SetBool('offline', FOffline); + TempParams.SetDouble('latency', 0); + TempParams.SetDouble('downloadThroughput', 0); + TempParams.SetDouble('uploadThroughput', 0); + + ExecuteDevToolsMethod(0, 'Network.emulateNetworkConditions', TempParams); + finally + TempParams := nil; + end; +end; + +procedure TChromiumCore.SetUserAgentOverride(const aUserAgent, aAcceptLanguage, aPlatform : ustring); +var + TempParams : ICefDictionaryValue; +begin + try + TempParams := TCefDictionaryValueRef.New; + TempParams.SetString('userAgent', aUserAgent); + + if (length(aAcceptLanguage) > 0) then + TempParams.SetString('acceptLanguage', aAcceptLanguage); + + if (length(aPlatform) > 0) then + TempParams.SetString('platform', aPlatform); + + ExecuteDevToolsMethod(0, 'Emulation.setUserAgentOverride', TempParams); + finally + TempParams := nil; + end; +end; + +procedure TChromiumCore.ClearDataForOrigin(const aOrigin : ustring; aStorageTypes : TCefClearDataStorageTypes); +var + TempParams : ICefDictionaryValue; +begin + try + TempParams := TCefDictionaryValueRef.New; + TempParams.SetString('origin', aOrigin); + + case aStorageTypes of + cdstAppCache : TempParams.SetString('storageTypes', 'appcache'); + cdstCookies : TempParams.SetString('storageTypes', 'cookies'); + cdstFileSystems : TempParams.SetString('storageTypes', 'file_systems'); + cdstIndexeddb : TempParams.SetString('storageTypes', 'indexeddb'); + cdstLocalStorage : TempParams.SetString('storageTypes', 'local_storage'); + cdstShaderCache : TempParams.SetString('storageTypes', 'shader_cache'); + cdstWebsql : TempParams.SetString('storageTypes', 'websql'); + cdstServiceWorkers : TempParams.SetString('storageTypes', 'service_workers'); + cdstCacheStorage : TempParams.SetString('storageTypes', 'cache_storage'); + else TempParams.SetString('storageTypes', 'all'); + end; + + ExecuteDevToolsMethod(0, 'Storage.clearDataForOrigin', TempParams); + finally + TempParams := nil; + end; +end; + +procedure TChromiumCore.SetYouTubeRestrict(aValue : integer); +begin + if (FYouTubeRestrict <> aValue) then + begin + FYouTubeRestrict := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetPrintingEnabled(aValue : boolean); +begin + if (FPrintingEnabled <> aValue) then + begin + FPrintingEnabled := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetAcceptLanguageList(const aValue : ustring); +begin + if (FAcceptLanguageList <> aValue) then + begin + FAcceptLanguageList := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetAcceptCookies(const aValue : TCefCookiePref); +begin + if (FAcceptCookies <> aValue) then + begin + FAcceptCookies := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetBlock3rdPartyCookies(const aValue : boolean); +begin + if (FBlock3rdPartyCookies <> aValue) then + begin + FBlock3rdPartyCookies := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized); +begin + FOnRequestContextInitialized := aValue; + + CreateReqContextHandler; +end; + +procedure TChromiumCore.SetOnBeforePluginLoad(const aValue : TOnBeforePluginLoad); +begin + FOnBeforePluginLoad := aValue; + + CreateReqContextHandler; +end; + +procedure TChromiumCore.UpdateHostZoomLevel(const aValue : double); +begin + if Initialized then + Browser.Host.ZoomLevel := aValue; +end; + +procedure TChromiumCore.UpdateHostZoomPct(const aValue : double); +begin + if (aValue > 0) then + UpdateHostZoomLevel(LogN(1.2, aValue / 100)); +end; + +procedure TChromiumCore.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); +begin + if (FWebRTCIPHandlingPolicy <> aValue) then + begin + FWebRTCIPHandlingPolicy := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetWebRTCMultipleRoutes(aValue : TCefState); +begin + if (FWebRTCMultipleRoutes <> aValue) then + begin + FWebRTCMultipleRoutes := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetWebRTCNonProxiedUDP(aValue : TCefState); +begin + if (FWebRTCNonProxiedUDP <> aValue) then + begin + FWebRTCNonProxiedUDP := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetProxyType(aValue : integer); +begin + if (FProxyType <> aValue) then + begin + FProxyType := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetProxyScheme(aValue : TCefProxyScheme); +begin + if (FProxyScheme <> aValue) then + begin + FProxyScheme := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetProxyServer(const aValue : ustring); +begin + if (FProxyServer <> aValue) then + begin + FProxyServer := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetProxyPort(aValue : integer); +begin + if (FProxyPort <> aValue) then + begin + FProxyPort := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetProxyUsername(const aValue : ustring); +begin + if (FProxyUsername <> aValue) then + begin + FProxyUsername := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetProxyPassword(const aValue : ustring); +begin + if (FProxyPassword <> aValue) then + begin + FProxyPassword := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetProxyScriptURL(const aValue : ustring); +begin + if (FProxyScriptURL <> aValue) then + begin + FProxyScriptURL := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetProxyByPassList(const aValue : ustring); +begin + if (FProxyByPassList <> aValue) then + begin + FProxyByPassList := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetMaxConnectionsPerProxy(const aValue : integer); +begin + if (FMaxConnectionsPerProxy <> aValue) and + (aValue in [CEF_MAX_CONNECTIONS_PER_PROXY_MIN_VALUE..CEF_MAX_CONNECTIONS_PER_PROXY_MAX_VALUE]) then + begin + FMaxConnectionsPerProxy := aValue; + FUpdatePreferences := True; + end; +end; + +procedure TChromiumCore.SetCustomHeaderName(const aValue : ustring); +begin + if (FCustomHeaderName <> aValue) then + begin + FCustomHeaderName := aValue; + FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); + end; +end; + +procedure TChromiumCore.SetCustomHeaderValue(const aValue : ustring); +begin + if (FCustomHeaderValue <> aValue) then + begin + FCustomHeaderValue := aValue; + FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); + end; +end; + +// If aDeleteImmediately is false TChromiumCore.DeleteCookies triggers the TChromiumCore.OnCookiesDeleted +// event when the cookies are deleted. +function TChromiumCore.DeleteCookies(const url, cookieName: ustring; aDeleteImmediately : boolean) : boolean; +var + TempManager : ICefCookieManager; + TempCallback : ICefDeleteCookiesCallback; + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + begin + TempManager := TempContext.GetCookieManager(nil); + + if (TempManager <> nil) then + try + if aDeleteImmediately then + TempCallBack := nil + else + TempCallback := TCefCustomDeleteCookiesCallback.Create(self); + + Result := TempManager.DeleteCookies(url, cookieName, TempCallback); + finally + TempCallback := nil; + end; + end; + end; +end; + +// TChromiumCore.VisitAllCookies triggers the TChromiumCore.OnCookiesVisited event for each cookie +// aID is an optional parameter to identify which VisitAllCookies call has triggered the +// OnCookiesVisited event. +// TChromiumCore.OnCookiesVisited may not be triggered if the cookie store is empty but the +// TChromium.OnCookieVisitorDestroyed event will always be triggered to signal when the browser +// when the visit is over. +function TChromiumCore.VisitAllCookies(aID : integer) : boolean; +var + TempManager : ICefCookieManager; + TempVisitor : ICefCookieVisitor; + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + begin + TempManager := TempContext.GetCookieManager(nil); + + if (TempManager <> nil) then + try + TempVisitor := TCefCustomCookieVisitor.Create(self, aID); + Result := TempManager.VisitAllCookies(TempVisitor); + finally + TempVisitor := nil; + end; + end; + end; +end; + +// TChromiumCore.VisitURLCookies triggers the TChromiumCore.OnCookiesVisited event for each cookie +// aID is an optional parameter to identify which VisitURLCookies call has triggered the +// OnCookiesVisited event. +// TChromiumCore.OnCookiesVisited may not be triggered if the cookie store is empty but the +// TChromium.OnCookieVisitorDestroyed event will always be triggered to signal when the browser +// when the visit is over. +function TChromiumCore.VisitURLCookies(const url : ustring; + includeHttpOnly : boolean; + aID : integer) : boolean; +var + TempManager : ICefCookieManager; + TempVisitor : ICefCookieVisitor; + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + begin + TempManager := TempContext.GetCookieManager(nil); + + if (TempManager <> nil) then + try + TempVisitor := TCefCustomCookieVisitor.Create(self, aID); + Result := TempManager.VisitUrlCookies(url, includeHttpOnly, TempVisitor); + finally + TempVisitor := nil; + end; + end; + end; +end; + +// TChromiumCore.SetCookie triggers the TChromiumCore.OnCookieSet event when the cookie has been set +// aID is an optional parameter to identify which SetCookie call has triggered the +// OnCookieSet event. +function TChromiumCore.SetCookie(const url, name_, value, domain, path: ustring; + secure, httponly, hasExpires: Boolean; + const creation, lastAccess, expires: TDateTime; + same_site : TCefCookieSameSite; + priority : TCefCookiePriority; + aSetImmediately : boolean; + aID : integer): Boolean; +var + TempManager : ICefCookieManager; + TempCallback : ICefSetCookieCallback; + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + begin + TempManager := TempContext.GetCookieManager(nil); + + if (TempManager <> nil) then + try + if aSetImmediately then + TempCallback := nil + else + TempCallback := TCefCustomSetCookieCallback.Create(self, aID); + + Result := TempManager.SetCookie(url, name_, value, domain, path, + secure, httponly, hasExpires, + creation, lastAccess, expires, + same_site, priority, + TempCallback); + finally + TempCallback := nil; + end; + end; + end; +end; + +// If aFlushImmediately is false then OnCookiesFlushed is triggered when the cookies are flushed +function TChromiumCore.FlushCookieStore(aFlushImmediately : boolean) : boolean; +var + TempManager : ICefCookieManager; + TempCallback : ICefCompletionCallback; + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + begin + TempManager := TempContext.GetCookieManager(nil); + + if (TempManager <> nil) then + try + if aFlushImmediately then + TempCallback := nil + else + TempCallback := TCefFlushStoreCompletionCallback.Create(self); + + Result := TempManager.FlushStore(TempCallback); + finally + TempCallback := nil; + end; + end; + end; +end; + +procedure TChromiumCore.UpdateSupportedSchemes(const aSchemes : TStrings; aIncludeDefaults : boolean); +var + TempManager : ICefCookieManager; + TempContext : ICefRequestContext; +begin + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + begin + TempManager := TempContext.GetCookieManager(nil); + + if (TempManager <> nil) then + try + TempManager.SetSupportedSchemes(aSchemes, aIncludeDefaults, nil); + finally + TempManager := nil; + end; + end; + end; +end; + +// If aClearImmediately is false then OnCertificateExceptionsCleared is triggered when the exceptions are cleared +function TChromiumCore.ClearCertificateExceptions(aClearImmediately : boolean) : boolean; +var + TempCallback : ICefCompletionCallback; + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + try + if aClearImmediately then + TempCallback := nil + else + TempCallback := TCefClearCertificateExceptionsCompletionCallback.Create(self); + + TempContext.ClearCertificateExceptions(TempCallback); + Result := True; + finally + TempCallback := nil; + end; + end; +end; + +// If aClearImmediately is false then OnHttpAuthCredentialsCleared is triggered when the credeintials are cleared +function TChromiumCore.ClearHttpAuthCredentials(aClearImmediately : boolean) : boolean; +var + TempCallback : ICefCompletionCallback; + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + try + if aClearImmediately then + TempCallback := nil + else + TempCallback := TCefClearHttpAuthCredentialsCompletionCallback.Create(self); + + TempContext.ClearHttpAuthCredentials(TempCallback); + Result := True; + finally + TempCallback := nil; + end; + end; +end; + +// If aCloseImmediately is false then OnAllConnectionsClosed is triggered when the connections are closed +function TChromiumCore.CloseAllConnections(aCloseImmediately : boolean) : boolean; +var + TempCallback : ICefCompletionCallback; + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + try + if aCloseImmediately then + TempCallback := nil + else + TempCallback := TCefCloseAllConnectionsCompletionCallback.Create(self); + + TempContext.CloseAllConnections(TempCallback); + Result := True; + finally + TempCallback := nil; + end; + end; +end; + +// Leave aFrameName empty to get the HTML source from the main frame +procedure TChromiumCore.RetrieveHTML(const aFrameName : ustring); +var + TempFrame : ICefFrame; + TempVisitor : ICefStringVisitor; +begin + if Initialized then + begin + if (length(aFrameName) > 0) then + TempFrame := Browser.GetFrame(aFrameName) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + try + TempVisitor := TCustomCefStringVisitor.Create(self); + TempFrame.GetSource(TempVisitor); + finally + TempVisitor := nil; + end; + end; +end; + +procedure TChromiumCore.RetrieveHTML(const aFrame : ICefFrame); +var + TempVisitor : ICefStringVisitor; +begin + if Initialized and (aFrame <> nil) and aFrame.IsValid then + try + TempVisitor := TCustomCefStringVisitor.Create(self); + aFrame.GetSource(TempVisitor); + finally + TempVisitor := nil; + end; +end; + +procedure TChromiumCore.RetrieveHTML(const aFrameIdentifier : int64); +var + TempFrame : ICefFrame; + TempVisitor : ICefStringVisitor; +begin + if Initialized then + begin + if (aFrameIdentifier <> 0) then + TempFrame := Browser.GetFrameByident(aFrameIdentifier) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + try + TempVisitor := TCustomCefStringVisitor.Create(self); + TempFrame.GetSource(TempVisitor); + finally + TempVisitor := nil; + end; + end; +end; + +// Leave aFrameName empty to get the HTML source from the main frame +procedure TChromiumCore.RetrieveText(const aFrameName : ustring); +var + TempFrame : ICefFrame; + TempVisitor : ICefStringVisitor; +begin + if Initialized then + begin + if (length(aFrameName) > 0) then + TempFrame := Browser.GetFrame(aFrameName) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + try + TempVisitor := TCustomCefStringVisitor.Create(self); + TempFrame.GetText(TempVisitor); + finally + TempVisitor := nil; + end; + end; +end; + +procedure TChromiumCore.RetrieveText(const aFrame : ICefFrame); +var + TempVisitor : ICefStringVisitor; +begin + if Initialized and (aFrame <> nil) and aFrame.IsValid then + try + TempVisitor := TCustomCefStringVisitor.Create(self); + aFrame.GetText(TempVisitor); + finally + TempVisitor := nil; + end; +end; + +procedure TChromiumCore.RetrieveText(const aFrameIdentifier : int64); +var + TempFrame : ICefFrame; + TempVisitor : ICefStringVisitor; +begin + if Initialized then + begin + if (aFrameIdentifier <> 0) then + TempFrame := Browser.GetFrameByident(aFrameIdentifier) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + try + TempVisitor := TCustomCefStringVisitor.Create(self); + TempFrame.GetText(TempVisitor); + finally + TempVisitor := nil; + end; + end; +end; + +procedure TChromiumCore.GetNavigationEntries(currentOnly: Boolean); +var + TempVisitor : ICefNavigationEntryVisitor; +begin + if Initialized then + try + TempVisitor := TCustomCefNavigationEntryVisitor.Create(self); + Browser.Host.GetNavigationEntries(TempVisitor, currentOnly); + finally + TempVisitor := nil; + end; +end; + +function TChromiumCore.GetFrameNames(var aFrameNames : TStrings) : boolean; +begin + Result := Initialized and Browser.GetFrameNames(aFrameNames); +end; + +function TChromiumCore.GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean; +begin + Result := Initialized and Browser.GetFrameIdentifiers(aFrameCount, aFrameIdentifierArray); +end; + +procedure TChromiumCore.UpdatePreferences; +var + TempTask: ICefTask; +begin + if Initialized then + try + TempTask := TCefUpdatePrefsTask.Create(self); + CefPostTask(TID_UI, TempTask); + finally + TempTask := nil; + end; +end; + +procedure TChromiumCore.SavePreferences(const aFileName : string); +var + TempTask: ICefTask; +begin + if Initialized and (length(aFileName) > 0) then + try + FPrefsFileName := aFileName; + TempTask := TCefSavePrefsTask.Create(self); + CefPostTask(TID_UI, TempTask); + finally + TempTask := nil; + end; +end; + +{$IFDEF MSWINDOWS} +function TChromiumCore.SetNewBrowserParent(aNewParentHwnd : HWND) : boolean; +var + TempHandle : HWND; +begin + Result := False; + + if Initialized then + begin + TempHandle := Browser.Host.WindowHandle; + Result := (TempHandle <> 0) and (SetParent(TempHandle, aNewParentHwnd) <> 0); + end; +end; +{$ENDIF} + +procedure TChromiumCore.ResolveHost(const aURL : ustring); +var + TempCallback : ICefResolveCallback; +begin + // Results will be received in the OnResolvedHostAvailable event of this class + if Initialized and (length(aURL) > 0) then + try + TempCallback := TCefCustomResolveCallback.Create(self); + Browser.Host.RequestContext.ResolveHost(aURL, TempCallback); + finally + TempCallback := nil; + end; +end; + +function TChromiumCore.IsSameBrowser(const aBrowser : ICefBrowser) : boolean; +begin + Result := Initialized and (aBrowser <> nil) and Browser.IsSame(aBrowser); +end; + +// Calling ExecuteTaskOnCefThread function will trigger the TChromiumCore.OnExecuteTaskOnCefThread event. +// "aCefThreadId" indicates the CEF thread on which TChromiumCore.OnExecuteTaskOnCefThread will be executed. +// "aTaskID" is a custom ID used to identify the task that triggered the TChromiumCore.OnExecuteTaskOnCefThread event. +// "aDelayMs" is an optional delay in milliseconds to trigger the TChromiumCore.OnExecuteTaskOnCefThread event. +function TChromiumCore.ExecuteTaskOnCefThread(aCefThreadId : TCefThreadId; aTaskID : cardinal; aDelayMs : Int64) : boolean; +var + TempTask : ICefTask; +begin + Result := False; + + try + if Initialized then + begin + TempTask := TCefGenericTask.Create(self, aTaskID); + + if (aDelayMs <> 0) then + Result := CefPostDelayedTask(aCefThreadId, TempTask, aDelayMs) + else + Result := CefPostTask(aCefThreadId, TempTask); + end; + finally + TempTask := nil; + end; +end; + +procedure TChromiumCore.ClearCache; +begin + ExecuteDevToolsMethod(0, 'Network.clearBrowserCache', nil); +end; + +function TChromiumCore.GetRequestContext : ICefRequestContext; +begin + if Initialized then + Result := Browser.Host.RequestContext + else + Result := nil; +end; + +function TChromiumCore.GetMediaRouter : ICefMediaRouter; +var + TempRequestContext : ICefRequestContext; +begin + TempRequestContext := RequestContext; + + if (TempRequestContext <> nil) then + Result := TempRequestContext.MediaRouter + else + Result := nil; +end; + +procedure TChromiumCore.SimulateMouseWheel(aDeltaX, aDeltaY : integer); +var + TempEvent : TCefMouseEvent; +begin + if Initialized then + begin + TempEvent.x := 0; + TempEvent.y := 0; + TempEvent.modifiers := EVENTFLAG_NONE; + Browser.Host.SendMouseWheelEvent(@TempEvent, aDeltaX, aDeltaY); + end; +end; + +procedure TChromiumCore.doUpdatePreferences(const aBrowser: ICefBrowser); +var + TempLanguagesList : ustring; +begin + FUpdatePreferences := False; + + // The preferences registered in CEF are defined in : + // /libcef/browser/prefs/browser_prefs.cc + + UpdateProxyPrefs(aBrowser); + UpdatePreference(aBrowser, 'enable_do_not_track', FDoNotTrack); + UpdatePreference(aBrowser, 'enable_referrers', FSendReferrer); + UpdatePreference(aBrowser, 'enable_a_ping', FHyperlinkAuditing); + UpdatePreference(aBrowser, 'plugins.allow_outdated', FAllowOutdatedPlugins); + UpdatePreference(aBrowser, 'plugins.always_authorize', FAlwaysAuthorizePlugins); + UpdatePreference(aBrowser, 'browser.enable_spellchecking', FSpellChecking); + UpdateStringListPref(aBrowser, 'spellcheck.dictionaries', FSpellCheckerDicts); + UpdatePreference(aBrowser, 'settings.force_google_safesearch', FSafeSearch); + UpdatePreference(aBrowser, 'settings.force_youtube_restrict', FYouTubeRestrict); + UpdatePreference(aBrowser, 'printing.enabled', FPrintingEnabled); + + TempLanguagesList := FAcceptLanguageList; + + if (length(TempLanguagesList) = 0) and (FOptions <> nil) then + TempLanguagesList := FOptions.AcceptLanguageList; + + if (length(TempLanguagesList) = 0) then + TempLanguagesList := GlobalCEFApp.AcceptLanguageList; + + if (length(TempLanguagesList) = 0) then + TempLanguagesList := 'en-US,en'; + + UpdatePreference(aBrowser, 'intl.accept_languages', TempLanguagesList); + + case FAcceptCookies of + cpAllow : UpdatePreference(aBrowser, 'profile.default_content_setting_values.cookies', CEF_COOKIE_PREF_ALLOW); + cpBlock : UpdatePreference(aBrowser, 'profile.default_content_setting_values.cookies', CEF_COOKIE_PREF_BLOCK); + else UpdatePreference(aBrowser, 'profile.default_content_setting_values.cookies', CEF_COOKIE_PREF_DEFAULT); + end; + + UpdatePreference(aBrowser, 'profile.block_third_party_cookies', FBlock3rdPartyCookies); + + if (FMaxConnectionsPerProxy <> CEF_MAX_CONNECTIONS_PER_PROXY_DEFAULT_VALUE) then + UpdatePreference(aBrowser, 'net.max_connections_per_proxy', FMaxConnectionsPerProxy); + + case FWebRTCIPHandlingPolicy of + hpDefaultPublicAndPrivateInterfaces : + UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'default_public_and_private_interfaces'); + + hpDefaultPublicInterfaceOnly : + UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'default_public_interface_only'); + + hpDisableNonProxiedUDP : + UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'disable_non_proxied_udp'); + end; + + if (FWebRTCMultipleRoutes <> STATE_DEFAULT) then + UpdatePreference(aBrowser, 'webrtc.multiple_routes_enabled', (FWebRTCMultipleRoutes = STATE_ENABLED)); + + if (FWebRTCNonProxiedUDP <> STATE_DEFAULT) then + UpdatePreference(aBrowser, 'webrtc.nonproxied_udp_enabled', (FWebRTCNonProxiedUDP = STATE_ENABLED)); + + UpdatePreference(aBrowser, 'net.network_prediction_options', integer(FNetworkPredictions)); + UpdatePreference(aBrowser, 'net.quic_allowed', FQuicAllowed); + + UpdatePreference(aBrowser, 'webkit.webprefs.javascript_enabled', FJavascriptEnabled); + UpdatePreference(aBrowser, 'webkit.webprefs.loads_images_automatically', FLoadImagesAutomatically); +end; + +procedure TChromiumCore.doUpdateOwnPreferences; +begin + if Initialized then doUpdatePreferences(Browser); +end; + +function TChromiumCore.UpdateProxyPrefs(const aBrowser: ICefBrowser) : boolean; +var + TempError : ustring; + TempProxy : ICefValue; + TempValue : ICefValue; + TempDict : ICefDictionaryValue; +begin + Result := False; + + try + try + if (aBrowser <> nil) and + (aBrowser.Host <> nil) and + aBrowser.Host.RequestContext.CanSetPreference('proxy') then + begin + TempProxy := TCefValueRef.New; + TempValue := TCefValueRef.New; + TempDict := TCefDictionaryValueRef.New; + + case FProxyType of + CEF_PROXYTYPE_AUTODETECT : + begin + TempValue.SetString('auto_detect'); + TempDict.SetValue('mode', TempValue); + end; + + CEF_PROXYTYPE_SYSTEM : + begin + TempValue.SetString('system'); + TempDict.SetValue('mode', TempValue); + end; + + CEF_PROXYTYPE_FIXED_SERVERS : + begin + TempValue.SetString('fixed_servers'); + TempDict.SetValue('mode', TempValue); + + case FProxyScheme of + psSOCKS4 : TempDict.SetString('server', 'socks4://' + FProxyServer + ':' + inttostr(FProxyPort)); + psSOCKS5 : TempDict.SetString('server', 'socks5://' + FProxyServer + ':' + inttostr(FProxyPort)); + else TempDict.SetString('server', FProxyServer + ':' + inttostr(FProxyPort)); + end; + + if (length(FProxyByPassList) > 0) then TempDict.SetString('bypass_list', FProxyByPassList); + end; + + CEF_PROXYTYPE_PAC_SCRIPT : + begin + TempValue.SetString('pac_script'); + TempDict.SetValue('mode', TempValue); + TempDict.SetString('pac_url', FProxyScriptURL); + end; + + else // CEF_PROXYTYPE_DIRECT + begin + TempValue.SetString('direct'); + TempDict.SetValue('mode', TempValue); + end; + end; + + Result := TempProxy.SetDictionary(TempDict) and + aBrowser.Host.RequestContext.SetPreference('proxy', TempProxy, TempError); + + if not(Result) then + OutputDebugMessage('TChromiumCore.UpdateProxyPrefs error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.UpdateProxyPrefs', e) then raise; + end; + finally + TempProxy := nil; + TempValue := nil; + TempDict := nil; + end; +end; + +function TChromiumCore.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : boolean) : boolean; +var + TempError : ustring; + TempValue : ICefValue; +begin + Result := False; + + try + try + if (aBrowser <> nil) and + (aBrowser.Host <> nil) and + aBrowser.Host.RequestContext.CanSetPreference(aName) then + begin + TempValue := TCefValueRef.New; + TempValue.SetBool(aValue); + Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); + + if not(Result) then + OutputDebugMessage('TChromiumCore.UpdatePreference error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.UpdatePreference', e) then raise; + end; + finally + TempValue := nil; + end; +end; + +function TChromiumCore.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : integer) : boolean; +var + TempError : ustring; + TempValue : ICefValue; +begin + Result := False; + + try + try + if (aBrowser <> nil) and + (aBrowser.Host <> nil) and + aBrowser.Host.RequestContext.CanSetPreference(aName) then + begin + TempValue := TCefValueRef.New; + TempValue.SetInt(aValue); + Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); + + if not(Result) then + OutputDebugMessage('TChromiumCore.UpdatePreference error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.UpdatePreference', e) then raise; + end; + finally + TempValue := nil; + end; +end; + +function TChromiumCore.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; const aValue : double) : boolean; +var + TempError : ustring; + TempValue : ICefValue; +begin + Result := False; + + try + try + if (aBrowser <> nil) and + (aBrowser.Host <> nil) and + aBrowser.Host.RequestContext.CanSetPreference(aName) then + begin + TempValue := TCefValueRef.New; + TempValue.SetDouble(aValue); + Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); + + if not(Result) then + OutputDebugMessage('TChromiumCore.UpdatePreference error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.UpdatePreference', e) then raise; + end; + finally + TempValue := nil; + end; +end; + +function TChromiumCore.UpdatePreference(const aBrowser: ICefBrowser; const aName, aValue : ustring) : boolean; +var + TempError : ustring; + TempValue : ICefValue; +begin + Result := False; + + try + try + if (aBrowser <> nil) and + (aBrowser.Host <> nil) and + aBrowser.Host.RequestContext.CanSetPreference(aName) then + begin + TempValue := TCefValueRef.New; + TempValue.SetString(aValue); + Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); + + if not(Result) then + OutputDebugMessage('TChromiumCore.UpdatePreference error : ' + quotedstr(TempError)); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.UpdatePreference', e) then raise; + end; + finally + TempValue := nil; + end; +end; + +function TChromiumCore.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; const aValue : TStringList) : boolean; +var + TempError : ustring; + TempValue : ICefValue; + TempList : ICefListValue; + i : NativeUInt; + TempSize : NativeUInt; +begin + Result := False; + + try + try + if (aValue <> nil) and + (aValue.Count > 0) and + (aBrowser <> nil) and + (aBrowser.Host <> nil) and + aBrowser.Host.RequestContext.CanSetPreference(aName) then + begin + TempSize := aValue.Count; + TempList := TCefListValueRef.New; + + if TempList.SetSize(TempSize) then + begin + i := 0; + while (i < TempSize) do + begin + TempList.SetString(i, aValue[i]); + inc(i); + end; + + TempValue := TCefValueRef.New; + Result := TempValue.SetList(TempList) and + aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); + + if not(Result) then + OutputDebugMessage('TChromiumCore.UpdatePreference error : ' + quotedstr(TempError)); + end; + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.UpdatePreference', e) then raise; + end; + finally + TempValue := nil; + TempList := nil; + end; +end; + +function TChromiumCore.UpdateStringListPref(const aBrowser: ICefBrowser; const aName, aValue : ustring) : boolean; +var + TempSL : TStringList; +begin + Result := False; + TempSL := nil; + + try + if (length(aName) > 0) and (length(aValue) > 0) then + begin + TempSL := TStringList.Create; + TempSL.CommaText := aValue; + Result := UpdatePreference(aBrowser, aName, TempSL); + end; + finally + if (TempSL <> nil) then FreeAndNil(TempSL); + end; +end; + +function TChromiumCore.doSavePreferences : boolean; +begin + Result := Initialized and + TCEFJson.SaveToFile(Browser.Host.RequestContext.GetAllPreferences(True), FPrefsFileName); + + {$IFDEF MSWINDOWS} + SendCompMessage(CEF_PREFERENCES_SAVED, Ord(Result)); + {$ENDIF} +end; + +procedure TChromiumCore.doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); +begin + if assigned(FOnResolvedHostAvailable) then + FOnResolvedHostAvailable(self, result, resolvedIps); +end; + +function TChromiumCore.doNavigationVisitorResultAvailable(const entry : ICefNavigationEntry; + current : Boolean; + index : Integer; + total : Integer) : boolean; +begin + Result := False; + + if assigned(FOnNavigationVisitorResultAvailable) then + FOnNavigationVisitorResultAvailable(self, entry, current, index, total, Result); +end; + +procedure TChromiumCore.doDownloadImageFinished(const imageUrl : ustring; + httpStatusCode : Integer; + const image : ICefImage); +begin + if assigned(FOnDownloadImageFinished) then + FOnDownloadImageFinished(self, imageUrl, httpStatusCode, image); +end; + +procedure TChromiumCore.doOnCookiesStoreFlushed; +begin + if assigned(FOnCookiesFlushed) then + FOnCookiesFlushed(self); +end; + +procedure TChromiumCore.doCertificateExceptionsCleared; +begin + if assigned(FOnCertificateExceptionsCleared) then + FOnCertificateExceptionsCleared(self); +end; + +procedure TChromiumCore.doHttpAuthCredentialsCleared; +begin + if assigned(FOnHttpAuthCredentialsCleared) then + FOnHttpAuthCredentialsCleared(self); +end; + +procedure TChromiumCore.doAllConnectionsClosed; +begin + if assigned(FOnAllConnectionsClosed) then + FOnAllConnectionsClosed(self); +end; + +procedure TChromiumCore.doOnExecuteTaskOnCefThread(aTaskID : cardinal); +begin + if assigned(FOnExecuteTaskOnCefThread) then + FOnExecuteTaskOnCefThread(self, aTaskID); +end; + +procedure TChromiumCore.doOnCookiesVisited(const name_, value, domain, path: ustring; + secure, httponly, hasExpires: Boolean; + const creation, lastAccess, expires: TDateTime; + count, total, aID : Integer; + same_site : TCefCookieSameSite; + priority : TCefCookiePriority; + var aDeleteCookie, aResult : Boolean); +begin + if assigned(FOnCookiesVisited) then + FOnCookiesVisited(self, name_, value, domain, path, + secure, httponly, hasExpires, + creation, lastAccess, expires, + count, total, aID, + same_site, priority, + aDeleteCookie, aResult); +end; + +procedure TChromiumCore.doOnCookieVisitorDestroyed(aID : integer); +begin + if assigned(FOnCookieVisitorDestroyed) then + FOnCookieVisitorDestroyed(self, aID); +end; + +procedure TChromiumCore.doOnCookieSet(aSuccess : boolean; aID : integer); +begin + if assigned(FOnCookieSet) then + FOnCookieSet(self, aSuccess, aID); +end; + +procedure TChromiumCore.doUpdateZoomStep(aInc : boolean); +var + TempPct, TempPrev, TempNext : double; + i : integer; +begin + if not(Initialized) or (FZoomStepCS = nil) then exit; + + try + FZoomStepCS.Acquire; + + if (FZoomStep in [ZOOM_STEP_MIN..ZOOM_STEP_MAX]) then + begin + if aInc then + begin + if (FZoomStep < ZOOM_STEP_MAX) then + begin + inc(FZoomStep); + UpdateHostZoomPct(ZoomStepValues[FZoomStep]); + end; + end + else + if (FZoomStep > ZOOM_STEP_MIN) then + begin + dec(FZoomStep); + UpdateHostZoomPct(ZoomStepValues[FZoomStep]); + end; + end + else + begin + TempPct := ZoomPct; + TempPrev := 0; + i := ZOOM_STEP_MIN; + + repeat + if (i <= ZOOM_STEP_MAX) then + TempNext := ZoomStepValues[i] + else + TempNext := ZoomStepValues[ZOOM_STEP_MAX] * 2; + + if (TempPct > TempPrev) and (TempPct < TempNext) then + begin + if aInc then + begin + if (i <= ZOOM_STEP_MAX) then + begin + FZoomStep := i; + UpdateHostZoomPct(ZoomStepValues[FZoomStep]); + end; + end + else + if (i > ZOOM_STEP_MIN) then + begin + FZoomStep := pred(i); + UpdateHostZoomPct(ZoomStepValues[FZoomStep]); + end; + + i := ZOOM_STEP_MAX + 2; + end + else + begin + TempPrev := TempNext; + inc(i); + end; + + until (i > succ(ZOOM_STEP_MAX)); + end; + finally + FZoomStepCS.Release; + + if assigned(FOnZoomPctAvailable) then + FOnZoomPctAvailable(self, ZoomPct); + end; +end; + +procedure TChromiumCore.doUpdateZoomPct(aInc : boolean); +var + TempNewZoom : double; + i : integer; +begin + if not(Initialized) or (FZoomStepCS = nil) then exit; + + TempNewZoom := ZoomPct; + + try + FZoomStepCS.Acquire; + + if aInc then + TempNewZoom := min(TempNewZoom + ZOOM_PCT_DELTA, ZoomStepValues[ZOOM_STEP_MAX]) + else + TempNewZoom := max(TempNewZoom - ZOOM_PCT_DELTA, ZoomStepValues[ZOOM_STEP_MIN]); + + for i := ZOOM_STEP_MIN to ZOOM_STEP_MAX do + if (TempNewZoom = ZoomStepValues[i]) then break; + + FZoomStep := i; + UpdateHostZoomPct(TempNewZoom); + finally + FZoomStepCS.Release; + + if assigned(FOnZoomPctAvailable) then + FOnZoomPctAvailable(self, TempNewZoom); + end; +end; + +procedure TChromiumCore.doReadZoom; +begin + if Initialized and assigned(FOnZoomPctAvailable) then + FOnZoomPctAvailable(self, ZoomPct); +end; + +procedure TChromiumCore.doSetZoomLevel(const aValue : double); +var + TempZoom : double; + i : integer; +begin + if not(Initialized) or (FZoomStepCS = nil) then exit; + + try + FZoomStepCS.Acquire; + + UpdateHostZoomLevel(aValue); + TempZoom := ZoomPct; + + for i := ZOOM_STEP_MIN to ZOOM_STEP_MAX do + if (TempZoom = ZoomStepValues[i]) then break; + + FZoomStep := i; + finally + FZoomStepCS.Release; + + if assigned(FOnZoomPctAvailable) then + FOnZoomPctAvailable(self, ZoomPct); + end; +end; + +procedure TChromiumCore.doSetZoomPct(const aValue : double); +var + TempZoom : double; + i : integer; +begin + if not(Initialized) or (FZoomStepCS = nil) then exit; + + try + FZoomStepCS.Acquire; + + if (aValue >= ZoomStepValues[ZOOM_STEP_MIN]) and + (aValue <= ZoomStepValues[ZOOM_STEP_MAX]) then + begin + UpdateHostZoomPct(aValue); + TempZoom := ZoomPct; + + for i := ZOOM_STEP_MIN to ZOOM_STEP_MAX do + if (TempZoom = ZoomStepValues[i]) then break; + + FZoomStep := i; + end; + finally + FZoomStepCS.Release; + + if assigned(FOnZoomPctAvailable) then + FOnZoomPctAvailable(self, ZoomPct); + end; +end; + +procedure TChromiumCore.doSetZoomStep(aValue : byte); +begin + if not(Initialized) or (FZoomStepCS = nil) then exit; + + try + FZoomStepCS.Acquire; + + if (aValue in [ZOOM_STEP_MIN..ZOOM_STEP_MAX]) then + begin + FZoomStep := aValue; + UpdateHostZoomPct(ZoomStepValues[aValue]); + end; + finally + FZoomStepCS.Release; + + if assigned(FOnZoomPctAvailable) then + FOnZoomPctAvailable(self, ZoomPct); + end; +end; + +procedure TChromiumCore.doMediaRouteCreateFinished( result : TCefMediaRouterCreateResult; + const error : ustring; + const route : ICefMediaRoute); +begin + if assigned(FOnMediaRouteCreateFinished) then + FOnMediaRouteCreateFinished(self, result, error, route); +end; + +procedure TChromiumCore.doOnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); +begin + if assigned(FOnMediaSinkDeviceInfo) then + FOnMediaSinkDeviceInfo(self, ip_address, port, model_name); +end; + +procedure TChromiumCore.doBrowserNavigation(aTask : TCefBrowserNavigation); +begin + if Initialized then + case aTask of + bnBack : if CanGoBack then Browser.GoBack; + bnForward : if CanGoForward then Browser.GoForward; + bnReload : Browser.Reload; + bnReloadIgnoreCache : Browser.ReloadIgnoreCache; + bnStopLoad : Browser.StopLoad; + end; +end; + +{$IFDEF LINUX} +procedure TChromiumCore.UpdateBrowserSize(aLeft, aTop, aWidth, aHeight : integer); +{$IFDEF FPC} +var + TempHandle : TCefWindowHandle; + TempChanges : TXWindowChanges; + TempXDisplay : PXDisplay; +{$ENDIF} +begin + {$IFDEF FPC} + TempHandle := WindowHandle; + + if ValidCefWindowHandle(TempHandle) then + begin + TempXDisplay := XDisplay; + + if (TempXDisplay <> nil) then + begin + TempChanges.x := aLeft; + TempChanges.y := aTop; + TempChanges.width := aWidth; + TempChanges.height := aHeight; + + XConfigureWindow(TempXDisplay, TempHandle, CWX or CWY or CWHeight or CWWidth, @TempChanges); + end; + end; + {$ENDIF} +end; + +procedure TChromiumCore.UpdateXWindowVisibility(aVisible : boolean); +{$IFDEF FPC} +var + TempXDisplay : PXDisplay; + TempHandle : TCefWindowHandle; + TempState : TAtom; + TempHidden : TAtom; +{$ENDIF} +begin + {$IFDEF FPC} + TempHandle := WindowHandle; + + if ValidCefWindowHandle(TempHandle) then + begin + TempXDisplay := XDisplay; + + if (TempXDisplay <> nil) then + begin + TempState := XInternAtom(TempXDisplay, '_NET_WM_STATE', False); + + if aVisible then + XChangeProperty(TempXDisplay, TempHandle, TempState, XA_ATOM, 32, PropModeReplace, nil, 0) + else + begin + TempHidden := XInternAtom(TempXDisplay, '_NET_WM_STATE_HIDDEN', False); + XChangeProperty(TempXDisplay, TempHandle, TempState, XA_ATOM, 32, PropModeReplace, @TempHidden, 1); + end; + end; + end; + {$ENDIF} +end; +{$ENDIF} + +function TChromiumCore.MustCreateLoadHandler : boolean; +begin + Result := assigned(FOnLoadStart) or + assigned(FOnLoadEnd) or + assigned(FOnLoadError) or + assigned(FOnLoadingStateChange); +end; + +function TChromiumCore.MustCreateFocusHandler : boolean; +begin + Result := assigned(FOnTakeFocus) or + assigned(FOnSetFocus) or + assigned(FOnGotFocus); +end; + +function TChromiumCore.MustCreateContextMenuHandler : boolean; +begin + Result := assigned(FOnBeforeContextMenu) or + assigned(FOnRunContextMenu) or + assigned(FOnContextMenuCommand) or + assigned(FOnContextMenuDismissed); +end; + +function TChromiumCore.MustCreateDialogHandler : boolean; +begin + Result := assigned(FOnFileDialog); +end; + +function TChromiumCore.MustCreateKeyboardHandler : boolean; +begin + Result := assigned(FOnPreKeyEvent) or + assigned(FOnKeyEvent); +end; + +function TChromiumCore.MustCreateDisplayHandler : boolean; +begin + Result := assigned(FOnAddressChange) or + assigned(FOnTitleChange) or + assigned(FOnFavIconUrlChange) or + assigned(FOnFullScreenModeChange) or + assigned(FOnTooltip) or + assigned(FOnStatusMessage) or + assigned(FOnConsoleMessage) or + assigned(FOnAutoResize) or + assigned(FOnLoadingProgressChange) or + assigned(FOnCursorChange); +end; + +function TChromiumCore.MustCreateDownloadHandler : boolean; +begin + Result := assigned(FOnBeforeDownload) or + assigned(FOnDownloadUpdated); +end; + +function TChromiumCore.MustCreateJsDialogHandler : boolean; +begin + Result := assigned(FOnJsdialog) or + assigned(FOnBeforeUnloadDialog) or + assigned(FOnResetDialogState) or + assigned(FOnDialogClosed); +end; + +function TChromiumCore.MustCreateLifeSpanHandler : boolean; +begin + Result := True; +end; + +function TChromiumCore.MustCreateRenderHandler : boolean; +begin + Result := FIsOSR; +end; + +function TChromiumCore.MustCreateRequestHandler : boolean; +begin + Result := True; +end; + +function TChromiumCore.MustCreateDragHandler : boolean; +begin + Result := assigned(FOnDragEnter) or + assigned(FOnDraggableRegionsChanged); +end; + +function TChromiumCore.MustCreateFindHandler : boolean; +begin + Result := assigned(FOnFindResult); +end; + +function TChromiumCore.MustCreateResourceRequestHandler : boolean; +begin + Result := assigned(FOnBeforeResourceLoad) or + assigned(FOnGetResourceHandler) or + assigned(FOnResourceRedirect) or + assigned(FOnResourceResponse) or + assigned(FOnGetResourceResponseFilter) or + assigned(FOnResourceLoadComplete) or + assigned(FOnProtocolExecution) or + MustCreateCookieAccessFilter; +end; + +function TChromiumCore.MustCreateCookieAccessFilter : boolean; +begin + Result := assigned(FOnCanSendCookie) or + assigned(FOnCanSaveCookie); +end; + +function TChromiumCore.MustCreateRequestContextHandler : boolean; +begin + Result := assigned(FOnRequestContextInitialized) or + assigned(FOnBeforePluginLoad) or + assigned(FOnGetResourceRequestHandler_ReqCtxHdlr) or + MustCreateResourceRequestHandler; +end; + +function TChromiumCore.MustCreateMediaObserver : boolean; +begin + Result := assigned(FOnSinks) or + assigned(FOnRoutes) or + assigned(FOnRouteStateChanged) or + assigned(FOnRouteMessageReceived); +end; + +function TChromiumCore.MustCreateAudioHandler : boolean; +begin + Result := assigned(FOnGetAudioParameters) or + assigned(FOnAudioStreamStarted) or + assigned(FOnAudioStreamPacket) or + assigned(FOnAudioStreamStopped) or + assigned(FOnAudioStreamError); +end; + +function TChromiumCore.MustCreateDevToolsMessageObserver : boolean; +begin + Result := assigned(FOnDevToolsMessage) or + assigned(FOnDevToolsRawMessage) or + assigned(FOnDevToolsMethodResult) or + assigned(FOnDevToolsMethodRawResult) or + assigned(FOnDevToolsEvent) or + assigned(FOnDevToolsRawEvent) or + assigned(FOnDevToolsAgentAttached) or + assigned(FOnDevToolsAgentDetached); +end; + +function TChromiumCore.MustCreateExtensionHandler : boolean; +begin + Result := assigned(FOnExtensionLoadFailed) or + assigned(FOnExtensionLoaded) or + assigned(FOnExtensionUnloaded) or + assigned(FOnExtensionBeforeBackgroundBrowser) or + assigned(FOnExtensionBeforeBrowser) or + assigned(FOnExtensionGetActiveBrowser) or + assigned(FOnExtensionCanAccessBrowser) or + assigned(FOnExtensionGetExtensionResource); +end; + +{$IFDEF MSWINDOWS} +procedure TChromiumCore.PrefsAvailableMsg(aResultOK : boolean); +begin + if assigned(FOnPrefsAvailable) then + FOnPrefsAvailable(self, aResultOK); +end; + +function TChromiumCore.SendCompMessage(aMsg : cardinal; aWParam : WPARAM; aLParam : LPARAM) : boolean; +begin + Result := (FCompHandle <> 0) and PostMessage(FCompHandle, aMsg, aWParam, aLParam); +end; +{$ENDIF} + +procedure TChromiumCore.doTextResultAvailable(const aText : ustring); +begin + if assigned(FOnTextResultAvailable) then + FOnTextResultAvailable(self, aText); +end; + +procedure TChromiumCore.ExecuteJavaScript(const aCode, aScriptURL, aFrameName : ustring; aStartLine : integer); +var + TempFrame : ICefFrame; +begin + try + if Initialized then + begin + if (length(aFrameName) > 0) then + TempFrame := Browser.GetFrame(aFrameName) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + TempFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.ExecuteJavaScript', e) then raise; + end; +end; + +procedure TChromiumCore.ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrame : ICefFrame; aStartLine : integer); +begin + try + if Initialized and (aFrame <> nil) and aFrame.IsValid then + aFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.ExecuteJavaScript', e) then raise; + end; +end; + +procedure TChromiumCore.ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameIdentifier : int64; aStartLine : integer = 0); +var + TempFrame : ICefFrame; +begin + try + if Initialized then + begin + if (aFrameIdentifier <> 0) then + TempFrame := Browser.GetFrameByident(aFrameIdentifier) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + TempFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.ExecuteJavaScript', e) then raise; + end; +end; + +procedure TChromiumCore.doCookiesDeleted(numDeleted : integer); +begin + if assigned(FOnCookiesDeleted) then + FOnCookiesDeleted(self, numDeleted); +end; + +procedure TChromiumCore.doPdfPrintFinished(aResultOK : boolean); +begin + if assigned(FOnPdfPrintFinished) then + FOnPdfPrintFinished(self, aResultOK); +end; + +procedure TChromiumCore.ShowDevTools(const inspectElementAt: TPoint; aWindowInfo: PCefWindowInfo); +var + TempPoint : TCefPoint; + TempClient : ICefClient; + TempPPoint : PCefPoint; + TempHandle : TCefWindowHandle; +begin + try + try + if Initialized then + begin + InitializeSettings(FDevBrowserSettings); + if aWindowInfo = nil then + begin + InitializeWindowHandle(TempHandle); + DefaultInitializeDevToolsWindowInfo(TempHandle, Rect(0, 0, 0, 0), ''); + end + else + if aWindowInfo <> @FDevWindowInfo then + FDevWindowInfo := aWindowInfo^; + + TempClient := TCustomClientHandler.Create(Self, True); + + if (inspectElementAt.x <> low(integer)) and + (inspectElementAt.y <> low(integer)) then + begin + TempPoint.x := inspectElementAt.x; + TempPoint.y := inspectElementAt.y; + TempPPoint := @TempPoint; + end + else + TempPPoint := nil; + + Browser.Host.ShowDevTools(@FDevWindowInfo, TempClient, @FDevBrowserSettings, TempPPoint); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.ShowDevTools', e) then raise; + end; + finally + TempClient := nil; + end; +end; + +procedure TChromiumCore.CloseDevTools; +begin + if Initialized then + Browser.Host.CloseDevTools; +end; + +procedure TChromiumCore.CloseDevTools(const aDevToolsWnd : TCefWindowHandle); +begin + if Initialized then + begin + {$IFDEF MSWINDOWS} + if ValidCefWindowHandle(aDevToolsWnd) then + SetParent(GetWindow(aDevToolsWnd, GW_CHILD), 0); + {$ENDIF} + + Browser.Host.CloseDevTools; + end; +end; + +function TChromiumCore.SendDevToolsMessage(const message_: ustring): boolean; +begin + Result := Initialized and Browser.Host.SendDevToolsMessage(message_); +end; + +function TChromiumCore.ExecuteDevToolsMethod(message_id: integer; const method: ustring; const params: ICefDictionaryValue): Integer; +begin + if Initialized then + Result := Browser.Host.ExecuteDevToolsMethod(message_id, method, params) + else + Result := 0; +end; + +function TChromiumCore.AddDevToolsMessageObserver(const observer: ICefDevToolsMessageObserver): ICefRegistration; +begin + if Initialized then + Result := Browser.Host.AddDevToolsMessageObserver(observer) + else + Result := nil; +end; + +{$IFDEF MSWINDOWS} +procedure TChromiumCore.WndProc(var aMessage: TMessage); +begin + case aMessage.Msg of + CEF_PREFERENCES_SAVED : PrefsAvailableMsg(aMessage.WParam <> 0); + CEF_STARTDRAGGING : DelayedDragging; + + else aMessage.Result := DefWindowProc(FCompHandle, aMessage.Msg, aMessage.WParam, aMessage.LParam); + end; +end; + +procedure TChromiumCore.BrowserCompWndProc(var aMessage: TMessage); +var + TempHandled : boolean; +begin + try + TempHandled := False; + + try + if assigned(FOnBrowserCompMsg) then + FOnBrowserCompMsg(self, aMessage, TempHandled); + + if not(TempHandled) then + CallOldCompWndProc(FOldBrowserCompWndPrc, FBrowserCompHWND, aMessage); + finally + if aMessage.Msg = WM_DESTROY then + RestoreCompWndProc(FBrowserCompHWND, 0, FOldBrowserCompWndPrc); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.BrowserCompWndProc', e) then raise; + end; +end; + +procedure TChromiumCore.WidgetCompWndProc(var aMessage: TMessage); +var + TempHandled : boolean; +begin + try + TempHandled := False; + + try + if assigned(FOnWidgetCompMsg) then + FOnWidgetCompMsg(self, aMessage, TempHandled); + + if not(TempHandled) then + CallOldCompWndProc(FOldWidgetCompWndPrc, FWidgetCompHWND, aMessage); + finally + if aMessage.Msg = WM_DESTROY then + RestoreCompWndProc(FWidgetCompHWND, 0, FOldWidgetCompWndPrc); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.WidgetCompWndProc', e) then raise; + end; +end; + +procedure TChromiumCore.RenderCompWndProc(var aMessage: TMessage); +var + TempHandled : boolean; +begin + try + TempHandled := False; + + try + if assigned(FOnRenderCompMsg) then + FOnRenderCompMsg(self, aMessage, TempHandled); + + if not(TempHandled) then + CallOldCompWndProc(FOldRenderCompWndPrc, FRenderCompHWND, aMessage); + finally + if aMessage.Msg = WM_DESTROY then + RestoreCompWndProc(FRenderCompHWND, 0, FOldRenderCompWndPrc); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.RenderCompWndProc', e) then raise; + end; +end; + +procedure TChromiumCore.RestoreOldCompWndProc; +begin + RestoreCompWndProc(FBrowserCompHWND, 0, FOldBrowserCompWndPrc); + FreeAndNilStub(FBrowserCompStub); + + RestoreCompWndProc(FWidgetCompHWND, 0, FOldWidgetCompWndPrc); + FreeAndNilStub(FWidgetCompStub); + + RestoreCompWndProc(FRenderCompHWND, 0, FOldRenderCompWndPrc); + FreeAndNilStub(FRenderCompStub); +end; +{$ENDIF} + +function TChromiumCore.RemoveBrowser(const aBrowser : ICefBrowser) : boolean; +begin + Result := False; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + + if (FBrowsers <> nil) and + FBrowsers.RemoveBrowser(aBrowser) and + (FBrowserId = aBrowser.Identifier) then + FBrowserId := FBrowsers.FirstID; + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.AddBrowser(const aBrowser : ICefBrowser) : boolean; +begin + Result := False; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + + if (FBrowsers <> nil) and + (FMultiBrowserMode or (FBrowsers.Count = 0)) and + FBrowsers.AddBrowser(aBrowser) then + begin + Result := True; + + if (FBrowserId = 0) then + FBrowserId := aBrowser.Identifier; + end; + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.SelectBrowser(aID : integer) : boolean; +begin + Result := False; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + + if FMultiBrowserMode and (FBrowsers <> nil) and (FBrowsers.SearchBrowser(aID) >= 0) then + begin + FBrowserId := aID; + Result := True; + end; + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.IndexOfBrowserID(aID : integer) : integer; +begin + Result := -1; + + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + + if (FBrowsers <> nil) then + Result := FBrowsers.SearchBrowser(aID); + finally + FBrowsersCS.Release; + end; +end; + +procedure TChromiumCore.SetBrowserIsClosing(aID : integer); +begin + if (FBrowsersCS <> nil) then + try + FBrowsersCS.Acquire; + if (FBrowsers <> nil) then + FBrowsers.BrowserIsClosing[aID] := True; + finally + FBrowsersCS.Release; + end; +end; + +function TChromiumCore.doOnClose(const browser: ICefBrowser): Boolean; +var + TempAction : TCefCloseBrowserAction; + TempID : Integer; +begin + Result := False; + TempAction := cbaClose; + TempID := browser.Identifier; + + // TempAction values + // ----------------- + // cbaCancel : stop closing the browser + // cbaClose : continue closing the browser + // cbaDelay : stop closing the browser momentarily. Used when the application + // needs to execute some custom processes before closing the + // browser. This is usually needed to destroy a TCEFWindowParent + // in the main thread before closing the browser. + if assigned(FOnClose) then + FOnClose(Self, browser, TempAction); + + case TempAction of + cbaCancel : Result := True; + + cbaDelay : + begin + Result := True; + SetBrowserIsClosing(TempID); + end; + + else + SetBrowserIsClosing(TempID); + end; +end; + +procedure TChromiumCore.doOnBeforeClose(const browser: ICefBrowser); +begin + RemoveBrowser(browser); + + if (BrowserCount = 0) then + DestroyAllHandlersAndObservers; + + if assigned(FOnBeforeClose) then + FOnBeforeClose(Self, browser); +end; + +procedure TChromiumCore.doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); +begin + if assigned(FOnAddressChange) then + FOnAddressChange(Self, browser, frame, url); +end; + +procedure TChromiumCore.doOnAfterCreated(const browser: ICefBrowser); +begin + if MultithreadApp or MultiBrowserMode then + AddBrowser(browser); + + doUpdatePreferences(browser); + + if (FMediaObserver <> nil) and (FMediaObserverReg = nil) then + FMediaObserverReg := AddObserver(FMediaObserver); + + if (FDevToolsMsgObserver <> nil) and (FDevToolsMsgObserverReg = nil) then + FDevToolsMsgObserverReg := AddDevToolsMessageObserver(FDevToolsMsgObserver); + + if assigned(FOnAfterCreated) then + FOnAfterCreated(Self, browser); +end; + +function TChromiumCore.doOnBeforeBrowse(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + user_gesture : Boolean; + isRedirect : Boolean): Boolean; +begin + Result := False; + + if FUpdatePreferences then + doUpdatePreferences(browser); + + if assigned(FOnBeforeBrowse) then + FOnBeforeBrowse(Self, browser, frame, request, user_gesture, isRedirect, Result); +end; + +procedure TChromiumCore.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 TChromiumCore.doRunContextMenu(const browser : ICefBrowser; + const frame : ICefFrame; + const params : ICefContextMenuParams; + const model : ICefMenuModel; + const callback : ICefRunContextMenuCallback): Boolean; +begin + Result := False; + + if assigned(FOnRunContextMenu) then + FOnRunContextMenu(Self, browser, frame, params, model, callback, Result); +end; + +procedure TChromiumCore.doOnBeforeDownload(const browser : ICefBrowser; + const downloadItem : ICefDownloadItem; + const suggestedName : ustring; + const callback : ICefBeforeDownloadCallback); +begin + if assigned(FOnBeforeDownload) then + FOnBeforeDownload(Self, browser, downloadItem, suggestedName, callback); +end; + +function TChromiumCore.doOnBeforePopup(const browser : ICefBrowser; + const frame : ICefFrame; + const targetUrl : ustring; + const targetFrameName : ustring; + targetDisposition : TCefWindowOpenDisposition; + userGesture : Boolean; + const popupFeatures : TCefPopupFeatures; + var windowInfo : TCefWindowInfo; + var client : ICefClient; + var settings : TCefBrowserSettings; + var extra_info : ICefDictionaryValue; + var noJavascriptAccess : Boolean): Boolean; +begin + Result := False; + + if assigned(FOnBeforePopup) then + FOnBeforePopup(Self, browser, frame, targetUrl, targetFrameName, + targetDisposition, userGesture, popupFeatures, windowInfo, client, + settings, extra_info, noJavascriptAccess, Result); +end; + +function TChromiumCore.doOnBeforeResourceLoad(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const callback : ICefRequestCallback): TCefReturnValue; +var + TempHeaderMap : ICefStringMultimap; +begin + if FAddCustomHeader then + try + TempHeaderMap := TCefStringMultimapOwn.Create; + request.GetHeaderMap(TempHeaderMap); + TempHeaderMap.Append(FCustomHeaderName, FCustomHeaderValue); + request.SetHeaderMap(TempHeaderMap); + finally + TempHeaderMap := nil; + end; + + if not(FSendReferrer) then + request.SetReferrer('', REFERRER_POLICY_NO_REFERRER); + + Result := RV_CONTINUE; + + if assigned(FOnBeforeResourceLoad) then + FOnBeforeResourceLoad(Self, browser, frame, request, callback, Result); +end; + +function TChromiumCore.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; + +function TChromiumCore.doOnCertificateError(const browser : ICefBrowser; + certError : TCefErrorcode; + const requestUrl : ustring; + const sslInfo : ICefSslInfo; + const callback : ICefRequestCallback): Boolean; +begin + Result := False; + + if assigned(FOnCertificateError) then + FOnCertificateError(Self, browser, certError, requestUrl, sslInfo, callback, Result); +end; + +function TChromiumCore.doOnConsoleMessage(const browser : ICefBrowser; + level : TCefLogSeverity; + const aMessage : ustring; + const source : ustring; + line : Integer): Boolean; +begin + Result := False; + + if assigned(FOnConsoleMessage) then + FOnConsoleMessage(Self, browser, level, aMessage, source, line, Result); +end; + +function TChromiumCore.doOnAutoResize(const browser : ICefBrowser; + const new_size : PCefSize): Boolean; +begin + Result := False; + + if assigned(FOnAutoResize) then + FOnAutoResize(Self, browser, new_size, Result); +end; + +procedure TChromiumCore.doOnLoadingProgressChange(const browser: ICefBrowser; const progress: double); +begin + if assigned(FOnLoadingProgressChange) then + FOnLoadingProgressChange(self, browser, progress); +end; + +function TChromiumCore.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 TChromiumCore.doOnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); +begin + if assigned(FOnContextMenuDismissed) then + FOnContextMenuDismissed(Self, browser, frame); +end; + +procedure TChromiumCore.doOnCursorChange(const browser : ICefBrowser; + cursor_ : TCefCursorHandle; + cursorType : TCefCursorType; + const customCursorInfo : PCefCursorInfo; + var aResult : boolean); +begin + aResult := False; + + if assigned(FOnCursorChange) then + FOnCursorChange(self, browser, cursor_, cursorType, customCursorInfo, aResult); +end; + +procedure TChromiumCore.doOnDialogClosed(const browser: ICefBrowser); +begin + if assigned(FOnDialogClosed) then + FOnDialogClosed(Self, browser); +end; + +procedure TChromiumCore.doOnDownloadUpdated(const browser : ICefBrowser; + const downloadItem : ICefDownloadItem; + const callback : ICefDownloadItemCallback); +begin + if assigned(FOnDownloadUpdated) then + FOnDownloadUpdated(Self, browser, downloadItem, callback); +end; + +function TChromiumCore.doOnDragEnter(const browser : ICefBrowser; + const dragData : ICefDragData; + mask : TCefDragOperations): Boolean; +begin + Result := False; + + if assigned(FOnDragEnter) then + FOnDragEnter(Self, browser, dragData, mask, Result); +end; + +procedure TChromiumCore.doOnDraggableRegionsChanged(const browser : ICefBrowser; + const frame : ICefFrame; + regionsCount : NativeUInt; + const regions : PCefDraggableRegionArray); +begin + if assigned(FOnDraggableRegionsChanged) then + FOnDraggableRegionsChanged(Self, browser, frame, regionsCount, regions); +end; + +procedure TChromiumCore.doOnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); +begin + if assigned(FOnFavIconUrlChange) then + FOnFavIconUrlChange(Self, browser, iconUrls); +end; + +function TChromiumCore.doOnFileDialog(const browser : ICefBrowser; + mode : TCefFileDialogMode; + const title : ustring; + const defaultFilePath : ustring; + const acceptFilters : TStrings; + selectedAcceptFilter : Integer; + const callback : ICefFileDialogCallback): Boolean; +begin + Result := False; + + if assigned(FOnFileDialog) then + FOnFileDialog(Self, browser, mode, title, defaultFilePath, acceptFilters, + selectedAcceptFilter, callback, Result); +end; + +procedure TChromiumCore.doOnFindResult(const browser : ICefBrowser; + identifier : integer; + count : Integer; + const selectionRect : PCefRect; + activeMatchOrdinal : Integer; + finalUpdate : Boolean); +begin + if assigned(FOnFindResult) then + FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate); +end; + +procedure TChromiumCore.doOnRequestContextInitialized(const request_context: ICefRequestContext); +begin + if assigned(FOnRequestContextInitialized) then + FOnRequestContextInitialized(self, request_context); +end; + +function TChromiumCore.doOnBeforePluginLoad(const mimeType : ustring; + const pluginUrl : ustring; + isMainFrame : boolean; + const topOriginUrl : ustring; + const pluginInfo : ICefWebPluginInfo; + var pluginPolicy : TCefPluginPolicy): Boolean; +begin + Result := False; + + if assigned(FOnBeforePluginLoad) then + FOnBeforePluginLoad(self, mimeType, pluginUrl, isMainFrame, topOriginUrl, pluginInfo, pluginPolicy, Result); +end; + +procedure TChromiumCore.doGetResourceRequestHandler_ReqCtxHdlr(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + is_navigation : boolean; + is_download : boolean; + const request_initiator : ustring; + var disable_default_handling : boolean; + var aResourceRequestHandler : ICefResourceRequestHandler); +begin + if (FResourceRequestHandler <> nil) then + aResourceRequestHandler := FResourceRequestHandler; + + if assigned(FOnGetResourceRequestHandler_ReqCtxHdlr) then + FOnGetResourceRequestHandler_ReqCtxHdlr(self, browser, frame, request, is_navigation, is_download, + request_initiator, disable_default_handling, + aResourceRequestHandler); +end; + +procedure TChromiumCore.doOnSinks(const sinks: TCefMediaSinkArray); +begin + if assigned(FOnSinks) then + FOnSinks(self, sinks); +end; + +procedure TChromiumCore.doOnRoutes(const routes: TCefMediaRouteArray); +begin + if assigned(FOnRoutes) then + FOnRoutes(self, routes); +end; + +procedure TChromiumCore.doOnRouteStateChanged(const route : ICefMediaRoute; + state : TCefMediaRouteConnectionState); +begin + if assigned(FOnRouteStateChanged) then + FOnRouteStateChanged(self, route, state); +end; + +procedure TChromiumCore.doOnRouteMessageReceived(const route : ICefMediaRoute; + const message_ : ustring); +begin + if assigned(FOnRouteMessageReceived) then + FOnRouteMessageReceived(self, route, message_); +end; + +procedure TChromiumCore.doOnGetAudioParameters(const browser : ICefBrowser; + var params : TCefAudioParameters; + var aResult : boolean); +begin + if assigned(FOnGetAudioParameters) then + FOnGetAudioParameters(self, browser, params, aResult); +end; + +procedure TChromiumCore.doOnAudioStreamStarted(const browser : ICefBrowser; + const params : TCefAudioParameters; + channels : integer); +begin + if assigned(FOnAudioStreamStarted) then + FOnAudioStreamStarted(self, browser, params, channels); +end; + +procedure TChromiumCore.doOnAudioStreamPacket(const browser : ICefBrowser; + const data : PPSingle; + frames : integer; + pts : int64); +begin + if assigned(FOnAudioStreamPacket) then + FOnAudioStreamPacket(self, browser, data, frames, pts); +end; + +procedure TChromiumCore.doOnAudioStreamStopped(const browser: ICefBrowser); +begin + if assigned(FOnAudioStreamStopped) then + FOnAudioStreamStopped(self, browser); +end; + +procedure TChromiumCore.doOnAudioStreamError(const browser : ICefBrowser; + const message_ : ustring); +begin + if assigned(FOnAudioStreamError) then + FOnAudioStreamError(self, browser, message_); +end; + +// ICefDevToolsMessageObserver +procedure TChromiumCore.doOnDevToolsMessage(const browser : ICefBrowser; + const message_ : Pointer; + message_size : NativeUInt; + var aHandled : boolean); +var + TempValue : ICefValue; +begin + if assigned(FOnDevToolsRawMessage) then + FOnDevToolsRawMessage(self, browser, message_, message_size, aHandled) + else + if assigned(FOnDevToolsMessage) then + try + TempValue := TCEFJson.Parse(message_, message_size); + FOnDevToolsMessage(self, browser, TempValue, aHandled); + finally + TempValue := nil; + end; +end; + +procedure TChromiumCore.doOnDevToolsMethodResult(const browser : ICefBrowser; + message_id : integer; + success : boolean; + const result : Pointer; + result_size : NativeUInt); +var + TempValue : ICefValue; +begin + if assigned(FOnDevToolsMethodRawResult) then + FOnDevToolsMethodRawResult(self, browser, message_id, success, result, result_size) + else + if assigned(FOnDevToolsMethodResult) then + try + TempValue := TCEFJson.Parse(result, result_size); + FOnDevToolsMethodResult(self, browser, message_id, success, TempValue); + finally + TempValue := nil; + end; +end; + +procedure TChromiumCore.doOnDevToolsEvent(const browser : ICefBrowser; + const method : ustring; + const params : Pointer; + params_size : NativeUInt); +var + TempValue : ICefValue; +begin + if assigned(FOnDevToolsRawEvent) then + FOnDevToolsRawEvent(self, browser, method, params, params_size) + else + if assigned(FOnDevToolsEvent) then + try + TempValue := TCEFJson.Parse(params, params_size); + FOnDevToolsEvent(self, browser, method, TempValue); + finally + TempValue := nil; + end; +end; + +procedure TChromiumCore.doOnDevToolsAgentAttached(const browser: ICefBrowser); +begin + if assigned(FOnDevToolsAgentAttached) then + FOnDevToolsAgentAttached(self, browser); +end; + +procedure TChromiumCore.doOnDevToolsAgentDetached(const browser: ICefBrowser); +begin + if assigned(FOnDevToolsAgentDetached) then + FOnDevToolsAgentDetached(self, browser); +end; + +procedure TChromiumCore.doOnExtensionLoadFailed(result: TCefErrorcode); +begin + if assigned(FOnExtensionLoadFailed) then + FOnExtensionLoadFailed(self, result); +end; + +procedure TChromiumCore.doOnExtensionLoaded(const extension: ICefExtension); +begin + if assigned(FOnExtensionLoaded) then + FOnExtensionLoaded(self, extension); +end; + +procedure TChromiumCore.doOnExtensionUnloaded(const extension: ICefExtension); +begin + if assigned(FOnExtensionUnloaded) then + FOnExtensionUnloaded(self, extension); +end; + +function TChromiumCore.doOnExtensionBeforeBackgroundBrowser(const extension : ICefExtension; + const url : ustring; + var client : ICefClient; + var settings : TCefBrowserSettings) : boolean; +begin + Result := False; + + if assigned(FOnExtensionBeforeBackgroundBrowser) then + FOnExtensionBeforeBackgroundBrowser(self, extension, url, client, settings, Result); +end; + +function TChromiumCore.doOnExtensionBeforeBrowser(const extension : ICefExtension; + const browser : ICefBrowser; + const active_browser : ICefBrowser; + index : Integer; + const url : ustring; + active : boolean; + var windowInfo : TCefWindowInfo; + var client : ICefClient; + var settings : TCefBrowserSettings) : boolean; +begin + Result := False; + + if assigned(FOnExtensionBeforeBrowser) then + FOnExtensionBeforeBrowser(self, extension, browser, active_browser, index, url, + active, windowInfo, client, settings, Result); +end; + +procedure TChromiumCore.doOnExtensionGetActiveBrowser(const extension : ICefExtension; + const browser : ICefBrowser; + include_incognito : boolean; + var aRsltBrowser : ICefBrowser); +begin + aRsltBrowser := nil; + + if assigned(FOnExtensionGetActiveBrowser) then + FOnExtensionGetActiveBrowser(self, extension, browser, include_incognito, aRsltBrowser); +end; + +function TChromiumCore.doOnExtensionCanAccessBrowser(const extension : ICefExtension; + const browser : ICefBrowser; + include_incognito : boolean; + const target_browser : ICefBrowser): boolean; +begin + Result := False; + + if assigned(FOnExtensionCanAccessBrowser) then + FOnExtensionCanAccessBrowser(self, extension, browser, include_incognito, target_browser, Result); +end; + +function TChromiumCore.doOnExtensionGetExtensionResource(const extension : ICefExtension; + const browser : ICefBrowser; + const file_ : ustring; + const callback : ICefGetExtensionResourceCallback): boolean; +begin + Result := False; + + if assigned(FOnExtensionGetExtensionResource) then + FOnExtensionGetExtensionResource(self, extension, browser, file_, callback, Result); +end; + +procedure TChromiumCore.doOnFullScreenModeChange(const browser : ICefBrowser; + fullscreen : Boolean); +begin + if assigned(FOnFullScreenModeChange) then + FOnFullScreenModeChange(Self, browser, fullscreen); +end; + +function TChromiumCore.doOnGetAuthCredentials(const browser : ICefBrowser; + const originUrl : ustring; + isProxy : Boolean; + const host : ustring; + port : Integer; + const realm : ustring; + const scheme : ustring; + const callback : ICefAuthCallback): Boolean; +begin + Result := False; + + if isProxy and (FProxyType = CEF_PROXYTYPE_FIXED_SERVERS) and (callback <> nil) then + begin + Result := True; + callback.cont(FProxyUsername, FProxyPassword); + end + else + if assigned(FOnGetAuthCredentials) then + FOnGetAuthCredentials(Self, browser, originUrl, isProxy, host, port, realm, scheme, callback, Result); +end; + +function TChromiumCore.doCanSendCookie(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const cookie : PCefCookie): boolean; +begin + Result := True; + + if assigned(FOnCanSendCookie) then + FOnCanSendCookie(self, browser, frame, request, cookie, Result); +end; + +function TChromiumCore.doCanSaveCookie(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + const cookie : PCefCookie): boolean; +begin + Result := True; + + if assigned(FOnCanSaveCookie) then + FOnCanSaveCookie(self, browser, frame, request, response, cookie, Result); +end; + +procedure TChromiumCore.doOnGetResourceHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var aResourceHandler : ICefResourceHandler); +begin + aResourceHandler := nil; + + if assigned(FOnGetResourceHandler) then + FOnGetResourceHandler(Self, browser, frame, request, aResourceHandler); +end; + +procedure TChromiumCore.doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); +begin + if assigned(FOnGetAccessibilityHandler) then + FOnGetAccessibilityHandler(Self, aAccessibilityHandler); +end; + +function TChromiumCore.doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; +begin + Result := False; + + if assigned(FOnGetRootScreenRect) then + FOnGetRootScreenRect(Self, browser, rect, Result); +end; + +function TChromiumCore.doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; +begin + Result := False; + + if assigned(FOnGetScreenInfo) then + FOnGetScreenInfo(Self, browser, screenInfo, Result); +end; + +function TChromiumCore.doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; +begin + Result := False; + + if assigned(FOnGetScreenPoint) then + FOnGetScreenPoint(Self, browser, viewX, viewY, screenX, screenY, Result); +end; + +procedure TChromiumCore.doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect); +begin + if assigned(FOnGetViewRect) then + FOnGetViewRect(Self, browser, rect); +end; + +procedure TChromiumCore.doOnGotFocus(const browser: ICefBrowser); +begin + if assigned(FOnGotFocus) then + FOnGotFocus(Self, browser) +end; + +function TChromiumCore.doOnJsdialog(const browser : ICefBrowser; + const originUrl : ustring; + dialogType : TCefJsDialogType; + const messageText : ustring; + const defaultPromptText : ustring; + const callback : ICefJsDialogCallback; + out suppressMessage : Boolean): Boolean; +begin + Result := False; + + if not(Initialized) then + suppressMessage := True + else + begin + suppressMessage := False; + + if assigned(FOnJsdialog) then + FOnJsdialog(Self, browser, originUrl, dialogType, messageText, + defaultPromptText, callback, suppressMessage, Result); + end; +end; + +function TChromiumCore.doOnKeyEvent(const browser : ICefBrowser; + const event : PCefKeyEvent; + osEvent : TCefEventHandle): Boolean; +begin + Result := False; + + if assigned(FOnKeyEvent) then + FOnKeyEvent(Self, browser, event, osEvent, Result); +end; + +procedure TChromiumCore.doOnLoadEnd(const browser : ICefBrowser; + const frame : ICefFrame; + httpStatusCode : Integer); +begin + if assigned(FOnLoadEnd) then + FOnLoadEnd(Self, browser, frame, httpStatusCode); +end; + +procedure TChromiumCore.doOnLoadError(const browser : ICefBrowser; + const frame : ICefFrame; + errorCode : TCefErrorCode; + const errorText : ustring; + const failedUrl : ustring); +begin + if assigned(FOnLoadError) then + FOnLoadError(Self, browser, frame, errorCode, errorText, failedUrl); +end; + +procedure TChromiumCore.doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); +begin + if assigned(FOnLoadingStateChange) then + FOnLoadingStateChange(Self, browser, isLoading, canGoBack, canGoForward); +end; + +procedure TChromiumCore.doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); +begin + if assigned(FOnLoadStart) then + FOnLoadStart(Self, browser, frame, transitionType); +end; + +function TChromiumCore.doOnOpenUrlFromTab(const browser : ICefBrowser; + const frame : ICefFrame; + const targetUrl : ustring; + targetDisposition : TCefWindowOpenDisposition; + userGesture : Boolean): Boolean; +begin + Result := False; + + if assigned(FOnOpenUrlFromTab) then + FOnOpenUrlFromTab(Self, browser, frame, targetUrl, targetDisposition, userGesture, Result); +end; + +procedure TChromiumCore.doGetResourceRequestHandler_ReqHdlr(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + is_navigation : boolean; + is_download : boolean; + const request_initiator : ustring; + var disable_default_handling : boolean; + var aResourceRequestHandler : ICefResourceRequestHandler); +begin + if (FResourceRequestHandler <> nil) then + aResourceRequestHandler := FResourceRequestHandler; + + if assigned(FOnGetResourceRequestHandler_ReqHdlr) then + FOnGetResourceRequestHandler_ReqHdlr(self, browser, frame, request, is_navigation, is_download, + request_initiator, disable_default_handling, + aResourceRequestHandler); +end; + +procedure TChromiumCore.doOnPaint(const browser : ICefBrowser; + type_ : TCefPaintElementType; + dirtyRectsCount : NativeUInt; + const dirtyRects : PCefRectArray; + const buffer : Pointer; + width : Integer; + height : Integer); +begin + if assigned(FOnPaint) then + FOnPaint(Self, browser, type_, dirtyRectsCount, dirtyRects, buffer, width, height); +end; + +procedure TChromiumCore.doOnAcceleratedPaint(const browser : ICefBrowser; + type_ : TCefPaintElementType; + dirtyRectsCount : NativeUInt; + const dirtyRects : PCefRectArray; + shared_handle : Pointer); +begin + if assigned(FOnAcceleratedPaint) then + FOnAcceleratedPaint(Self, browser, type_, dirtyRectsCount, dirtyRects, shared_handle); +end; + +function TChromiumCore.doOnSelectClientCertificate(const browser : ICefBrowser; + isProxy : boolean; + const host : ustring; + port : integer; + certificatesCount : NativeUInt; + const certificates : TCefX509CertificateArray; + const callback : ICefSelectClientCertificateCallback): boolean; +begin + Result := False; + + if assigned(FOnSelectClientCertificate) then + FOnSelectClientCertificate(self, browser, isProxy, host, port, certificatesCount, certificates, callback, Result); +end; + +procedure TChromiumCore.doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); +begin + if assigned(FOnPluginCrashed) then + FOnPluginCrashed(Self, browser, pluginPath); +end; + +procedure TChromiumCore.doOnPopupShow(const browser: ICefBrowser; show: Boolean); +begin + if assigned(FOnPopupShow) then + FOnPopupShow(self, browser, show); +end; + +procedure TChromiumCore.doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); +begin + if assigned(FOnPopupSize) then + FOnPopupSize(self, browser, rect); +end; + +function TChromiumCore.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 TChromiumCore.doOnProcessMessageReceived(const browser : ICefBrowser; + const frame : ICefFrame; + sourceProcess : TCefProcessId; + const aMessage : ICefProcessMessage): Boolean; +begin + Result := False; + + if assigned(FOnProcessMessageReceived) then + FOnProcessMessageReceived(Self, browser, frame, sourceProcess, aMessage, Result); +end; + +procedure TChromiumCore.doOnProtocolExecution(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var allowOsExecution : Boolean); +begin + if assigned(FOnProtocolExecution) then + FOnProtocolExecution(Self, browser, frame, request, allowOsExecution); +end; + +function TChromiumCore.doOnQuotaRequest(const browser : ICefBrowser; + const originUrl : ustring; + newSize : Int64; + const callback : ICefRequestCallback): Boolean; +begin + Result := False; + + if assigned(FOnQuotaRequest) then + FOnQuotaRequest(Self, browser, originUrl, newSize, callback, Result); +end; + +procedure TChromiumCore.doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); +begin + if assigned(FOnRenderProcessTerminated) then + FOnRenderProcessTerminated(Self, browser, status); +end; + +procedure TChromiumCore.doOnDocumentAvailableInMainFrame(const browser: ICefBrowser); +begin + if assigned(FOnDocumentAvailableInMainFrame) then + FOnDocumentAvailableInMainFrame(Self, browser); +end; + +{$IFDEF MSWINDOWS} +function EnumProcOSRChromeWidgetWin0(hWnd: HWND; lParam: LPARAM): BOOL; stdcall; +var + ClsName: array[0..256] of Char; +begin + ClsName[GetClassName(hWnd, ClsName, 256)] := #0; + if StrComp(ClsName, 'Chrome_WidgetWin_0') = 0 then + begin + PHandle(lParam)^ := hWnd; + Result := False; + end + else + Result := True; +end; +{$ENDIF MSWINDOWS} + +procedure TChromiumCore.doOnRenderViewReady(const browser: ICefBrowser); +{$IFDEF MSWINDOWS} +var + OldBrowserCompHWND, OldWidgetCompHWND, OldRenderCompHWND: THandle; +{$ENDIF} +begin + if (browser <> nil) and + (browser.Host <> nil) and + (browser.Identifier = BrowserId) then + begin + {$IFDEF MSWINDOWS} + OldBrowserCompHWND := FBrowserCompHWND; + OldWidgetCompHWND := FWidgetCompHWND; + OldRenderCompHWND := FRenderCompHWND; + FBrowserCompHWND := browser.Host.WindowHandle; + + if (FBrowserCompHWND <> 0) then + begin + FWidgetCompHWND := FindWindowEx(FBrowserCompHWND, 0, 'Chrome_WidgetWin_0', ''); + + if (FWidgetCompHWND = 0) and FIsOSR and CefCurrentlyOn(TID_UI) then + begin + // The WidgetCompHWND window doesn't have a HwndParent (Owner). If we are in OSR mode this + // causes popup menus that are opened by CEF to stay open if the user clicks somewhere else. + // With this code we search for the Widget window in the UI Thread's window list and set + // the Browser window as its HwndParent. This works around the bug. + EnumThreadWindows(GetCurrentThreadId, @EnumProcOSRChromeWidgetWin0, NativeInt(@FWidgetCompHWND)); + + if (FWidgetCompHWND <> 0) then + SetWindowLongPtr(FWidgetCompHWND, GWLP_HWNDPARENT, NativeInt(FBrowserCompHWND)); + end; + end; + + if (FWidgetCompHWND <> 0) then + FRenderCompHWND := FindWindowEx(FWidgetCompHWND, 0, 'Chrome_RenderWidgetHostHWND', 'Chrome Legacy Window'); + + RestoreCompWndProc(OldBrowserCompHWND, FBrowserCompHWND, FOldBrowserCompWndPrc); + if assigned(FOnBrowserCompMsg) and (FBrowserCompHWND <> 0) and (FOldBrowserCompWndPrc = nil) then + begin + CreateStub({$IFDEF FPC}@{$ENDIF}BrowserCompWndProc, FBrowserCompStub); + FOldBrowserCompWndPrc := InstallCompWndProc(FBrowserCompHWND, FBrowserCompStub); + end; + + RestoreCompWndProc(OldWidgetCompHWND, FWidgetCompHWND, FOldWidgetCompWndPrc); + if assigned(FOnWidgetCompMsg) and (FWidgetCompHWND <> 0) and (FOldWidgetCompWndPrc = nil) then + begin + CreateStub({$IFDEF FPC}@{$ENDIF}WidgetCompWndProc, FWidgetCompStub); + FOldWidgetCompWndPrc := InstallCompWndProc(FWidgetCompHWND, FWidgetCompStub); + end; + + RestoreCompWndProc(OldRenderCompHWND, FRenderCompHWND, FOldRenderCompWndPrc); + if assigned(FOnRenderCompMsg) and (FRenderCompHWND <> 0) and (FOldRenderCompWndPrc = nil) then + begin + CreateStub({$IFDEF FPC}@{$ENDIF}RenderCompWndProc, FRenderCompStub); + FOldRenderCompWndPrc := InstallCompWndProc(FRenderCompHWND, FRenderCompStub); + end; + {$ENDIF} + end; + + if assigned(FOnRenderViewReady) then + FOnRenderViewReady(Self, browser); +end; + +procedure TChromiumCore.doOnResetDialogState(const browser: ICefBrowser); +begin + if assigned(FOnResetDialogState) then + FOnResetDialogState(Self, browser); +end; + +procedure TChromiumCore.doOnResourceRedirect(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + var newUrl : ustring); +begin + if assigned(FOnResourceRedirect) then + FOnResourceRedirect(Self, browser, frame, request, response, newUrl); +end; + +function TChromiumCore.doOnResourceResponse(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse): Boolean; +begin + Result := False; + + if assigned(FOnResourceResponse) then + FOnResourceResponse(Self, browser, frame, request, response, Result); +end; + +procedure TChromiumCore.doOnGetResourceResponseFilter(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + var aResponseFilter : ICefResponseFilter); +begin + aResponseFilter := nil; + + if assigned(FOnGetResourceResponseFilter) then + FOnGetResourceResponseFilter(self, browser, frame, request, response, aResponseFilter); +end; + +procedure TChromiumCore.doOnResourceLoadComplete(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + status : TCefUrlRequestStatus; + receivedContentLength : Int64); +begin + if assigned(FOnResourceLoadComplete) then + FOnResourceLoadComplete(self, browser, frame, request, response, status, receivedContentLength); +end; + +procedure TChromiumCore.doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); +begin + if assigned(FOnScrollOffsetChanged) then + FOnScrollOffsetChanged(Self, browser, x, y); +end; + +procedure TChromiumCore.doOnIMECompositionRangeChanged(const browser : ICefBrowser; + const selected_range : PCefRange; + character_boundsCount : NativeUInt; + const character_bounds : PCefRect); +begin + if assigned(FOnIMECompositionRangeChanged) then + FOnIMECompositionRangeChanged(self, browser, selected_range, character_boundsCount, character_bounds); +end; + +procedure TChromiumCore.doOnTextSelectionChanged(const browser : ICefBrowser; + const selected_text : ustring; + const selected_range : PCefRange); +begin + if assigned(FOnTextSelectionChanged) then + FOnTextSelectionChanged(self, browser, selected_text, selected_range); +end; + +procedure TChromiumCore.doOnVirtualKeyboardRequested(const browser : ICefBrowser; + input_mode : TCefTextInpuMode); +begin + if assigned(FOnVirtualKeyboardRequested) then + FOnVirtualKeyboardRequested(self, browser, input_mode); +end; + +function TChromiumCore.doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; +begin + Result := False; + + if assigned(FOnSetFocus) then + FOnSetFocus(Self, browser, source, Result); +end; + +function TChromiumCore.doOnStartDragging(const browser : ICefBrowser; + const dragData : ICefDragData; + allowedOps : TCefDragOperations; + x : integer; + y : Integer): Boolean; +begin + Result := False; + {$IFDEF MSWINDOWS} + if FDragAndDropInitialized and + FDragDropManager.CloneDragData(dragData, allowedOps) then + begin + Result := True; + SendCompMessage(CEF_STARTDRAGGING); + end; + + if assigned(FOnStartDragging) then + FOnStartDragging(Self, browser, dragData, allowedOps, x, y, Result); + {$ENDIF} +end; + +procedure TChromiumCore.DelayedDragging; +{$IFDEF MSWINDOWS} +var + TempOperation : TCefDragOperation; + TempPoint : TPoint; +{$ENDIF} +begin + {$IFDEF MSWINDOWS} + if FDragAndDropInitialized and (FDropTargetWnd <> 0) and (GlobalCEFApp <> nil) then + begin + FDragOperations := DRAG_OPERATION_NONE; + TempOperation := FDragDropManager.StartDragging; + FDragOperations := DRAG_OPERATION_NONE; + + GetCursorPos(TempPoint); + MapWindowPoints(0, FDropTargetWnd, TempPoint, 1); + DeviceToLogical(TempPoint, GlobalCEFApp.DeviceScaleFactor); + + DragSourceEndedAt(TempPoint.x, TempPoint.y, TempOperation); + DragSourceSystemDragEnded; + end; + {$ENDIF} +end; + +procedure TChromiumCore.doOnStatusMessage(const browser: ICefBrowser; const value: ustring); +begin + if assigned(FOnStatusMessage) then + FOnStatusMessage(Self, browser, value); +end; + +procedure TChromiumCore.doOnTakeFocus(const browser: ICefBrowser; next: Boolean); +begin + if assigned(FOnTakeFocus) then + FOnTakeFocus(Self, browser, next); +end; + +procedure TChromiumCore.doOnTitleChange(const browser: ICefBrowser; const title: ustring); +begin + if assigned(FOnTitleChange) then + FOnTitleChange(Self, browser, title); +end; + +function TChromiumCore.doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; +begin + Result := False; + + if assigned(FOnTooltip) then + FOnTooltip(Self, browser, text, Result); +end; + +procedure TChromiumCore.doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); +begin + if FDragAndDropInitialized then FDragOperations := operation; + + if assigned(FOnUpdateDragCursor) then + FOnUpdateDragCursor(Self, browser, operation); +end; + +procedure TChromiumCore.WasResized; +begin + if Initialized then + Browser.Host.WasResized; +end; + +procedure TChromiumCore.WasHidden(hidden: Boolean); +begin + if Initialized then + Browser.Host.WasHidden(hidden); +end; + +procedure TChromiumCore.NotifyScreenInfoChanged; +begin + if Initialized then + Browser.Host.NotifyScreenInfoChanged; +end; + +procedure TChromiumCore.NotifyMoveOrResizeStarted; +begin + if Initialized then + Browser.Host.NotifyMoveOrResizeStarted; +end; + +procedure TChromiumCore.Invalidate(type_: TCefPaintElementType); +begin + if Initialized then + begin + if FIsOSR then + Browser.Host.Invalidate(type_) + {$IFDEF MSWINDOWS} + else + if (RenderHandle <> 0) then + InvalidateRect(RenderHandle, nil, False) + else + InvalidateRect(WindowHandle, nil, False); + {$ENDIF} + end; +end; + +procedure TChromiumCore.SendExternalBeginFrame; +begin + if Initialized then + Browser.Host.SendExternalBeginFrame; +end; + +procedure TChromiumCore.SendKeyEvent(const event: PCefKeyEvent); +begin + if Initialized then + Browser.Host.SendKeyEvent(event); +end; + +procedure TChromiumCore.SendMouseClickEvent(const event : PCefMouseEvent; + type_ : TCefMouseButtonType; + mouseUp : Boolean; + clickCount : Integer); +begin + if Initialized then + Browser.Host.SendMouseClickEvent(event, type_, mouseUp, clickCount); +end; + +procedure TChromiumCore.SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); +begin + if Initialized then + Browser.Host.SendMouseMoveEvent(event, mouseLeave); +end; + +procedure TChromiumCore.SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); +begin + if Initialized then + Browser.Host.SendMouseWheelEvent(event, deltaX, deltaY); +end; + +procedure TChromiumCore.SendTouchEvent(const event: PCefTouchEvent); +begin + if Initialized then + Browser.Host.SendTouchEvent(event); +end; + +procedure TChromiumCore.SendFocusEvent(setFocus: Boolean); +begin + if Initialized then + Browser.Host.SendFocusEvent(setFocus); +end; + +procedure TChromiumCore.SendCaptureLostEvent; +{$IFDEF LINUX}{$IFDEF FPC} +var + TempXDisplay : PXDisplay; +{$ENDIF}{$ENDIF} +begin + if not(Initialized) then exit; + + {$IFDEF LINUX}{$IFDEF FPC} + TempXDisplay := XDisplay; + + if (TempXDisplay <> nil) then + XSetInputFocus(TempXDisplay, X.None, RevertToNone, CurrentTime); + {$ENDIF}{$ENDIF} + + Browser.Host.SendCaptureLostEvent; +end; + +procedure TChromiumCore.SetFocus(focus: Boolean); +begin + if Initialized then + Browser.Host.SetFocus(focus); +end; + +procedure TChromiumCore.SetAccessibilityState(accessibilityState: TCefState); +begin + if Initialized then + Browser.Host.SetAccessibilityState(accessibilityState); +end; + +procedure TChromiumCore.SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage; const aFrameName : ustring); +var + TempFrame : ICefFrame; +begin + try + if Initialized then + begin + if (length(aFrameName) > 0) then + TempFrame := Browser.GetFrame(aFrameName) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + TempFrame.SendProcessMessage(targetProcess, ProcMessage); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.SendProcessMessage', e) then raise; + end; +end; + +procedure TChromiumCore.SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage; const aFrame : ICefFrame); +begin + try + if Initialized and (aFrame <> nil) and aFrame.IsValid then + aFrame.SendProcessMessage(targetProcess, ProcMessage); + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.SendProcessMessage', e) then raise; + end; +end; + +procedure TChromiumCore.SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage; const aFrameIdentifier : int64); +var + TempFrame : ICefFrame; +begin + try + if Initialized then + begin + if (aFrameIdentifier <> 0) then + TempFrame := Browser.GetFrameByident(aFrameIdentifier) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + TempFrame.SendProcessMessage(targetProcess, ProcMessage); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.SendProcessMessage', e) then raise; + end; +end; + +function TChromiumCore.CreateUrlRequest(const request: ICefRequest; const client: ICefUrlrequestClient; const aFrameName : ustring): ICefUrlRequest; +var + TempFrame : ICefFrame; +begin + Result := nil; + + try + if Initialized then + begin + if (length(aFrameName) > 0) then + TempFrame := Browser.GetFrame(aFrameName) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + Result := TempFrame.CreateUrlRequest(request, client); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.CreateUrlRequest', e) then raise; + end; +end; + +function TChromiumCore.CreateUrlRequest(const request: ICefRequest; const client: ICefUrlrequestClient; const aFrame : ICefFrame): ICefUrlRequest; +begin + Result := nil; + + try + if Initialized and (aFrame <> nil) and aFrame.IsValid then + Result := aFrame.CreateUrlRequest(request, client); + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.CreateUrlRequest', e) then raise; + end; +end; + +function TChromiumCore.CreateUrlRequest(const request: ICefRequest; const client: ICefUrlrequestClient; const aFrameIdentifier : int64): ICefUrlRequest; +var + TempFrame : ICefFrame; +begin + Result := nil; + + try + if Initialized then + begin + if (aFrameIdentifier <> 0) then + TempFrame := Browser.GetFrameByident(aFrameIdentifier) + else + TempFrame := Browser.MainFrame; + + if (TempFrame <> nil) and TempFrame.IsValid then + Result := TempFrame.CreateUrlRequest(request, client); + end; + except + on e : exception do + if CustomExceptionHandler('TChromiumCore.CreateUrlRequest', e) then raise; + end; +end; + +procedure TChromiumCore.DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); +begin + if Initialized then + Browser.Host.DragTargetDragEnter(dragData, event, allowedOps); +end; + +procedure TChromiumCore.DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); +begin + if Initialized then + Browser.Host.DragTargetDragOver(event, allowedOps); +end; + +procedure TChromiumCore.DragTargetDragLeave; +begin + if Initialized then + Browser.Host.DragTargetDragLeave; +end; + +procedure TChromiumCore.DragTargetDrop(const event: PCefMouseEvent); +begin + if Initialized then + Browser.Host.DragTargetDrop(event); +end; + +procedure TChromiumCore.DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); +begin + if Initialized then + Browser.Host.DragSourceEndedAt(x, y, op); +end; + +procedure TChromiumCore.DragSourceSystemDragEnded; +begin + if Initialized then + Browser.Host.DragSourceSystemDragEnded; +end; + +procedure TChromiumCore.IMESetComposition(const text : ustring; + const underlines : TCefCompositionUnderlineDynArray; + const replacement_range : PCefRange; + const selection_range : PCefRange); +begin + if Initialized then + Browser.Host.IMESetComposition(text, underlines, replacement_range, selection_range); +end; + +procedure TChromiumCore.IMECommitText(const text : ustring; + const replacement_range : PCefRange; + relative_cursor_pos : integer); +begin + if Initialized then + Browser.Host.IMECommitText(text, replacement_range, relative_cursor_pos); +end; + +procedure TChromiumCore.IMEFinishComposingText(keep_selection : boolean); +begin + if Initialized then + Browser.Host.IMEFinishComposingText(keep_selection); +end; + +procedure TChromiumCore.IMECancelComposition; +begin + if Initialized then + Browser.Host.IMECancelComposition; +end; + +procedure TChromiumCore.ReplaceMisspelling(const aWord : ustring); +begin + if Initialized then + Browser.Host.ReplaceMisspelling(aWord); +end; + +procedure TChromiumCore.AddWordToDictionary(const aWord : ustring); +begin + if Initialized then + Browser.Host.AddWordToDictionary(aWord); +end; + +// ICefMediaRouter methods +function TChromiumCore.AddObserver(const observer: ICefMediaObserver): ICefRegistration; +var + TempMediaRouter : ICefMediaRouter; +begin + Result := nil; + TempMediaRouter := MediaRouter; + + if (TempMediaRouter <> nil) then + Result := TempMediaRouter.AddObserver(observer); +end; + +function TChromiumCore.GetSource(const urn: ustring): ICefMediaSource; +var + TempMediaRouter : ICefMediaRouter; +begin + Result := nil; + TempMediaRouter := MediaRouter; + + if (TempMediaRouter <> nil) then + Result := TempMediaRouter.GetSource(urn); +end; + +procedure TChromiumCore.NotifyCurrentSinks; +var + TempMediaRouter : ICefMediaRouter; +begin + TempMediaRouter := MediaRouter; + + if (TempMediaRouter <> nil) then + TempMediaRouter.NotifyCurrentSinks; +end; + +procedure TChromiumCore.NotifyCurrentRoutes; +var + TempMediaRouter : ICefMediaRouter; +begin + TempMediaRouter := MediaRouter; + + if (TempMediaRouter <> nil) then + TempMediaRouter.NotifyCurrentRoutes; +end; + +// This procedure is asynchronous and the result, ICefMediaRoute and the error +// message will be available in the TChromium.OnMediaRouteCreateFinished event. +procedure TChromiumCore.CreateRoute(const source: ICefMediaSource; const sink: ICefMediaSink); +var + TempMediaRouter : ICefMediaRouter; + TempCallback : ICefMediaRouteCreateCallback; +begin + TempMediaRouter := MediaRouter; + + if (TempMediaRouter <> nil) then + try + TempCallback := TCefCustomMediaRouteCreateCallback.Create(self); + TempMediaRouter.CreateRoute(source, sink, TempCallback); + finally + TempCallback := nil; + end; +end; + +procedure TChromiumCore.GetDeviceInfo(const aMediaSink: ICefMediaSink); +var + TempCallback : ICefMediaSinkDeviceInfoCallback; +begin + if (aMediaSink <> nil) then + try + TempCallback := TCefCustomMediaSinkDeviceInfoCallback.Create(self); + aMediaSink.GetDeviceInfo(TempCallback); + finally + TempCallback := nil; + end; +end; + +function TChromiumCore.LoadExtension(const root_directory : ustring; + const manifest : ICefDictionaryValue; + const handler : ICefExtensionHandler; + const requestContext : ICefRequestContext) : boolean; +var + TempContext : ICefRequestContext; + TempHandler : ICefExtensionHandler; +begin + Result := False; + + // The global context must be initalized to load extensions + // This TChromium must not be initialized before loading an extension. + if (GlobalCEFApp = nil) or + not(GlobalCEFApp.GlobalContextInitialized) or + Initialized then + exit; + + // We use a custom request context if available or the global request context if not. + if (requestContext <> nil) then + TempContext := requestContext + else + TempContext := TCefRequestContextRef.Global; + + if (handler <> nil) then + TempHandler := handler + else + begin + // All TChromium events must be assigned before calling LoadExtension. + CreateExtensionHandler; + TempHandler := FExtensionHandler; + end; + + if (TempContext <> nil) then + try + TempContext.LoadExtension(root_directory, manifest, TempHandler); + Result := True; + finally + TempHandler := nil; + end; +end; + +function TChromiumCore.DidLoadExtension(const extension_id: ustring): boolean; +var + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + Result := (TempContext <> nil) and + TempContext.DidLoadExtension(extension_id); + end; +end; + +function TChromiumCore.HasExtension(const extension_id: ustring): boolean; +var + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + Result := (TempContext <> nil) and + TempContext.HasExtension(extension_id); + end; +end; + +function TChromiumCore.GetExtensions(const extension_ids: TStringList): boolean; +var + TempContext : ICefRequestContext; +begin + Result := False; + + if Initialized and (extension_ids <> nil) then + begin + TempContext := Browser.Host.RequestContext; + Result := (TempContext <> nil) and + TempContext.GetExtensions(extension_ids); + end; +end; + +function TChromiumCore.GetExtension(const extension_id: ustring): ICefExtension; +var + TempContext : ICefRequestContext; +begin + Result := nil; + + if Initialized then + begin + TempContext := Browser.Host.RequestContext; + + if (TempContext <> nil) then + Result := TempContext.GetExtension(extension_id); + end; +end; + +{$IFDEF MSWINDOWS} +function TChromiumCore.CopyDCToBitmapStream(aSrcDC : HDC; const aSrcRect : TRect; var aStream : TStream) : boolean; +var + TempDstDC : HDC; + TempWidth : Integer; + TempHeight : Integer; + TempInfo : TBitmapInfo; + TempBits : Pointer; + TempNewBitmap : HBITMAP; + TempOldBitmap : HBITMAP; + TempHeader : TBitmapFileHeader; +begin + Result := False; + if (aSrcDC = 0) or (aStream = nil) then exit; + + TempDstDC := CreateCompatibleDC(aSrcDC); + if (TempDstDC = 0) then exit; + + TempWidth := aSrcRect.Right - aSrcRect.Left; + TempHeight := aSrcRect.Bottom - aSrcRect.Top; + TempBits := nil; + + if (TempWidth > 0) and (TempHeight > 0) then + begin + ZeroMemory(@TempInfo, SizeOf(TBitmapInfo)); + ZeroMemory(@TempHeader, SizeOf(TBitmapFileHeader)); + + TempInfo.bmiHeader.biSize := SizeOf(TBitmapInfoHeader); + TempInfo.bmiHeader.biWidth := TempWidth; + TempInfo.bmiHeader.biHeight := TempHeight; + TempInfo.bmiHeader.biPlanes := 1; + TempInfo.bmiHeader.biBitCount := 32; + TempInfo.bmiHeader.biCompression := BI_RGB; + TempInfo.bmiHeader.biSizeImage := TempWidth * TempHeight * SizeOf(TRGBQuad); + + TempNewBitmap := CreateDIBSection(TempDstDC, TempInfo, DIB_RGB_COLORS, TempBits, 0, 0); + + if (TempNewBitmap <> 0) then + try + TempOldBitmap := SelectObject(TempDstDC, TempNewBitmap); + + if BitBlt(TempDstDC, 0, 0, TempWidth, TempHeight, aSrcDC, aSrcRect.Left, aSrcRect.Top, SRCCOPY) then + begin + TempHeader.bfType := $4D42; // "BM" bitmap header + TempHeader.bfOffBits := sizeof(TBitmapFileHeader) + TempInfo.bmiHeader.biSize + TempInfo.bmiHeader.biClrUsed * SizeOf(TRGBQuad); + TempHeader.bfSize := TempHeader.bfOffBits + TempInfo.bmiHeader.biSizeImage; + + aStream.position := 0; + + aStream.Write(TempHeader, SizeOf(TBitmapFileHeader)); + aStream.Write(TempInfo.bmiHeader, SizeOf(TBitmapInfoHeader)); + aStream.Write(TempBits^, TempInfo.bmiHeader.biSizeImage); + + aStream.position := 0; + Result := True; + end; + + SelectObject(TempDstDC, TempOldBitmap); + finally + DeleteObject(TempNewBitmap); + end; + end; + + ReleaseDC(0, TempDstDC); +end; +{$ENDIF} + + +// ****************************************** +// ************** TBrowserInfo ************** +// ****************************************** + +constructor TBrowserInfo.Create(const aBrowser : ICefBrowser); +begin + inherited Create; + + FBrowser := aBrowser; + FID := aBrowser.Identifier; + FIsClosing := False; +end; + +destructor TBrowserInfo.Destroy; +begin + FBrowser := nil; + + inherited Destroy; +end; + + +// ****************************************** +// *********** TBrowserInfoList ************* +// ****************************************** + +destructor TBrowserInfoList.Destroy; +begin + FreeAndClearAllItems; + + inherited Destroy; +end; + +function TBrowserInfoList.AddBrowser(const aBrowser : ICefBrowser) : boolean; +var + i : integer; + TempInfo : TBrowserInfo; +begin + Result := False; + + if (aBrowser <> nil) then + begin + i := SearchBrowser(aBrowser.Identifier); + + if (i < 0) then + begin + TempInfo := TBrowserInfo.Create(aBrowser); + + if (Add(TempInfo) >= 0) then + Result := True + else + TempInfo.Free; + end; + end; +end; + +function TBrowserInfoList.RemoveBrowser(const aBrowser : ICefBrowser) : boolean; +var + i : integer; +begin + Result := False; + + if (aBrowser <> nil) then + begin + i := SearchBrowser(aBrowser.Identifier); + + if (i >= 0) then + begin + TBrowserInfo(Items[i]).Free; + Delete(i); + Result := True; + end; + end; +end; + +function TBrowserInfoList.SearchBrowser(aID : integer) : integer; +var + i : integer; +begin + i := 0; + + while (i < Count) do + if (TBrowserInfo(Items[i]).ID = aID) then + begin + Result := i; + exit; + end + else + inc(i); + + Result := -1; +end; + +procedure TBrowserInfoList.SetBrowserIsClosing(aID : integer; aValue : boolean); +var + i : integer; +begin + i := SearchBrowser(aID); + if (i >= 0) then TBrowserInfo(Items[i]).IsClosing := aValue; +end; + +function TBrowserInfoList.GetBrowserIsClosing(aID : integer) : boolean; +var + i : integer; +begin + i := SearchBrowser(aID); + Result := (i >= 0) and TBrowserInfo(Items[i]).IsClosing; +end; + +function TBrowserInfoList.GetBrowser(aID : integer) : ICefBrowser; +var + i : integer; +begin + i := SearchBrowser(aID); + + if (i >= 0) then + Result := TBrowserInfo(Items[i]).Browser + else + Result := nil; +end; + +function TBrowserInfoList.GetFirstBrowser : ICefBrowser; +begin + if (Count > 0) then + Result := TBrowserInfo(Items[0]).Browser + else + Result := nil; +end; + +function TBrowserInfoList.GetFirstID : integer; +begin + if (Count > 0) then + Result := TBrowserInfo(Items[0]).ID + else + Result := 0; +end; + +procedure TBrowserInfoList.FreeAndClearAllItems; +var + i : integer; +begin + i := pred(Count); + + while (i >= 0) do + begin + TBrowserInfo(Items[i]).Free; + dec(i); + end; + + Clear; +end; + +procedure TBrowserInfoList.CloseAllBrowsers; +var + i : integer; +begin + try + i := pred(Count); + while (i >= 0) do + begin + if (TBrowserInfo(Items[i]).Browser.Host <> nil) then + TBrowserInfo(Items[i]).Browser.Host.CloseBrowser(True); + + dec(i); + end; + except + on e : exception do + if CustomExceptionHandler('TBrowserInfoList.CloseAllBrowsers', e) then raise; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFChromiumEvents.pas b/windows/src/ext/cef4delphi/source/uCEFChromiumEvents.pas index 9fe9caec52b5afbf16cb1bfed75126b899ad4f31..7eceacd5df6f166a22238bd66dded23f26a17880 100644 --- a/windows/src/ext/cef4delphi/source/uCEFChromiumEvents.pas +++ b/windows/src/ext/cef4delphi/source/uCEFChromiumEvents.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFChromiumEvents; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -60,7 +58,7 @@ uses type // ICefClient - TOnProcessMessageReceived = procedure(Sender: TObject; const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage; out Result: Boolean) of object; + TOnProcessMessageReceived = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message: ICefProcessMessage; out Result: Boolean) of object; // ICefLoadHandler TOnLoadStart = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType) of object; @@ -93,6 +91,7 @@ type TOnConsoleMessage = procedure(Sender: TObject; const browser: ICefBrowser; level: TCefLogSeverity; const message, source: ustring; line: Integer; out Result: Boolean) of object; TOnAutoResize = procedure(Sender: TObject; const browser: ICefBrowser; const new_size: PCefSize; out Result: Boolean) of object; TOnLoadingProgressChange = procedure(Sender: TObject; const browser: ICefBrowser; const progress: double) of object; + TOnCursorChange = procedure(Sender: TObject; const browser: ICefBrowser; cursor_: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean) of Object; // ICefDownloadHandler TOnBeforeDownload = procedure(Sender: TObject; const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback) of object; @@ -105,30 +104,36 @@ type TOnDialogClosed = procedure(Sender: TObject; const browser: ICefBrowser) of object; // ICefLifeSpanHandler - TOnBeforePopup = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean; var Result: Boolean) of object; + TOnBeforePopup = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean) of object; TOnAfterCreated = procedure(Sender: TObject; const browser: ICefBrowser) of object; TOnBeforeClose = procedure(Sender: TObject; const browser: ICefBrowser) of object; - TOnClose = procedure(Sender: TObject; const browser: ICefBrowser; out Result: Boolean) of object; + TOnClose = procedure(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction) of object; // ICefRequestHandler TOnBeforeBrowse = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean; out Result: Boolean) of object; - TOnOpenUrlFromTab = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean) of Object; + TOnOpenUrlFromTab = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean) of object; + TOnGetAuthCredentials = procedure(Sender: TObject; const browser: ICefBrowser; const originUrl: ustring; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback; out Result: Boolean) of object; + TOnQuotaRequest = procedure(Sender: TObject; const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback; out Result: Boolean) of object; + TOnCertificateError = procedure(Sender: TObject; const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback; out Result: Boolean) of object; + TOnSelectClientCertificate = procedure(Sender: TObject; const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback; var aResult : boolean) of object; + TOnPluginCrashed = procedure(Sender: TObject; const browser: ICefBrowser; const pluginPath: ustring) of object; + TOnRenderViewReady = procedure(Sender: Tobject; const browser: ICefBrowser) of object; + TOnRenderProcessTerminated = procedure(Sender: TObject; const browser: ICefBrowser; status: TCefTerminationStatus) of object; + TOnGetResourceRequestHandler = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aExternalResourceRequestHandler : ICefResourceRequestHandler) of object; + TOnDocumentAvailableInMainFrame = procedure(Sender: Tobject; const browser: ICefBrowser) of object; + + // ICefResourceRequestHandler TOnBeforeResourceLoad = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback; out Result: TCefReturnValue) of object; - TOnGetResourceHandler = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; out Result: ICefResourceHandler) of object; + TOnGetResourceHandler = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aResourceHandler : ICefResourceHandler) of object; TOnResourceRedirect = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring) of object; TOnResourceResponse = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; out Result: Boolean) of Object; TOnGetResourceResponseFilter = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; out Result: ICefResponseFilter) of object; TOnResourceLoadComplete = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64) of object; - TOnGetAuthCredentials = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback; out Result: Boolean) of object; - TOnCanGetCookies = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aResult: boolean) of object; - TOnCanSetCookie = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie : PCefCookie; var aResult : boolean) of object; - TOnQuotaRequest = procedure(Sender: TObject; const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback; out Result: Boolean) of object; - TOnProtocolExecution = procedure(Sender: TObject; const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean) of object; - TOnCertificateError = procedure(Sender: TObject; const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback; out Result: Boolean) of Object; - TOnSelectClientCertificate = procedure(Sender: TObject; const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback; var aResult : boolean) of object; - TOnPluginCrashed = procedure(Sender: TObject; const browser: ICefBrowser; const pluginPath: ustring) of object; - TOnRenderViewReady = procedure(Sender: Tobject; const browser: ICefBrowser) of Object; - TOnRenderProcessTerminated = procedure(Sender: TObject; const browser: ICefBrowser; status: TCefTerminationStatus) of object; + TOnProtocolExecution = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var allowOsExecution: Boolean) of object; + + // ICefCookieAccessFilter + TOnCanSendCookie = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie: PCefCookie; var aResult: boolean) of object; + TOnCanSaveCookie = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; const cookie: PCefCookie; var aResult : boolean) of object; // ICefDialogHandler TOnFileDialog = procedure(Sender: TObject; const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback; out Result: Boolean) of Object; @@ -136,34 +141,82 @@ type // ICefRenderHandler TOnGetAccessibilityHandler = procedure(Sender: TObject; var aAccessibilityHandler : ICefAccessibilityHandler) of Object; TOnGetRootScreenRect = procedure(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect; out Result: Boolean) of Object; - TOnGetViewRect = procedure(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect; out Result: Boolean) of Object; + TOnGetViewRect = procedure(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect) of Object; TOnGetScreenPoint = procedure(Sender: TObject; const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer; 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; TOnPopupSize = procedure(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect) of Object; - TOnPaint = procedure(Sender: TObject; const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer) of Object; - TOnCursorChange = procedure(Sender: TObject; const browser: ICefBrowser; cursor: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo) of Object; + TOnPaint = procedure(Sender: TObject; const browser: ICefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer) of Object; + TOnAcceleratedPaint = procedure(Sender: TObject; const browser: ICefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; shared_handle: Pointer) of Object; TOnStartDragging = procedure(Sender: TObject; const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer; out Result: Boolean) of Object; TOnUpdateDragCursor = procedure(Sender: TObject; const browser: ICefBrowser; operation: TCefDragOperation) of Object; TOnScrollOffsetChanged = procedure(Sender: TObject; const browser: ICefBrowser; x, y: Double) of Object; TOnIMECompositionRangeChanged = procedure(Sender: TObject; const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect) of Object; TOnTextSelectionChanged = procedure(Sender: TObject; const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange) of Object; + TOnVirtualKeyboardRequested = procedure(Sender: TObject; const browser: ICefBrowser; input_mode: TCefTextInpuMode) of Object; // ICefDragHandler TOnDragEnter = procedure(Sender: TObject; const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations; out Result: Boolean) of Object; - TOnDraggableRegionsChanged = procedure(Sender: TObject; const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray)of Object; + TOnDraggableRegionsChanged = procedure(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; regionsCount: NativeUInt; const regions: PCefDraggableRegionArray) of Object; // ICefFindHandler TOnFindResult = procedure(Sender: TObject; const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean) of Object; + // ICefRequestContextHandler + TOnRequestContextInitialized = procedure(Sender: TObject; const request_context: ICefRequestContext) of Object; + TOnBeforePluginLoad = procedure(Sender: TObject; const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy; var aResult : boolean) of Object; + // ICefRequestContextHandler uses the same TOnGetResourceRequestHandler event type defined for ICefRequestHandler + + // ICefMediaObserver + TOnSinksEvent = procedure(Sender: TObject; const sinks: TCefMediaSinkArray) of object; + TOnRoutesEvent = procedure(Sender: TObject; const routes: TCefMediaRouteArray) of object; + TOnRouteStateChangedEvent = procedure(Sender: TObject; const route: ICefMediaRoute; state: TCefMediaRouteConnectionState) of object; + TOnRouteMessageReceivedEvent = procedure(Sender: TObject; const route: ICefMediaRoute; const message_: ustring) of object; + + // ICefAudioHandler + TOnGetAudioParametersEvent = procedure(Sender: TObject; const browser: ICefBrowser; var params: TCefAudioParameters; var aResult: boolean) of object; + TOnAudioStreamStartedEvent = procedure(Sender: TObject; const browser: ICefBrowser; const params: TCefAudioParameters; channels: integer) of object; + TOnAudioStreamPacketEvent = procedure(Sender: TObject; const browser: ICefBrowser; const data : PPSingle; frames: integer; pts: int64) of object; + TOnAudioStreamStoppedEvent = procedure(Sender: TObject; const browser: ICefBrowser) of object; + TOnAudioStreamErrorEvent = procedure(Sender: TObject; const browser: ICefBrowser; const message_: ustring) of object; + + // ICefDevToolsMessageObserver + TOnDevToolsMessageEvent = procedure(Sender: TObject; const browser: ICefBrowser; const message_: ICefValue; var aHandled: boolean) of object; + TOnDevToolsRawMessageEvent = procedure(Sender: TObject; const browser: ICefBrowser; const message_: Pointer; message_size: NativeUInt; var aHandled: boolean) of object; + TOnDevToolsMethodResultEvent = procedure(Sender: TObject; const browser: ICefBrowser; message_id: integer; success: boolean; const result: ICefValue) of object; + TOnDevToolsMethodRawResultEvent = procedure(Sender: TObject; const browser: ICefBrowser; message_id: integer; success: boolean; const result: Pointer; result_size: NativeUInt) of object; + TOnDevToolsEventEvent = procedure(Sender: TObject; const browser: ICefBrowser; const method: ustring; const params: ICefValue) of object; + TOnDevToolsEventRawEvent = procedure(Sender: TObject; const browser: ICefBrowser; const method: ustring; const params: Pointer; params_size: NativeUInt) of object; + TOnDevToolsAgentAttachedEvent = procedure(Sender: TObject; const browser: ICefBrowser) of object; + TOnDevToolsAgentDetachedEvent = procedure(Sender: TObject; const browser: ICefBrowser) of object; + + // ICefExtensionHandler + TOnExtensionLoadFailedEvent = procedure(Sender: TObject; result: TCefErrorcode) of object; + TOnExtensionLoadedEvent = procedure(Sender: TObject; const extension: ICefExtension) of object; + TOnExtensionUnloadedEvent = procedure(Sender: TObject; const extension: ICefExtension) of object; + TOnBeforeBackgroundBrowserEvent = procedure(Sender: TObject; const extension: ICefExtension; const url: ustring; var client: ICefClient; var settings: TCefBrowserSettings; var aResult : boolean) of object; + TOnBeforeBrowserEvent = procedure(Sender: TObject; const extension: ICefExtension; const browser, active_browser: ICefBrowser; index: Integer; const url: ustring; active: boolean; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var aResult : boolean) of object; + TOnGetActiveBrowserEvent = procedure(Sender: TObject; const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; var aRsltBrowser : ICefBrowser) of object; + TOnCanAccessBrowserEvent = procedure(Sender: TObject; const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; const target_browser: ICefBrowser; var aResult : boolean) of object; + TOnGetExtensionResourceEvent = procedure(Sender: TObject; const extension: ICefExtension; const browser: ICefBrowser; const file_: ustring; const callback: ICefGetExtensionResourceCallback; var aResult : boolean) of object; + // Custom - TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object; - TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object; - TOnPrefsAvailableEvent = procedure(Sender: TObject; aResultOK : boolean) of object; - TOnCookiesDeletedEvent = procedure(Sender: TObject; numDeleted : integer) of object; - TOnResolvedIPsAvailableEvent = procedure(Sender: TObject; result: TCefErrorCode; const resolvedIps: TStrings) of object; + TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object; + TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object; + TOnPrefsAvailableEvent = procedure(Sender: TObject; aResultOK : boolean) of object; + TOnCookiesDeletedEvent = procedure(Sender: TObject; numDeleted : integer) of object; + TOnResolvedIPsAvailableEvent = procedure(Sender: TObject; result: TCefErrorCode; const resolvedIps: TStrings) of object; + TOnNavigationVisitorResultAvailableEvent = procedure(Sender: TObject; const entry: ICefNavigationEntry; current: Boolean; index, total: Integer; var aResult : boolean) of object; + TOnDownloadImageFinishedEvent = procedure(Sender: TObject; const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage) of object; + TOnExecuteTaskOnCefThread = procedure(Sender: TObject; aTaskID : cardinal) of object; + TOnCookiesVisited = procedure(Sender: TObject; const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; same_site : TCefCookieSameSite; priority : TCefCookiePriority; var aDeleteCookie, aResult : Boolean) of object; + TOnCookieVisitorDestroyed = procedure(Sender: TObject; aID : integer) of object; + TOnCookieSet = procedure(Sender: TObject; aSuccess : boolean; aID : integer) of object; + TOnZoomPctAvailable = procedure(Sender: TObject; const aZoomPct : double) of object; + TOnMediaRouteCreateFinishedEvent = procedure(Sender: TObject; result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute) of object; + TOnMediaSinkDeviceInfoEvent = procedure(Sender: TObject; const ip_address: ustring; port: integer; const model_name: ustring) of object; {$IFDEF MSWINDOWS} - TOnCompMsgEvent = procedure (var aMessage: TMessage; var aHandled: Boolean) of object; + TOnCompMsgEvent = procedure(Sender: TObject; var aMessage: TMessage; var aHandled: Boolean) of object; {$ENDIF} implementation diff --git a/windows/src/ext/cef4delphi/source/uCEFChromiumFontOptions.pas b/windows/src/ext/cef4delphi/source/uCEFChromiumFontOptions.pas index 867d4c252e9bcf77cc4889c9f49e1c4cdaa8b9c9..78a7a2ab8989ad5b0d888828606607abd15db2ea 100644 --- a/windows/src/ext/cef4delphi/source/uCEFChromiumFontOptions.pas +++ b/windows/src/ext/cef4delphi/source/uCEFChromiumFontOptions.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFChromiumFontOptions; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFChromiumOptions.pas b/windows/src/ext/cef4delphi/source/uCEFChromiumOptions.pas index 0c1b11f558bc06e698f3d75efa0be824014c1787..666d6339c7d0042c96fcb1105988e3d62d1fc4f2 100644 --- a/windows/src/ext/cef4delphi/source/uCEFChromiumOptions.pas +++ b/windows/src/ext/cef4delphi/source/uCEFChromiumOptions.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFChromiumOptions; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFChromiumWindow.pas b/windows/src/ext/cef4delphi/source/uCEFChromiumWindow.pas index 8e99a8b23a2bf8bf59339b42f5bf9c397dce0e8a..f8b93a7900f7f99458176fdda4ec60f8cc9b2b48 100644 --- a/windows/src/ext/cef4delphi/source/uCEFChromiumWindow.pas +++ b/windows/src/ext/cef4delphi/source/uCEFChromiumWindow.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFChromiumWindow; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -52,7 +50,7 @@ interface uses {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, + {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, Vcl.Controls, {$ELSE} {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics, {$IFDEF FPC} @@ -61,26 +59,40 @@ uses Messages, {$ENDIF} {$ENDIF} - uCEFWindowParent, uCEFChromium, uCEFInterfaces, uCEFConstants, uCEFTypes; + uCEFWindowParent, uCEFChromium, uCEFInterfaces, uCEFConstants, uCEFTypes, + uCEFWinControl, uCEFLinkedWinControlBase; type - TChromiumWindow = class(TCEFWindowParent) + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + + { TChromiumWindow } + + TChromiumWindow = class(TCEFLinkedWinControlBase) protected FChromium : TChromium; FOnClose : TNotifyEvent; FOnBeforeClose : TNotifyEvent; FOnAfterCreated : TNotifyEvent; + FUseSetFocus : boolean; - function GetChildWindowHandle : THandle; override; + function GetChromium: TChromium; override; + function GetUseSetFocus: Boolean; override; function GetBrowserInitialized : boolean; - + {$IFDEF MSWINDOWS} procedure OnCloseMsg(var aMessage : TMessage); message CEF_DOONCLOSE; - procedure OnBeforeCloseMsg(var aMessage : TMessage); message CEF_DOONBEFORECLOSE; procedure OnAfterCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; - - procedure WebBrowser_OnClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean); + {$ENDIF} + procedure WebBrowser_OnClose(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction); procedure WebBrowser_OnBeforeClose(Sender: TObject; const browser: ICefBrowser); procedure WebBrowser_OnAfterCreated(Sender: TObject; const browser: ICefBrowser); + {$IFDEF FPC} + procedure WebBrowser_OnGotFocus(Sender: TObject; const browser: ICefBrowser); + procedure BrowserSetFocusMsg(Data: PtrInt); + procedure BrowserAfterCreated(Data: PtrInt); + procedure BrowserOnCLose(Data: PtrInt); + {$ENDIF} + procedure DoEnter; override; + procedure DoExit; override; public constructor Create(AOwner: TComponent); override; @@ -90,10 +102,11 @@ type procedure LoadURL(const aURL : ustring); procedure NotifyMoveOrResizeStarted; - property ChromiumBrowser : TChromium read FChromium; - property Initialized : boolean read GetBrowserInitialized; + property ChromiumBrowser : TChromium read GetChromium; + property Initialized : boolean read GetBrowserInitialized; published + property UseSetFocus : boolean read FUseSetFocus write FUseSetFocus default True; property OnClose : TNotifyEvent read FOnClose write FOnClose; property OnBeforeClose : TNotifyEvent read FOnBeforeClose write FOnBeforeClose; property OnAfterCreated : TNotifyEvent read FOnAfterCreated write FOnAfterCreated; @@ -103,6 +116,37 @@ type procedure Register; {$ENDIF} +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +// This component should *ONLY* be used in emtremely simple applications with simple browsers. +// In other cases it's recomended using a TChromium with a TCEFWindowParent as shown in the +// SimpleBrowser2 demo. + implementation uses @@ -120,6 +164,7 @@ begin FOnClose := nil; FOnBeforeClose := nil; FOnAfterCreated := nil; + FUseSetFocus := True; end; procedure TChromiumWindow.AfterConstruction; @@ -132,60 +177,87 @@ begin FChromium.OnClose := {$IFDEF FPC}@{$ENDIF}WebBrowser_OnClose; FChromium.OnBeforeClose := {$IFDEF FPC}@{$ENDIF}WebBrowser_OnBeforeClose; FChromium.OnAfterCreated := {$IFDEF FPC}@{$ENDIF}WebBrowser_OnAfterCreated; + {$IFDEF LINUX} + // This is a workaround for the CEF issue #2026. Read below for more info. + FChromium.OnGotFocus := {$IFDEF FPC}@{$ENDIF}WebBrowser_OnGotFocus; + TabStop := True; + {$ENDIF} end; end; -function TChromiumWindow.GetChildWindowHandle : THandle; -begin - Result := 0; - - if (FChromium <> nil) then Result := FChromium.WindowHandle; - - if (Result = 0) then Result := inherited GetChildWindowHandle; -end; - function TChromiumWindow.GetBrowserInitialized : boolean; begin Result := (FChromium <> nil) and FChromium.Initialized; end; -procedure TChromiumWindow.WebBrowser_OnClose(Sender: TObject; const browser: ICefBrowser; out Result: Boolean); +procedure TChromiumWindow.WebBrowser_OnClose(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction); begin + aAction := cbaClose; if assigned(FOnClose) then begin - PostMessage(Handle, CEF_DOONCLOSE, 0, 0); - Result := True; - end - else - Result := False; + {$IFDEF MSWINDOWS} + PostMessage(Handle, CEF_DOONCLOSE, 0, 0); + aAction := cbaDelay; + {$ELSE} + {$IFDEF FPC} + Application.QueueAsyncCall(@BrowserOnClose, 0); + {$ENDIF} + {$ENDIF} + end; end; procedure TChromiumWindow.WebBrowser_OnBeforeClose(Sender: TObject; const browser: ICefBrowser); begin - if assigned(FOnBeforeClose) then PostMessage(Handle, CEF_DOONBEFORECLOSE, 0, 0); + if assigned(FOnBeforeClose) then FOnBeforeClose(self); end; procedure TChromiumWindow.WebBrowser_OnAfterCreated(Sender: TObject; const browser: ICefBrowser); begin - PostMessage(Handle, CEF_AFTERCREATED, 0, 0); + {$IFDEF MSWINDOWS} + PostMessage(Handle, CEF_AFTERCREATED, 0, 0); + {$ELSE} + {$IFDEF FPC} + Application.QueueAsyncCall(@BrowserAfterCreated, 0); + {$ENDIF} + {$ENDIF} end; +{$IFDEF MSWINDOWS} procedure TChromiumWindow.OnCloseMsg(var aMessage : TMessage); begin if assigned(FOnClose) then FOnClose(self); end; -procedure TChromiumWindow.OnBeforeCloseMsg(var aMessage : TMessage); +procedure TChromiumWindow.OnAfterCreatedMsg(var aMessage : TMessage); begin - if assigned(FOnBeforeClose) then FOnBeforeClose(self); + UpdateSize; + if assigned(FOnAfterCreated) then FOnAfterCreated(self); end; +{$ENDIF} -procedure TChromiumWindow.OnAfterCreatedMsg(var aMessage : TMessage); +{$IFDEF FPC} +procedure TChromiumWindow.WebBrowser_OnGotFocus(Sender: TObject; const browser: ICefBrowser); +begin + Application.QueueAsyncCall(@BrowserSetFocusMsg, 0); +end; + +procedure TChromiumWindow.BrowserSetFocusMsg(Data: PtrInt); +begin + SetFocus; +end; + +procedure TChromiumWindow.BrowserAfterCreated(Data: PtrInt); begin UpdateSize; if assigned(FOnAfterCreated) then FOnAfterCreated(self); end; +procedure TChromiumWindow.BrowserOnCLose(Data: PtrInt); +begin + if assigned(FOnClose) then FOnClose(self); +end; +{$ENDIF} + function TChromiumWindow.CreateBrowser : boolean; begin Result := not(csDesigning in ComponentState) and @@ -209,6 +281,43 @@ begin if (FChromium <> nil) then FChromium.NotifyMoveOrResizeStarted; end; +function TChromiumWindow.GetChromium: TChromium; +begin + result := FChromium; +end; + +function TChromiumWindow.GetUseSetFocus: Boolean; +begin + Result := FUseSetFocus; +end; + +// This is a workaround for the CEF issue #2026 +// https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on +// We use ChromiumWindow1.OnEnter, ChromiumWindow1.OnExit and +// TChromium.OnGotFocus to avoid most of the focus issues. +// ChromiumWindow1.TabStop must be TRUE. +procedure TChromiumWindow.DoEnter; +begin + inherited DoEnter; + + {$IFDEF LINUX} + if not(csDesigning in ComponentState) and + FChromium.Initialized and + not(FChromium.FrameIsFocused) then + FChromium.SendFocusEvent(True); + {$ENDIF} +end; + +procedure TChromiumWindow.DoExit; +begin + inherited DoExit; + + {$IFDEF LINUX} + if not(csDesigning in ComponentState) then + FChromium.SendCaptureLostEvent; + {$ENDIF} +end; + {$IFDEF FPC} procedure Register; begin diff --git a/windows/src/ext/cef4delphi/source/uCEFClient.pas b/windows/src/ext/cef4delphi/source/uCEFClient.pas index ee61243cbf8bbd37f153655017ddb4ac16f9ece0..99732742d738d4462e60b19e8f1fcddf76d2e694 100644 --- a/windows/src/ext/cef4delphi/source/uCEFClient.pas +++ b/windows/src/ext/cef4delphi/source/uCEFClient.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFClient; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,6 +54,7 @@ uses type TCefClientRef = class(TCefBaseRefCountedRef, ICefClient) protected + procedure GetAudioHandler(var aHandler : ICefAudioHandler); virtual; procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); virtual; procedure GetDialogHandler(var aHandler : ICefDialogHandler); virtual; procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); virtual; @@ -69,7 +68,7 @@ type procedure GetLoadHandler(var aHandler : ICefLoadHandler); virtual; procedure GetRenderHandler(var aHandler : ICefRenderHandler); virtual; procedure GetRequestHandler(var aHandler : ICefRequestHandler); virtual; - function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; virtual; + function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; virtual; procedure RemoveReferences; virtual; @@ -79,6 +78,7 @@ type TCefClientOwn = class(TCefBaseRefCountedOwn, ICefClient) protected + procedure GetAudioHandler(var aHandler : ICefAudioHandler); virtual; procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); virtual; procedure GetDialogHandler(var aHandler : ICefDialogHandler); virtual; procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); virtual; @@ -92,7 +92,7 @@ type procedure GetLoadHandler(var aHandler : ICefLoadHandler); virtual; procedure GetRenderHandler(var aHandler : ICefRenderHandler); virtual; procedure GetRequestHandler(var aHandler : ICefRequestHandler); virtual; - function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; virtual; + function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; virtual; procedure RemoveReferences; virtual; @@ -103,6 +103,7 @@ type TCustomClientHandler = class(TCefClientOwn) protected FEvents : Pointer; + FAudioHandler : ICefAudioHandler; FLoadHandler : ICefLoadHandler; FFocusHandler : ICefFocusHandler; FContextMenuHandler : ICefContextMenuHandler; @@ -117,6 +118,7 @@ type FDragHandler : ICefDragHandler; FFindHandler : ICefFindHandler; + procedure GetAudioHandler(var aHandler : ICefAudioHandler); override; procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); override; procedure GetDialogHandler(var aHandler : ICefDialogHandler); override; procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); override; @@ -130,16 +132,12 @@ type procedure GetLoadHandler(var aHandler : ICefLoadHandler); override; procedure GetRenderHandler(var aHandler : ICefRenderHandler); override; procedure GetRequestHandler(var aHandler : ICefRequestHandler); override; - function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; override; + function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; override; procedure InitializeVars; public - constructor Create(const events: IChromiumEvents; - aCreateLoadHandler, aCreateFocusHandler, aCreateContextMenuHandler, aCreateDialogHandler, - aCreateKeyboardHandler, aCreateDisplayHandler, aCreateDownloadHandler, aCreateJsDialogHandler, - aCreateLifeSpanHandler, aCreateRenderHandler, aCreateRequestHandler, aCreateDragHandler, - aCreateFindHandler : boolean); reintroduce; virtual; + constructor Create(const events: IChromiumEvents; aDevToolsClient : boolean = False); reintroduce; virtual; procedure BeforeDestruction; override; procedure RemoveReferences; override; end; @@ -156,7 +154,7 @@ uses uCEFFocusHandler, uCEFContextMenuHandler, uCEFDialogHandler, uCEFKeyboardHandler, uCEFDisplayHandler, uCEFDownloadHandler, uCEFJsDialogHandler, uCEFLifeSpanHandler, uCEFRequestHandler, uCEFRenderHandler, uCEFDragHandler, - uCEFFindHandler, uCEFConstants, uCEFApplication; + uCEFFindHandler, uCEFConstants, uCEFApplicationCore, uCEFFrame, uCEFAudioHandler; // ****************************************************** @@ -171,6 +169,11 @@ begin Result := nil; end; +procedure TCefClientRef.GetAudioHandler(var aHandler : ICefAudioHandler); +begin + aHandler := nil; +end; + procedure TCefClientRef.GetContextMenuHandler(var aHandler : ICefContextMenuHandler); begin aHandler := nil; @@ -236,7 +239,7 @@ begin aHandler := nil; end; -function TCefClientRef.OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; +function TCefClientRef.OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; begin Result := False; end; @@ -252,6 +255,23 @@ end; // ****************************************************** +function cef_client_own_get_audio_handler(self: PCefClient): PCefAudioHandler; stdcall; +var + TempObject : TObject; + TempHandler : ICefAudioHandler; +begin + Result := nil; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefClientOwn) then + try + TCefClientOwn(TempObject).GetAudioHandler(TempHandler); + if (TempHandler <> nil) then Result := TempHandler.Wrap; + finally + TempHandler := nil; + end; +end; + function cef_client_own_get_context_menu_handler(self: PCefClient): PCefContextMenuHandler; stdcall; var TempObject : TObject; @@ -475,6 +495,7 @@ end; function cef_client_own_on_process_message_received(self : PCefClient; browser : PCefBrowser; + frame : PCefFrame; source_process : TCefProcessId; message_ : PCefProcessMessage): Integer; stdcall; var @@ -485,6 +506,7 @@ begin if (TempObject <> nil) and (TempObject is TCefClientOwn) then Result := Ord(TCefClientOwn(TempObject).OnProcessMessageReceived(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), source_process, TCefProcessMessageRef.UnWrap(message_))); end; @@ -495,6 +517,7 @@ begin with PCefClient(FData)^ do begin + get_audio_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_audio_handler; get_context_menu_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_context_menu_handler; get_dialog_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_dialog_handler; get_display_handler := {$IFDEF FPC}@{$ENDIF}cef_client_own_get_display_handler; @@ -512,6 +535,11 @@ begin end; end; +procedure TCefClientOwn.GetAudioHandler(var aHandler : ICefAudioHandler); +begin + aHandler := nil; +end; + procedure TCefClientOwn.GetContextMenuHandler(var aHandler : ICefContextMenuHandler); begin aHandler := nil; @@ -578,6 +606,7 @@ begin end; function TCefClientOwn.OnProcessMessageReceived(const browser : ICefBrowser; + const frame : ICefFrame; sourceProcess : TCefProcessId; const message_ : ICefProcessMessage): Boolean; begin @@ -595,20 +624,7 @@ end; // ****************************************************** -constructor TCustomClientHandler.Create(const events : IChromiumEvents; - aCreateLoadHandler : boolean; - aCreateFocusHandler : boolean; - aCreateContextMenuHandler : boolean; - aCreateDialogHandler : boolean; - aCreateKeyboardHandler : boolean; - aCreateDisplayHandler : boolean; - aCreateDownloadHandler : boolean; - aCreateJsDialogHandler : boolean; - aCreateLifeSpanHandler : boolean; - aCreateRenderHandler : boolean; - aCreateRequestHandler : boolean; - aCreateDragHandler : boolean; - aCreateFindHandler : boolean); +constructor TCustomClientHandler.Create(const events : IChromiumEvents; aDevToolsClient : boolean); begin inherited Create; @@ -616,21 +632,29 @@ begin FEvents := Pointer(events); - if (FEvents <> nil) then + if (events <> nil) then begin - if aCreateLoadHandler then FLoadHandler := TCustomLoadHandler.Create(FEvents); - if aCreateFocusHandler then FFocusHandler := TCustomFocusHandler.Create(FEvents); - if aCreateContextMenuHandler then FContextMenuHandler := TCustomContextMenuHandler.Create(FEvents); - if aCreateDialogHandler then FDialogHandler := TCustomDialogHandler.Create(FEvents); - if aCreateKeyboardHandler then FKeyboardHandler := TCustomKeyboardHandler.Create(FEvents); - if aCreateDisplayHandler then FDisplayHandler := TCustomDisplayHandler.Create(FEvents); - if aCreateDownloadHandler then FDownloadHandler := TCustomDownloadHandler.Create(FEvents); - if aCreateJsDialogHandler then FJsDialogHandler := TCustomJsDialogHandler.Create(FEvents); - if aCreateLifeSpanHandler then FLifeSpanHandler := TCustomLifeSpanHandler.Create(FEvents); - if aCreateRenderHandler then FRenderHandler := TCustomRenderHandler.Create(FEvents); - if aCreateRequestHandler then FRequestHandler := TCustomRequestHandler.Create(FEvents); - if aCreateDragHandler then FDragHandler := TCustomDragHandler.Create(FEvents); - if aCreateFindHandler then FFindHandler := TCustomFindHandler.Create(FEvents); + if aDevToolsClient then + begin + if events.MustCreateKeyboardHandler then FKeyboardHandler := TCustomKeyboardHandler.Create(events); + end + else + begin + if events.MustCreateAudioHandler then FAudioHandler := TCustomAudioHandler.Create(events); + if events.MustCreateLoadHandler then FLoadHandler := TCustomLoadHandler.Create(events); + if events.MustCreateFocusHandler then FFocusHandler := TCustomFocusHandler.Create(events); + if events.MustCreateContextMenuHandler then FContextMenuHandler := TCustomContextMenuHandler.Create(events); + if events.MustCreateDialogHandler then FDialogHandler := TCustomDialogHandler.Create(events); + if events.MustCreateKeyboardHandler then FKeyboardHandler := TCustomKeyboardHandler.Create(events); + if events.MustCreateDisplayHandler then FDisplayHandler := TCustomDisplayHandler.Create(events); + if events.MustCreateDownloadHandler then FDownloadHandler := TCustomDownloadHandler.Create(events); + if events.MustCreateJsDialogHandler then FJsDialogHandler := TCustomJsDialogHandler.Create(events); + if events.MustCreateLifeSpanHandler then FLifeSpanHandler := TCustomLifeSpanHandler.Create(events); + if events.MustCreateRenderHandler then FRenderHandler := TCustomRenderHandler.Create(events); + if events.MustCreateRequestHandler then FRequestHandler := TCustomRequestHandler.Create(events); + if events.MustCreateDragHandler then FDragHandler := TCustomDragHandler.Create(events); + if events.MustCreateFindHandler then FFindHandler := TCustomFindHandler.Create(events); + end; end; end; @@ -645,6 +669,7 @@ procedure TCustomClientHandler.RemoveReferences; begin FEvents := nil; + if (FAudioHandler <> nil) then FAudioHandler.RemoveReferences; if (FLoadHandler <> nil) then FLoadHandler.RemoveReferences; if (FFocusHandler <> nil) then FFocusHandler.RemoveReferences; if (FContextMenuHandler <> nil) then FContextMenuHandler.RemoveReferences; @@ -662,6 +687,7 @@ end; procedure TCustomClientHandler.InitializeVars; begin + FAudioHandler := nil; FLoadHandler := nil; FFocusHandler := nil; FContextMenuHandler := nil; @@ -678,6 +704,14 @@ begin FEvents := nil; end; +procedure TCustomClientHandler.GetAudioHandler(var aHandler : ICefAudioHandler); +begin + if (FAudioHandler <> nil) then + aHandler := FAudioHandler + else + aHandler := nil; +end; + procedure TCustomClientHandler.GetContextMenuHandler(var aHandler : ICefContextMenuHandler); begin if (FContextMenuHandler <> nil) then @@ -783,13 +817,14 @@ begin end; function TCustomClientHandler.OnProcessMessageReceived(const browser : ICefBrowser; + const frame : ICefFrame; sourceProcess : TCefProcessId; const message_ : ICefProcessMessage): Boolean; begin if (FEvents <> nil) then - Result := IChromiumEvents(FEvents).doOnProcessMessageReceived(browser, sourceProcess, message_) + Result := IChromiumEvents(FEvents).doOnProcessMessageReceived(browser, frame, sourceProcess, message_) else - Result := inherited OnProcessMessageReceived(browser, sourceProcess, message_); + Result := inherited OnProcessMessageReceived(browser, frame, sourceProcess, message_); end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFCommandLine.pas b/windows/src/ext/cef4delphi/source/uCEFCommandLine.pas index d4ad227553600dee447c4b9b95d4571e744f47c9..fc7316ae5d3e55d30e01b4fc824c014dd73acd15 100644 --- a/windows/src/ext/cef4delphi/source/uCEFCommandLine.pas +++ b/windows/src/ext/cef4delphi/source/uCEFCommandLine.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFCommandLine; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -74,7 +72,8 @@ type function HasSwitches: Boolean; function HasSwitch(const name: ustring): Boolean; function GetSwitchValue(const name: ustring): ustring; - procedure GetSwitches(var switches: TStrings); + function GetSwitches(var switches: TStrings): boolean; overload; + function GetSwitches(var SwitchKeys, SwitchValues: TStringList): boolean; overload; procedure AppendSwitch(const name: ustring); procedure AppendSwitchWithValue(const name, value: ustring); function HasArguments: Boolean; @@ -157,12 +156,13 @@ begin Result := CefStringFreeAndGet(PCefCommandLine(FData)^.get_program(PCefCommandLine(FData))); end; -procedure TCefCommandLineRef.GetSwitches(var switches: TStrings); +function TCefCommandLineRef.GetSwitches(var switches: TStrings): boolean; var TempStrMap : ICefStringMap; i, j : NativeUInt; TempKey, TempValue : ustring; begin + Result := False; TempStrMap := nil; try @@ -191,6 +191,44 @@ begin inc(i); end; + + Result := (j > 0); + end; + except + on e : exception do + if CustomExceptionHandler('TCefCommandLineRef.GetSwitches', e) then raise; + end; + finally + TempStrMap := nil; + end; +end; + +function TCefCommandLineRef.GetSwitches(var SwitchKeys, SwitchValues: TStringList): boolean; +var + TempStrMap : ICefStringMap; + i, j : NativeUInt; +begin + Result := False; + TempStrMap := nil; + + try + try + if (SwitchKeys <> nil) and (SwitchValues <> nil) then + begin + TempStrMap := TCefStringMapOwn.Create; + PCefCommandLine(FData)^.get_switches(PCefCommandLine(FData), TempStrMap.Handle); + + i := 0; + j := TempStrMap.Size; + + while (i < j) do + begin + SwitchKeys.Add(TempStrMap.Key[i]); + SwitchValues.Add(TempStrMap.Value[i]); + inc(i); + end; + + Result := (j > 0); end; except on e : exception do diff --git a/windows/src/ext/cef4delphi/source/uCEFCompletionCallback.pas b/windows/src/ext/cef4delphi/source/uCEFCompletionCallback.pas index 1f70ad8f4a84d812b969a50d432327bd6aac2de1..37ada943651dd29c0871d0e5f6f13556005cc94f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFCompletionCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFCompletionCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,17 +41,15 @@ unit uCEFCompletionCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} interface uses - uCEFBaseRefCounted, uCEFInterfaces; + uCEFBaseRefCounted, uCEFInterfaces, uCEFWaitableEvent; type TCefCompletionCallbackOwn = class(TCefBaseRefCountedOwn, ICefCompletionCallback) @@ -72,6 +70,26 @@ type constructor Create(const proc: TCefCompletionCallbackProc); reintroduce; end; + TCefEventCompletionCallback = class(TCefCompletionCallbackOwn) + protected + FEvent : ICefWaitableEvent; + + procedure OnComplete; override; + + public + constructor Create(const event : ICefWaitableEvent); reintroduce; + destructor Destroy; override; + end; + + TCefCustomCompletionCallback = class(TCefCompletionCallbackOwn) + protected + FEvents : Pointer; + + public + constructor Create(const aEvents : IChromiumEvents); reintroduce; + destructor Destroy; override; + end; + implementation uses @@ -115,4 +133,44 @@ begin FProc(); end; + +// TCefEventCompletionCallback + + +constructor TCefEventCompletionCallback.Create(const event : ICefWaitableEvent); +begin + inherited Create; + + FEvent := event; +end; + +destructor TCefEventCompletionCallback.Destroy; +begin + FEvent := nil; + + inherited Destroy; +end; + +procedure TCefEventCompletionCallback.OnComplete; +begin + if (FEvent <> nil) then FEvent.Signal; +end; + + +// TCefCustomCompletionCallback + +constructor TCefCustomCompletionCallback.Create(const aEvents : IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(aEvents); +end; + +destructor TCefCustomCompletionCallback.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFConstants.pas b/windows/src/ext/cef4delphi/source/uCEFConstants.pas index a11783fd4bcb515e2e915d6c65f0b846c6d0cb0f..ad816d934ab19a62da2223fd61902fec7c47a04a 100644 --- a/windows/src/ext/cef4delphi/source/uCEFConstants.pas +++ b/windows/src/ext/cef4delphi/source/uCEFConstants.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,79 +41,255 @@ unit uCEFConstants; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} interface +{$IFDEF MSWINDOWS} uses {$IFDEF DELPHI16_UP} Winapi.Messages; {$ELSE} Messages; {$ENDIF} +{$ENDIF} const - // /include/internal/cef_types.h (cef_errorcode_t) - ERR_NONE = 0; - ERR_FAILED = -2; - ERR_ABORTED = -3; - ERR_INVALID_ARGUMENT = -4; - ERR_INVALID_HANDLE = -5; - ERR_FILE_NOT_FOUND = -6; - ERR_TIMED_OUT = -7; - ERR_FILE_TOO_BIG = -8; - ERR_UNEXPECTED = -9; - ERR_ACCESS_DENIED = -10; - ERR_NOT_IMPLEMENTED = -11; - ERR_CONNECTION_CLOSED = -100; - ERR_CONNECTION_RESET = -101; - ERR_CONNECTION_REFUSED = -102; - ERR_CONNECTION_ABORTED = -103; - ERR_CONNECTION_FAILED = -104; - ERR_NAME_NOT_RESOLVED = -105; - ERR_INTERNET_DISCONNECTED = -106; - ERR_SSL_PROTOCOL_ERROR = -107; - ERR_ADDRESS_INVALID = -108; - ERR_ADDRESS_UNREACHABLE = -109; - ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110; - ERR_TUNNEL_CONNECTION_FAILED = -111; - ERR_NO_SSL_VERSIONS_ENABLED = -112; - ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113; - ERR_SSL_RENEGOTIATION_REQUESTED = -114; - ERR_CERT_COMMON_NAME_INVALID = -200; - ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID; - ERR_CERT_DATE_INVALID = -201; - ERR_CERT_AUTHORITY_INVALID = -202; - ERR_CERT_CONTAINS_ERRORS = -203; - ERR_CERT_NO_REVOCATION_MECHANISM = -204; - ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205; - ERR_CERT_REVOKED = -206; - ERR_CERT_INVALID = -207; - ERR_CERT_WEAK_SIGNATURE_ALGORITHM = -208; - ERR_CERT_NON_UNIQUE_NAME = -210; - ERR_CERT_WEAK_KEY = -211; - ERR_CERT_NAME_CONSTRAINT_VIOLATION = -212; - ERR_CERT_VALIDITY_TOO_LONG = -213; - ERR_CERT_END = ERR_CERT_VALIDITY_TOO_LONG; - ERR_INVALID_URL = -300; - ERR_DISALLOWED_URL_SCHEME = -301; - ERR_UNKNOWN_URL_SCHEME = -302; - ERR_TOO_MANY_REDIRECTS = -310; - ERR_UNSAFE_REDIRECT = -311; - ERR_UNSAFE_PORT = -312; - ERR_INVALID_RESPONSE = -320; - ERR_INVALID_CHUNKED_ENCODING = -321; - ERR_METHOD_NOT_SUPPORTED = -322; - ERR_UNEXPECTED_PROXY_AUTH = -323; - ERR_EMPTY_RESPONSE = -324; - ERR_RESPONSE_HEADERS_TOO_BIG = -325; - ERR_CACHE_MISS = -400; - ERR_INSECURE_RESPONSE = -501; + // Error list defined in /include/internal/cef_types.h (cef_errorcode_t) + // which includes this file /include/base/internal/cef_net_error_list.h + // which includes this Chromium source file /net/base/net_error_list.h + // available here in the master branch -> https://chromium.googlesource.com/chromium/src/+/master/net/base/net_error_list.h + // compare the values in the right Chromium branch. + ERR_NONE = 0; + ERR_IO_PENDING = -1; + ERR_FAILED = -2; + ERR_ABORTED = -3; + ERR_INVALID_ARGUMENT = -4; + ERR_INVALID_HANDLE = -5; + ERR_FILE_NOT_FOUND = -6; + ERR_TIMED_OUT = -7; + ERR_FILE_TOO_BIG = -8; + ERR_UNEXPECTED = -9; + ERR_ACCESS_DENIED = -10; + ERR_NOT_IMPLEMENTED = -11; + ERR_INSUFFICIENT_RESOURCES = -12; + ERR_OUT_OF_MEMORY = -13; + ERR_UPLOAD_FILE_CHANGED = -14; + ERR_SOCKET_NOT_CONNECTED = -15; + ERR_FILE_EXISTS = -16; + ERR_FILE_PATH_TOO_LONG = -17; + ERR_FILE_NO_SPACE = -18; + ERR_FILE_VIRUS_INFECTED = -19; + ERR_BLOCKED_BY_CLIENT = -20; + ERR_NETWORK_CHANGED = -21; + ERR_BLOCKED_BY_ADMINISTRATOR = -22; + ERR_SOCKET_IS_CONNECTED = -23; + ERR_BLOCKED_ENROLLMENT_CHECK_PENDING = -24; + ERR_UPLOAD_STREAM_REWIND_NOT_SUPPORTED = -25; + ERR_CONTEXT_SHUT_DOWN = -26; + ERR_BLOCKED_BY_RESPONSE = -27; + ERR_BLOCKED_BY_XSS_AUDITOR = -28; + ERR_CLEARTEXT_NOT_PERMITTED = -29; + ERR_CONNECTION_CLOSED = -100; + ERR_CONNECTION_RESET = -101; + ERR_CONNECTION_REFUSED = -102; + ERR_CONNECTION_ABORTED = -103; + ERR_CONNECTION_FAILED = -104; + ERR_NAME_NOT_RESOLVED = -105; + ERR_INTERNET_DISCONNECTED = -106; + ERR_SSL_PROTOCOL_ERROR = -107; + ERR_ADDRESS_INVALID = -108; + ERR_ADDRESS_UNREACHABLE = -109; + ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110; + ERR_TUNNEL_CONNECTION_FAILED = -111; + ERR_NO_SSL_VERSIONS_ENABLED = -112; + ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113; + ERR_SSL_RENEGOTIATION_REQUESTED = -114; + ERR_PROXY_AUTH_UNSUPPORTED = -115; + ERR_CERT_ERROR_IN_SSL_RENEGOTIATION = -116; + ERR_BAD_SSL_CLIENT_AUTH_CERT = -117; + ERR_CONNECTION_TIMED_OUT = -118; + ERR_HOST_RESOLVER_QUEUE_TOO_LARGE = -119; + ERR_SOCKS_CONNECTION_FAILED = -120; + ERR_SOCKS_CONNECTION_HOST_UNREACHABLE = -121; + ERR_ALPN_NEGOTIATION_FAILED = -122; + ERR_SSL_NO_RENEGOTIATION = -123; + ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES = -124; + ERR_SSL_DECOMPRESSION_FAILURE_ALERT = -125; + ERR_SSL_BAD_RECORD_MAC_ALERT = -126; + ERR_PROXY_AUTH_REQUESTED = -127; + ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY = -129; + ERR_PROXY_CONNECTION_FAILED = -130; + ERR_MANDATORY_PROXY_CONFIGURATION_FAILED = -131; + ERR_PRECONNECT_MAX_SOCKET_LIMIT = -133; + ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED = -134; + ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY = -135; + ERR_PROXY_CERTIFICATE_INVALID = -136; + ERR_NAME_RESOLUTION_FAILED = -137; + ERR_NETWORK_ACCESS_DENIED = -138; + ERR_TEMPORARILY_THROTTLED = -139; + ERR_HTTPS_PROXY_TUNNEL_RESPONSE_REDIRECT = -140; + ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED = -141; + ERR_MSG_TOO_BIG = -142; + ERR_SPDY_SESSION_ALREADY_EXISTS = -143; + ERR_WS_PROTOCOL_ERROR = -145; + ERR_ADDRESS_IN_USE = -147; + ERR_SSL_HANDSHAKE_NOT_COMPLETED = -148; + ERR_SSL_BAD_PEER_PUBLIC_KEY = -149; + ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN = -150; + ERR_CLIENT_AUTH_CERT_TYPE_UNSUPPORTED = -151; + ERR_ORIGIN_BOUND_CERT_GENERATION_TYPE_MISMATCH = -152; + ERR_SSL_DECRYPT_ERROR_ALERT = -153; + ERR_WS_THROTTLE_QUEUE_TOO_LARGE = -154; + ERR_SSL_SERVER_CERT_CHANGED = -156; + ERR_SSL_UNRECOGNIZED_NAME_ALERT = -159; + ERR_SOCKET_SET_RECEIVE_BUFFER_SIZE_ERROR = -160; + ERR_SOCKET_SET_SEND_BUFFER_SIZE_ERROR = -161; + ERR_SOCKET_RECEIVE_BUFFER_SIZE_UNCHANGEABLE = -162; + ERR_SOCKET_SEND_BUFFER_SIZE_UNCHANGEABLE = -163; + ERR_SSL_CLIENT_AUTH_CERT_BAD_FORMAT = -164; + ERR_ICANN_NAME_COLLISION = -166; + ERR_SSL_SERVER_CERT_BAD_FORMAT = -167; + ERR_CT_STH_PARSING_FAILED = -168; + ERR_CT_STH_INCOMPLETE = -169; + ERR_UNABLE_TO_REUSE_CONNECTION_FOR_PROXY_AUTH = -170; + ERR_CT_CONSISTENCY_PROOF_PARSING_FAILED = -171; + ERR_SSL_OBSOLETE_CIPHER = -172; + ERR_WS_UPGRADE = -173; + ERR_READ_IF_READY_NOT_IMPLEMENTED = -174; + ERR_SSL_VERSION_INTERFERENCE = -175; + ERR_NO_BUFFER_SPACE = -176; + ERR_SSL_CLIENT_AUTH_NO_COMMON_ALGORITHMS = -177; + ERR_EARLY_DATA_REJECTED = -178; + ERR_WRONG_VERSION_ON_EARLY_DATA = -179; + ERR_TLS13_DOWNGRADE_DETECTED = -180; + ERR_SSL_KEY_USAGE_INCOMPATIBLE = -181; + ERR_CERT_COMMON_NAME_INVALID = -200; + ERR_CERT_DATE_INVALID = -201; + ERR_CERT_AUTHORITY_INVALID = -202; + ERR_CERT_CONTAINS_ERRORS = -203; + ERR_CERT_NO_REVOCATION_MECHANISM = -204; + ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205; + ERR_CERT_REVOKED = -206; + ERR_CERT_INVALID = -207; + ERR_CERT_WEAK_SIGNATURE_ALGORITHM = -208; + ERR_CERT_NON_UNIQUE_NAME = -210; + ERR_CERT_WEAK_KEY = -211; + ERR_CERT_NAME_CONSTRAINT_VIOLATION = -212; + ERR_CERT_VALIDITY_TOO_LONG = -213; + ERR_CERTIFICATE_TRANSPARENCY_REQUIRED = -214; + ERR_CERT_SYMANTEC_LEGACY = -215; + ERR_CERT_END = -216; + ERR_INVALID_URL = -300; + ERR_DISALLOWED_URL_SCHEME = -301; + ERR_UNKNOWN_URL_SCHEME = -302; + ERR_INVALID_REDIRECT = -303; + ERR_TOO_MANY_REDIRECTS = -310; + ERR_UNSAFE_REDIRECT = -311; + ERR_UNSAFE_PORT = -312; + ERR_INVALID_RESPONSE = -320; + ERR_INVALID_CHUNKED_ENCODING = -321; + ERR_METHOD_NOT_SUPPORTED = -322; + ERR_UNEXPECTED_PROXY_AUTH = -323; + ERR_EMPTY_RESPONSE = -324; + ERR_RESPONSE_HEADERS_TOO_BIG = -325; + ERR_PAC_STATUS_NOT_OK = -326; + ERR_PAC_SCRIPT_FAILED = -327; + ERR_REQUEST_RANGE_NOT_SATISFIABLE = -328; + ERR_MALFORMED_IDENTITY = -329; + ERR_CONTENT_DECODING_FAILED = -330; + ERR_NETWORK_IO_SUSPENDED = -331; + ERR_SYN_REPLY_NOT_RECEIVED = -332; + ERR_ENCODING_CONVERSION_FAILED = -333; + ERR_UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT = -334; + ERR_NO_SUPPORTED_PROXIES = -336; + ERR_SPDY_PROTOCOL_ERROR = -337; + ERR_INVALID_AUTH_CREDENTIALS = -338; + ERR_UNSUPPORTED_AUTH_SCHEME = -339; + ERR_ENCODING_DETECTION_FAILED = -340; + ERR_MISSING_AUTH_CREDENTIALS = -341; + ERR_UNEXPECTED_SECURITY_LIBRARY_STATUS = -342; + ERR_MISCONFIGURED_AUTH_ENVIRONMENT = -343; + ERR_UNDOCUMENTED_SECURITY_LIBRARY_STATUS = -344; + ERR_RESPONSE_BODY_TOO_BIG_TO_DRAIN = -345; + ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH = -346; + ERR_INCOMPLETE_SPDY_HEADERS = -347; + ERR_PAC_NOT_IN_DHCP = -348; + ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION = -349; + ERR_RESPONSE_HEADERS_MULTIPLE_LOCATION = -350; + ERR_SPDY_SERVER_REFUSED_STREAM = -351; + ERR_SPDY_PING_FAILED = -352; + ERR_CONTENT_LENGTH_MISMATCH = -354; + ERR_INCOMPLETE_CHUNKED_ENCODING = -355; + ERR_QUIC_PROTOCOL_ERROR = -356; + ERR_RESPONSE_HEADERS_TRUNCATED = -357; + ERR_QUIC_HANDSHAKE_FAILED = -358; + ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY = -360; + ERR_SPDY_FLOW_CONTROL_ERROR = -361; + ERR_SPDY_FRAME_SIZE_ERROR = -362; + ERR_SPDY_COMPRESSION_ERROR = -363; + ERR_PROXY_AUTH_REQUESTED_WITH_NO_CONNECTION = -364; + ERR_HTTP_1_1_REQUIRED = -365; + ERR_PROXY_HTTP_1_1_REQUIRED = -366; + ERR_PAC_SCRIPT_TERMINATED = -367; + ERR_INVALID_HTTP_RESPONSE = -370; + ERR_CONTENT_DECODING_INIT_FAILED = -371; + ERR_SPDY_RST_STREAM_NO_ERROR_RECEIVED = -372; + ERR_SPDY_PUSHED_STREAM_NOT_AVAILABLE = -373; + ERR_SPDY_CLAIMED_PUSHED_STREAM_RESET_BY_SERVER = -374; + ERR_TOO_MANY_RETRIES = -375; + ERR_SPDY_STREAM_CLOSED = -376; + ERR_SPDY_CLIENT_REFUSED_STREAM = -377; + ERR_SPDY_PUSHED_RESPONSE_DOES_NOT_MATCH = -378; + ERR_CACHE_MISS = -400; + ERR_CACHE_READ_FAILURE = -401; + ERR_CACHE_WRITE_FAILURE = -402; + ERR_CACHE_OPERATION_NOT_SUPPORTED = -403; + ERR_CACHE_OPEN_FAILURE = -404; + ERR_CACHE_CREATE_FAILURE = -405; + ERR_CACHE_RACE = -406; + ERR_CACHE_CHECKSUM_READ_FAILURE = -407; + ERR_CACHE_CHECKSUM_MISMATCH = -408; + ERR_CACHE_LOCK_TIMEOUT = -409; + ERR_CACHE_AUTH_FAILURE_AFTER_READ = -410; + ERR_CACHE_ENTRY_NOT_SUITABLE = -411; + ERR_CACHE_DOOM_FAILURE = -412; + ERR_CACHE_OPEN_OR_CREATE_FAILURE = -413; + ERR_INSECURE_RESPONSE = -501; + ERR_NO_PRIVATE_KEY_FOR_CERT = -502; + ERR_ADD_USER_CERT_FAILED = -503; + ERR_INVALID_SIGNED_EXCHANGE = -504; + ERR_FTP_FAILED = -601; + ERR_FTP_SERVICE_UNAVAILABLE = -602; + ERR_FTP_TRANSFER_ABORTED = -603; + ERR_FTP_FILE_BUSY = -604; + ERR_FTP_SYNTAX_ERROR = -605; + ERR_FTP_COMMAND_NOT_SUPPORTED = -606; + ERR_FTP_BAD_COMMAND_SEQUENCE = -607; + ERR_PKCS12_IMPORT_BAD_PASSWORD = -701; + ERR_PKCS12_IMPORT_FAILED = -702; + ERR_IMPORT_CA_CERT_NOT_CA = -703; + ERR_IMPORT_CERT_ALREADY_EXISTS = -704; + ERR_IMPORT_CA_CERT_FAILED = -705; + ERR_IMPORT_SERVER_CERT_FAILED = -706; + ERR_PKCS12_IMPORT_INVALID_MAC = -707; + ERR_PKCS12_IMPORT_INVALID_FILE = -708; + ERR_PKCS12_IMPORT_UNSUPPORTED = -709; + ERR_KEY_GENERATION_FAILED = -710; + ERR_PRIVATE_KEY_EXPORT_FAILED = -712; + ERR_SELF_SIGNED_CERT_GENERATION_FAILED = -713; + ERR_CERT_DATABASE_CHANGED = -714; + ERR_DNS_MALFORMED_RESPONSE = -800; + ERR_DNS_SERVER_REQUIRES_TCP = -801; + ERR_DNS_SERVER_FAILED = -802; + ERR_DNS_TIMED_OUT = -803; + ERR_NS_CACHE_MISS = -804; + ERR_DNS_SEARCH_EMPTY = -805; + ERR_DNS_SORT_ERROR = -806; + ERR_DNS_HTTP_FAILED = -807; // /include/internal/cef_types.h (cef_cert_status_t) CERT_STATUS_NONE = 0; @@ -160,6 +336,7 @@ const TT_SOURCE_MASK = $000000FF; TT_BLOCKED_FLAG = $00800000; TT_FORWARD_BACK_FLAG = $01000000; + TT_DIRECT_LOAD_FLAG = $02000000; TT_CHAIN_START_FLAG = $10000000; TT_CHAIN_END_FLAG = $20000000; TT_CLIENT_REDIRECT_FLAG = $40000000; @@ -171,11 +348,22 @@ const UR_FLAG_NONE = 0; UR_FLAG_SKIP_CACHE = 1 shl 0; UR_FLAG_ONLY_FROM_CACHE = 1 shl 1; - UR_FLAG_ALLOW_STORED_CREDENTIALS = 1 shl 2; - UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 shl 3; - UR_FLAG_NO_DOWNLOAD_DATA = 1 shl 4; - UR_FLAG_NO_RETRY_ON_5XX = 1 shl 5; - UR_FLAG_STOP_ON_REDIRECT = 1 shl 6; + UR_FLAG_DISABLE_CACHE = 1 shl 2; + UR_FLAG_ALLOW_STORED_CREDENTIALS = 1 shl 3; + UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 shl 4; + UR_FLAG_NO_DOWNLOAD_DATA = 1 shl 5; + UR_FLAG_NO_RETRY_ON_5XX = 1 shl 6; + UR_FLAG_STOP_ON_REDIRECT = 1 shl 7; + + // /include/internal/cef_types.h (cef_scheme_options_t) + CEF_SCHEME_OPTION_NONE = 0; + CEF_SCHEME_OPTION_STANDARD = 1 shl 0; + CEF_SCHEME_OPTION_LOCAL = 1 shl 1; + CEF_SCHEME_OPTION_DISPLAY_ISOLATED = 1 shl 2; + CEF_SCHEME_OPTION_SECURE = 1 shl 3; + CEF_SCHEME_OPTION_CORS_ENABLED = 1 shl 4; + CEF_SCHEME_OPTION_CSP_BYPASSING = 1 shl 5; + CEF_SCHEME_OPTION_FETCH_ENABLED = 1 shl 6; // /include/internal/cef_types.h (cef_dom_event_category_t) DOM_EVENT_CATEGORY_UNKNOWN = 0; @@ -210,6 +398,7 @@ const EVENTFLAG_IS_KEY_PAD = 1 shl 9; EVENTFLAG_IS_LEFT = 1 shl 10; EVENTFLAG_IS_RIGHT = 1 shl 11; + EVENTFLAG_ALTGR_DOWN = 1 shl 12; // /include/internal/cef_types.h (cef_drag_operations_mask_t) DRAG_OPERATION_NONE = 0; @@ -222,6 +411,10 @@ const DRAG_OPERATION_EVERY = $FFFFFFFF; // /include/internal/cef_types.h (cef_file_dialog_mode_t) + FILE_DIALOG_OPEN = $00000000; + FILE_DIALOG_OPEN_MULTIPLE = $00000001; + FILE_DIALOG_OPEN_FOLDER = $00000002; + FILE_DIALOG_SAVE = $00000003; FILE_DIALOG_TYPE_MASK = $000000FF; FILE_DIALOG_OVERWRITEPROMPT_FLAG = $01000000; FILE_DIALOG_HIDEREADONLY_FLAG = $02000000; @@ -232,8 +425,7 @@ const UU_SPACES = 1 shl 1; UU_PATH_SEPARATORS = 1 shl 2; UU_URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS = 1 shl 3; - UU_SPOOFING_AND_CONTROL_CHARS = 1 shl 4; - UU_REPLACE_PLUS_WITH_SPACE = 1 shl 5; + UU_REPLACE_PLUS_WITH_SPACE = 1 shl 4; // /include/internal/cef_types.h (cef_menu_id_t) MENU_ID_BACK = 100; @@ -304,6 +496,7 @@ const SSL_CONNECTION_VERSION_TLS1 = 3; SSL_CONNECTION_VERSION_TLS1_1 = 4; SSL_CONNECTION_VERSION_TLS1_2 = 5; + SSL_CONNECTION_VERSION_TLS1_3 = 6; SSL_CONNECTION_VERSION_QUIC = 7; // /include/internal/cef_types.h (cef_ssl_content_status_t) @@ -324,8 +517,46 @@ const LOGSEVERITY_INFO = 2; LOGSEVERITY_WARNING = 3; LOGSEVERITY_ERROR = 4; + LOGSEVERITY_FATAL = 5; LOGSEVERITY_DISABLE = 99; + // /include/internal/cef_types.h (cef_duplex_mode_t) + DUPLEX_MODE_UNKNOWN = -1; + DUPLEX_MODE_SIMPLEX = 0; + DUPLEX_MODE_LONG_EDGE = 1; + DUPLEX_MODE_SHORT_EDGE = 2; + + // /include/internal/cef_types.h (cef_media_route_create_result_t) + CEF_MRCR_UNKNOWN_ERROR = 0; + CEF_MRCR_OK = 1; + CEF_MRCR_TIMED_OUT = 2; + CEF_MRCR_ROUTE_NOT_FOUND = 3; + CEF_MRCR_SINK_NOT_FOUND = 4; + CEF_MRCR_INVALID_ORIGIN = 5; + CEF_MRCR_NO_SUPPORTED_PROVIDER = 7; + CEF_MRCR_CANCELLED = 8; + CEF_MRCR_ROUTE_ALREADY_EXISTS = 9; + CEF_MRCR_ROUTE_ALREADY_TERMINATED = 11; + CEF_MRCR_TOTAL_COUNT = 12; + + // /include/internal/cef_types.h (cef_cookie_priority_t) + CEF_COOKIE_PRIORITY_LOW = -1; + CEF_COOKIE_PRIORITY_MEDIUM = 0; + CEF_COOKIE_PRIORITY_HIGH = 1; + + // /include/internal/cef_types.h (cef_text_field_commands_t) + CEF_TFC_CUT = 1; + CEF_TFC_COPY = 2; + CEF_TFC_PASTE = 3; + CEF_TFC_UNDO = 4; + CEF_TFC_DELETE = 5; + CEF_TFC_SELECT_ALL = 6; + + // /include/cef_api_hash.h (used as "cef_api_hash" parameters) + CEF_API_HASH_PLATFORM = 0; + CEF_API_HASH_UNIVERSAL = 1; + CEF_COMMIT_HASH = 2; + //****************************************************** //****************** OTHER CONSTANTS ******************* @@ -339,18 +570,25 @@ const CEF_PROXYTYPE_FIXED_SERVERS = 3; CEF_PROXYTYPE_PAC_SCRIPT = 4; - CEF_CONTENT_SETTING_DEFAULT = 0; - CEF_CONTENT_SETTING_ALLOW = 1; - CEF_CONTENT_SETTING_BLOCK = 2; - CEF_CONTENT_SETTING_ASK = 3; - CEF_CONTENT_SETTING_SESSION_ONLY = 4; - CEF_CONTENT_SETTING_NUM_SETTINGS = 5; - // Used in the severity parameter in the 'cef_log' function, also known as 'CefLog' in CEF4Delphi. CEF_LOG_SEVERITY_INFO = 0; CEF_LOG_SEVERITY_WARNING = 1; CEF_LOG_SEVERITY_ERROR = 2; + CEF_MAX_CONNECTIONS_PER_PROXY_DEFAULT_VALUE = 32; + CEF_MAX_CONNECTIONS_PER_PROXY_MIN_VALUE = 7; + CEF_MAX_CONNECTIONS_PER_PROXY_MAX_VALUE = 99; + + CEF_COOKIE_PREF_DEFAULT = 0; + CEF_COOKIE_PREF_ALLOW = 1; + CEF_COOKIE_PREF_BLOCK = 2; + + // https://chromium.googlesource.com/chromium/src/+/refs/tags/77.0.3865.90/chrome/common/net/safe_search_util.h (YouTubeRestrictMode) + // https://www.chromium.org/administrators/policy-list-3#ForceYouTubeRestrict + YOUTUBE_RESTRICT_OFF = 0; + YOUTUBE_RESTRICT_MODERATE = 1; + YOUTUBE_RESTRICT_STRICT = 2; + ZOOM_STEP_25 = 0; ZOOM_STEP_33 = 1; ZOOM_STEP_50 = 2; @@ -367,21 +605,38 @@ const ZOOM_STEP_300 = 13; ZOOM_STEP_400 = 14; ZOOM_STEP_500 = 15; + ZOOM_STEP_UNK = 16; ZOOM_STEP_MIN = ZOOM_STEP_25; ZOOM_STEP_MAX = ZOOM_STEP_500; ZOOM_STEP_DEF = ZOOM_STEP_100; - {$IFDEF MSWINDOWS} - CEF_PREFERENCES_SAVED = WM_APP + $A00; - CEF_DOONCLOSE = WM_APP + $A01; - CEF_STARTDRAGGING = WM_APP + $A02; - CEF_AFTERCREATED = WM_APP + $A03; - CEF_PENDINGRESIZE = WM_APP + $A04; - CEF_PUMPHAVEWORK = WM_APP + $A05; - CEF_DESTROY = WM_APP + $A06; - CEF_DOONBEFORECLOSE = WM_APP + $A07; - CEF_PENDINGINVALIDATE = WM_APP + $A08; - {$ENDIF} + ZOOM_PCT_DELTA = 5; + + ZoomStepValues : array[ZOOM_STEP_MIN..ZOOM_STEP_MAX] of integer = (25, 33, 50, 67, 75, 90, 100, 110, 125, 150, 175, 200, 250, 300, 400, 500); + + CEF_PREFERENCES_SAVED = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A00; + CEF_DOONCLOSE = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A01; + CEF_STARTDRAGGING = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A02; + CEF_AFTERCREATED = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A03; + CEF_PENDINGRESIZE = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A04; + CEF_PUMPHAVEWORK = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A05; + CEF_DESTROY = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A06; + CEF_DOONBEFORECLOSE = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A07; + CEF_PENDINGINVALIDATE = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A08; + CEF_IMERANGECHANGED = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A09; + CEF_SENTINEL_START = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A0A; + CEF_SENTINEL_DOCLOSE = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A0B; + CEF_BEFORECLOSE = {$IFDEF MSWINDOWS}WM_APP +{$ENDIF} $A0C; + + // Lazarus and some old Delphi versions don't have these message contants + {$IF NOT DECLARED(WM_TOUCH)} + WM_TOUCH = $0240; + {$IFEND} + {$IF NOT DECLARED(WM_POINTERUPDATE)} + WM_POINTERUPDATE = $0245; + WM_POINTERDOWN = $0246; + WM_POINTERUP = $0247; + {$IFEND} CEF_TIMER_MINIMUM = $0000000A; CEF_TIMER_MAXIMUM = $7FFFFFFF; @@ -392,6 +647,20 @@ const CEF4DELPHI_URL = 'https://github.com/salvadordf/CEF4Delphi'; CRLF = #13 + #10; + // These contants are declared in the "Windows" unit but + // some old Delphi versions don't have them. + // We have to add "CEF_" to be compatible with C++ Builder. + CEF_IMAGE_FILE_MACHINE_I386 = $014C; + CEF_IMAGE_FILE_MACHINE_AMD64 = $8664; + + {$IF NOT DECLARED(USER_DEFAULT_SCREEN_DPI)} + USER_DEFAULT_SCREEN_DPI = 96; + {$IFEND} + + {$IF NOT DECLARED(INFINITE)} + INFINITE = Cardinal($FFFFFFFF); + {$IFEND} + implementation end. diff --git a/windows/src/ext/cef4delphi/source/uCEFContextMenuHandler.pas b/windows/src/ext/cef4delphi/source/uCEFContextMenuHandler.pas index 63319ec685946a90e6e537a1397fc4cc4ae0939f..ed52331ba954b4736359a0f412b9033dc8e15caa 100644 --- a/windows/src/ext/cef4delphi/source/uCEFContextMenuHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFContextMenuHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFContextMenuHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -79,7 +77,7 @@ type procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -216,11 +214,11 @@ end; // TCustomContextMenuHandler -constructor TCustomContextMenuHandler.Create(const events: Pointer); +constructor TCustomContextMenuHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomContextMenuHandler.Destroy; diff --git a/windows/src/ext/cef4delphi/source/uCEFContextMenuParams.pas b/windows/src/ext/cef4delphi/source/uCEFContextMenuParams.pas index 091269e2b7ba81ced4c8e7603f6585ed7c579d52..48bfb76abe4c08b737b43893f00ba7e7402550b1 100644 --- a/windows/src/ext/cef4delphi/source/uCEFContextMenuParams.pas +++ b/windows/src/ext/cef4delphi/source/uCEFContextMenuParams.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFContextMenuParams; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFCookieAccessFilter.pas b/windows/src/ext/cef4delphi/source/uCEFCookieAccessFilter.pas new file mode 100644 index 0000000000000000000000000000000000000000..64493a13acad4e6e73a1ae56ca626a4cd7ea5ea1 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFCookieAccessFilter.pas @@ -0,0 +1,247 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFCookieAccessFilter; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefCookieAccessFilterRef = class(TCefBaseRefCountedRef, ICefCookieAccessFilter) + protected + function CanSendCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie: PCefCookie): boolean; + function CanSaveCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; const cookie: PCefCookie): boolean; + + procedure RemoveReferences; + + public + class function UnWrap(data: Pointer): ICefCookieAccessFilter; + end; + + TCefCookieAccessFilterOwn = class(TCefBaseRefCountedOwn, ICefCookieAccessFilter) + protected + function CanSendCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie: PCefCookie): boolean; virtual; + function CanSaveCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; const cookie: PCefCookie): boolean; virtual; + + procedure RemoveReferences; virtual; + + public + constructor Create; virtual; + end; + + TCustomCookieAccessFilter = class(TCefCookieAccessFilterOwn) + protected + FEvents : Pointer; + + function CanSendCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie: PCefCookie): boolean; override; + function CanSaveCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; const cookie: PCefCookie): boolean; override; + + public + constructor Create(const events : IChromiumEvents); reintroduce; + procedure BeforeDestruction; override; + procedure RemoveReferences; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame, uCEFRequest, uCefResponse, uCEFRequestCallback; + +// TCefCookieAccessFilterOwn + +function cef_cookie_access_filter_can_send_cookie( self : PCefCookieAccessFilter; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + const cookie : PCefCookie): Integer; stdcall; +var + TempObject : TObject; +begin + Result := Ord(True); + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefCookieAccessFilterOwn) then + Result := Ord(TCefCookieAccessFilterOwn(TempObject).CanSendCookie(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + cookie)); +end; + +function cef_cookie_access_filter_can_save_cookie( self : PCefCookieAccessFilter; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + response : PCefResponse; + const cookie : PCefCookie): Integer; stdcall; +var + TempObject : TObject; +begin + Result := Ord(True); + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefCookieAccessFilterOwn) then + Result := Ord(TCefCookieAccessFilterOwn(TempObject).CanSaveCookie(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TCefResponseRef.UnWrap(response), + cookie)); +end; + +constructor TCefCookieAccessFilterOwn.Create; +begin + inherited CreateData(SizeOf(TCefCookieAccessFilter)); + + with PCefCookieAccessFilter(FData)^ do + begin + can_send_cookie := {$IFDEF FPC}@{$ENDIF}cef_cookie_access_filter_can_send_cookie; + can_save_cookie := {$IFDEF FPC}@{$ENDIF}cef_cookie_access_filter_can_save_cookie; + end; +end; + +function TCefCookieAccessFilterOwn.CanSendCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie: PCefCookie): boolean; +begin + Result := True; +end; + +function TCefCookieAccessFilterOwn.CanSaveCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; const cookie: PCefCookie): boolean; +begin + Result := True; +end; + +procedure TCefCookieAccessFilterOwn.RemoveReferences; +begin + // +end; + + +// TCefCookieAccessFilterRef + +class function TCefCookieAccessFilterRef.UnWrap(data: Pointer): ICefCookieAccessFilter; +begin + if (data <> nil) then + Result := Create(data) as ICefCookieAccessFilter + else + Result := nil; +end; + +function TCefCookieAccessFilterRef.CanSendCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie: PCefCookie): boolean; +begin + Result := (PCefCookieAccessFilter(FData)^.can_send_cookie(PCefCookieAccessFilter(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request), + cookie) <> 0); +end; + +function TCefCookieAccessFilterRef.CanSaveCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; const cookie: PCefCookie): boolean; +begin + Result := (PCefCookieAccessFilter(FData)^.can_save_cookie(PCefCookieAccessFilter(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request), + CefGetData(response), + cookie) <> 0); +end; + +procedure TCefCookieAccessFilterRef.RemoveReferences; +begin + // +end; + + +// TCustomCookieAccessFilter + + +constructor TCustomCookieAccessFilter.Create(const events : IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +procedure TCustomCookieAccessFilter.BeforeDestruction; +begin + FEvents := nil; + + inherited BeforeDestruction; +end; + +procedure TCustomCookieAccessFilter.RemoveReferences; +begin + FEvents := nil; +end; + +function TCustomCookieAccessFilter.CanSendCookie(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const cookie : PCefCookie): boolean; +begin + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doCanSendCookie(browser, frame, request, cookie) + else + Result := inherited CanSendCookie(browser, frame, request, cookie); +end; + +function TCustomCookieAccessFilter.CanSaveCookie(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + const cookie : PCefCookie): boolean; +begin + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doCanSaveCookie(browser, frame, request, response, cookie) + else + Result := inherited CanSaveCookie(browser, frame, request, response, cookie); +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFCookieManager.pas b/windows/src/ext/cef4delphi/source/uCEFCookieManager.pas index 26f253eb21bcd4fc930af6a7203acbb022c55fb7..63ca6c8c7be1d24b3ba3a106ddf2c4984e28312b 100644 --- a/windows/src/ext/cef4delphi/source/uCEFCookieManager.pas +++ b/windows/src/ext/cef4delphi/source/uCEFCookieManager.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFCookieManager; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,57 +54,41 @@ uses {$ELSE} Classes, SysUtils, {$ENDIF} - uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFCompletionCallback; type TCefCookieManagerRef = class(TCefBaseRefCountedRef, ICefCookieManager) protected - procedure SetSupportedSchemes(const schemes: TStrings; const callback: ICefCompletionCallback); - procedure SetSupportedSchemesProc(const schemes: TStrings; const callback: TCefCompletionCallbackProc); + procedure SetSupportedSchemes(const schemes: TStrings; include_defaults: boolean; const callback: ICefCompletionCallback); + procedure SetSupportedSchemesProc(const schemes: TStrings; include_defaults: boolean; const callback: TCefCompletionCallbackProc); function VisitAllCookies(const visitor: ICefCookieVisitor): Boolean; function VisitAllCookiesProc(const visitor: TCefCookieVisitorProc): Boolean; function VisitUrlCookies(const url: ustring; includeHttpOnly: Boolean; const visitor: ICefCookieVisitor): Boolean; function VisitUrlCookiesProc(const url: ustring; includeHttpOnly: Boolean; const visitor: TCefCookieVisitorProc): Boolean; - function SetCookie(const url: ustring; const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; const callback: ICefSetCookieCallback): Boolean; - function SetCookieProc(const url: ustring; const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; const callback: TCefSetCookieCallbackProc): Boolean; + function SetCookie(const url, name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; same_site : TCefCookieSameSite; priority : TCefCookiePriority; const callback: ICefSetCookieCallback): Boolean; + function SetCookieProc(const url: ustring; const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; same_site : TCefCookieSameSite; priority : TCefCookiePriority; const callback: TCefSetCookieCallbackProc): Boolean; function DeleteCookies(const url, cookieName: ustring; const callback: ICefDeleteCookiesCallback): Boolean; function DeleteCookiesProc(const url, cookieName: ustring; const callback: TCefDeleteCookiesCallbackProc): Boolean; - function SetStoragePath(const path: ustring; persistSessionCookies: Boolean; const callback: ICefCompletionCallback): Boolean; - function SetStoragePathProc(const path: ustring; persistSessionCookies: Boolean; const callback: TCefCompletionCallbackProc): Boolean; - function FlushStore(const handler: ICefCompletionCallback): Boolean; + function FlushStore(const callback: ICefCompletionCallback): Boolean; function FlushStoreProc(const proc: TCefCompletionCallbackProc): Boolean; public class function UnWrap(data: Pointer): ICefCookieManager; class function Global(const callback: ICefCompletionCallback): ICefCookieManager; class function GlobalProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; - class function Blocking : ICefCookieManager; - class function New(const path: ustring; persistSessionCookies: Boolean; const callback: ICefCompletionCallback): ICefCookieManager; - class function NewProc(const path: ustring; persistSessionCookies: Boolean; const callback: TCefCompletionCallbackProc): ICefCookieManager; + end; + + TCefFlushStoreCompletionCallback = class(TCefCustomCompletionCallback) + protected + procedure OnComplete; override; end; implementation uses - uCEFMiscFunctions, uCEFLibFunctions, uCEFCompletionCallback, uCEFDeleteCookiesCallback, + uCEFMiscFunctions, uCEFLibFunctions, uCEFDeleteCookiesCallback, uCEFSetCookieCallback, uCEFCookieVisitor, uCEFStringList; -class function TCefCookieManagerRef.New(const path : ustring; - persistSessionCookies : Boolean; - const callback : ICefCompletionCallback): ICefCookieManager; -var - pth: TCefString; -begin - pth := CefString(path); - Result := UnWrap(cef_cookie_manager_create_manager(@pth, Ord(persistSessionCookies), CefGetData(callback))); -end; - -class function TCefCookieManagerRef.NewProc(const path : ustring; - persistSessionCookies : Boolean; - const callback : TCefCompletionCallbackProc): ICefCookieManager; -begin - Result := New(path, persistSessionCookies, TCefFastCompletionCallback.Create(callback)); -end; function TCefCookieManagerRef.DeleteCookies(const url : ustring; const cookieName : ustring; @@ -126,9 +108,9 @@ begin Result := DeleteCookies(url, cookieName, TCefFastDeleteCookiesCallback.Create(callback)); end; -function TCefCookieManagerRef.FlushStore(const handler: ICefCompletionCallback): Boolean; +function TCefCookieManagerRef.FlushStore(const callback: ICefCompletionCallback): Boolean; begin - Result := PCefCookieManager(FData)^.flush_store(PCefCookieManager(FData), CefGetData(handler)) <> 0; + Result := PCefCookieManager(FData)^.flush_store(PCefCookieManager(FData), CefGetData(callback)) <> 0; end; function TCefCookieManagerRef.FlushStoreProc(const proc: TCefCompletionCallbackProc): Boolean; @@ -141,11 +123,6 @@ begin Result := UnWrap(cef_cookie_manager_get_global_manager(CefGetData(callback))); end; -class function TCefCookieManagerRef.Blocking : ICefCookieManager; -begin - Result := UnWrap(cef_cookie_manager_get_blocking_manager()); -end; - class function TCefCookieManagerRef.GlobalProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; begin Result := Global(TCefFastCompletionCallback.Create(callback)); @@ -154,77 +131,79 @@ end; function TCefCookieManagerRef.SetCookie(const url, name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; + same_site : TCefCookieSameSite; + priority : TCefCookiePriority; const callback: ICefSetCookieCallback): Boolean; var - str : TCefString; - cook : TCefCookie; + TempURL : TCefString; + TempCookie : TCefCookie; begin - str := CefString(url); - cook.name := CefString(name); - cook.value := CefString(value); - cook.domain := CefString(domain); - cook.path := CefString(path); - cook.secure := Ord(secure); - cook.httponly := Ord(httponly); - cook.creation := DateTimeToCefTime(creation); - cook.last_access := DateTimeToCefTime(lastAccess); - cook.has_expires := Ord(hasExpires); + TempURL := CefString(url); + TempCookie.name := CefString(name); + TempCookie.value := CefString(value); + TempCookie.domain := CefString(domain); + TempCookie.path := CefString(path); + TempCookie.secure := Ord(secure); + TempCookie.httponly := Ord(httponly); + TempCookie.creation := DateTimeToCefTime(creation); + TempCookie.last_access := DateTimeToCefTime(lastAccess); + TempCookie.has_expires := Ord(hasExpires); + TempCookie.same_site := same_site; + TempCookie.priority := priority; if hasExpires then - cook.expires := DateTimeToCefTime(expires) + TempCookie.expires := DateTimeToCefTime(expires) else - FillChar(cook.expires, SizeOf(TCefTime), 0); + FillChar(TempCookie.expires, SizeOf(TCefTime), 0); - Result := PCefCookieManager(FData)^.set_cookie(PCefCookieManager(FData), @str, @cook, CefGetData(callback)) <> 0; + Result := PCefCookieManager(FData)^.set_cookie(PCefCookieManager(FData), @TempURL, @TempCookie, CefGetData(callback)) <> 0; end; function TCefCookieManagerRef.SetCookieProc(const url, name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; + same_site : TCefCookieSameSite; + priority : TCefCookiePriority; const callback: TCefSetCookieCallbackProc): Boolean; begin Result := SetCookie(url, name, value, domain, path, secure, httponly, hasExpires, creation, lastAccess, expires, + same_site, priority, TCefFastSetCookieCallback.Create(callback)); end; -function TCefCookieManagerRef.SetStoragePath(const path : ustring; - persistSessionCookies : Boolean; - const callback : ICefCompletionCallback): Boolean; -var - p: TCefString; -begin - p := CefString(path); - Result := PCefCookieManager(FData)^.set_storage_path(PCefCookieManager(FData), @p, Ord(persistSessionCookies), CefGetData(callback)) <> 0; -end; - -function TCefCookieManagerRef.SetStoragePathProc(const path : ustring; - persistSessionCookies : Boolean; - const callback : TCefCompletionCallbackProc): Boolean; -begin - Result := SetStoragePath(path, persistSessionCookies, TCefFastCompletionCallback.Create(callback)); -end; - -procedure TCefCookieManagerRef.SetSupportedSchemes(const schemes: TStrings; const callback: ICefCompletionCallback); +procedure TCefCookieManagerRef.SetSupportedSchemes(const schemes : TStrings; + include_defaults : boolean; + const callback : ICefCompletionCallback); var - TempSL : ICefStringList; + TempSL : ICefStringList; + TempHandle : TCefStringList; begin try - TempSL := TCefStringListOwn.Create; - TempSL.AddStrings(schemes); + if (schemes <> nil) and (schemes.count > 0) then + begin + TempSL := TCefStringListOwn.Create; + TempSL.AddStrings(schemes); + TempHandle := TempSL.Handle; + end + else + TempHandle := nil; PCefCookieManager(FData)^.set_supported_schemes(PCefCookieManager(FData), - TempSL.Handle, + TempHandle, + ord(include_defaults), CefGetData(callback)); finally TempSL := nil; end; end; -procedure TCefCookieManagerRef.SetSupportedSchemesProc(const schemes: TStrings; const callback: TCefCompletionCallbackProc); +procedure TCefCookieManagerRef.SetSupportedSchemesProc(const schemes : TStrings; + include_defaults : boolean; + const callback : TCefCompletionCallbackProc); begin - SetSupportedSchemes(schemes, TCefFastCompletionCallback.Create(callback)); + SetSupportedSchemes(schemes, include_defaults, TCefFastCompletionCallback.Create(callback)); end; class function TCefCookieManagerRef.UnWrap(data: Pointer): ICefCookieManager; @@ -262,4 +241,21 @@ begin Result := VisitUrlCookies(url, includeHttpOnly, TCefFastCookieVisitor.Create(visitor) as ICefCookieVisitor); end; + +// TCefFlushStoreCompletionCallback + +procedure TCefFlushStoreCompletionCallback.OnComplete; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doOnCookiesStoreFlushed; + except + on e : exception do + if CustomExceptionHandler('TCefFlushStoreCompletionCallback.OnComplete', e) then raise; + end; + finally + FEvents := nil; + end; +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFCookieVisitor.pas b/windows/src/ext/cef4delphi/source/uCEFCookieVisitor.pas index 5b7e1d33bf909c56d7122eddd70a645211b1bc97..a9a33ca8b094ad89f8bf3451796857b18c5751e9 100644 --- a/windows/src/ext/cef4delphi/source/uCEFCookieVisitor.pas +++ b/windows/src/ext/cef4delphi/source/uCEFCookieVisitor.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFCookieVisitor; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,7 +54,7 @@ uses type TCefCookieVisitorOwn = class(TCefBaseRefCountedOwn, ICefCookieVisitor) protected - function visit(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; out deleteCookie: Boolean): Boolean; virtual; + function visit(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; same_site : TCefCookieSameSite; priority : TCefCookiePriority; out deleteCookie: Boolean): Boolean; virtual; public constructor Create; virtual; @@ -66,21 +64,39 @@ type protected FVisitor: TCefCookieVisitorProc; - function visit(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; out deleteCookie: Boolean): Boolean; override; + function visit(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; same_site : TCefCookieSameSite; priority : TCefCookiePriority; out deleteCookie: Boolean): Boolean; override; public constructor Create(const visitor: TCefCookieVisitorProc); reintroduce; end; + TCefCustomCookieVisitor = class(TCefCookieVisitorOwn) + protected + FEvents : Pointer; + FID : integer; + + function visit(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; same_site : TCefCookieSameSite; priority : TCefCookiePriority; out deleteCookie: Boolean): Boolean; override; + + public + constructor Create(const aEvents : IChromiumEvents; aID : integer); reintroduce; + destructor Destroy; override; + end; + implementation uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} uCEFMiscFunctions, uCEFLibFunctions; -function cef_cookie_visitor_visit(self: PCefCookieVisitor; - const cookie: PCefCookie; - count, total: Integer; - deleteCookie: PInteger): Integer; stdcall; +function cef_cookie_visitor_visit( self : PCefCookieVisitor; + const cookie : PCefCookie; + count : Integer; + total : Integer; + deleteCookie : PInteger): Integer; stdcall; var delete : Boolean; exp : TDateTime; @@ -108,6 +124,8 @@ begin exp, count, total, + cookie^.same_site, + cookie^.priority, delete)); deleteCookie^ := Ord(delete); @@ -126,6 +144,8 @@ function TCefCookieVisitorOwn.visit(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; + same_site : TCefCookieSameSite; + priority : TCefCookiePriority; out deleteCookie: Boolean): Boolean; begin Result := True; @@ -144,12 +164,68 @@ function TCefFastCookieVisitor.visit(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; + same_site : TCefCookieSameSite; + priority : TCefCookiePriority; out deleteCookie: Boolean): Boolean; begin Result := FVisitor(name, value, domain, path, secure, httponly, hasExpires, - creation, lastAccess, expires, count, total, deleteCookie); + creation, lastAccess, expires, count, total, same_site, + priority, deleteCookie); end; +// TCefCustomCookieVisitor + +constructor TCefCustomCookieVisitor.Create(const aEvents : IChromiumEvents; aID : integer); +begin + inherited Create; + + FEvents := Pointer(aEvents); + FID := aID; +end; + +destructor TCefCustomCookieVisitor.Destroy; +begin + try + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnCookieVisitorDestroyed(FID); + except + on e : exception do + if CustomExceptionHandler('TCefCustomCookieVisitor.Destroy', e) then raise; + end; + finally + FEvents := nil; + inherited Destroy; + end; +end; + +function TCefCustomCookieVisitor.visit(const name, value, domain, path: ustring; + secure, httponly, hasExpires: Boolean; + const creation, lastAccess, expires: TDateTime; + count, total: Integer; + same_site : TCefCookieSameSite; + priority : TCefCookiePriority; + out deleteCookie: Boolean): Boolean; +var + TempDelete : boolean; +begin + Result := True; + TempDelete := False; + + try + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnCookiesVisited(name, value, domain, path, secure, httponly, hasExpires, + creation, lastAccess, expires, count, total, FID, + same_site, priority, TempDelete, Result); + except + on e : exception do + if CustomExceptionHandler('TCefCustomCookieVisitor.visit', e) then raise; + end; + finally + deleteCookie := TempDelete; + end; +end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFCustomStreamReader.pas b/windows/src/ext/cef4delphi/source/uCEFCustomStreamReader.pas index 18c701088c0ea016403d5099f698579acb7fed2d..c7c2f5c042f6b76400e2ee76a3d2da5b5d31020f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFCustomStreamReader.pas +++ b/windows/src/ext/cef4delphi/source/uCEFCustomStreamReader.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFCustomStreamReader; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFDeleteCookiesCallback.pas b/windows/src/ext/cef4delphi/source/uCEFDeleteCookiesCallback.pas index f5a46c53443260e654624890aad989878d805486..80bc148b63edd04cd34822bfd54f674313aa6d5f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDeleteCookiesCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDeleteCookiesCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDeleteCookiesCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFDevToolsMessageObserver.pas b/windows/src/ext/cef4delphi/source/uCEFDevToolsMessageObserver.pas new file mode 100644 index 0000000000000000000000000000000000000000..86910e0271051991da5c94b1c1a0c01c6f415b97 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFDevToolsMessageObserver.pas @@ -0,0 +1,308 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDevToolsMessageObserver; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCEFDevToolsMessageObserverOwn = class(TCefBaseRefCountedOwn, ICefDevToolsMessageObserver) + protected + procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: Pointer; message_size: NativeUInt; var aHandled: boolean); virtual; + procedure OnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: Pointer; result_size: NativeUInt); virtual; + procedure OnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: Pointer; params_size: NativeUInt); virtual; + procedure OnDevToolsAgentAttached(const browser: ICefBrowser); virtual; + procedure OnDevToolsAgentDetached(const browser: ICefBrowser); virtual; + + public + constructor Create; virtual; + end; + + TCustomDevToolsMessageObserver = class(TCEFDevToolsMessageObserverOwn) + protected + FEvents : Pointer; + + procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: Pointer; message_size: NativeUInt; var aHandled: boolean); override; + procedure OnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: Pointer; result_size: NativeUInt); override; + procedure OnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: Pointer; params_size: NativeUInt); override; + procedure OnDevToolsAgentAttached(const browser: ICefBrowser); override; + procedure OnDevToolsAgentDetached(const browser: ICefBrowser); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; + destructor Destroy; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFJson; + + +// ************************************************************ +// ************** TCEFDevToolsMessageObserverOwn ************** +// ************************************************************ + +function cef_on_dev_tools_message( self : PCefDevToolsMessageObserver; + browser : PCefBrowser; + const message_ : Pointer; + message_size : NativeUInt): Integer; stdcall; +var + TempObject : TObject; + TempHandled : boolean; +begin + TempObject := CefGetObject(self); + TempHandled := False; + + if (TempObject <> nil) and (TempObject is TCEFDevToolsMessageObserverOwn) then + TCEFDevToolsMessageObserverOwn(TempObject).OnDevToolsMessage(TCefBrowserRef.UnWrap(browser), + message_, + message_size, + TempHandled); + + Result := ord(TempHandled); +end; + +procedure cef_on_dev_tools_method_result( self : PCefDevToolsMessageObserver; + browser : PCefBrowser; + message_id : Integer; + success : Integer; + const result : Pointer; + result_size : NativeUInt); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCEFDevToolsMessageObserverOwn) then + TCEFDevToolsMessageObserverOwn(TempObject).OnDevToolsMethodResult(TCefBrowserRef.UnWrap(browser), + message_id, + success <> 0, + result, + result_size); +end; + +procedure cef_on_dev_tools_event( self : PCefDevToolsMessageObserver; + browser : PCefBrowser; + const method : PCefString; + const params : Pointer; + params_size : NativeUInt); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCEFDevToolsMessageObserverOwn) then + TCEFDevToolsMessageObserverOwn(TempObject).OnDevToolsEvent(TCefBrowserRef.UnWrap(browser), + CefString(method), + params, + params_size); +end; + +procedure cef_on_dev_tools_agent_attached(self : PCefDevToolsMessageObserver; + browser : PCefBrowser); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCEFDevToolsMessageObserverOwn) then + TCEFDevToolsMessageObserverOwn(TempObject).OnDevToolsAgentAttached(TCefBrowserRef.UnWrap(browser)); +end; + +procedure cef_on_dev_tools_agent_detached(self : PCefDevToolsMessageObserver; + browser : PCefBrowser); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCEFDevToolsMessageObserverOwn) then + TCEFDevToolsMessageObserverOwn(TempObject).OnDevToolsAgentDetached(TCefBrowserRef.UnWrap(browser)); +end; + +constructor TCEFDevToolsMessageObserverOwn.Create; +begin + inherited CreateData(SizeOf(TCefDevToolsMessageObserver)); + + with PCefDevToolsMessageObserver(FData)^ do + begin + on_dev_tools_message := {$IFDEF FPC}@{$ENDIF}cef_on_dev_tools_message; + on_dev_tools_method_result := {$IFDEF FPC}@{$ENDIF}cef_on_dev_tools_method_result; + on_dev_tools_event := {$IFDEF FPC}@{$ENDIF}cef_on_dev_tools_event; + on_dev_tools_agent_attached := {$IFDEF FPC}@{$ENDIF}cef_on_dev_tools_agent_attached; + on_dev_tools_agent_detached := {$IFDEF FPC}@{$ENDIF}cef_on_dev_tools_agent_detached; + end; +end; + +procedure TCEFDevToolsMessageObserverOwn.OnDevToolsMessage(const browser : ICefBrowser; + const message_ : Pointer; + message_size : NativeUInt; + var aHandled : boolean); +begin + // +end; + +procedure TCEFDevToolsMessageObserverOwn.OnDevToolsMethodResult(const browser : ICefBrowser; + message_id : integer; + success : boolean; + const result : Pointer; + result_size : NativeUInt); +begin + // +end; + +procedure TCEFDevToolsMessageObserverOwn.OnDevToolsEvent(const browser : ICefBrowser; + const method : ustring; + const params : Pointer; + params_size : NativeUInt); +begin + // +end; + +procedure TCEFDevToolsMessageObserverOwn.OnDevToolsAgentAttached(const browser: ICefBrowser); +begin + // +end; + +procedure TCEFDevToolsMessageObserverOwn.OnDevToolsAgentDetached(const browser: ICefBrowser); +begin + // +end; + + +// ************************************************************ +// ************** TCustomDevToolsMessageObserver ************** +// ************************************************************ + +constructor TCustomDevToolsMessageObserver.Create(const events: IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +destructor TCustomDevToolsMessageObserver.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + +procedure TCustomDevToolsMessageObserver.OnDevToolsMessage(const browser : ICefBrowser; + const message_ : Pointer; + message_size : NativeUInt; + var aHandled : boolean); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnDevToolsMessage(browser, message_, message_size, aHandled); + except + on e : exception do + if CustomExceptionHandler('TCustomDevToolsMessageObserver.OnDevToolsMessage', e) then raise; + end; +end; + +procedure TCustomDevToolsMessageObserver.OnDevToolsMethodResult(const browser : ICefBrowser; + message_id : integer; + success : boolean; + const result : Pointer; + result_size : NativeUInt); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnDevToolsMethodResult(browser, message_id, success, result, result_size); + except + on e : exception do + if CustomExceptionHandler('TCustomDevToolsMessageObserver.OnDevToolsMethodResult', e) then raise; + end; +end; + +procedure TCustomDevToolsMessageObserver.OnDevToolsEvent(const browser : ICefBrowser; + const method : ustring; + const params : Pointer; + params_size : NativeUInt); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnDevToolsEvent(browser, method, params, params_size); + except + on e : exception do + if CustomExceptionHandler('TCustomDevToolsMessageObserver.OnDevToolsEvent', e) then raise; + end; +end; + +procedure TCustomDevToolsMessageObserver.OnDevToolsAgentAttached(const browser: ICefBrowser); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnDevToolsAgentAttached(browser); + except + on e : exception do + if CustomExceptionHandler('TCustomDevToolsMessageObserver.OnDevToolsAgentAttached', e) then raise; + end; +end; + +procedure TCustomDevToolsMessageObserver.OnDevToolsAgentDetached(const browser: ICefBrowser); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnDevToolsAgentDetached(browser); + except + on e : exception do + if CustomExceptionHandler('TCustomDevToolsMessageObserver.OnDevToolsAgentDetached', e) then raise; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFDialogHandler.pas b/windows/src/ext/cef4delphi/source/uCEFDialogHandler.pas index bc29d159a856462f89442873cb31e8db01386794..d1bed69ee753710858a60afb25c04c2f14a7de02 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDialogHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDialogHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDialogHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -78,7 +76,7 @@ type procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -160,11 +158,11 @@ end; // TCustomDialogHandler -constructor TCustomDialogHandler.Create(const events: Pointer); +constructor TCustomDialogHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomDialogHandler.Destroy; diff --git a/windows/src/ext/cef4delphi/source/uCEFDictionaryValue.pas b/windows/src/ext/cef4delphi/source/uCEFDictionaryValue.pas index 3d37a170b7557fb43b12b5ba3bf41cc630a25edc..222b244bc2ab0c0a232a3f3a68119fc21ea5d66a 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDictionaryValue.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDictionaryValue.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDictionaryValue; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFDisplay.pas b/windows/src/ext/cef4delphi/source/uCEFDisplay.pas new file mode 100644 index 0000000000000000000000000000000000000000..d60d58f7cc5724b21faaea1e7c3dff5ccbf1ea0f --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFDisplay.pas @@ -0,0 +1,181 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFDisplay; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefDisplayRef = class(TCefBaseRefCountedRef, ICefDisplay) + protected + function GetID : int64; + function GetDeviceScaleFactor : Single; + procedure ConvertPointToPixels(var point: TCefPoint); + procedure ConvertPointFromPixels(var point: TCefPoint); + function GetBounds : TCefRect; + function GetWorkArea : TCefRect; + function GetRotation : Integer; + + public + class function UnWrap(data: Pointer): ICefDisplay; + class function Primary: ICefDisplay; + class function NearestPoint(const point: TCefPoint; input_pixel_coords: boolean): ICefDisplay; + class function MatchingBounds(const bounds: TCefRect; input_pixel_coords: boolean): ICefDisplay; + class function GetCount: NativeUInt; + class function GetAlls(var aDisplayArray : TCefDisplayArray) : boolean; + end; + +implementation + +uses + uCEFLibFunctions; + +function TCefDisplayRef.GetID : int64; +begin + Result := PCefDisplay(FData)^.get_id(PCefDisplay(FData)); +end; + +function TCefDisplayRef.GetDeviceScaleFactor : Single; +begin + Result := PCefDisplay(FData)^.get_device_scale_factor(PCefDisplay(FData)); +end; + +procedure TCefDisplayRef.ConvertPointToPixels(var point: TCefPoint); +begin + PCefDisplay(FData)^.convert_point_to_pixels(PCefDisplay(FData), @point); +end; + +procedure TCefDisplayRef.ConvertPointFromPixels(var point: TCefPoint); +begin + PCefDisplay(FData)^.convert_point_from_pixels(PCefDisplay(FData), @point); +end; + +function TCefDisplayRef.GetBounds : TCefRect; +begin + Result := PCefDisplay(FData)^.get_bounds(PCefDisplay(FData)); +end; + +function TCefDisplayRef.GetWorkArea : TCefRect; +begin + Result := PCefDisplay(FData)^.get_work_area(PCefDisplay(FData)); +end; + +function TCefDisplayRef.GetRotation : Integer; +begin + Result := PCefDisplay(FData)^.get_rotation(PCefDisplay(FData)); +end; + +class function TCefDisplayRef.UnWrap(data: Pointer): ICefDisplay; +begin + if (data <> nil) then + Result := Create(data) as ICefDisplay + else + Result := nil; +end; + +class function TCefDisplayRef.Primary: ICefDisplay; +begin + Result := UnWrap(cef_display_get_primary()); +end; + +class function TCefDisplayRef.NearestPoint(const point: TCefPoint; input_pixel_coords: boolean): ICefDisplay; +begin + Result := UnWrap(cef_display_get_nearest_point(@point, ord(input_pixel_coords))); +end; + +class function TCefDisplayRef.MatchingBounds(const bounds: TCefRect; input_pixel_coords: boolean): ICefDisplay; +begin + Result := UnWrap(cef_display_get_matching_bounds(@bounds, ord(input_pixel_coords))); +end; + +class function TCefDisplayRef.GetCount: NativeUInt; +begin + Result := cef_display_get_count(); +end; + +class function TCefDisplayRef.GetAlls(var aDisplayArray : TCefDisplayArray) : boolean; +type + TDisplayArray = array of PCefDisplay; +var + i, displaysCount: NativeUInt; + displays: PPCefDisplay; + TempSize : integer; +begin + Result := False; + displaysCount := GetCount; + + if (displaysCount > 0) then + try + TempSize := SizeOf(TCefDisplay) * displaysCount; + GetMem(displays, TempSize); + FillChar(displays, TempSize, 0); + + cef_display_get_alls(@displaysCount, displays); + + SetLength(aDisplayArray, displaysCount); + + i := 0; + while (i < displaysCount) do + begin + aDisplayArray[i] := TCefDisplayRef.UnWrap(TDisplayArray(displays)[i]); + inc(i); + end; + + Result := True; + finally + FreeMem(displays); + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFDisplayHandler.pas b/windows/src/ext/cef4delphi/source/uCEFDisplayHandler.pas index ccf4e75264f42e9615ebd36be5b17d7b68d99774..84c288935e9900dd81cae063ca5e15273be07bbb 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDisplayHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDisplayHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDisplayHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -70,6 +68,7 @@ type function OnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const message_, source: ustring; line: Integer): Boolean; virtual; function OnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; virtual; procedure OnLoadingProgressChange(const browser: ICefBrowser; const progress: double); virtual; + procedure OnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); virtual; procedure RemoveReferences; virtual; @@ -90,11 +89,12 @@ type function OnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const message_, source: ustring; line: Integer): Boolean; override; function OnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; override; procedure OnLoadingProgressChange(const browser: ICefBrowser; const progress: double); override; + procedure OnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); override; procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -194,10 +194,10 @@ begin if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then begin - TempText := CefStringClearAndGet(text^); + TempText := CefStringClearAndGet(text); Result := Ord(TCefDisplayHandlerOwn(TempObject).OnTooltip(TCefBrowserRef.UnWrap(browser), TempText)); - text^ := CefStringAlloc(TempText); + if (text <> nil) then text^ := CefStringAlloc(TempText); end; end; @@ -262,6 +262,28 @@ begin progress); end; +function cef_display_handler_on_cursor_change( self : PCefDisplayHandler; + browser : PCefBrowser; + cursor : TCefCursorHandle; + type_ : TCefCursorType; + const custom_cursor_info : PCefCursorInfo): Integer; stdcall; +var + TempObject : TObject; + TempResult : boolean; +begin + TempResult := False; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefDisplayHandlerOwn) then + TCefDisplayHandlerOwn(TempObject).OnCursorChange(TCefBrowserRef.UnWrap(browser), + cursor, + type_, + custom_cursor_info, + TempResult); + + Result := Ord(TempResult); +end; + constructor TCefDisplayHandlerOwn.Create; begin inherited CreateData(SizeOf(TCefDisplayHandler)); @@ -277,6 +299,7 @@ begin on_console_message := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_console_message; on_auto_resize := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_auto_resize; on_loading_progress_change := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_loading_progress_change; + on_cursor_change := {$IFDEF FPC}@{$ENDIF}cef_display_handler_on_cursor_change; end; end; @@ -300,6 +323,11 @@ begin // end; +procedure TCefDisplayHandlerOwn.OnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); +begin + aResult := False; +end; + procedure TCefDisplayHandlerOwn.OnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); begin // @@ -332,11 +360,11 @@ end; // TCustomDisplayHandler -constructor TCustomDisplayHandler.Create(const events: Pointer); +constructor TCustomDisplayHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomDisplayHandler.Destroy; @@ -355,7 +383,8 @@ procedure TCustomDisplayHandler.OnAddressChange(const browser : ICefBrowser; const frame : ICefFrame; const url : ustring); begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnAddressChange(browser, frame, url); + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnAddressChange(browser, frame, url); end; function TCustomDisplayHandler.OnConsoleMessage(const browser : ICefBrowser; @@ -380,27 +409,42 @@ end; procedure TCustomDisplayHandler.OnLoadingProgressChange(const browser: ICefBrowser; const progress: double); begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnLoadingProgressChange(browser, progress); + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnLoadingProgressChange(browser, progress); +end; + +procedure TCustomDisplayHandler.OnCursorChange(const browser : ICefBrowser; + cursor_ : TCefCursorHandle; + cursorType : TCefCursorType; + const customCursorInfo : PCefCursorInfo; + var aResult : boolean); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnCursorChange(browser, cursor_, cursorType, customCursorInfo, aResult); end; procedure TCustomDisplayHandler.OnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnFaviconUrlChange(browser, iconUrls); + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnFaviconUrlChange(browser, iconUrls); end; procedure TCustomDisplayHandler.OnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnFullScreenModeChange(browser, fullscreen); + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnFullScreenModeChange(browser, fullscreen); end; procedure TCustomDisplayHandler.OnStatusMessage(const browser: ICefBrowser; const value: ustring); begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnStatusMessage(browser, value); + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnStatusMessage(browser, value); end; procedure TCustomDisplayHandler.OnTitleChange(const browser: ICefBrowser; const title: ustring); begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnTitleChange(browser, title); + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnTitleChange(browser, title); end; function TCustomDisplayHandler.OnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; diff --git a/windows/src/ext/cef4delphi/source/uCEFDomDocument.pas b/windows/src/ext/cef4delphi/source/uCEFDomDocument.pas index 32291aa9cbe0f4d599ab71415530ddd69ec297ba..fbcd593727555dcfc83e29666b856908fefec31a 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDomDocument.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDomDocument.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDomDocument; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFDomNode.pas b/windows/src/ext/cef4delphi/source/uCEFDomNode.pas index 1984f866cb43ef3cce5109b9729cb83f2955bffe..02cea3a6c261d5357d395af157370bbcbeaa7152 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDomNode.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDomNode.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDomNode; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFDomVisitor.pas b/windows/src/ext/cef4delphi/source/uCEFDomVisitor.pas index cf22bc12b8580e42713c6ab762683d7ba830a7a6..2aaa8d5a1b75b6d5c38c3ce8f49031123620e443 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDomVisitor.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDomVisitor.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,17 +41,15 @@ unit uCEFDomVisitor; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} interface uses - uCEFBaseRefCounted, uCEFInterfaces; + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; type TCefDomVisitorOwn = class(TCefBaseRefCountedOwn, ICefDomVisitor) @@ -76,18 +74,34 @@ type protected FProc : TCefDomVisitorProc2; FBrowser : ICefBrowser; + FFrame : ICefFrame; procedure visit(const document: ICefDomDocument); override; public - constructor Create(const browser: ICefBrowser; const proc: TCefDomVisitorProc2); reintroduce; virtual; + constructor Create(const browser: ICefBrowser; const frame: ICefFrame; const proc: TCefDomVisitorProc2); reintroduce; virtual; destructor Destroy; override; end; + TCefFastDomVisitor3 = class(TCefDomVisitorOwn) + protected + FProc : TCefDomVisitorProc3; + FBrowser : ICefBrowser; + FFrame : ICefFrame; + FValue : ustring; + + procedure visit(const document: ICefDomDocument); override; + + public + constructor Create(const browser: ICefBrowser; const frame: ICefFrame; const proc: TCefDomVisitorProc3; const aValue : ustring); reintroduce; virtual; + destructor Destroy; override; + end; + + implementation uses - uCEFMiscFunctions, uCEFLibFunctions, uCEFTypes, uCEFDomDocument; + uCEFMiscFunctions, uCEFLibFunctions, uCEFDomDocument; procedure cef_dom_visitor_visite(self: PCefDomVisitor; document: PCefDomDocument); stdcall; var @@ -130,24 +144,52 @@ end; // TCefFastDomVisitor2 -constructor TCefFastDomVisitor2.Create(const browser: ICefBrowser; const proc: TCefDomVisitorProc2); +constructor TCefFastDomVisitor2.Create(const browser: ICefBrowser; const frame: ICefFrame; const proc: TCefDomVisitorProc2); begin inherited Create; FBrowser := browser; + FFrame := frame; FProc := proc; end; destructor TCefFastDomVisitor2.Destroy; begin FBrowser := nil; + FFrame := nil; inherited Destroy; end; procedure TCefFastDomVisitor2.visit(const document: ICefDomDocument); begin - FProc(FBrowser, document); + FProc(FBrowser, FFrame, document); +end; + + +// TCefFastDomVisitor3 + +constructor TCefFastDomVisitor3.Create(const browser: ICefBrowser; const frame: ICefFrame; const proc: TCefDomVisitorProc3; const aValue : ustring); +begin + inherited Create; + + FBrowser := browser; + FFrame := frame; + FProc := proc; + FValue := aValue; +end; + +destructor TCefFastDomVisitor3.Destroy; +begin + FBrowser := nil; + FFrame := nil; + + inherited Destroy; +end; + +procedure TCefFastDomVisitor3.visit(const document: ICefDomDocument); +begin + FProc(FBrowser, FFrame, document, FValue); end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFDownLoadItem.pas b/windows/src/ext/cef4delphi/source/uCEFDownLoadItem.pas index a2475f15f76202cf1db9de49da8da9e1475c246a..5263bcfd5b5d2d786104586a88eec35c691a9559 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDownLoadItem.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDownLoadItem.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDownLoadItem; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFDownloadHandler.pas b/windows/src/ext/cef4delphi/source/uCEFDownloadHandler.pas index 4179fa03b827faafb3e2a24038bb677c745c8d2b..13c0185ab2aafd14e9bedd04f0dafc80ec896474 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDownloadHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDownloadHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDownloadHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -75,7 +73,7 @@ type procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -150,11 +148,11 @@ end; // TCustomDownloadHandler -constructor TCustomDownloadHandler.Create(const events: Pointer); +constructor TCustomDownloadHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomDownloadHandler.Destroy; diff --git a/windows/src/ext/cef4delphi/source/uCEFDownloadImageCallBack.pas b/windows/src/ext/cef4delphi/source/uCEFDownloadImageCallBack.pas index 4c27f85ef3f1987bcf7a50a31fa0ac99ff03b57b..eb77e7728b402b2a4277d14764eec86a9d32b6dc 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDownloadImageCallBack.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDownloadImageCallBack.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDownloadImageCallBack; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -72,11 +70,31 @@ type constructor Create(const proc: TOnDownloadImageFinishedProc); reintroduce; end; + TCefCustomDownloadImageCallback = class(TCefDownloadImageCallbackOwn) + protected + FEvents : Pointer; + + procedure OnDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); override; + + public + constructor Create(const aEvents : IChromiumEvents); reintroduce; + destructor Destroy; override; + end; + implementation + uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} uCEFMiscFunctions, uCEFLibFunctions, uCEFImage; + +// TCefDownloadImageCallbackOwn + procedure cef_download_image_callback_on_download_image_finished( self : PCefDownloadImageCallback; const image_url : PCefString; http_status_code : Integer; @@ -100,6 +118,9 @@ begin on_download_image_finished := {$IFDEF FPC}@{$ENDIF}cef_download_image_callback_on_download_image_finished; end; + +// TCefFastDownloadImageCallback + constructor TCefFastDownloadImageCallback.Create(const proc: TOnDownloadImageFinishedProc); begin inherited Create; @@ -113,5 +134,37 @@ begin end; +// TCefCustomDownloadImageCallback + +constructor TCefCustomDownloadImageCallback.Create(const aEvents : IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(aEvents); +end; + +destructor TCefCustomDownloadImageCallback.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + +procedure TCefCustomDownloadImageCallback.OnDownloadImageFinished(const imageUrl : ustring; + httpStatusCode : Integer; + const image : ICefImage); +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doDownloadImageFinished(imageUrl, httpStatusCode, image); + except + on e : exception do + if CustomExceptionHandler('TCefCustomDownloadImageCallback.OnDownloadImageFinished', e) then raise; + end; + finally + FEvents := nil; + end; +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFDownloadItemCallback.pas b/windows/src/ext/cef4delphi/source/uCEFDownloadItemCallback.pas index 7ac4f978c10a9ddc13fe6ddd9ae87f55118610e6..cfc872ef9068f15d2d9b2bc6b8dbd264a48a4197 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDownloadItemCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDownloadItemCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDownloadItemCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFDragAndDropMgr.pas b/windows/src/ext/cef4delphi/source/uCEFDragAndDropMgr.pas index ab250cf7550cb63c08a4a6ad6963623c887849d0..a11dbbf9a2abcda26b9544cad9ec6015853f4c03 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDragAndDropMgr.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDragAndDropMgr.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -43,17 +43,22 @@ unit uCEFDragAndDropMgr; {$I cef.inc} +{$IFNDEF FPC}{$IFNDEF DELPHI12_UP} + // Workaround for "Internal error" in old Delphi versions caused by uint64 handling + {$R-} +{$ENDIF}{$ENDIF} + interface uses {$IFDEF DELPHI16_UP} {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.ActiveX, WinApi.ShlObj, WinApi.ShellApi,{$ENDIF} - System.Classes, Vcl.Controls, System.SysUtils, System.Math, System.StrUtils, System.AnsiStrings, + System.Classes, System.SysUtils, System.Math, System.StrUtils, System.AnsiStrings, {$ELSE} {$IFDEF MSWINDOWS}Windows, ActiveX, ShlObj, Shellapi,{$ENDIF} - Classes, Controls, SysUtils, Math, StrUtils, + Classes, SysUtils, Math, StrUtils, {$IFDEF DELPHI12_UP}AnsiStrings,{$ENDIF} {$ENDIF} - uCEFDragData, uCEFInterfaces, uCEFTypes, uOLEDragAndDrop; + uCEFDragData, uCEFInterfaces, uCEFTypes, uCEFOLEDragAndDrop; type TDragEnterEvent = procedure(Sender: TObject; const aDragData : ICefDragData; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint) of object; @@ -116,6 +121,14 @@ implementation uses uCEFMiscFunctions, uCEFWriteHandler, uCEFStreamWriter, uCEFConstants; +{$IFDEF FPC} +const + //CFSTR_FILEDESCRIPTORA = 'FileGroupDescriptor'; // CF_FILEGROUPDESCRIPTORA + CFSTR_FILEDESCRIPTORW = 'FileGroupDescriptorW'; // CF_FILEGROUPDESCRIPTORW + CFSTR_FILEDESCRIPTOR = CFSTR_FILEDESCRIPTORW; + CFSTR_FILECONTENTS = 'FileContents'; // CF_FILECONTENTS +{$ENDIF} + // ***************************************************** // **************** TCEFDragAndDropMgr ***************** // ***************************************************** @@ -352,21 +365,21 @@ begin BODY_END_TAG + CRLF + HTML_END_TAG; - TempPos := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(HTML_START_TAG, TempString) + length(HTML_START_TAG); + TempPos := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(HTML_START_TAG, TempString) + length(HTML_START_TAG); TempDigits := ZeroFiller(TempPos, length(PATTERN1)); - TempString := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}StringReplace(TempString, PATTERN1, TempDigits, [rfReplaceAll]); + TempString := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}StringReplace(TempString, PATTERN1, TempDigits, [rfReplaceAll]); - TempPos := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(HTML_END_TAG, TempString); + TempPos := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(HTML_END_TAG, TempString); TempDigits := ZeroFiller(TempPos, length(PATTERN2)); - TempString := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}StringReplace(TempString, PATTERN2, TempDigits, [rfReplaceAll]); + TempString := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}StringReplace(TempString, PATTERN2, TempDigits, [rfReplaceAll]); - TempPos := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(FRAGMENT_START, TempString) + length(FRAGMENT_START); + TempPos := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(FRAGMENT_START, TempString) + length(FRAGMENT_START); TempDigits := ZeroFiller(TempPos, length(PATTERN3)); - TempString := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}StringReplace(TempString, PATTERN3, TempDigits, [rfReplaceAll]); + TempString := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}StringReplace(TempString, PATTERN3, TempDigits, [rfReplaceAll]); - TempPos := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(FRAGMENT_END, TempString); + TempPos := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(FRAGMENT_END, TempString); TempDigits := ZeroFiller(TempPos, length(PATTERN4)); - TempString := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}StringReplace(TempString, PATTERN4, TempDigits, [rfReplaceAll]); + TempString := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}StringReplace(TempString, PATTERN4, TempDigits, [rfReplaceAll]); Result := TempString; end; @@ -443,12 +456,12 @@ begin TempFragStartCommentPos := pos(FRAGMENT_START, cf_html); if (TempFragStartCommentPos > 0) then - TempFragStartCommentPos := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx('-->', cf_html, TempFragStartCommentPos + length(FRAGMENT_START)); + TempFragStartCommentPos := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx('-->', cf_html, TempFragStartCommentPos + length(FRAGMENT_START)); if (TempFragStartCommentPos > 0) then begin TempFragStartCommentPos := TempFragStartCommentPos + 3; - TempFragEndCommentPos := {$IFDEF DELPHI18_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(FRAGMENT_END, cf_html, TempFragStartCommentPos); + TempFragEndCommentPos := {$IFDEF DELPHI12_UP}{$IFDEF DELPHI16_UP}System.{$ENDIF}AnsiStrings.{$ENDIF}PosEx(FRAGMENT_END, cf_html, TempFragStartCommentPos); end else if (TempFragStart > 0) and @@ -549,6 +562,7 @@ begin begin TempText := PWideChar(TempPointer); TempPos := LastDelimiter(#13, TempText); + if (TempPos <= 0) then TempPos := LastDelimiter(#10, TempText); if (TempPos > 0) then begin @@ -666,7 +680,11 @@ begin while (TempEnumFrmt.Next(1, TempFormat, nil) = S_OK) and not(TempUsed) do begin try + {$IFNDEF FPC} TempMedium.unkForRelease := nil; + {$ELSE} + TempMedium.PUnkForRelease := nil; + {$ENDIF} if ((TempFormat.tymed and TYMED_HGLOBAL) <> 0) and (aDataObject.GetData(TempFormat, TempMedium) = S_OK) then @@ -721,7 +739,11 @@ begin TempResEffect := DROPEFFECT_NONE; TempDataObject := TOLEDataObject.Create(TempFormatArray, TempMediumArray, i); TempDropSource := TOLEDropSource.Create; + {$IFNDEF FPC} TempResult := DoDragDrop(TempDataObject, TempDropSource, FOLEEffect, TempResEffect); + {$ELSE} + TempResult := DoDragDrop(TempDataObject, TempDropSource, DWORD(FOLEEffect), LPDWORD(TempResEffect)); + {$ENDIF} if (TempResult <> DRAGDROP_S_DROP) then TempResEffect := DROPEFFECT_NONE; FCurrentDragData := nil; diff --git a/windows/src/ext/cef4delphi/source/uCEFDragData.pas b/windows/src/ext/cef4delphi/source/uCEFDragData.pas index 75c98a8565a956c72e44b7388a0781d3331f43c1..f76fe9edc818883a2ab17d362988896d604331e3 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDragData.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDragData.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDragData; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFDragHandler.pas b/windows/src/ext/cef4delphi/source/uCEFDragHandler.pas index 35d18a49960e60a7e7d7a0cc5ed89dd662cf2f0a..b901f0366d2e6abc375f8927f48e9e0c2b08c0ac 100644 --- a/windows/src/ext/cef4delphi/source/uCEFDragHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFDragHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFDragHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -57,7 +55,7 @@ type TCefDragHandlerOwn = class(TCefBaseRefCountedOwn, ICefDragHandler) protected function OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; virtual; - procedure OnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); virtual; + procedure OnDraggableRegionsChanged(const browser: ICefBrowser; const frame: ICefFrame; regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); virtual; procedure RemoveReferences; virtual; @@ -70,12 +68,12 @@ type FEvents : Pointer; function OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; override; - procedure OnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); override; + procedure OnDraggableRegionsChanged(const browser: ICefBrowser; const frame: ICefFrame; regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); override; procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -87,7 +85,7 @@ uses {$ELSE} SysUtils, {$ENDIF} - uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFDragData; + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFDragData, uCEFFrame; function cef_drag_handler_on_drag_enter(self : PCefDragHandler; browser : PCefBrowser; @@ -105,10 +103,11 @@ begin mask)); end; -procedure cef_drag_handler_on_draggable_regions_changed(self : PCefDragHandler; - browser : PCefBrowser; - regionsCount : NativeUInt; - regions : PCefDraggableRegionArray); stdcall; +procedure cef_drag_handler_on_draggable_regions_changed( self : PCefDragHandler; + browser : PCefBrowser; + frame : PCefFrame; + regionsCount : NativeUInt; + const regions : PCefDraggableRegionArray); stdcall; var TempObject : TObject; begin @@ -116,6 +115,7 @@ begin if (TempObject <> nil) and (TempObject is TCefDragHandlerOwn) then TCefDragHandlerOwn(TempObject).OnDraggableRegionsChanged(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), regionsCount, regions); end; @@ -139,8 +139,9 @@ begin end; procedure TCefDragHandlerOwn.OnDraggableRegionsChanged(const browser : ICefBrowser; + const frame : ICefFrame; regionsCount : NativeUInt; - regions : PCefDraggableRegionArray); + const regions : PCefDraggableRegionArray); begin // end; @@ -152,11 +153,11 @@ end; // TCustomDragHandler -constructor TCustomDragHandler.Create(const events: Pointer); +constructor TCustomDragHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomDragHandler.Destroy; @@ -182,10 +183,11 @@ begin end; procedure TCustomDragHandler.OnDraggableRegionsChanged(const browser : ICefBrowser; + const frame : ICefFrame; regionsCount : NativeUInt; - regions : PCefDraggableRegionArray); + const regions : PCefDraggableRegionArray); begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnDraggableRegionsChanged(browser, regionsCount, regions); + if (FEvents <> nil) then IChromiumEvents(FEvents).doOnDraggableRegionsChanged(browser, frame, regionsCount, regions); end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFEndTracingCallback.pas b/windows/src/ext/cef4delphi/source/uCEFEndTracingCallback.pas index e32657e249b00201229dbb1718fc0b2df7b5dc6c..2c6f905436cc8f977f98b4e596f033590570c09c 100644 --- a/windows/src/ext/cef4delphi/source/uCEFEndTracingCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFEndTracingCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFEndTracingCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFExtension.pas b/windows/src/ext/cef4delphi/source/uCEFExtension.pas index 275efb0fb7449c81e3add82e61631d460e22a682..12f20c914131032a952d666ff39964a3c8aca052 100644 --- a/windows/src/ext/cef4delphi/source/uCEFExtension.pas +++ b/windows/src/ext/cef4delphi/source/uCEFExtension.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFExtension; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -64,6 +62,16 @@ type function GetLoaderContext: ICefRequestContext; function IsLoaded : boolean; procedure unload; + function GetPopup(const aParent : ustring) : ustring; + function GetIcon(const aParent : ustring) : ustring; + function GetBrowserActionPopup : ustring; + function GetBrowserActionIcon : ustring; + function GetPageActionPopup : ustring; + function GetPageActionIcon : ustring; + function GetOptionsPage : ustring; + function GetOptionsUIPage : ustring; + function GetBackgroundPage : ustring; + function GetURL : ustring; public class function UnWrap(data: Pointer): ICefExtension; @@ -72,7 +80,8 @@ type implementation uses - uCEFMiscFunctions, uCEFLibFunctions, uCEFDictionaryValue, uCEFRequestContext, uCefExtensionHandler; + uCEFMiscFunctions, uCEFLibFunctions, uCEFDictionaryValue, uCEFRequestContext, + uCEFExtensionHandler, uCEFJson; function TCefExtensionRef.GetIdentifier : ustring; begin @@ -114,6 +123,101 @@ begin PCefExtension(FData)^.unload(PCefExtension(FData)); end; +function TCefExtensionRef.GetPopup(const aParent : ustring) : ustring; +var + TempManifest, TempBrowserAction : ICefDictionaryValue; +begin + Result := ''; + TempManifest := GetManifest; + + if (TempManifest <> nil) and + TCEFJson.ReadDictionary(TempManifest, aParent, TempBrowserAction) then + TCEFJson.ReadString(TempBrowserAction, 'default_popup', Result); +end; + +function TCefExtensionRef.GetIcon(const aParent : ustring) : ustring; +var + TempManifest, TempBrowserAction, TempDefIcon : ICefDictionaryValue; + TempResult : ustring; +begin + Result := ''; + TempManifest := GetManifest; + + if (TempManifest <> nil) and + TCEFJson.ReadDictionary(TempManifest, aParent, TempBrowserAction) then + begin + if TCEFJson.ReadString(TempBrowserAction, 'default_icon', TempResult) then + Result := TempResult + else + if TCEFJson.ReadDictionary(TempManifest, 'default_icon', TempDefIcon) and + (TCEFJson.ReadString(TempDefIcon, '128', TempResult) or + TCEFJson.ReadString(TempDefIcon, '48', TempResult) or + TCEFJson.ReadString(TempDefIcon, '32', TempResult) or + TCEFJson.ReadString(TempDefIcon, '16', TempResult)) then + Result := TempResult + end; +end; + +function TCefExtensionRef.GetBrowserActionPopup : ustring; +begin + Result := GetPopup('browser_action'); +end; + +function TCefExtensionRef.GetBrowserActionIcon : ustring; +begin + Result := GetIcon('browser_action'); +end; + +function TCefExtensionRef.GetPageActionPopup : ustring; +begin + Result := GetPopup('page_action'); +end; + +function TCefExtensionRef.GetPageActionIcon : ustring; +begin + Result := GetIcon('page_action'); +end; + +function TCefExtensionRef.GetOptionsPage : ustring; +var + TempManifest : ICefDictionaryValue; +begin + Result := ''; + TempManifest := GetManifest; + + if (TempManifest <> nil) then + TCEFJson.ReadString(TempManifest, 'options_page', Result); +end; + +function TCefExtensionRef.GetOptionsUIPage : ustring; +var + TempManifest, TempOptions : ICefDictionaryValue; +begin + Result := ''; + TempManifest := GetManifest; + + if (TempManifest <> nil) and + TCEFJson.ReadDictionary(TempManifest, 'options_ui', TempOptions) then + TCEFJson.ReadString(TempOptions, 'page', Result); +end; + +function TCefExtensionRef.GetBackgroundPage : ustring; +var + TempManifest, TempBackground : ICefDictionaryValue; +begin + Result := ''; + TempManifest := GetManifest; + + if (TempManifest <> nil) and + TCEFJson.ReadDictionary(TempManifest, 'background', TempBackground) then + TCEFJson.ReadString(TempBackground, 'page', Result); +end; + +function TCefExtensionRef.GetURL : ustring; +begin + Result := 'chrome-extension://' + GetIdentifier + '/'; +end; + class function TCefExtensionRef.UnWrap(data: Pointer): ICefExtension; begin if (data <> nil) then diff --git a/windows/src/ext/cef4delphi/source/uCEFExtensionHandler.pas b/windows/src/ext/cef4delphi/source/uCEFExtensionHandler.pas index 3c163b1efe19ef589c6348f23c1612816eaaf153..0bcc15318f0fead26f046a0d6d4cef7e6b885604 100644 --- a/windows/src/ext/cef4delphi/source/uCEFExtensionHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFExtensionHandler.pas @@ -1,8 +1,8 @@ -// ************************************************************************ +// ************************************************************************ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -36,24 +36,22 @@ *) unit uCEFExtensionHandler; - -{$IFDEF FPC} + +{$IFDEF FPC} {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface -{$I cef.inc} - -interface - -uses - uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; - -type +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type TCefExtensionHandlerRef = class(TCefBaseRefCountedRef, ICefExtensionHandler) protected procedure OnExtensionLoadFailed(result: TCefErrorcode); @@ -61,61 +59,88 @@ type procedure OnExtensionUnloaded(const extension: ICefExtension); function OnBeforeBackgroundBrowser(const extension: ICefExtension; const url: ustring; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; function OnBeforeBrowser(const extension: ICefExtension; const browser, active_browser: ICefBrowser; index: Integer; const url: ustring; active: boolean; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; - function GetActiveBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean): ICefBrowser; + procedure GetActiveBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; var aRsltBrowser: ICefBrowser); function CanAccessBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; const target_browser: ICefBrowser): boolean; function GetExtensionResource(const extension: ICefExtension; const browser: ICefBrowser; const file_: ustring; const callback: ICefGetExtensionResourceCallback): boolean; + procedure RemoveReferences; public class function UnWrap(data: Pointer): ICefExtensionHandler; - end; - - TCefExtensionHandlerOwn = class(TCefBaseRefCountedOwn, ICefExtensionHandler) + end; + + TCefExtensionHandlerOwn = class(TCefBaseRefCountedOwn, ICefExtensionHandler) protected procedure OnExtensionLoadFailed(result: TCefErrorcode); virtual; procedure OnExtensionLoaded(const extension: ICefExtension); virtual; procedure OnExtensionUnloaded(const extension: ICefExtension); virtual; function OnBeforeBackgroundBrowser(const extension: ICefExtension; const url: ustring; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; virtual; - function OnBeforeBrowser(const extension: ICefExtension; const browser, active_browser: ICefBrowser; index: Integer; const url: ustring; active: boolean; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; - function GetActiveBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean): ICefBrowser; virtual; + function OnBeforeBrowser(const extension: ICefExtension; const browser, active_browser: ICefBrowser; index: Integer; const url: ustring; active: boolean; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; virtual; + procedure GetActiveBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; var aRsltBrowser: ICefBrowser); virtual; function CanAccessBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; const target_browser: ICefBrowser): boolean; virtual; function GetExtensionResource(const extension: ICefExtension; const browser: ICefBrowser; const file_: ustring; const callback: ICefGetExtensionResourceCallback): boolean; virtual; + procedure RemoveReferences; virtual; public constructor Create; virtual; - end; - -implementation - -uses - uCEFMiscFunctions, uCEFLibFunctions, uCEFGetExtensionResourceCallback, uCEFExtension, uCEFBrowser, uCEFClient; - - -// *************************************************************************** -// ************************ TCefExtensionHandlerRef ************************** -// *************************************************************************** - -procedure TCefExtensionHandlerRef.OnExtensionLoadFailed(result: TCefErrorcode); -begin - -end; - + end; + + TCustomExtensionHandler = class(TCefExtensionHandlerOwn) + protected + FEvents : Pointer; + + procedure OnExtensionLoadFailed(result: TCefErrorcode); override; + procedure OnExtensionLoaded(const extension: ICefExtension); override; + procedure OnExtensionUnloaded(const extension: ICefExtension); override; + function OnBeforeBackgroundBrowser(const extension: ICefExtension; const url: ustring; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; override; + function OnBeforeBrowser(const extension: ICefExtension; const browser, active_browser: ICefBrowser; index: Integer; const url: ustring; active: boolean; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; override; + procedure GetActiveBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; var aRsltBrowser: ICefBrowser); override; + function CanAccessBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; const target_browser: ICefBrowser): boolean; override; + function GetExtensionResource(const extension: ICefExtension; const browser: ICefBrowser; const file_: ustring; const callback: ICefGetExtensionResourceCallback): boolean; override; + procedure RemoveReferences; override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; + destructor Destroy; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFGetExtensionResourceCallback, + uCEFExtension, uCEFBrowser, uCEFClient; + + +// *************************************************************************** +// ************************ TCefExtensionHandlerRef ************************** +// *************************************************************************** + +procedure TCefExtensionHandlerRef.OnExtensionLoadFailed(result: TCefErrorcode); +begin + // +end; + procedure TCefExtensionHandlerRef.OnExtensionLoaded(const extension: ICefExtension); -begin - -end; +begin + // +end; procedure TCefExtensionHandlerRef.OnExtensionUnloaded(const extension: ICefExtension); -begin - -end; +begin + // +end; function TCefExtensionHandlerRef.OnBeforeBackgroundBrowser(const extension : ICefExtension; const url : ustring; var client : ICefClient; var settings : TCefBrowserSettings) : boolean; -begin - Result := False; -end; +begin + Result := False; +end; function TCefExtensionHandlerRef.OnBeforeBrowser(const extension : ICefExtension; const browser : ICefBrowser; @@ -127,78 +152,70 @@ function TCefExtensionHandlerRef.OnBeforeBrowser(const extension : ICefExte var client : ICefClient; var settings : TCefBrowserSettings) : boolean; begin - Result := True; + Result := False; end; -function TCefExtensionHandlerRef.GetActiveBrowser(const extension : ICefExtension; - const browser : ICefBrowser; - include_incognito : boolean): ICefBrowser; -begin - Result := TCefBrowserRef.UnWrap(PCefExtensionHandler(FData)^.get_active_browser(PCefExtensionHandler(FData), - CefGetData(extension), - CefGetData(browser), - Ord(include_incognito))); -end; +procedure TCefExtensionHandlerRef.GetActiveBrowser(const extension : ICefExtension; + const browser : ICefBrowser; + include_incognito : boolean; + var aRsltBrowser : ICefBrowser); +begin + aRsltBrowser := nil; +end; function TCefExtensionHandlerRef.CanAccessBrowser(const extension : ICefExtension; const browser : ICefBrowser; include_incognito : boolean; const target_browser : ICefBrowser): boolean; -begin - Result := PCefExtensionHandler(FData)^.can_access_browser(PCefExtensionHandler(FData), - CefGetData(extension), - CefGetData(browser), - Ord(include_incognito), - CefGetData(target_browser)) <> 0; -end; +begin + Result := True; +end; function TCefExtensionHandlerRef.GetExtensionResource(const extension : ICefExtension; const browser : ICefBrowser; const file_ : ustring; const callback : ICefGetExtensionResourceCallback): boolean; -var - TempFile : TCefString; -begin - TempFile := CefString(file_); - Result := PCefExtensionHandler(FData)^.get_extension_resource(PCefExtensionHandler(FData), - CefGetData(extension), - CefGetData(browser), - @TempFile, - CefGetData(callback)) <> 0; -end; - -class function TCefExtensionHandlerRef.UnWrap(data: Pointer): ICefExtensionHandler; +begin + Result := False; +end; + +procedure TCefExtensionHandlerRef.RemoveReferences; +begin + // +end; + +class function TCefExtensionHandlerRef.UnWrap(data: Pointer): ICefExtensionHandler; begin if (data <> nil) then Result := Create(data) as ICefExtensionHandler else Result := nil; -end; - - -// *************************************************************************** -// ************************ TCefExtensionHandlerOwn ************************** -// *************************************************************************** - -procedure cef_extension_handler_on_extension_load_failed(self : PCefExtensionHandler; - result : TCefErrorcode); stdcall; -var +end; + + +// *************************************************************************** +// ************************ TCefExtensionHandlerOwn ************************** +// *************************************************************************** + +procedure cef_extension_handler_on_extension_load_failed(self : PCefExtensionHandler; + result : TCefErrorcode); stdcall; +var TempObject : TObject; begin - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then - TCefExtensionHandlerOwn(TempObject).OnExtensionLoadFailed(result); -end; - + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then + TCefExtensionHandlerOwn(TempObject).OnExtensionLoadFailed(result); +end; + procedure cef_extension_handler_on_extension_loaded(self : PCefExtensionHandler; extension : PCefExtension); stdcall; var TempObject : TObject; begin - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then TCefExtensionHandlerOwn(TempObject).OnExtensionLoaded(TCefExtensionRef.UnWrap(extension)); end; @@ -207,9 +224,9 @@ procedure cef_extension_handler_on_extension_unloaded(self : PCefExtensionH var TempObject : TObject; begin - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then TCefExtensionHandlerOwn(TempObject).OnExtensionUnloaded(TCefExtensionRef.UnWrap(extension)); end; @@ -227,20 +244,21 @@ begin TempObject := CefGetObject(self); TempClient := TCefClientRef.UnWrap(client); - if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then + + if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then Result := Ord(TCefExtensionHandlerOwn(TempObject).OnBeforeBackgroundBrowser(TCefExtensionRef.UnWrap(extension), - CefString(url), - TempClient, - settings^)); - - if (TempClient = nil) then + CefString(url), + TempClient, + settings^)); + + if (TempClient = nil) then client := nil else if not(TempClient.SameAs(client)) then client := TempClient.Wrap; - finally - TempClient := nil; - end; + finally + TempClient := nil; + end; end; function cef_extension_handler_on_before_browser( self : PCefExtensionHandler; @@ -260,27 +278,27 @@ begin try Result := Ord(True); TempObject := CefGetObject(self); - TempClient := TCefClientRef.UnWrap(client); - - if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then - Result := Ord(TCefExtensionHandlerOwn(TempObject).OnBeforeBrowser(TCefExtensionRef.UnWrap(extension), - TCefBrowserRef.UnWrap(browser), - TCefBrowserRef.UnWrap(active_browser), - index, - CefString(url), - active <> 0, - windowInfo^, - TempClient, - settings^)); - - if (TempClient = nil) then + TempClient := TCefClientRef.UnWrap(client); + + if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then + Result := Ord(TCefExtensionHandlerOwn(TempObject).OnBeforeBrowser(TCefExtensionRef.UnWrap(extension), + TCefBrowserRef.UnWrap(browser), + TCefBrowserRef.UnWrap(active_browser), + index, + CefString(url), + active <> 0, + windowInfo^, + TempClient, + settings^)); + + if (TempClient = nil) then client := nil else if not(TempClient.SameAs(client)) then client := TempClient.Wrap; - finally - TempClient := nil; - end; + finally + TempClient := nil; + end; end; function cef_extension_handler_get_active_browser(self : PCefExtensionHandler; @@ -288,15 +306,25 @@ function cef_extension_handler_get_active_browser(self : PCefExtens browser : PCefBrowser; include_incognito : Integer): PCefBrowser; stdcall; var - TempObject : TObject; + TempObject : TObject; + TempBrowser : ICefBrowser; begin - Result := nil; - TempObject := CefGetObject(self); - + Result := nil; + TempBrowser := nil; + TempObject := CefGetObject(self); + if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then - Result := CefGetData(TCefExtensionHandlerOwn(TempObject).GetActiveBrowser(TCefExtensionRef.UnWrap(extension), - TCefBrowserRef.UnWrap(browser), - include_incognito <> 0)); + try + TCefExtensionHandlerOwn(TempObject).GetActiveBrowser(TCefExtensionRef.UnWrap(extension), + TCefBrowserRef.UnWrap(browser), + include_incognito <> 0, + TempBrowser); + + if (TempBrowser <> nil) {$IFDEF DELPHI16_UP}and (TempBrowser is TCefBrowserRef){$ENDIF} then + Result := TCefBrowserRef(TempBrowser).wrap; + finally + TempBrowser := nil; + end; end; function cef_extension_handler_can_access_browser(self : PCefExtensionHandler; @@ -308,8 +336,8 @@ var TempObject : TObject; begin Result := Ord(True); - TempObject := CefGetObject(self); - + TempObject := CefGetObject(self); + if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then Result := Ord(TCefExtensionHandlerOwn(TempObject).CanAccessBrowser(TCefExtensionRef.UnWrap(extension), TCefBrowserRef.UnWrap(browser), @@ -322,22 +350,22 @@ function cef_extension_handler_get_extension_resource( self : PCefExte browser : PCefBrowser; const file_ : PCefString; callback : PCefGetExtensionResourceCallback): Integer; stdcall; -var +var TempObject : TObject; begin Result := Ord(False); - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefExtensionHandlerOwn) then Result := Ord(TCefExtensionHandlerOwn(TempObject).GetExtensionResource(TCefExtensionRef.UnWrap(extension), TCefBrowserRef.UnWrap(browser), CefString(file_), TCefGetExtensionResourceCallbackRef.UnWrap(callback))); end; - -constructor TCefExtensionHandlerOwn.Create; -begin - inherited CreateData(SizeOf(TCefExtensionHandler)); + +constructor TCefExtensionHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefExtensionHandler)); with PCefExtensionHandler(FData)^ do begin @@ -350,21 +378,23 @@ begin can_access_browser := {$IFDEF FPC}@{$ENDIF}cef_extension_handler_can_access_browser; get_extension_resource := {$IFDEF FPC}@{$ENDIF}cef_extension_handler_get_extension_resource; end; -end; - -procedure TCefExtensionHandlerOwn.OnExtensionLoadFailed(result: TCefErrorcode); -begin - -end; - +end; + +procedure TCefExtensionHandlerOwn.OnExtensionLoadFailed(result: TCefErrorcode); +begin + // +end; + procedure TCefExtensionHandlerOwn.OnExtensionLoaded(const extension: ICefExtension); begin - + + // end; procedure TCefExtensionHandlerOwn.OnExtensionUnloaded(const extension: ICefExtension); begin - + + // end; function TCefExtensionHandlerOwn.OnBeforeBackgroundBrowser(const extension : ICefExtension; @@ -372,7 +402,7 @@ function TCefExtensionHandlerOwn.OnBeforeBackgroundBrowser(const extension : ICe var client : ICefClient; var settings : TCefBrowserSettings) : boolean; begin - Result := True; + Result := False; end; function TCefExtensionHandlerOwn.OnBeforeBrowser(const extension : ICefExtension; @@ -385,14 +415,15 @@ function TCefExtensionHandlerOwn.OnBeforeBrowser(const extension : ICefExte var client : ICefClient; var settings : TCefBrowserSettings) : boolean; begin - Result := True; + Result := False; end; -function TCefExtensionHandlerOwn.GetActiveBrowser(const extension : ICefExtension; - const browser : ICefBrowser; - include_incognito : boolean): ICefBrowser; +procedure TCefExtensionHandlerOwn.GetActiveBrowser(const extension : ICefExtension; + const browser : ICefBrowser; + include_incognito : boolean; + var aRsltBrowser : ICefBrowser); begin - Result := nil; + // end; function TCefExtensionHandlerOwn.CanAccessBrowser(const extension : ICefExtension; @@ -400,15 +431,179 @@ function TCefExtensionHandlerOwn.CanAccessBrowser(const extension : ICef include_incognito : boolean; const target_browser : ICefBrowser): boolean; begin - Result := True; + Result := True; end; function TCefExtensionHandlerOwn.GetExtensionResource(const extension : ICefExtension; const browser : ICefBrowser; const file_ : ustring; const callback : ICefGetExtensionResourceCallback): boolean; -begin - Result := False; -end; - -end. +begin + Result := False; +end; + +procedure TCefExtensionHandlerOwn.RemoveReferences; +begin + // +end; + +// *************************************************************************** +// ************************ TCustomExtensionHandler ************************** +// *************************************************************************** + +constructor TCustomExtensionHandler.Create(const events: IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +destructor TCustomExtensionHandler.Destroy; +begin + RemoveReferences; + + inherited Destroy; +end; + +procedure TCustomExtensionHandler.RemoveReferences; +begin + FEvents := nil; +end; + +procedure TCustomExtensionHandler.OnExtensionLoadFailed(result: TCefErrorcode); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnExtensionLoadFailed(result); + except + on e : exception do + if CustomExceptionHandler('TCustomExtensionHandler.OnExtensionLoadFailed', e) then raise; + end; +end; + +procedure TCustomExtensionHandler.OnExtensionLoaded(const extension: ICefExtension); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnExtensionLoaded(extension); + except + on e : exception do + if CustomExceptionHandler('TCustomExtensionHandler.OnExtensionLoaded', e) then raise; + end; +end; + +procedure TCustomExtensionHandler.OnExtensionUnloaded(const extension: ICefExtension); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnExtensionUnloaded(extension); + except + on e : exception do + if CustomExceptionHandler('TCustomExtensionHandler.OnExtensionUnloaded', e) then raise; + end; +end; + +function TCustomExtensionHandler.OnBeforeBackgroundBrowser(const extension : ICefExtension; + const url : ustring; + var client : ICefClient; + var settings : TCefBrowserSettings) : boolean; +begin + Result := False; + + try + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doOnExtensionBeforeBackgroundBrowser(extension, + url, + client, + settings); + except + on e : exception do + if CustomExceptionHandler('TCustomExtensionHandler.OnBeforeBackgroundBrowser', e) then raise; + end; +end; + +function TCustomExtensionHandler.OnBeforeBrowser(const extension : ICefExtension; + const browser : ICefBrowser; + const active_browser : ICefBrowser; + index : Integer; + const url : ustring; + active : boolean; + var windowInfo : TCefWindowInfo; + var client : ICefClient; + var settings : TCefBrowserSettings) : boolean; +begin + Result := False; + + try + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doOnExtensionBeforeBrowser(extension, + browser, + active_browser, + index, + url, + active, + windowInfo, + client, + settings); + except + on e : exception do + if CustomExceptionHandler('TCustomExtensionHandler.OnBeforeBrowser', e) then raise; + end; +end; + +procedure TCustomExtensionHandler.GetActiveBrowser(const extension : ICefExtension; + const browser : ICefBrowser; + include_incognito : boolean; + var aRsltBrowser : ICefBrowser); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnExtensionGetActiveBrowser(extension, + browser, + include_incognito, + aRsltBrowser); + except + on e : exception do + if CustomExceptionHandler('TCustomExtensionHandler.GetActiveBrowser', e) then raise; + end; +end; + +function TCustomExtensionHandler.CanAccessBrowser(const extension : ICefExtension; + const browser : ICefBrowser; + include_incognito : boolean; + const target_browser : ICefBrowser): boolean; +begin + Result := True; + + try + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doOnExtensionCanAccessBrowser(extension, + browser, + include_incognito, + target_browser); + except + on e : exception do + if CustomExceptionHandler('TCustomExtensionHandler.CanAccessBrowser', e) then raise; + end; +end; + +function TCustomExtensionHandler.GetExtensionResource(const extension : ICefExtension; + const browser : ICefBrowser; + const file_ : ustring; + const callback : ICefGetExtensionResourceCallback): boolean; +begin + Result := False; + + try + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doOnExtensionGetExtensionResource(extension, + browser, + file_, + callback); + except + on e : exception do + if CustomExceptionHandler('TCustomExtensionHandler.GetExtensionResource', e) then raise; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uFMXBufferPanel.pas b/windows/src/ext/cef4delphi/source/uCEFFMXBufferPanel.pas similarity index 61% rename from windows/src/ext/cef4delphi/source/uFMXBufferPanel.pas rename to windows/src/ext/cef4delphi/source/uCEFFMXBufferPanel.pas index 5548ebb11b58804ef952198e55cca75008cc72b9..6091fdc25e048bf354f49b11861eef9fd9f2b0bf 100644 --- a/windows/src/ext/cef4delphi/source/uFMXBufferPanel.pas +++ b/windows/src/ext/cef4delphi/source/uCEFFMXBufferPanel.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -35,7 +35,7 @@ * *) -unit uFMXBufferPanel; +unit uCEFFMXBufferPanel; {$I cef.inc} @@ -43,7 +43,7 @@ interface uses {$IFDEF MSWINDOWS} - Winapi.Windows, + Winapi.Windows, FMX.Platform.Win, {$ELSE} System.SyncObjs, {$ENDIF} @@ -51,32 +51,38 @@ uses {$IFDEF DELPHI17_UP} FMX.Graphics, {$ENDIF} - FMX.Types, FMX.Controls; + FMX.Types, FMX.Controls, FMX.Forms, + uCEFTypes; type TDialogKeyEvent = procedure(Sender: TObject; var Key: Word; Shift: TShiftState) of object; + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} TFMXBufferPanel = class(TControl) protected {$IFDEF MSWINDOWS} - FMutex : THandle; + FMutex : THandle; {$ELSE} - FBufferCS : TCriticalSection; + FBufferCS : TCriticalSection; {$ENDIF} - FBuffer : TBitmap; - FScanlineSize : integer; - FColor : TAlphaColor; - FHighSpeedDrawing : boolean; - FOnDialogKey : TDialogKeyEvent; + FBuffer : TBitmap; + FScanlineSize : integer; + FColor : TAlphaColor; + FHighSpeedDrawing : boolean; + FOnDialogKey : TDialogKeyEvent; + FForcedDeviceScaleFactor : single; procedure CreateSyncObj; procedure DestroySyncObj; procedure DestroyBuffer; - function GetScreenScale : Single; + function GetScreenScale : single; virtual; function GetBufferWidth : integer; function GetBufferHeight : integer; + function GetParentForm : TCustomForm; + function GetParentFormHandle : TCefWindowHandle; + function GetRealScreenScale(var aResultScale : single) : boolean; virtual; function CopyBuffer : boolean; function SaveBufferToFile(const aFilename : string) : boolean; @@ -92,17 +98,20 @@ type procedure InvalidatePanel; function BeginBufferDraw : boolean; procedure EndBufferDraw; - procedure BufferDraw(x, y : integer; const aBitmap : TBitmap); + procedure BufferDraw(const aBitmap : TBitmap; const aSrcRect, aDstRect : TRectF); function UpdateBufferDimensions(aWidth, aHeight : integer) : boolean; function BufferIsResized(aUseMutex : boolean = True) : boolean; - function ScreenToClient(aPoint : TPoint) : TPoint; - function ClientToScreen(aPoint : TPoint) : TPoint; - - property Buffer : TBitmap read FBuffer; - property ScanlineSize : integer read FScanlineSize; - property BufferWidth : integer read GetBufferWidth; - property BufferHeight : integer read GetBufferHeight; - property ScreenScale : single read GetScreenScale; + function ScreenToClient(aPoint : TPoint) : TPoint; overload; + function ScreenToClient(aPoint : TPointF) : TPointF; overload; + function ClientToScreen(aPoint : TPoint) : TPoint; overload; + function ClientToScreen(aPoint : TPointF) : TPointF; overload; + + property Buffer : TBitmap read FBuffer; + property ScanlineSize : integer read FScanlineSize; + property BufferWidth : integer read GetBufferWidth; + property BufferHeight : integer read GetBufferHeight; + property ScreenScale : single read GetScreenScale; + property ForcedDeviceScaleFactor : single read FForcedDeviceScaleFactor write FForcedDeviceScaleFactor; published property Align; @@ -128,6 +137,10 @@ type property Scale; property Size; {$ENDIF} + {$IFNDEF DELPHI23_UP} + property Hint; + property ShowHint; + {$ENDIF} property OnEnter; property OnExit; @@ -148,7 +161,8 @@ implementation uses System.SysUtils, System.Math, - FMX.Platform, uCEFMiscFunctions, uCEFApplication; + {$IFDEF MSWINDOWS}FMX.Helpers.Win,{$ENDIF} + FMX.Platform, uCEFMiscFunctions, uCEFApplicationCore; constructor TFMXBufferPanel.Create(AOwner: TComponent); begin @@ -164,6 +178,11 @@ begin FColor := claWhite; FOnDialogKey := nil; FHighSpeedDrawing := True; + + if (GlobalCEFApp <> nil) and (GlobalCEFApp.ForcedDeviceScaleFactor <> 0) then + FForcedDeviceScaleFactor := GlobalCEFApp.ForcedDeviceScaleFactor + else + FForcedDeviceScaleFactor := 0; end; destructor TFMXBufferPanel.Destroy; @@ -270,24 +289,33 @@ end; function TFMXBufferPanel.CopyBuffer : boolean; var - TempSrc, TempDst : TRectF; + TempSrc, TempDst, TempClip : TRectF; + TempState : TCanvasSaveState; + TempScale : single; begin Result := False; if Canvas.BeginScene then try if BeginBufferDraw then - begin + try if (FBuffer <> nil) then begin - TempSrc := TRectF.Create(0, 0, FBuffer.Width, FBuffer.Height); - TempDst := TRectF.Create(0, 0, FBuffer.Width / ScreenScale, FBuffer.Height / ScreenScale); - - Canvas.DrawBitmap(FBuffer, TempSrc, TempDst, 1, FHighSpeedDrawing); - - Result := True; + TempScale := ScreenScale; + TempSrc := TRectF.Create(0, 0, FBuffer.Width, FBuffer.Height); + TempDst := TRectF.Create(0, 0, FBuffer.Width / TempScale, FBuffer.Height / TempScale); + TempClip := TRectF.Create(0, 0, Width, Height); + + TempState := Canvas.SaveState; + try + Canvas.IntersectClipRect(TempClip); + Canvas.DrawBitmap(FBuffer, TempSrc, TempDst, 1, FHighSpeedDrawing); + Result := True; + finally + Canvas.RestoreState(TempState); + end; end; - + finally EndBufferDraw; end; finally @@ -319,12 +347,77 @@ begin end; end; -function TFMXBufferPanel.GetScreenScale : Single; +function TFMXBufferPanel.GetParentForm : TCustomForm; +var + TempComp : TComponent; begin - if (GlobalCEFApp <> nil) then - Result := GlobalCEFApp.DeviceScaleFactor + Result := nil; + TempComp := Owner; + + while (TempComp <> nil) do + if (TempComp is TCustomForm) then + begin + Result := TCustomForm(TempComp); + exit; + end + else + TempComp := TempComp.owner; +end; + +function TFMXBufferPanel.GetParentFormHandle : TCefWindowHandle; +{$IFDEF MSWINDOWS} +var + TempForm : TCustomForm; +{$ENDIF} +begin + InitializeWindowHandle(Result); + + {$IFDEF MSWINDOWS} + TempForm := GetParentForm; + + if (TempForm <> nil) then + Result := FmxHandleToHWND(TempForm.Handle) else - Result := 1; + if (Application <> nil) and + (Application.MainForm <> nil) then + Result := FmxHandleToHWND(Application.MainForm.Handle); + {$ENDIF} +end; + +function TFMXBufferPanel.GetRealScreenScale(var aResultScale : single) : boolean; +{$IFDEF DELPHI24_UP}{$IFDEF MSWINDOWS} +var + TempHandle : TCefWindowHandle; +{$ENDIF}{$ENDIF} +begin + Result := False; + aResultScale := 1; + + {$IFDEF DELPHI24_UP}{$IFDEF MSWINDOWS} + TempHandle := GetParentFormHandle; + + if (TempHandle <> 0) then + begin + Result := True; + aResultScale := GetWndScale(TempHandle); + end; + {$ENDIF}{$ENDIF} +end; + +function TFMXBufferPanel.GetScreenScale : single; +var + TempScale : single; +begin + if (FForcedDeviceScaleFactor <> 0) then + Result := FForcedDeviceScaleFactor + else + if GetRealScreenScale(TempScale) then + Result := TempScale + else + if (GlobalCEFApp <> nil) then + Result := GlobalCEFApp.DeviceScaleFactor + else + Result := 1; end; function TFMXBufferPanel.GetBufferWidth : integer; @@ -343,37 +436,34 @@ begin Result := 0; end; -procedure TFMXBufferPanel.BufferDraw(x, y : integer; const aBitmap : TBitmap); -var - TempSrc, TempDst : TRectF; +procedure TFMXBufferPanel.BufferDraw(const aBitmap : TBitmap; const aSrcRect, aDstRect : TRectF); begin if (FBuffer <> nil) then - begin - TempSrc := TRectF.Create(0, 0, aBitmap.Width, aBitmap.Height); - TempDst := TRectF.Create(x, y, x + (aBitmap.Width / ScreenScale), y + (aBitmap.Height / ScreenScale)); - - if FBuffer.Canvas.BeginScene then - try - FBuffer.Canvas.DrawBitmap(aBitmap, TempSrc, TempDst, 1, FHighSpeedDrawing); - finally - FBuffer.Canvas.EndScene; - end; - end; + if FBuffer.Canvas.BeginScene then + try + FBuffer.Canvas.DrawBitmap(aBitmap, aSrcRect, aDstRect, 1, FHighSpeedDrawing); + finally + FBuffer.Canvas.EndScene; + end; end; function TFMXBufferPanel.UpdateBufferDimensions(aWidth, aHeight : integer) : boolean; +var + TempScale : single; begin - Result := False; + Result := False; + TempScale := ScreenScale; - if ((FBuffer = nil) or - (FBuffer.Width <> aWidth) or - (FBuffer.Height <> aHeight)) then + if ((FBuffer = nil) or + (FBuffer.BitmapScale <> TempScale) or + (FBuffer.Width <> aWidth) or + (FBuffer.Height <> aHeight)) then begin if (FBuffer <> nil) then FreeAndNil(FBuffer); FBuffer := TBitmap.Create(aWidth, aHeight); {$IFDEF DELPHI17_UP} - FBuffer.BitmapScale := ScreenScale; + FBuffer.BitmapScale := TempScale; FScanlineSize := FBuffer.BytesPerLine; {$ELSE} FScanlineSize := aWidth * SizeOf(TRGBQuad); @@ -385,18 +475,20 @@ end; function TFMXBufferPanel.BufferIsResized(aUseMutex : boolean) : boolean; var TempWidth, TempHeight : integer; + TempScale : single; begin Result := False; - if (GlobalCEFApp = nil) then exit; if not(aUseMutex) or BeginBufferDraw then begin - TempWidth := round(Width * GlobalCEFApp.DeviceScaleFactor); - TempHeight := round(Height * GlobalCEFApp.DeviceScaleFactor); + TempScale := ScreenScale; + TempWidth := round(Width * TempScale); + TempHeight := round(Height * TempScale); Result := (FBuffer <> nil) and - (FBuffer.Width = TempWidth) and - (FBuffer.Height = TempHeight); + (FBuffer.BitmapScale = TempScale) and + (FBuffer.Width = TempWidth) and + (FBuffer.Height = TempHeight); if aUseMutex then EndBufferDraw; end; @@ -413,6 +505,11 @@ begin Result.y := round(TempPoint.y); end; +function TFMXBufferPanel.ScreenToClient(aPoint : TPointF) : TPointF; +begin + Result := ScreenToLocal(aPoint); +end; + function TFMXBufferPanel.ClientToScreen(aPoint : TPoint) : TPoint; var TempPoint : TPointF; @@ -424,4 +521,9 @@ begin Result.y := round(TempPoint.y); end; +function TFMXBufferPanel.ClientToScreen(aPoint : TPointF) : TPointF; +begin + Result := LocalToScreen(aPoint); +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFFMXChromium.pas b/windows/src/ext/cef4delphi/source/uCEFFMXChromium.pas new file mode 100644 index 0000000000000000000000000000000000000000..ad8716c52104aa854a34e9b18a1314e70210dcc6 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFFMXChromium.pas @@ -0,0 +1,364 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFFMXChromium; + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + System.Classes, System.Types, + {$IFDEF MSWINDOWS} + WinApi.Windows, WinApi.Messages, FMX.Platform.Win, + {$ENDIF} + FMX.Types, FMX.Platform, FMX.Forms, FMX.Controls, FMX.Graphics, + uCEFTypes, uCEFInterfaces, uCEFChromiumCore; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TFMXChromium = class(TChromiumCore, IChromiumEvents) + protected + function GetParentFormHandle : TCefWindowHandle; override; + function GetParentForm : TCustomForm; + function GetScreenScale : Single; + procedure InitializeDevToolsWindowInfo; virtual; + + public + procedure ShowDevTools(inspectElementAt: TPoint); + procedure CloseDevTools; + + procedure MoveFormTo(const x, y: Integer); + procedure MoveFormBy(const x, y: Integer); + procedure ResizeFormWidthTo(const x : Integer); + procedure ResizeFormHeightTo(const y : Integer); + procedure SetFormLeftTo(const x : Integer); + procedure SetFormTopTo(const y : Integer); + + function CreateBrowser(const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aExtraInfo : ICefDictionaryValue = nil) : boolean; overload; virtual; + function SaveAsBitmapStream(var aStream : TStream; const aRect : System.Types.TRect) : boolean; + function TakeSnapshot(var aBitmap : TBitmap; const aRect : System.Types.TRect) : boolean; + + property ScreenScale : single read GetScreenScale; + end; + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + {$IFDEF MSWINDOWS}FMX.Helpers.Win,{$ENDIF} + System.SysUtils, System.Math, + uCEFApplicationCore; + +function TFMXChromium.CreateBrowser(const aWindowName : ustring; + const aContext : ICefRequestContext; + const aExtraInfo : ICefDictionaryValue) : boolean; +var + TempHandle : TCefWindowHandle; +begin + {$IFDEF MACOS} + TempHandle := nil; + {$ELSE} + TempHandle := 0; + {$ENDIF} + Result := inherited CreateBrowser(TempHandle, Rect(0, 0, 0, 0), aWindowName, aContext, aExtraInfo); +end; + +procedure TFMXChromium.InitializeDevToolsWindowInfo; +var + TempHandle : TCefWindowHandle; +begin + {$IFDEF MACOS} + TempHandle := nil; + {$ELSE} + TempHandle := 0; + {$ENDIF} + DefaultInitializeDevToolsWindowInfo(TempHandle, Rect(0, 0, 0, 0), ''); +end; + +procedure TFMXChromium.ShowDevTools(inspectElementAt: TPoint); +begin + if Initialized then + begin + InitializeDevToolsWindowInfo; + inherited ShowDevTools(inspectElementAt, @FDevWindowInfo); + end; +end; + +procedure TFMXChromium.CloseDevTools; +begin + inherited CloseDevTools; +end; + +function TFMXChromium.GetParentForm : TCustomForm; +var + TempComp : TComponent; +begin + Result := nil; + TempComp := Owner; + + while (TempComp <> nil) do + if (TempComp is TCustomForm) then + begin + Result := TCustomForm(TempComp); + exit; + end + else + TempComp := TempComp.owner; +end; + +function TFMXChromium.GetScreenScale : Single; +{$IFDEF DELPHI24_UP}{$IFDEF MSWINDOWS} +var + TempHandle : TCefWindowHandle; +{$ENDIF}{$ENDIF} +begin + {$IFDEF DELPHI24_UP}{$IFDEF MSWINDOWS} + TempHandle := GetParentFormHandle; + + if (TempHandle <> 0) then + Result := GetWndScale(TempHandle) + else + {$ENDIF}{$ENDIF} + if (GlobalCEFApp <> nil) then + Result := GlobalCEFApp.DeviceScaleFactor + else + Result := 1; +end; + +function TFMXChromium.GetParentFormHandle : TCefWindowHandle; +{$IFDEF MSWINDOWS} +var + TempForm : TCustomForm; +{$ENDIF} +begin + Result := inherited GetParentFormHandle; + + {$IFDEF MSWINDOWS} + TempForm := GetParentForm; + + if (TempForm <> nil) then + Result := FmxHandleToHWND(TempForm.Handle) + else + if (Application <> nil) and + (Application.MainForm <> nil) then + Result := FmxHandleToHWND(Application.MainForm.Handle); + {$ENDIF} +end; + +procedure TFMXChromium.MoveFormTo(const x, y: Integer); +var + TempForm : TCustomForm; + {$IFDEF DELPHI17_UP} + TempRect : TRect; + {$ENDIF} +begin + TempForm := GetParentForm; + {$IFDEF DELPHI17_UP} + if (TempForm <> nil) then + begin + TempRect.Left := min(max(x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); + TempRect.Top := min(max(y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); + TempRect.Right := TempRect.Left + TempForm.Width - 1; + TempRect.Bottom := TempRect.Top + TempForm.Height - 1; + + TempForm.SetBounds(TempRect.Left, TempRect.Top, TempRect.Right - TempRect.Left + 1, TempRect.Bottom - TempRect.Top + 1); + end; + {$ELSE} + TempForm.SetBounds(x, y, TempForm.Width, TempForm.Height); + {$ENDIF} +end; + +procedure TFMXChromium.MoveFormBy(const x, y: Integer); +var + TempForm : TCustomForm; + {$IFDEF DELPHI17_UP} + TempRect : TRect; + {$ENDIF} +begin + TempForm := GetParentForm; + {$IFDEF DELPHI17_UP} + if (TempForm <> nil) then + begin + TempRect.Left := min(max(TempForm.Left + x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); + TempRect.Top := min(max(TempForm.Top + y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); + TempRect.Right := TempRect.Left + TempForm.Width - 1; + TempRect.Bottom := TempRect.Top + TempForm.Height - 1; + + TempForm.SetBounds(TempRect.Left, TempRect.Top, TempRect.Right - TempRect.Left + 1, TempRect.Bottom - TempRect.Top + 1); + end; + {$ELSE} + TempForm.SetBounds(TempForm.Left + x, TempForm.Top + y, TempForm.Width, TempForm.Height); + {$ENDIF} +end; + +procedure TFMXChromium.ResizeFormWidthTo(const x : Integer); +var + TempForm : TCustomForm; + TempX, TempDeltaX : integer; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + begin + TempX := max(x, 100); + TempDeltaX := TempForm.Width - TempForm.ClientWidth; + TempForm.Width := TempX + TempDeltaX; + end; +end; + +procedure TFMXChromium.ResizeFormHeightTo(const y : Integer); +var + TempForm : TCustomForm; + TempY, TempDeltaY : integer; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + begin + TempY := max(y, 100); + TempDeltaY := TempForm.Height - TempForm.ClientHeight; + TempForm.Height := TempY + TempDeltaY; + end; +end; + +procedure TFMXChromium.SetFormLeftTo(const x : Integer); +var + TempForm : TCustomForm; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + {$IFDEF DELPHI17_UP} + TempForm.Left := min(max(x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); + {$ELSE} + TempForm.Left := x; + {$ENDIF} +end; + +procedure TFMXChromium.SetFormTopTo(const y : Integer); +var + TempForm : TCustomForm; +begin + TempForm := GetParentForm; + + if (TempForm <> nil) then + {$IFDEF DELPHI17_UP} + TempForm.Top := min(max(y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); + {$ELSE} + TempForm.Top := y; + {$ENDIF} +end; + +function TFMXChromium.SaveAsBitmapStream(var aStream : TStream; const aRect : System.Types.TRect) : boolean; +{$IFDEF MSWINDOWS} +var + TempDC : HDC; + TempRect : System.Types.TRect; +{$ENDIF} +begin + Result := False; + + {$IFDEF MSWINDOWS} + if not(FIsOSR) and (FRenderCompHWND <> 0) and (aStream <> nil) then + begin + TempDC := GetDC(FRenderCompHWND); + + if (TempDC <> 0) then + try + TempRect := aRect; + Result := OffsetRect(TempRect, - TempRect.Left, - TempRect.Top) and + CopyDCToBitmapStream(TempDC, TempRect, aStream); + finally + ReleaseDC(FRenderCompHWND, TempDC); + end; + end; + {$ENDIF} +end; + +function TFMXChromium.TakeSnapshot(var aBitmap : TBitmap; const aRect : System.Types.TRect) : boolean; +var + TempStream : TMemoryStream; +begin + Result := False; + TempStream := nil; + + if FIsOSR or (aBitmap = nil) then exit; + + try + TempStream := TMemoryStream.Create; + + if SaveAsBitmapStream(TStream(TempStream), aRect) then + begin + aBitmap.LoadFromStream(TempStream); + Result := True; + end; + finally + FreeAndNil(TempStream); + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uFMXWindowParent.pas b/windows/src/ext/cef4delphi/source/uCEFFMXWindowParent.pas similarity index 91% rename from windows/src/ext/cef4delphi/source/uFMXWindowParent.pas rename to windows/src/ext/cef4delphi/source/uCEFFMXWindowParent.pas index b07d28b3fcb47856766225f63636ac46d2ec735f..7a9211fa1e8d46a22ee23700ed063f4d5e6dd6ec 100644 --- a/windows/src/ext/cef4delphi/source/uFMXWindowParent.pas +++ b/windows/src/ext/cef4delphi/source/uCEFFMXWindowParent.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -35,12 +35,10 @@ * *) -unit uFMXWindowParent; +unit uCEFFMXWindowParent; -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -54,6 +52,7 @@ uses FMX.Controls, FMX.Types, FMX.Forms; type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} TFMXWindowParent = class(TCommonCustomForm) protected {$IFDEF MSWINDOWS} @@ -72,6 +71,8 @@ type property Visible; property Height; property Width; + property Touch; + property OnGesture; end; implementation diff --git a/windows/src/ext/cef4delphi/source/uFMXWorkScheduler.pas b/windows/src/ext/cef4delphi/source/uCEFFMXWorkScheduler.pas similarity index 69% rename from windows/src/ext/cef4delphi/source/uFMXWorkScheduler.pas rename to windows/src/ext/cef4delphi/source/uCEFFMXWorkScheduler.pas index 5acc32e87ac01984ec5f2aee7abc3af1cadfbaba..c2dd35a8805d47f2b7380c94a8e05f5563455c6e 100644 --- a/windows/src/ext/cef4delphi/source/uFMXWorkScheduler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFFMXWorkScheduler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -35,26 +35,36 @@ * *) -unit uFMXWorkScheduler; +unit uCEFFMXWorkScheduler; -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} +// Define this conditional to use TCEFWorkSchedulerQueueThread instead of using +// PostMessage, Application.QueueAsyncCall or TThread.Queue inside +// TCEFWorkScheduler.ScheduleMessagePumpWork +// TCEFWorkSchedulerQueueThread is just a new experimental way to handle the +// external message pump events for all platforms. +{.$DEFINE USEQUEUETHREAD} + interface uses System.Classes, System.Types, FMX.Types, FMX.Controls, - uCEFConstants, uCEFWorkSchedulerThread; + uCEFConstants, {$IFDEF USEQUEUETHREAD}uCEFWorkSchedulerQueueThread,{$ENDIF} uCEFWorkSchedulerThread; type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TFMXWorkScheduler = class(TComponent) protected FThread : TCEFWorkSchedulerThread; + {$IFDEF USEQUEUETHREAD} + FQueueThread : TCEFWorkSchedulerQueueThread; + {$ENDIF} FDepleteWorkCycles : cardinal; FDepleteWorkDelay : cardinal; FDefaultInterval : integer; @@ -65,12 +75,18 @@ type {$WARN SYMBOL_PLATFORM ON} {$ENDIF} - procedure CreateThread; + {$IFDEF USEQUEUETHREAD} + procedure CreateQueueThread; + procedure DestroyQueueThread; + procedure QueueThread_OnPulse(Sender : TObject; aDelay : integer); + {$ENDIF} + procedure DestroyThread; procedure DepleteWork; procedure NextPulse(aInterval : integer); procedure DoWork; procedure DoMessageLoopWork; + procedure Initialize; procedure SetDefaultInterval(aValue : integer); {$IFDEF MSWINDOWS} @@ -79,16 +95,16 @@ type {$WARN SYMBOL_PLATFORM ON} {$ENDIF} - procedure Thread_OnPulse(Sender : TObject); public constructor Create(AOwner: TComponent); override; + constructor CreateDelayed; destructor Destroy; override; - procedure AfterConstruction; override; procedure ScheduleMessagePumpWork(const delay_ms : int64); procedure StopScheduler; procedure ScheduleWork(const delay_ms : int64); + procedure CreateThread; published {$IFDEF MSWINDOWS} @@ -110,8 +126,8 @@ implementation uses {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.SysUtils, System.Math, - FMX.Platform, FMX.Platform.Win, FMX.Forms, - uCEFMiscFunctions, uCEFApplication; + FMX.Platform, {$IFDEF MSWINDOWS}FMX.Platform.Win,{$ENDIF} FMX.Forms, + uCEFMiscFunctions, uCEFApplicationCore; procedure DestroyGlobalFMXWorkScheduler; begin @@ -122,34 +138,49 @@ constructor TFMXWorkScheduler.Create(AOwner: TComponent); begin inherited Create(AOwner); - FThread := nil; - FStopped := False; - {$IFDEF MSWINDOWS} - {$WARN SYMBOL_PLATFORM OFF} - FPriority := tpNormal; - {$WARN SYMBOL_PLATFORM ON} - {$ENDIF} - FDefaultInterval := CEF_TIMER_MAXDELAY; - FDepleteWorkCycles := CEF_TIMER_DEPLETEWORK_CYCLES; - FDepleteWorkDelay := CEF_TIMER_DEPLETEWORK_DELAY; + Initialize; + + if not(csDesigning in ComponentState) then CreateThread; +end; + +constructor TFMXWorkScheduler.CreateDelayed; +begin + inherited Create(nil); + + Initialize; end; destructor TFMXWorkScheduler.Destroy; begin DestroyThread; + {$IFDEF USEQUEUETHREAD} + DestroyQueueThread; + {$ENDIF} inherited Destroy; end; -procedure TFMXWorkScheduler.AfterConstruction; +procedure TFMXWorkScheduler.Initialize; begin - inherited AfterConstruction; - - if not(csDesigning in ComponentState) then CreateThread; + FThread := nil; + {$IFDEF USEQUEUETHREAD} + FQueueThread := nil; + {$ENDIF} + FStopped := False; + {$IFDEF MSWINDOWS} + {$WARN SYMBOL_PLATFORM OFF} + FPriority := tpNormal; + {$WARN SYMBOL_PLATFORM ON} + {$ENDIF} + FDefaultInterval := CEF_TIMER_MAXDELAY; + FDepleteWorkCycles := CEF_TIMER_DEPLETEWORK_CYCLES; + FDepleteWorkDelay := CEF_TIMER_DEPLETEWORK_DELAY; end; procedure TFMXWorkScheduler.CreateThread; begin + if (FThread <> nil) then exit; + FThread := TCEFWorkSchedulerThread.Create; {$IFDEF MSWINDOWS} FThread.Priority := FPriority; @@ -157,8 +188,50 @@ begin FThread.DefaultInterval := FDefaultInterval; FThread.OnPulse := Thread_OnPulse; FThread.Start; + + {$IFDEF USEQUEUETHREAD} + CreateQueueThread; + {$ENDIF} +end; + +{$IFDEF USEQUEUETHREAD} +procedure TFMXWorkScheduler.CreateQueueThread; +begin + FQueueThread := TCEFWorkSchedulerQueueThread.Create; + FQueueThread.OnPulse := {$IFDEF FPC}@{$ENDIF}QueueThread_OnPulse; + {$IFDEF DELPHI14_UP} + FQueueThread.Start; + {$ELSE} + {$IFNDEF FPC} + FQueueThread.Resume; + {$ELSE} + FQueueThread.Start; + {$ENDIF} + {$ENDIF} +end; + +procedure TFMXWorkScheduler.DestroyQueueThread; +begin + try + if (FQueueThread <> nil) then + begin + FQueueThread.Terminate; + FQueueThread.StopThread; + FQueueThread.WaitFor; + FreeAndNil(FQueueThread); + end; + except + on e : exception do + if CustomExceptionHandler('TFMXWorkScheduler.DestroyQueueThread', e) then raise; + end; end; +procedure TFMXWorkScheduler.QueueThread_OnPulse(Sender : TObject; aDelay : integer); +begin + ScheduleWork(aDelay); +end; +{$ENDIF} + procedure TFMXWorkScheduler.DestroyThread; begin try @@ -211,23 +284,21 @@ begin end; procedure TFMXWorkScheduler.ScheduleMessagePumpWork(const delay_ms : int64); -{$IFDEF MSWINDOWS} -var - TempHandle : HWND; -{$ENDIF} begin - if not(FStopped) then - begin - {$IFDEF MSWINDOWS} - {$IFDEF DELPHI17_UP} - TempHandle := ApplicationHWND; - {$ELSE} - TempHandle := FmxHandleToHWND(Application.MainForm.Handle); - {$ENDIF} - if (TempHandle <> 0) then - WinApi.Windows.PostMessage(TempHandle, CEF_PUMPHAVEWORK, 0, LPARAM(delay_ms)); - {$ENDIF} - end; + if FStopped then exit; + + {$IFDEF USEQUEUETHREAD} + if (FQueueThread <> nil) and FQueueThread.Ready then + begin + FQueueThread.EnqueueValue(integer(delay_ms)); + exit; + end; + {$ENDIF} + + TThread.Queue(nil, procedure + begin + ScheduleWork(delay_ms); + end); end; procedure TFMXWorkScheduler.StopScheduler; diff --git a/windows/src/ext/cef4delphi/source/uCEFFileDialogCallback.pas b/windows/src/ext/cef4delphi/source/uCEFFileDialogCallback.pas index 4325728b112c1e787c86e88e56c87788b61d1fc1..abea92235f765400f09359797a9a4be169abaf1e 100644 --- a/windows/src/ext/cef4delphi/source/uCEFFileDialogCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFFileDialogCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFFileDialogCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFFillLayout.pas b/windows/src/ext/cef4delphi/source/uCEFFillLayout.pas new file mode 100644 index 0000000000000000000000000000000000000000..35559bd2bf79dde8795cb16303bf6ecf41785287 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFFillLayout.pas @@ -0,0 +1,76 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFFillLayout; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFLayout; + +type + TCefFillLayoutRef = class(TCefLayoutRef, ICefFillLayout) + public + class function UnWrap(data: Pointer): ICefFillLayout; + end; + +implementation + +class function TCefFillLayoutRef.UnWrap(data: Pointer): ICefFillLayout; +begin + if (data <> nil) then + Result := Create(data) as ICefFillLayout + else + Result := nil; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFFindHandler.pas b/windows/src/ext/cef4delphi/source/uCEFFindHandler.pas index d8cd0f5ab04fd8ed0b9bc1f8d46be9f4dfb01c2d..782844e27577ca83cc9ecfd24d1806fe6fcda95a 100644 --- a/windows/src/ext/cef4delphi/source/uCEFFindHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFFindHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFFindHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -73,7 +71,7 @@ type procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -122,11 +120,11 @@ end; // TCustomFindHandler -constructor TCustomFindHandler.Create(const events: Pointer); +constructor TCustomFindHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomFindHandler.Destroy; diff --git a/windows/src/ext/cef4delphi/source/uCEFFocusHandler.pas b/windows/src/ext/cef4delphi/source/uCEFFocusHandler.pas index c30aa6d95ad4550ebc43caeafb612146527aad32..c15b6991661ac564a638f2899b1265f28bcbfc91 100644 --- a/windows/src/ext/cef4delphi/source/uCEFFocusHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFFocusHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFFocusHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -77,7 +75,7 @@ type procedure RemoveReferences; override; public - constructor Create(const events : Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -163,11 +161,11 @@ end; // TCustomFocusHandler -constructor TCustomFocusHandler.Create(const events: Pointer); +constructor TCustomFocusHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomFocusHandler.Destroy; diff --git a/windows/src/ext/cef4delphi/source/uCEFFrame.pas b/windows/src/ext/cef4delphi/source/uCEFFrame.pas index 77e5838d59d704cb5a2a7b1aa4aaa1eaaab88ebc..d2443a6e718c78d9813d77d835e6a243a5ca766f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFFrame.pas +++ b/windows/src/ext/cef4delphi/source/uCEFFrame.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFFrame; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -71,7 +69,6 @@ type procedure GetTextProc(const proc: TCefStringVisitorProc); procedure LoadRequest(const request: ICefRequest); procedure LoadUrl(const url: ustring); - procedure LoadString(const str, url: ustring); procedure ExecuteJavaScript(const code, scriptUrl: ustring; startLine: Integer); function IsMain: Boolean; function IsFocused: Boolean; @@ -83,6 +80,8 @@ type function GetV8Context: ICefv8Context; procedure VisitDom(const visitor: ICefDomVisitor); procedure VisitDomProc(const proc: TCefDomVisitorProc); + function CreateUrlRequest(const request: ICefRequest; const client: ICefUrlrequestClient): ICefUrlRequest; + procedure SendProcessMessage(targetProcess: TCefProcessId; const message_: ICefProcessMessage); class function UnWrap(data: Pointer): ICefFrame; end; @@ -90,7 +89,7 @@ type implementation uses - uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFStringVisitor, uCEFv8Context, uCEFDomVisitor; + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFStringVisitor, uCEFv8Context, uCEFDomVisitor, uCEFUrlRequest; function TCefFrameRef.IsValid: Boolean; begin @@ -186,22 +185,12 @@ begin PCefFrame(FData)^.load_request(PCefFrame(FData), CefGetData(request)); end; -procedure TCefFrameRef.LoadString(const str, url: ustring); -var - TempString, TempURL : TCefString; -begin - TempString := CefString(str); - TempURL := CefString(url); - PCefFrame(FData)^.load_string(PCefFrame(FData), @TempString, @TempURL); -end; - procedure TCefFrameRef.LoadUrl(const url: ustring); var TempURL : TCefString; begin TempURL := CefString(url); PCefFrame(FData)^.load_url(PCefFrame(FData), @TempURL); - end; procedure TCefFrameRef.Paste; @@ -239,6 +228,22 @@ begin VisitDom(TCefFastDomVisitor.Create(proc) as ICefDomVisitor); end; +function TCefFrameRef.CreateUrlRequest(const request : ICefRequest; + const client : ICefUrlrequestClient): ICefUrlRequest; +begin + Result := TCefUrlRequestRef.UnWrap(PCefFrame(FData)^.create_urlrequest(PCefFrame(FData), + CefGetData(request), + CefGetData(client))); +end; + +procedure TCefFrameRef.SendProcessMessage( targetProcess : TCefProcessId; + const message_ : ICefProcessMessage); +begin + PCefFrame(FData)^.send_process_message(PCefFrame(FData), + targetProcess, + CefGetData(message_)); +end; + class function TCefFrameRef.UnWrap(data: Pointer): ICefFrame; begin if (data <> nil) then diff --git a/windows/src/ext/cef4delphi/source/uCEFGetExtensionResourceCallback.pas b/windows/src/ext/cef4delphi/source/uCEFGetExtensionResourceCallback.pas index 090590778ee9af07efbea7adb94e5c086b85f2df..4b425e7ac807fdbf139d34a9051b2c46ed8d889b 100644 --- a/windows/src/ext/cef4delphi/source/uCEFGetExtensionResourceCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFGetExtensionResourceCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFGetExtensionResourceCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFImage.pas b/windows/src/ext/cef4delphi/source/uCEFImage.pas index 0f7d72f4789b6968115ccdce10177fc75946fc68..5e0606a1d5dd7b15ac4268cbeb8dc8611e07b6cf 100644 --- a/windows/src/ext/cef4delphi/source/uCEFImage.pas +++ b/windows/src/ext/cef4delphi/source/uCEFImage.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFImage; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -54,7 +52,7 @@ uses {$IFDEF DELPHI16_UP} {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} {$ELSE} - Windows, + {$IFDEF MSWINDOWS}Windows,{$ENDIF} {$ENDIF} uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; @@ -70,10 +68,10 @@ type function GetHeight: NativeUInt; function HasRepresentation(scaleFactor: Single): Boolean; function RemoveRepresentation(scaleFactor: Single): Boolean; - function GetRepresentationInfo(scaleFactor: Single; actualScaleFactor: PSingle; pixelWidth, pixelHeight: PInteger): Boolean; - function GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; alphaType: TCefAlphaType; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; - function GetAsPng(scaleFactor: Single; withTransparency: Boolean; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; - function GetAsJpeg(scaleFactor: Single; quality: Integer; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; + function GetRepresentationInfo(scaleFactor: Single; var actualScaleFactor: Single; var pixelWidth, pixelHeight: Integer): Boolean; + function GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; alphaType: TCefAlphaType; var pixelWidth, pixelHeight: Integer): ICefBinaryValue; + function GetAsPng(scaleFactor: Single; withTransparency: Boolean; var pixelWidth, pixelHeight: Integer): ICefBinaryValue; + function GetAsJpeg(scaleFactor: Single; quality: Integer; var pixelWidth, pixelHeight: Integer): ICefBinaryValue; public class function UnWrap(data: Pointer): ICefImage; class function New: ICefImage; @@ -105,19 +103,19 @@ begin Result := PCefImage(FData)^.add_png(FData, scaleFactor, pngData, pngDataSize) <> 0; end; -function TCefImageRef.GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; alphaType: TCefAlphaType; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; +function TCefImageRef.GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; alphaType: TCefAlphaType; var pixelWidth, pixelHeight: Integer): ICefBinaryValue; begin - Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_bitmap(FData, scaleFactor, colorType, alphaType, pixelWidth, pixelHeight)); + Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_bitmap(FData, scaleFactor, colorType, alphaType, @pixelWidth, @pixelHeight)); end; -function TCefImageRef.GetAsJpeg(scaleFactor: Single; quality: Integer; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; +function TCefImageRef.GetAsJpeg(scaleFactor: Single; quality: Integer; var pixelWidth, pixelHeight: Integer): ICefBinaryValue; begin - Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_jpeg(FData, scaleFactor, quality, pixelWidth, pixelHeight)); + Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_jpeg(FData, scaleFactor, quality, @pixelWidth, @pixelHeight)); end; -function TCefImageRef.GetAsPng(scaleFactor: Single; withTransparency: Boolean; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; +function TCefImageRef.GetAsPng(scaleFactor: Single; withTransparency: Boolean; var pixelWidth, pixelHeight: Integer): ICefBinaryValue; begin - Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_png(FData, scaleFactor, Ord(withTransparency), pixelWidth, pixelHeight)); + Result := TCefBinaryValueRef.UnWrap(PCefImage(FData)^.get_as_png(FData, scaleFactor, Ord(withTransparency), @pixelWidth, @pixelHeight)); end; function TCefImageRef.GetHeight: NativeUInt; @@ -125,9 +123,9 @@ begin Result := PCefImage(FData)^.get_height(FData); end; -function TCefImageRef.GetRepresentationInfo(scaleFactor: Single; actualScaleFactor: PSingle; pixelWidth, pixelHeight: PInteger): Boolean; +function TCefImageRef.GetRepresentationInfo(scaleFactor: Single; var actualScaleFactor: Single; var pixelWidth, pixelHeight: Integer): Boolean; begin - Result := PCefImage(FData)^.get_representation_info(FData, scaleFactor, actualScaleFactor, pixelWidth, pixelHeight) <> 0; + Result := PCefImage(FData)^.get_representation_info(FData, scaleFactor, @actualScaleFactor, @pixelWidth, @pixelHeight) <> 0; end; function TCefImageRef.GetWidth: NativeUInt; diff --git a/windows/src/ext/cef4delphi/source/uCEFInterfaces.pas b/windows/src/ext/cef4delphi/source/uCEFInterfaces.pas index 7ac14cb1056593298e99ae678c0c549ff15d4ca6..f3797199b157c129c51351a4250a7c2087425dbb 100644 --- a/windows/src/ext/cef4delphi/source/uCEFInterfaces.pas +++ b/windows/src/ext/cef4delphi/source/uCEFInterfaces.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFInterfaces; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -96,6 +94,8 @@ type ICefSelectClientCertificateCallback = interface; ICefCommandLine = interface; ICefRequestHandler = interface; + ICefResourceRequestHandler = interface; + ICefCookieAccessFilter = interface; ICefResourceBundleHandler = interface; ICefBrowserProcessHandler = interface; ICefRenderProcessHandler = interface; @@ -116,6 +116,8 @@ type ICefJsDialogCallback = interface; ICefDownloadItemCallback = interface; ICefRequestCallback = interface; + ICefResourceSkipCallback = interface; + ICefResourceReadCallback = interface; ICefResourceHandler = interface; ICefResponse = interface; ICefResponseFilter = interface; @@ -139,38 +141,91 @@ type ICefWindow = interface; ICefLabelButton = interface; ICefMenuButton = interface; + ICefUrlRequest = interface; + ICefPostDataElement = interface; + ICefRegistration = interface; + ICefMediaRouter = interface; + ICefMediaObserver = interface; + ICefMediaRoute = interface; + ICefMediaRouteCreateCallback = interface; + ICefMediaSink = interface; + ICefMediaSinkDeviceInfoCallback = interface; + ICefMediaSource = interface; + ICefAudioHandler = interface; + ICefDevToolsMessageObserver = interface; + ICefValue = interface; + ICefPrintSettings = interface; TCefv8ValueArray = array of ICefv8Value; TCefX509CertificateArray = array of ICefX509Certificate; TCefBinaryValueArray = array of ICefBinaryValue; TCefFrameIdentifierArray = array of int64; + TCefPostDataElementArray = array of ICefPostDataElement; + TCefMediaRouteArray = array of ICefMediaRoute; + TCefMediaSinkArray = array of ICefMediaSink; + TCefDisplayArray = array of ICefDisplay; + TCefMediaSinkInfo = record + ID : ustring; + Name : ustring; + Description : ustring; + IconType : TCefMediaSinkIconType; + SinkType : TCefMediaType; + SinkIntf : ICefMediaSink; + end; + TCefMediaSinkInfoArray = array of TCefMediaSinkInfo; + TCefMediaRouteInfo = record + ID : ustring; + SourceID : ustring; + SinkID : ustring; + RouteIntf : ICefMediaRoute; + end; + TCefMediaRouteInfoArray = array of TCefMediaRouteInfo; + + TCefMediaSourceInfo = record + ID : ustring; + Valid : boolean; + SourceType : TCefMediaType; + SourceIntf : ICefMediaSource; + end; + TCefMediaSourceInfoArray = array of TCefMediaSourceInfo; // ******************************************* // ***************** Events ****************** // ******************************************* - TOnRegisterCustomSchemesEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const registrar: TCefSchemeRegistrarRef) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnRenderThreadCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const extraInfo: ICefListValue) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnWebKitInitializedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure() {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnBrowserCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnBrowserDestroyedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnContextCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnContextReleasedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnUncaughtExceptionEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnFocusedNodeChangedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnProcessMessageReceivedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage; var aHandled : boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnContextInitializedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure() {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnBeforeChildProcessLaunchEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const commandLine: ICefCommandLine) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnRenderProcessThreadCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const extraInfo: ICefListValue) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnScheduleMessagePumpWorkEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const delayMs: Int64) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnGetDataResourceEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(resourceId: Integer; out data: Pointer; out dataSize: NativeUInt; var aResult : Boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnGetLocalizedStringEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(stringId: Integer; out stringVal: ustring; var aResult : Boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnGetDataResourceForScaleEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(resourceId: Integer; scaleFactor: TCefScaleFactor; out data: Pointer; out dataSize: NativeUInt; var aResult : Boolean) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - TOnCDMRegistrationCompleteEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(result : TCefCDMRegistrationError; const error_message : ustring) {$IFNDEF DELPHI12_UP}of object{$ENDIF}; - + TOnRegisterCustomSchemesEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const registrar: TCefSchemeRegistrarRef) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnRenderThreadCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const extraInfo: ICefListValue) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnWebKitInitializedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure() {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnBrowserCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const extra_info: ICefDictionaryValue) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnBrowserDestroyedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnContextCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnContextReleasedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnUncaughtExceptionEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const exception: ICefV8Exception; const stackTrace: ICefV8StackTrace) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnFocusedNodeChangedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnProcessMessageReceivedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message: ICefProcessMessage; var aHandled : boolean) {$IFNDEF DELPHI12_UP}{$IFNDEF LCL} of object {$ENDIF} {$ENDIF}; + TOnGetCookieableSchemesEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(var schemes: TStringList; var include_defaults : boolean) {$IFNDEF DELPHI12_UP}{$IFNDEF LCL} of object {$ENDIF} {$ENDIF}; + TOnContextInitializedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure() {$IFNDEF DELPHI12_UP}{$IFNDEF FPC} of object{$ENDIF}{$ENDIF}; + TOnBeforeChildProcessLaunchEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const commandLine: ICefCommandLine) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnRenderProcessThreadCreatedEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const extraInfo: ICefListValue) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnScheduleMessagePumpWorkEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const delayMs: Int64) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC} of object{$ENDIF}{$ENDIF}; + TOnGetDefaultClientEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(var aClient : ICefClient) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC} of object{$ENDIF}{$ENDIF}; + TOnGetDataResourceEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(resourceId: Integer; out data: Pointer; out dataSize: NativeUInt; var aResult : Boolean) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnGetLocalizedStringEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(stringId: Integer; out stringVal: ustring; var aResult : Boolean) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnGetDataResourceForScaleEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(resourceId: Integer; scaleFactor: TCefScaleFactor; out data: Pointer; out dataSize: NativeUInt; var aResult : Boolean) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnCDMRegistrationCompleteEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(result : TCefCDMRegistrationError; const error_message : ustring) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnRenderLoadStart = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnRenderLoadEnd = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnRenderLoadError = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const frame: ICefFrame; errorCode: TCefErrorCode; const errorText, failedUrl: ustring) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnRenderLoadingStateChange = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnPrintStartEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnPrintSettingsEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const settings: ICefPrintSettings; getDefaults: boolean) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnPrintDialogEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult : boolean) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnPrintJobEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult : boolean) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnPrintResetEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser: ICefBrowser) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; + TOnGetPDFPaperSizeEvent = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(deviceUnitsPerInch: Integer; var aResult : TCefSize) {$IFNDEF DELPHI12_UP}{$IFNDEF FPC}of object{$ENDIF}{$ENDIF}; // ******************************************* // **** Callback procedures and functions **** @@ -179,20 +234,20 @@ type TCefEndTracingCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const tracingFile: ustring); TCefRegisterCDMProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(result: TCefCDMRegistrationError; const error_message: ustring); - TCefRequestContextHandlerProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function: ICefCookieManager; TCefFastTaskProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(); TCefv8ArrayBufferReleaseCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(buffer : Pointer); TCefWebPluginInfoVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const info: ICefWebPluginInfo; count, total: Integer): Boolean; TCefWebPluginIsUnstableProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const path: ustring; unstable: Boolean); - TCefV8AccessorGetterProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name: ustring; const obj: ICefv8Value; out value: ICefv8Value; const exception: ustring): Boolean; - TCefV8AccessorSetterProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): Boolean; - TCefV8InterceptorGetterByNameProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name: ustring; const obj: ICefv8Value; out value: ICefv8Value; const exception: ustring): Boolean; - TCefV8InterceptorSetterByNameProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): Boolean; - TCefV8InterceptorGetterByIndexProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(index: integer; const obj: ICefv8Value; out value: ICefv8Value; const exception: ustring): Boolean; - TCefV8InterceptorSetterByIndexProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(index: integer; const obj, value: ICefv8Value; const exception: ustring): Boolean; + TCefV8AccessorGetterProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name: ustring; const object_: ICefv8Value; var value: ICefv8Value; var exception: ustring): Boolean; + TCefV8AccessorSetterProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): Boolean; + TCefV8InterceptorGetterByNameProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name: ustring; const object_: ICefv8Value; var value: ICefv8Value; var exception: ustring): Boolean; + TCefV8InterceptorSetterByNameProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): Boolean; + TCefV8InterceptorGetterByIndexProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(index: integer; const object_: ICefv8Value; var value: ICefv8Value; var exception: ustring): Boolean; + TCefV8InterceptorSetterByIndexProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(index: integer; const object_, value: ICefv8Value; var exception: ustring): Boolean; TOnPdfPrintFinishedProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const path: ustring; ok: Boolean); TCefDomVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const document: ICefDomDocument); - TCefDomVisitorProc2 = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser : ICefBrowser; const document: ICefDomDocument); + TCefDomVisitorProc2 = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser : ICefBrowser; const frame: ICefFrame; const document: ICefDomDocument); + TCefDomVisitorProc3 = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const browser : ICefBrowser; const frame: ICefFrame; const document: ICefDomDocument; const aValue : ustring); TCefStringVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const str: ustring); TCefRunFileDialogCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(selectedAcceptFilter: Integer; const filePaths: TStrings); TCefCompletionCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(); @@ -200,9 +255,9 @@ type TCefDeleteCookiesCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(numDeleted: Integer); TCefNavigationEntryVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer): Boolean; TOnDownloadImageFinishedProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); - TCefCookieVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; out deleteCookie: Boolean): Boolean; - - + TCefCookieVisitorProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} function(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; same_site : TCefCookieSameSite; priority : TCefCookiePriority; out deleteCookie: Boolean): Boolean; + TCefMediaRouteCreateCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); + TCefMediaSinkDeviceInfoCallbackProc = {$IFDEF DELPHI12_UP}reference to{$ENDIF} procedure(const ip_address: ustring; port: integer; const model_name: ustring); // ******************************************* // ************ Custom interfaces ************ @@ -264,7 +319,7 @@ type procedure GetSettings(var settings: TCefBrowserSettings); // ICefClient - function doOnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; + function doOnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message: ICefProcessMessage): Boolean; // ICefLoadHandler procedure doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); @@ -297,6 +352,7 @@ type function doOnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const message, source: ustring; line: Integer): Boolean; function doOnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; procedure doOnLoadingProgressChange(const browser: ICefBrowser; const progress: double); + procedure doOnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); // ICefDownloadHandler procedure doOnBeforeDownload(const browser: ICefBrowser; const downloadItem: ICefDownloadItem; const suggestedName: ustring; const callback: ICefBeforeDownloadCallback); @@ -309,7 +365,7 @@ type procedure doOnDialogClosed(const browser: ICefBrowser); // ICefLifeSpanHandler - function doOnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean): Boolean; + function doOnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean): Boolean; procedure doOnAfterCreated(const browser: ICefBrowser); procedure doOnBeforeClose(const browser: ICefBrowser); function doOnClose(const browser: ICefBrowser): Boolean; @@ -317,22 +373,28 @@ type // ICefRequestHandler function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; - function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; - function doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; - procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); - function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; - function doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; - procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); - function doOnGetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; - function doCanGetCookies(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): boolean; - function doCanSetCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie : PCefCookie): boolean; + procedure doGetResourceRequestHandler_ReqHdlr(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); + function doOnGetAuthCredentials(const browser: ICefBrowser; const originUrl: ustring; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; - procedure doOnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; function doOnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; procedure doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); procedure doOnRenderViewReady(const browser: ICefBrowser); procedure doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); + procedure doOnDocumentAvailableInMainFrame(const browser: ICefBrowser); + + // ICefResourceRequestHandler + function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; + procedure doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aResourceHandler: ICefResourceHandler); + procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); + function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; + procedure doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var aResponseFilter: ICefResponseFilter); + procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); + procedure doOnProtocolExecution(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var allowOsExecution: Boolean); + + // ICefCookieAccessFilter + function doCanSendCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie: PCefCookie): boolean; + function doCanSaveCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; const cookie: PCefCookie): boolean; // ICefDialogHandler function doOnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; @@ -340,26 +402,62 @@ type // ICefRenderHandler procedure doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); function doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; - function doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; + procedure doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect); function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; 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: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); - procedure doOnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); + procedure doOnPaint(const browser: ICefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); + procedure doOnAcceleratedPaint(const browser: ICefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; shared_handle: Pointer); function doOnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; procedure doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); procedure doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); procedure doOnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); procedure doOnTextSelectionChanged(const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange); + procedure doOnVirtualKeyboardRequested(const browser: ICefBrowser; input_mode: TCefTextInpuMode); // ICefDragHandler function doOnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; - procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); + procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; const frame: ICefFrame; regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); // ICefFindHandler procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); + // ICefRequestContextHandler + procedure doOnRequestContextInitialized(const request_context: ICefRequestContext); + function doOnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; + procedure doGetResourceRequestHandler_ReqCtxHdlr(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); + + // ICefMediaObserver + procedure doOnSinks(const sinks: TCefMediaSinkArray); + procedure doOnRoutes(const routes: TCefMediaRouteArray); + procedure doOnRouteStateChanged(const route: ICefMediaRoute; state: TCefMediaRouteConnectionState); + procedure doOnRouteMessageReceived(const route: ICefMediaRoute; const message_: ustring); + + // ICefAudioHandler + procedure doOnGetAudioParameters(const browser: ICefBrowser; var params: TCefAudioParameters; var aResult: boolean); + procedure doOnAudioStreamStarted(const browser: ICefBrowser; const params: TCefAudioParameters; channels: integer); + procedure doOnAudioStreamPacket(const browser: ICefBrowser; const data : PPSingle; frames: integer; pts: int64); + procedure doOnAudioStreamStopped(const browser: ICefBrowser); + procedure doOnAudioStreamError(const browser: ICefBrowser; const message_: ustring); + + // ICefDevToolsMessageObserver + procedure doOnDevToolsMessage(const browser: ICefBrowser; const message_: Pointer; message_size: NativeUInt; var aHandled: boolean); + procedure doOnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: Pointer; result_size: NativeUInt); + procedure doOnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: Pointer; params_size: NativeUInt); + procedure doOnDevToolsAgentAttached(const browser: ICefBrowser); + procedure doOnDevToolsAgentDetached(const browser: ICefBrowser); + + // ICefExtensionHandler + procedure doOnExtensionLoadFailed(result: TCefErrorcode); + procedure doOnExtensionLoaded(const extension: ICefExtension); + procedure doOnExtensionUnloaded(const extension: ICefExtension); + function doOnExtensionBeforeBackgroundBrowser(const extension: ICefExtension; const url: ustring; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; + function doOnExtensionBeforeBrowser(const extension: ICefExtension; const browser, active_browser: ICefBrowser; index: Integer; const url: ustring; active: boolean; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; + procedure doOnExtensionGetActiveBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; var aRsltBrowser: ICefBrowser); + function doOnExtensionCanAccessBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; const target_browser: ICefBrowser): boolean; + function doOnExtensionGetExtensionResource(const extension: ICefExtension; const browser: ICefBrowser; const file_: ustring; const callback: ICefGetExtensionResourceCallback): boolean; + // Custom procedure doCookiesDeleted(numDeleted : integer); procedure doPdfPrintFinished(aResultOK : boolean); @@ -368,6 +466,43 @@ type procedure doUpdateOwnPreferences; function doSavePreferences : boolean; procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); + function doNavigationVisitorResultAvailable(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer) : boolean; + procedure doDownloadImageFinished(const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage); + procedure doOnCookiesStoreFlushed; + procedure doCertificateExceptionsCleared; + procedure doHttpAuthCredentialsCleared; + procedure doAllConnectionsClosed; + procedure doOnExecuteTaskOnCefThread(aTaskID : cardinal); + procedure doOnCookiesVisited(const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; same_site : TCefCookieSameSite; priority : TCefCookiePriority; var aDeleteCookie, aResult : Boolean); + procedure doOnCookieVisitorDestroyed(aID : integer); + procedure doOnCookieSet(aSuccess : boolean; aID : integer); + procedure doUpdateZoomStep(aInc : boolean); + procedure doUpdateZoomPct(aInc : boolean); + procedure doSetZoomLevel(const aValue : double); + procedure doSetZoomPct(const aValue : double); + procedure doSetZoomStep(aValue : byte); + procedure doReadZoom; + procedure doMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); + procedure doOnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); + procedure doBrowserNavigation(aTask : TCefBrowserNavigation); + function MustCreateAudioHandler : boolean; + function MustCreateLoadHandler : boolean; + function MustCreateFocusHandler : boolean; + function MustCreateContextMenuHandler : boolean; + function MustCreateDialogHandler : boolean; + function MustCreateKeyboardHandler : boolean; + function MustCreateDisplayHandler : boolean; + function MustCreateDownloadHandler : boolean; + function MustCreateJsDialogHandler : boolean; + function MustCreateLifeSpanHandler : boolean; + function MustCreateRenderHandler : boolean; + function MustCreateRequestHandler : boolean; + function MustCreateDragHandler : boolean; + function MustCreateFindHandler : boolean; + function MustCreateResourceRequestHandler : boolean; + function MustCreateCookieAccessFilter : boolean; + function MustCreateRequestContextHandler : boolean; + function MustCreateMediaObserver : boolean; end; IServerEvents = interface @@ -382,6 +517,18 @@ type procedure doOnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); end; + ICEFUrlRequestClientEvents = interface + ['{1AA800A7-56A1-43CA-A224-49368F18BDD8}'] + // ICefUrlrequestClient + procedure doOnRequestComplete(const request: ICefUrlRequest); + procedure doOnUploadProgress(const request: ICefUrlRequest; current, total: Int64); + procedure doOnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); + procedure doOnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); + function doOnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; + + // Custom + procedure doOnCreateURLRequest; + end; // ******************************************* @@ -394,7 +541,11 @@ type ICefBaseRefCounted = interface ['{1F9A7B44-DCDC-4477-9180-3ADD44BDEB7B}'] function Wrap: Pointer; - function SameAs(aData : Pointer) : boolean; + function SameAs(aData : Pointer) : boolean; overload; + function SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; overload; + function HasOneRef : boolean; + function HasAtLeastOneRef : boolean; + procedure DestroyOtherRefs; end; // TCefRunFileDialogCallback @@ -446,15 +597,16 @@ type procedure Print; procedure PrintToPdf(const path: ustring; settings: PCefPdfPrintSettings; const callback: ICefPdfPrintCallback); procedure PrintToPdfProc(const path: ustring; settings: PCefPdfPrintSettings; const callback: TOnPdfPrintFinishedProc); - procedure Find(identifier: Integer; const searchText: ustring; forward, matchCase, findNext: Boolean); + procedure Find(identifier: Integer; const searchText: ustring; forward_, matchCase, findNext: Boolean); procedure StopFinding(clearSelection: Boolean); procedure ShowDevTools(const windowInfo: PCefWindowInfo; const client: ICefClient; const settings: PCefBrowserSettings; inspectElementAt: PCefPoint); procedure CloseDevTools; function HasDevTools: Boolean; + function SendDevToolsMessage(const message_: ustring): boolean; + function ExecuteDevToolsMethod(message_id: integer; const method: ustring; const params: ICefDictionaryValue): Integer; + function AddDevToolsMessageObserver(const observer: ICefDevToolsMessageObserver): ICefRegistration; procedure GetNavigationEntries(const visitor: ICefNavigationEntryVisitor; currentOnly: Boolean); procedure GetNavigationEntriesProc(const proc: TCefNavigationEntryVisitorProc; currentOnly: Boolean); - procedure SetMouseCursorChangeDisabled(disabled: Boolean); - function IsMouseCursorChangeDisabled: Boolean; procedure ReplaceMisspelling(const word: ustring); procedure AddWordToDictionary(const word: ustring); function IsWindowRenderingDisabled: Boolean; @@ -462,23 +614,25 @@ type procedure WasHidden(hidden: Boolean); procedure NotifyScreenInfoChanged; procedure Invalidate(kind: TCefPaintElementType); + procedure SendExternalBeginFrame; procedure SendKeyEvent(const event: PCefKeyEvent); - procedure SendMouseClickEvent(const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); + procedure SendMouseClickEvent(const event: PCefMouseEvent; type_: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); procedure SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); procedure SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); + procedure SendTouchEvent(const event: PCefTouchEvent); procedure SendFocusEvent(aSetFocus: Boolean); procedure SendCaptureLostEvent; procedure NotifyMoveOrResizeStarted; function GetWindowlessFrameRate : Integer; procedure SetWindowlessFrameRate(frameRate: Integer); - procedure IMESetComposition(const text: ustring; underlinesCount : NativeUInt; const underlines : PCefCompositionUnderline; const replacement_range, selection_range : PCefRange); + procedure IMESetComposition(const text: ustring; const underlines : TCefCompositionUnderlineDynArray; const replacement_range, selection_range : PCefRange); procedure IMECommitText(const text: ustring; const replacement_range : PCefRange; relative_cursor_pos : integer); procedure IMEFinishComposingText(keep_selection : boolean); procedure IMECancelComposition; procedure DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); procedure DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); procedure DragTargetDragLeave; - procedure DragTargetDrop(event: PCefMouseEvent); + procedure DragTargetDrop(const event: PCefMouseEvent); procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); procedure DragSourceSystemDragEnded; function GetVisibleNavigationEntry : ICefNavigationEntry; @@ -486,13 +640,15 @@ type procedure SetAutoResizeEnabled(enabled: boolean; const min_size, max_size: PCefSize); function GetExtension : ICefExtension; function IsBackgroundHost : boolean; + procedure SetAudioMuted(mute: boolean); + function IsAudioMuted : boolean; - property Browser : ICefBrowser read GetBrowser; - property WindowHandle : TCefWindowHandle read GetWindowHandle; - property OpenerWindowHandle : TCefWindowHandle read GetOpenerWindowHandle; - property ZoomLevel : Double read GetZoomLevel write SetZoomLevel; - property RequestContext : ICefRequestContext read GetRequestContext; - property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; + property Browser : ICefBrowser read GetBrowser; + property WindowHandle : TCefWindowHandle read GetWindowHandle; + property OpenerWindowHandle : TCefWindowHandle read GetOpenerWindowHandle; + property ZoomLevel : Double read GetZoomLevel write SetZoomLevel; + property RequestContext : ICefRequestContext read GetRequestContext; + property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; end; // TCefProcessMessage @@ -532,7 +688,6 @@ type function GetFrameCount: NativeUInt; function GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean; function GetFrameNames(var aFrameNames : TStrings) : boolean; - function SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; property MainFrame : ICefFrame read GetMainFrame; property FocusedFrame : ICefFrame read GetFocusedFrame; @@ -561,10 +716,10 @@ type ['{1E677630-9339-4732-BB99-D6FE4DE4AEC0}'] function IsReadOnly: Boolean; function HasExcludedElements: Boolean; - function GetCount: NativeUInt; - function GetElements(Count: NativeUInt): IInterfaceList; // list of ICefPostDataElement - function RemoveElement(const element: ICefPostDataElement): Integer; - function AddElement(const element: ICefPostDataElement): Integer; + function GetElementCount: NativeUInt; + procedure GetElements(elementsCount: NativeUInt; var elements: TCefPostDataElementArray); + function RemoveElement(const element: ICefPostDataElement): Boolean; + function AddElement(const element: ICefPostDataElement): Boolean; procedure RemoveElements; end; @@ -584,6 +739,8 @@ type function GetReferrerPolicy: TCefReferrerPolicy; procedure SetPostData(const value: ICefPostData); procedure SetHeaderMap(const HeaderMap: ICefStringMultimap); + function GetHeaderByName(const name: ustring): ustring; + procedure SetHeaderByName(const name, value: ustring; overwrite: boolean); function GetFlags: TCefUrlRequestFlags; procedure SetFlags(flags: TCefUrlRequestFlags); function GetFirstPartyForCookies: ustring; @@ -631,7 +788,6 @@ type procedure GetTextProc(const proc: TCefStringVisitorProc); procedure LoadRequest(const request: ICefRequest); procedure LoadUrl(const url: ustring); - procedure LoadString(const str, url: ustring); procedure ExecuteJavaScript(const code, scriptUrl: ustring; startLine: Integer); function IsMain: Boolean; function IsFocused: Boolean; @@ -643,6 +799,8 @@ type function GetV8Context: ICefv8Context; procedure VisitDom(const visitor: ICefDomVisitor); procedure VisitDomProc(const proc: TCefDomVisitorProc); + function CreateUrlRequest(const request: ICefRequest; const client: ICefUrlrequestClient): ICefUrlRequest; + procedure SendProcessMessage(targetProcess: TCefProcessId; const message_: ICefProcessMessage); property Name : ustring read GetName; property Url : ustring read GetUrl; @@ -708,7 +866,10 @@ type procedure SetStatusText(const StatusText: ustring); function GetMimeType: ustring; procedure SetMimeType(const mimetype: ustring); - function GetHeader(const name: ustring): ustring; + function GetCharset: ustring; + procedure SetCharset(const charset: ustring); + function GetHeaderByName(const name: ustring): ustring; + procedure SetHeaderByName(const name, value: ustring; overwrite: boolean); procedure GetHeaderMap(const headerMap: ICefStringMultimap); procedure SetHeaderMap(const headerMap: ICefStringMultimap); function GetURL: ustring; @@ -717,6 +878,7 @@ type property Status : Integer read GetStatus write SetStatus; property StatusText : ustring read GetStatusText write SetStatusText; property MimeType : ustring read GetMimeType write SetMimeType; + property Charset : ustring read GetCharset write SetCharset; property Error : TCefErrorCode read GetError write SetError; property URL : ustring read GetURL write SetURL; end; @@ -837,25 +999,25 @@ type // /include/capi/cef_v8_capi.h (cef_v8handler_t) ICefv8Handler = interface(ICefBaseRefCounted) ['{F94CDC60-FDCB-422D-96D5-D2A775BD5D73}'] - function Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; + function Execute(const name: ustring; const object_: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; end; // TCefV8Interceptor // /include/capi/cef_v8_capi.h (cef_v8interceptor_t) ICefV8Interceptor = interface(ICefBaseRefCounted) ['{B3B8FD7C-A916-4B25-93A2-2892AC324F21}'] - function GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; - function GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; - function SetByName(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): boolean; - function SetByIndex(index: integer; const obj, value: ICefv8Value; const exception: ustring): boolean; + function GetByName(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; + function GetByIndex(index: integer; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; + function SetByName(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): boolean; + function SetByIndex(index: integer; const object_, value: ICefv8Value; var exception: ustring): boolean; end; // TCefV8Accessor // /include/capi/cef_v8_capi.h (cef_v8accessor_t) ICefV8Accessor = interface(ICefBaseRefCounted) ['{DCA6D4A2-726A-4E24-AA64-5E8C731D868A}'] - function Get(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; var exception: ustring): Boolean; - function Put(const name: ustring; const obj, value: ICefv8Value; var exception: ustring): Boolean; + function Get(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): Boolean; + function Set_(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): Boolean; end; // TCefTask @@ -1124,7 +1286,7 @@ type // /include/capi/cef_cookie_capi.h (cef_cookie_visitor_t) ICefCookieVisitor = interface(ICefBaseRefCounted) ['{8378CF1B-84AB-4FDB-9B86-34DDABCCC402}'] - function visit(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; out deleteCookie: Boolean): Boolean; + function visit(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; same_site : TCefCookieSameSite; priority : TCefCookiePriority; out deleteCookie: Boolean): Boolean; end; // TCefCommandLine @@ -1144,7 +1306,8 @@ type function HasSwitches: Boolean; function HasSwitch(const name: ustring): Boolean; function GetSwitchValue(const name: ustring): ustring; - procedure GetSwitches(var switches: TStrings); + function GetSwitches(var switches: TStrings): boolean; overload; + function GetSwitches(var SwitchKeys, SwitchValues: TStringList): boolean; overload; procedure AppendSwitch(const name: ustring); procedure AppendSwitchWithValue(const name, value: ustring); function HasArguments: Boolean; @@ -1155,6 +1318,111 @@ type property CommandLineString : ustring read GetCommandLineString; end; + // TCefRegistration + // /include/capi/cef_registration_capi.h (cef_registration_t) + ICefRegistration = interface(ICefBaseRefCounted) + ['{9226018F-7A56-4F2E-AF01-43268E33EE6B}'] + end; + + // TCefDevToolsMessageObserver + // /include/capi/cef_devtools_message_observer_capi.h (cef_dev_tools_message_observer_t) + ICefDevToolsMessageObserver = interface(ICefBaseRefCounted) + ['{76E5BB2B-7F69-4BC9-94C7-B55C61CE630F}'] + procedure OnDevToolsMessage(const browser: ICefBrowser; const message_: Pointer; message_size: NativeUInt; var aHandled: boolean); + procedure OnDevToolsMethodResult(const browser: ICefBrowser; message_id: integer; success: boolean; const result: Pointer; result_size: NativeUInt); + procedure OnDevToolsEvent(const browser: ICefBrowser; const method: ustring; const params: Pointer; params_size: NativeUInt); + procedure OnDevToolsAgentAttached(const browser: ICefBrowser); + procedure OnDevToolsAgentDetached(const browser: ICefBrowser); + end; + + // TCefMediaRouter + // /include/capi/cef_media_router_capi.h (cef_media_router_t) + ICefMediaRouter = interface(ICefBaseRefCounted) + ['{F18C3880-CB8D-48F9-9D74-DCFF4B9E88DF}'] + function AddObserver(const observer: ICefMediaObserver): ICefRegistration; + function GetSource(const urn: ustring): ICefMediaSource; + procedure NotifyCurrentSinks; + procedure CreateRoute(const source: ICefMediaSource; const sink: ICefMediaSink; const callback: ICefMediaRouteCreateCallback); + procedure NotifyCurrentRoutes; + end; + + // TCefMediaObserver + // /include/capi/cef_media_router_capi.h (cef_media_observer_t) + ICefMediaObserver = interface(ICefBaseRefCounted) + ['{0B27C8D1-63E3-4F69-939F-DCAD518654A3}'] + procedure OnSinks(const sinks: TCefMediaSinkArray); + procedure OnRoutes(const routes: TCefMediaRouteArray); + procedure OnRouteStateChanged(const route: ICefMediaRoute; state: TCefMediaRouteConnectionState); + procedure OnRouteMessageReceived(const route: ICefMediaRoute; const message_: ustring); + end; + + ICefMediaObserverEvents = interface + ['{267D5287-08DB-49D6-AF6E-B27C66C6E5D4}'] + procedure doOnSinks(const sinks: TCefMediaSinkArray); + procedure doOnRoutes(const routes: TCefMediaRouteArray); + procedure doOnRouteStateChanged(const route: ICefMediaRoute; state: TCefMediaRouteConnectionState); + procedure doOnRouteMessageReceived(const route: ICefMediaRoute; const message_: ustring); + end; + + // TCefMediaRoute + // /include/capi/cef_media_router_capi.h (cef_media_observer_t) + ICefMediaRoute = interface(ICefBaseRefCounted) + ['{D8959122-DD19-4933-B4D9-DF829062A0D3}'] + function GetId: ustring; + function GetSource: ICefMediaSource; + function GetSink: ICefMediaSink; + procedure SendRouteMessage(const message_: ustring); + procedure Terminate; + + property ID : ustring read GetId; + property Source : ICefMediaSource read GetSource; + property Sink : ICefMediaSink read GetSink; + end; + + // TCefMediaRouteCreateCallback + // /include/capi/cef_media_router_capi.h (cef_media_route_create_callback_t) + ICefMediaRouteCreateCallback = interface(ICefBaseRefCounted) + ['{8848CBFE-36AC-4AC8-BC10-386B69FB27BE}'] + procedure OnMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); + end; + + // + ICefMediaSinkDeviceInfoCallback = interface(ICefBaseRefCounted) + ['{633898DD-4169-45D0-ADDD-6E68B3686E0D}'] + procedure OnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); + end; + + // TCefMediaSink + // /include/capi/cef_media_router_capi.h (cef_media_sink_t) + ICefMediaSink = interface(ICefBaseRefCounted) + ['{EDA1A4B2-2A4C-42DD-A7DF-901BF93D908D}'] + function GetId: ustring; + function GetName: ustring; + function GetDescription: ustring; + function GetIconType: TCefMediaSinkIconType; + procedure GetDeviceInfo(const callback: ICefMediaSinkDeviceInfoCallback); + function IsCastSink: boolean; + function IsDialSink: boolean; + function IsCompatibleWith(const source: ICefMediaSource): boolean; + + property ID : ustring read GetId; + property Name : ustring read GetName; + property Description : ustring read GetDescription; + property IconType : TCefMediaSinkIconType read GetIconType; + end; + + // TCefMediaSource + // /include/capi/cef_media_router_capi.h (cef_media_source_t) + ICefMediaSource = interface(ICefBaseRefCounted) + ['{734ED6E4-6498-43ED-AAA4-6B993EDC30BE}'] + function GetId : ustring; + function IsCastSource : boolean; + function IsDialSource : boolean; + + property ID : ustring read GetId; + end; + + // TCefResourceBundleHandler // /include/capi/cef_resource_bundle_handler_capi.h (cef_resource_bundle_handler_t) ICefResourceBundleHandler = interface(ICefBaseRefCounted) @@ -1162,33 +1430,39 @@ type function GetLocalizedString(stringId: Integer; var stringVal: ustring): Boolean; function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean; function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean; + + procedure RemoveReferences; // custom procedure to clear all references end; // TCefBrowserProcessHandler // /include/capi/cef_browser_process_handler_capi.h (cef_browser_process_handler_t) ICefBrowserProcessHandler = interface(ICefBaseRefCounted) ['{27291B7A-C0AE-4EE0-9115-15C810E22F6C}'] + procedure GetCookieableSchemes(var schemes: TStringList; var include_defaults : boolean); procedure OnContextInitialized; procedure OnBeforeChildProcessLaunch(const commandLine: ICefCommandLine); - procedure OnRenderProcessThreadCreated(const extraInfo: ICefListValue); procedure GetPrintHandler(var aHandler : ICefPrintHandler); procedure OnScheduleMessagePumpWork(const delayMs: Int64); + procedure GetDefaultClient(var aClient : ICefClient); + + procedure RemoveReferences; // custom procedure to clear all references end; // TCefRenderProcessHandler // /include/capi/cef_render_process_handler_capi.h (cef_render_process_handler_t) ICefRenderProcessHandler = interface(ICefBaseRefCounted) ['{FADEE3BC-BF66-430A-BA5D-1EE3782ECC58}'] - procedure OnRenderThreadCreated(const extraInfo: ICefListValue); procedure OnWebKitInitialized; - procedure OnBrowserCreated(const browser: ICefBrowser); + procedure OnBrowserCreated(const browser: ICefBrowser; const extra_info: ICefDictionaryValue); procedure OnBrowserDestroyed(const browser: ICefBrowser); function GetLoadHandler : ICefLoadHandler; procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const V8Exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); - function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; + function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; + + procedure RemoveReferences; // custom procedure to clear all references end; // TCefApp @@ -1200,6 +1474,8 @@ type procedure GetResourceBundleHandler(var aHandler : ICefResourceBundleHandler); procedure GetBrowserProcessHandler(var aHandler : ICefBrowserProcessHandler); procedure GetRenderProcessHandler(var aHandler : ICefRenderProcessHandler); + + procedure RemoveReferences; // custom procedure to clear all references end; // TCefCompletionCallback @@ -1227,19 +1503,17 @@ type // /include/capi/cef_cookie_capi.h (cef_cookie_manager_t) ICefCookieManager = Interface(ICefBaseRefCounted) ['{CC1749E6-9AD3-4283-8430-AF6CBF3E8785}'] - procedure SetSupportedSchemes(const schemes: TStrings; const callback: ICefCompletionCallback); - procedure SetSupportedSchemesProc(const schemes: TStrings; const callback: TCefCompletionCallbackProc); + procedure SetSupportedSchemes(const schemes: TStrings; include_defaults: boolean; const callback: ICefCompletionCallback); + procedure SetSupportedSchemesProc(const schemes: TStrings; include_defaults: boolean; const callback: TCefCompletionCallbackProc); function VisitAllCookies(const visitor: ICefCookieVisitor): Boolean; function VisitAllCookiesProc(const visitor: TCefCookieVisitorProc): Boolean; function VisitUrlCookies(const url: ustring; includeHttpOnly: Boolean; const visitor: ICefCookieVisitor): Boolean; function VisitUrlCookiesProc(const url: ustring; includeHttpOnly: Boolean; const visitor: TCefCookieVisitorProc): Boolean; - function SetCookie(const url: ustring; const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; const callback: ICefSetCookieCallback): Boolean; - function SetCookieProc(const url: ustring; const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; const callback: TCefSetCookieCallbackProc): Boolean; + function SetCookie(const url, name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; same_site : TCefCookieSameSite; priority : TCefCookiePriority; const callback: ICefSetCookieCallback): Boolean; + function SetCookieProc(const url: ustring; const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; same_site : TCefCookieSameSite; priority : TCefCookiePriority; const callback: TCefSetCookieCallbackProc): Boolean; function DeleteCookies(const url, cookieName: ustring; const callback: ICefDeleteCookiesCallback): Boolean; function DeleteCookiesProc(const url, cookieName: ustring; const callback: TCefDeleteCookiesCallbackProc): Boolean; - function SetStoragePath(const path: ustring; persistSessionCookies: Boolean; const callback: ICefCompletionCallback): Boolean; - function SetStoragePathProc(const path: ustring; persistSessionCookies: Boolean; const callback: TCefCompletionCallbackProc): Boolean; - function FlushStore(const handler: ICefCompletionCallback): Boolean; + function FlushStore(const callback: ICefCompletionCallback): Boolean; function FlushStoreProc(const proc: TCefCompletionCallbackProc): Boolean; end; @@ -1266,15 +1540,30 @@ type procedure Cancel; end; + // TCefResourceSkipCallback + // /include/capi/cef_resource_handler_capi.h (cef_resource_skip_callback_t) + ICefResourceSkipCallback = interface(ICefBaseRefCounted) + ['{5ADDE93E-5858-41FD-81E8-ED8BF710D92A}'] + procedure Cont(bytes_skipped: int64); + end; + + // TCefResourceReadCallback + // /include/capi/cef_resource_handler_capi.h (cef_resource_read_callback_t) + ICefResourceReadCallback = interface(ICefBaseRefCounted) + ['{7669335F-7A4B-4657-86CA-C02B12369602}'] + procedure Cont(bytes_read: int64); + end; + // TCefResourceHandler // /include/capi/cef_resource_handler_capi.h (cef_resource_handler_t) ICefResourceHandler = interface(ICefBaseRefCounted) - ['{BD3EA208-AAAD-488C-BFF2-76993022F2B5}'] - function ProcessRequest(const request: ICefRequest; const callback: ICefCallback): Boolean; + ['{BD3EA208-AAAD-488C-BFF2-76993022F2B5}'] + function open(const request: ICefRequest; var handle_request: boolean; const callback: ICefCallback): boolean; + function ProcessRequest(const request: ICefRequest; const callback: ICefCallback): boolean; // deprecated procedure GetResponseHeaders(const response: ICefResponse; out responseLength: Int64; out redirectUrl: ustring); - function ReadResponse(const dataOut: Pointer; bytesToRead: Integer; var bytesRead: Integer; const callback: ICefCallback): Boolean; - function CanGetCookie(const cookie: PCefCookie): Boolean; - function CanSetCookie(const cookie: PCefCookie): Boolean; + function skip(bytes_to_skip: int64; var bytes_skipped: Int64; const callback: ICefResourceSkipCallback): boolean; + function read(const data_out: Pointer; bytes_to_read: Integer; var bytes_read: Integer; const callback: ICefResourceReadCallback): boolean; + function ReadResponse(const dataOut: Pointer; bytesToRead: Integer; var bytesRead: Integer; const callback: ICefCallback): boolean; // deprecated procedure Cancel; end; @@ -1423,7 +1712,7 @@ type function GetDictionary: ICefDictionaryValue; function GetList: ICefListValue; function SetNull: Boolean; - function SetBool(value: Integer): Boolean; + function SetBool(value: boolean): Boolean; function SetInt(value: Integer): Boolean; function SetDouble(value: Double): Boolean; function SetString(const value: ustring): Boolean; @@ -1520,7 +1809,7 @@ type // /include/capi/cef_life_span_handler_capi.h (cef_life_span_handler_t) ICefLifeSpanHandler = interface(ICefBaseRefCounted) ['{0A3EB782-A319-4C35-9B46-09B2834D7169}'] - function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean): Boolean; + function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean): Boolean; procedure OnAfterCreated(const browser: ICefBrowser); function DoClose(const browser: ICefBrowser): Boolean; procedure OnBeforeClose(const browser: ICefBrowser); @@ -1545,9 +1834,11 @@ type procedure OnExtensionUnloaded(const extension: ICefExtension); function OnBeforeBackgroundBrowser(const extension: ICefExtension; const url: ustring; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; function OnBeforeBrowser(const extension: ICefExtension; const browser, active_browser: ICefBrowser; index: Integer; const url: ustring; active: boolean; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings) : boolean; - function GetActiveBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean): ICefBrowser; + procedure GetActiveBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; var aRsltBrowser: ICefBrowser); function CanAccessBrowser(const extension: ICefExtension; const browser: ICefBrowser; include_incognito: boolean; const target_browser: ICefBrowser): boolean; function GetExtensionResource(const extension: ICefExtension; const browser: ICefBrowser; const file_: ustring; const callback: ICefGetExtensionResourceCallback): boolean; + + procedure RemoveReferences; // custom procedure to clear all references end; // TCefExtension @@ -1562,12 +1853,28 @@ type function GetLoaderContext : ICefRequestContext; function IsLoaded : boolean; procedure unload; - - property Identifier : ustring read GetIdentifier; - property Path : ustring read GetPath; - property Manifest : ICefDictionaryValue read GetManifest; - property Handler : ICefExtensionHandler read GetHandler; - property LoaderContext : ICefRequestContext read GetLoaderContext; + function GetBrowserActionPopup : ustring; + function GetBrowserActionIcon : ustring; + function GetPageActionPopup : ustring; + function GetPageActionIcon : ustring; + function GetOptionsPage : ustring; + function GetOptionsUIPage : ustring; + function GetBackgroundPage : ustring; + function GetURL : ustring; + + property Identifier : ustring read GetIdentifier; + property Path : ustring read GetPath; + property Manifest : ICefDictionaryValue read GetManifest; + property Handler : ICefExtensionHandler read GetHandler; + property LoaderContext : ICefRequestContext read GetLoaderContext; + property BrowserActionPopup : ustring read GetBrowserActionPopup; + property BrowserActionIcon : ustring read GetBrowserActionIcon; + property PageActionPopup : ustring read GetPageActionPopup; + property PageActionIcon : ustring read GetPageActionIcon; + property OptionsPage : ustring read GetOptionsPage; + property OptionsUIPage : ustring read GetOptionsUIPage; + property BackgroundPage : ustring read GetBackgroundPage; + property URL : ustring read GetURL; end; // TCefLoadHandler @@ -1583,7 +1890,7 @@ type end; // TCefRequestCallback - // /include/capi/cef_request_handler_capi.h (cef_request_callback_t) + // /include/capi/cef_request_callback_capi.h (cef_request_callback_t) ICefRequestCallback = interface(ICefBaseRefCounted) ['{A35B8FD5-226B-41A8-A763-1940787D321C}'] procedure Cont(allow: Boolean); @@ -1604,26 +1911,46 @@ type ['{050877A9-D1F8-4EB3-B58E-50DC3E3D39FD}'] function OnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; function OnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; - function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; - function GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; - procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); - function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; - function GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; - procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); - function GetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; - function CanGetCookies(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): boolean; - function CanSetCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie : PCefCookie): boolean; + procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); + function GetAuthCredentials(const browser: ICefBrowser; const originUrl: ustring; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; function OnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; - procedure OnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); function OnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; function OnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; procedure OnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); procedure OnRenderViewReady(const browser: ICefBrowser); procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); + procedure OnDocumentAvailableInMainFrame(const browser: ICefBrowser); procedure RemoveReferences; // custom procedure to clear all references end; + // TCefResourceRequestHandler + // /include/capi/cef_resource_request_handler_capi.h (cef_resource_request_handler_t) + ICefResourceRequestHandler = interface(ICefBaseRefCounted) + ['{CFA42A38-EA91-4A95-95CE-178BCD412411}'] + procedure GetCookieAccessFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aFilter: ICefCookieAccessFilter); + function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; + procedure GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aResourceHandler : ICefResourceHandler); + procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); + function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; + procedure GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var aResourceFilter: ICefResponseFilter); + procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); + procedure OnProtocolExecution(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var allowOsExecution: Boolean); + + procedure RemoveReferences; // custom procedure to clear all references + end; + + // TCefCookieAccessFilter + // /include/capi/cef_resource_request_handler_capi.h (cef_cookie_access_filter_t) + ICefCookieAccessFilter = interface(ICefBaseRefCounted) + ['{65ECD862-F55F-46E4-8AC3-2AE90DCC86F5}'] + function CanSendCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie: PCefCookie): boolean; + function CanSaveCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; const cookie: PCefCookie): boolean; + + procedure RemoveReferences; // custom procedure to clear all references + end; + + // TCefDisplayHandler // /include/capi/cef_display_handler_capi.h (cef_display_handler_t) ICefDisplayHandler = interface(ICefBaseRefCounted) @@ -1637,6 +1964,7 @@ type function OnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const message_, source: ustring; line: Integer): Boolean; function OnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; procedure OnLoadingProgressChange(const browser: ICefBrowser; const progress: double); + procedure OnCursorChange(const browser: ICefBrowser; cursor_: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; var aResult : boolean); procedure RemoveReferences; // custom procedure to clear all references end; @@ -1674,6 +2002,19 @@ type procedure RemoveReferences; // custom procedure to clear all references end; + // TCefAudioHandler + // /include/capi/cef_audio_handler_capi.h (cef_audio_handler_t) + ICefAudioHandler = interface(ICefBaseRefCounted) + ['{8963271A-0B94-4279-82C8-FB2EA7B3CDEC}'] + procedure OnGetAudioParameters(const browser: ICefBrowser; var params: TCefAudioParameters; var aResult: boolean); + procedure OnAudioStreamStarted(const browser: ICefBrowser; const params: TCefAudioParameters; channels: integer); + procedure OnAudioStreamPacket(const browser: ICefBrowser; const data : PPSingle; frames: integer; pts: int64); + procedure OnAudioStreamStopped(const browser: ICefBrowser); + procedure OnAudioStreamError(const browser: ICefBrowser; const message_: ustring); + + procedure RemoveReferences; // custom procedure to clear all references + end; + // TCefRunContextMenuCallback // /include/capi/cef_context_menu_handler_capi.h (cef_run_context_menu_callback_t) ICefRunContextMenuCallback = interface(ICefBaseRefCounted) @@ -1717,18 +2058,19 @@ type ['{1FC1C22B-085A-4741-9366-5249B88EC410}'] procedure GetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); function GetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; - function GetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; + procedure GetViewRect(const browser: ICefBrowser; var rect: TCefRect); function GetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; function GetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; procedure OnPopupShow(const browser: ICefBrowser; show: Boolean); procedure OnPopupSize(const browser: ICefBrowser; const rect: PCefRect); procedure OnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); - procedure OnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); + procedure OnAcceleratedPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; shared_handle: Pointer); function OnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; procedure OnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); procedure OnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); procedure OnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); procedure OnTextSelectionChanged(const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange); + procedure OnVirtualKeyboardRequested(const browser: ICefBrowser; input_mode: TCefTextInpuMode); procedure RemoveReferences; // custom procedure to clear all references end; @@ -1737,6 +2079,7 @@ type // /include/capi/cef_client_capi.h (cef_client_t) ICefClient = interface(ICefBaseRefCounted) ['{1D502075-2FF0-4E13-A112-9E541CD811F4}'] + procedure GetAudioHandler(var aHandler : ICefAudioHandler); procedure GetContextMenuHandler(var aHandler : ICefContextMenuHandler); procedure GetDialogHandler(var aHandler : ICefDialogHandler); procedure GetDisplayHandler(var aHandler : ICefDisplayHandler); @@ -1750,7 +2093,7 @@ type procedure GetLoadHandler(var aHandler : ICefLoadHandler); procedure GetRenderHandler(var aHandler : ICefRenderHandler); procedure GetRequestHandler(var aHandler : ICefRequestHandler); - function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; + function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const message_ : ICefProcessMessage): Boolean; procedure RemoveReferences; // custom procedure to clear all references end; @@ -1782,6 +2125,8 @@ type procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); function OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; + + procedure RemoveReferences; // custom procedure to clear all references end; // TCefWebPluginInfoVisitor @@ -1856,7 +2201,7 @@ type ICefDragHandler = interface(ICefBaseRefCounted) ['{59A89579-5B18-489F-A25C-5CC25FF831FC}'] function OnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; - procedure OnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); + procedure OnDraggableRegionsChanged(const browser: ICefBrowser; const frame: ICefFrame; regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); procedure RemoveReferences; // custom procedure to clear all references end; @@ -1875,8 +2220,10 @@ type ICefRequestContextHandler = interface(ICefBaseRefCounted) ['{76EB1FA7-78DF-4FD5-ABB3-1CDD3E73A140}'] procedure OnRequestContextInitialized(const request_context: ICefRequestContext); - function GetCookieManager: ICefCookieManager; - function OnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean; + function OnBeforePluginLoad(const mimeType, pluginUrl:ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; + procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); + + procedure RemoveReferences; // custom procedure to clear all references end; // TCefResolveCallback @@ -1895,8 +2242,8 @@ type function IsGlobal: Boolean; function GetHandler: ICefRequestContextHandler; function GetCachePath: ustring; - function GetDefaultCookieManager(const callback: ICefCompletionCallback): ICefCookieManager; - function GetDefaultCookieManagerProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; + function GetCookieManager(const callback: ICefCompletionCallback): ICefCookieManager; + function GetCookieManagerProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; function RegisterSchemeHandlerFactory(const schemeName, domainName: ustring; const factory: ICefSchemeHandlerFactory): Boolean; function ClearSchemeHandlerFactories: Boolean; procedure PurgePluginListCache(reloadPages: Boolean); @@ -1906,17 +2253,19 @@ type function CanSetPreference(const name: ustring): Boolean; function SetPreference(const name: ustring; const value: ICefValue; out error: ustring): Boolean; procedure ClearCertificateExceptions(const callback: ICefCompletionCallback); + procedure ClearHttpAuthCredentials(const callback: ICefCompletionCallback); procedure CloseAllConnections(const callback: ICefCompletionCallback); procedure ResolveHost(const origin: ustring; const callback: ICefResolveCallback); - function ResolveHostCached(const origin: ustring; const resolvedIps: TStrings): TCefErrorCode; procedure LoadExtension(const root_directory: ustring; const manifest: ICefDictionaryValue; const handler: ICefExtensionHandler); function DidLoadExtension(const extension_id: ustring): boolean; function HasExtension(const extension_id: ustring): boolean; function GetExtensions(const extension_ids: TStringList): boolean; function GetExtension(const extension_id: ustring): ICefExtension; + function GetMediaRouter: ICefMediaRouter; - property CachePath : ustring read GetCachePath; - property IsGlobalContext : boolean read IsGlobal; + property CachePath : ustring read GetCachePath; + property IsGlobalContext : boolean read IsGlobal; + property MediaRouter : ICefMediaRouter read GetMediaRouter; end; // TCefPrintSettings @@ -1925,7 +2274,6 @@ type ['{ACBD2395-E9C1-49E5-B7F3-344DAA4A0F12}'] function IsValid: Boolean; function IsReadOnly: Boolean; - function Copy: ICefPrintSettings; procedure SetOrientation(landscape: Boolean); function IsLandscape: Boolean; procedure SetPrinterPrintableArea(const physicalSizeDeviceUnits: PCefSize; const printableAreaDeviceUnits: PCefRect; landscapeNeedsFlip: Boolean); @@ -1978,10 +2326,12 @@ type ['{2831D5C9-6E2B-4A30-A65A-0F4435371EFC}'] procedure OnPrintStart(const browser: ICefBrowser); procedure OnPrintSettings(const browser: ICefBrowser; const settings: ICefPrintSettings; getDefaults: boolean); - function OnPrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback): boolean; - function OnPrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback): boolean; + procedure OnPrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult: boolean); + procedure OnPrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult: boolean); procedure OnPrintReset(const browser: ICefBrowser); - function GetPDFPaperSize(deviceUnitsPerInch: Integer): TCefSize; + procedure GetPDFPaperSize(deviceUnitsPerInch: integer; var aResult: TCefSize); + + procedure RemoveReferences; // custom procedure to clear all references end; // TCefNavigationEntry @@ -2071,8 +2421,8 @@ type ICefResourceBundle = interface(ICefBaseRefCounted) ['{3213CF97-C854-452B-B615-39192F8D07DC}'] function GetLocalizedString(stringId: Integer): ustring; - function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean; - function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean; + function GetDataResource(resourceId: Integer): ICefBinaryValue; + function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor): ICefBinaryValue; end; // TCefImage @@ -2088,10 +2438,10 @@ type function GetHeight: NativeUInt; function HasRepresentation(scaleFactor: Single): Boolean; function RemoveRepresentation(scaleFactor: Single): Boolean; - function GetRepresentationInfo(scaleFactor: Single; actualScaleFactor: PSingle; pixelWidth, pixelHeight: PInteger): Boolean; - function GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; alphaType: TCefAlphaType; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; - function GetAsPng(scaleFactor: Single; withTransparency: Boolean; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; - function GetAsJpeg(scaleFactor: Single; quality: Integer; pixelWidth, pixelHeight: PInteger): ICefBinaryValue; + function GetRepresentationInfo(scaleFactor: Single; var actualScaleFactor: Single; var pixelWidth, pixelHeight: Integer): Boolean; + function GetAsBitmap(scaleFactor: Single; colorType: TCefColorType; alphaType: TCefAlphaType; var pixelWidth, pixelHeight: Integer): ICefBinaryValue; + function GetAsPng(scaleFactor: Single; withTransparency: Boolean; var pixelWidth, pixelHeight: Integer): ICefBinaryValue; + function GetAsJpeg(scaleFactor: Single; quality: Integer; var pixelWidth, pixelHeight: Integer): ICefBinaryValue; property Width : NativeUInt read GetWidth; property Height : NativeUInt read GetHeight; @@ -2107,7 +2457,7 @@ type procedure UnhandledCloseSubmenu(const menuModel: ICefMenuModel; isRTL: boolean); procedure MenuWillShow(const menuModel: ICefMenuModel); procedure MenuClosed(const menuModel: ICefMenuModel); - function FormatLabel(const menuModel: ICefMenuModel; const label_ : ustring) : boolean; + function FormatLabel(const menuModel: ICefMenuModel; var label_ : ustring) : boolean; end; // TCefServer @@ -2144,6 +2494,8 @@ type end; + + // ********************************* // ************* Views ************* // ********************************* @@ -2160,6 +2512,12 @@ type function GetBounds : TCefRect; function GetWorkArea : TCefRect; function GetRotation : Integer; + + property ID : int64 read GetID; + property DeviceScaleFactor : Single read GetDeviceScaleFactor; + property Bounds : TCefRect read GetBounds; + property WorkArea : TCefRect read GetWorkArea; + property Rotation : Integer read GetRotation; end; // TCefLayout @@ -2169,6 +2527,8 @@ type function AsBoxLayout : ICefBoxLayout; function AsFillLayout : ICefFillLayout; function IsValid : boolean; + + property Valid : boolean read IsValid; end; // TCefBoxLayout @@ -2195,24 +2555,24 @@ type function AsScrollView : ICefScrollView; function AsTextfield : ICefTextfield; function GetTypeString : ustring; - function ToString(include_children: boolean): ustring; + function ToStringEx(include_children: boolean): ustring; function IsValid : boolean; function IsAttached : boolean; function IsSame(const that: ICefView): boolean; function GetDelegate : ICefViewDelegate; function GetWindow : ICefWindow; function GetID : Integer; - procedure SetID(id: Integer); + procedure SetID(id_: Integer); function GetGroupID : Integer; procedure SetGroupID(group_id: Integer); function GetParentView : ICefView; - function GetViewForID(id: Integer): ICefView; - procedure SetBounds(const bounds: PCefRect); + function GetViewForID(id_: Integer): ICefView; + procedure SetBounds(const bounds_: TCefRect); function GetBounds : TCefRect; function GetBoundsInScreen : TCefRect; - procedure SetSize(const size: PCefSize); + procedure SetSize(const size_: TCefSize); function GetSize : TCefSize; - procedure SetPosition(const position: PCefPoint); + procedure SetPosition(const position_: TCefPoint); function GetPosition : TCefPoint; function GetPreferredSize : TCefSize; procedure SizeToPreferredSize; @@ -2220,39 +2580,77 @@ type function GetMaximumSize : TCefSize; function GetHeightForWidth(width: Integer): Integer; procedure InvalidateLayout; - procedure SetVisible(visible: boolean); + procedure SetVisible(visible_: boolean); function IsVisible : boolean; function IsDrawn : boolean; - procedure SetEnabled(enabled: boolean); + procedure SetEnabled(enabled_: boolean); function IsEnabled : boolean; - procedure SetFocusable(focusable: boolean); + procedure SetFocusable(focusable_: boolean); function IsFocusable : boolean; function IsAccessibilityFocusable : boolean; procedure RequestFocus; procedure SetBackgroundColor(color: TCefColor); function GetBackgroundColor : TCefColor; - function ConvertPointToScreen(point: PCefPoint): boolean; - function ConvertPointFromScreen(point: PCefPoint): boolean; - function ConvertPointToWindow(point: PCefPoint): boolean; - function ConvertPointFromWindow(point: PCefPoint): boolean; - function ConvertPointToView(const view : ICefView; point: PCefPoint): boolean; - function ConvertPointFromView(const view : ICefView; point: PCefPoint): boolean; + function ConvertPointToScreen(var point: TCefPoint): boolean; + function ConvertPointFromScreen(var point: TCefPoint): boolean; + function ConvertPointToWindow(var point: TCefPoint): boolean; + function ConvertPointFromWindow(var point: TCefPoint): boolean; + function ConvertPointToView(const view : ICefView; var point: TCefPoint): boolean; + function ConvertPointFromView(const view : ICefView; var point: TCefPoint): boolean; + + property Valid : boolean read IsValid; + property Attached : boolean read IsAttached; + property Delegate : ICefViewDelegate read GetDelegate; + property Window : ICefWindow read GetWindow; + property ParentView : ICefView read GetParentView; + property BoundsInScreen : TCefRect read GetBoundsInScreen; + property PreferredSize : TCefSize read GetPreferredSize; + property MinimumSize : TCefSize read GetMinimumSize; + property MaximumSize : TCefSize read GetMaximumSize; + property Visible : boolean read IsVisible write SetVisible; + property Drawn : boolean read IsDrawn; + property Enabled : boolean read IsEnabled write SetEnabled; + property Focusable : boolean read IsFocusable write SetFocusable; + property AccessibilityFocusable : boolean read IsAccessibilityFocusable; + property BackgroundColor : TCefColor read GetBackgroundColor write SetBackgroundColor; + property ID : integer read GetID write SetID; + property GroupID : integer read GetGroupID write SetGroupID; + property Bounds : TCefRect read GetBounds write SetBounds; + property Size : TCefSize read GetSize write SetSize; + property Position : TCefPoint read GetPosition write SetPosition; + property TypeString : ustring read GetTypeString; end; // TCefViewDelegate // /include/capi/views/cef_view_delegate_capi.h (cef_view_delegate_t) ICefViewDelegate = interface(ICefBaseRefCounted) ['{5F900206-B969-4E51-B56C-0FF38D749C72}'] - function GetPreferredSize(const view: ICefView): TCefSize; - function GetMinimumSize(const view: ICefView): TCefSize; - function GetMaximumSize(const view: ICefView): TCefSize; - function GetHeightForWidth(const view: ICefView; width: Integer): Integer; + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); procedure OnFocus(const view: ICefView); procedure OnBlur(const view: ICefView); end; + ICefViewDelegateEvents = interface + ['{74DDDB37-8F08-4672-BDB6-55CA2CD374ED}'] + // ICefViewDelegate + procedure doOnGetPreferredSize(const view: ICefView; var aResult : TCefSize); + procedure doOnGetMinimumSize(const view: ICefView; var aResult : TCefSize); + procedure doOnGetMaximumSize(const view: ICefView; var aResult : TCefSize); + procedure doOnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); + procedure doOnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); + procedure doOnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); + procedure doOnFocus(const view: ICefView); + procedure doOnBlur(const view: ICefView); + + // Custom + procedure doCreateCustomView; + end; + // TCefTextfield // /include/capi/views/cef_textfield_capi.h (cef_textfield_t) ICefTextfield = interface(ICefView) @@ -2262,15 +2660,15 @@ type procedure SetReadOnly(read_only: boolean); function IsReadOnly : boolean; function GetText : ustring; - procedure SetText(const text: ustring); - procedure AppendText(const text: ustring); - procedure InsertOrReplaceText(const text: ustring); + procedure SetText(const text_: ustring); + procedure AppendText(const text_: ustring); + procedure InsertOrReplaceText(const text_: ustring); function HasSelection : boolean; function GetSelectedText : ustring; procedure SelectAll(reversed: boolean); procedure ClearSelection; function GetSelectedRange : TCefRange; - procedure SelectRange(const range: PCefRange); + procedure SelectRange(const range: TCefRange); function GetCursorPosition : NativeUInt; procedure SetTextColor(color: TCefColor); function GetTextColor : TCefColor; @@ -2279,25 +2677,40 @@ type procedure SetSelectionBackgroundColor(color: TCefColor); function GetSelectionBackgroundColor : TCefColor; procedure SetFontList(const font_list: ustring); - procedure ApplyTextColor(color: TCefColor; const range: PCefRange); - procedure ApplyTextStyle(style: TCefTextStyle; add: boolean; const range: PCefRange); - function IsCommandEnabled(command_id: Integer): boolean; - procedure ExecuteCommand(command_id: Integer); + procedure ApplyTextColor(color: TCefColor; const range: TCefRange); + procedure ApplyTextStyle(style: TCefTextStyle; add: boolean; const range: TCefRange); + function IsCommandEnabled(command_id: TCefTextFieldCommands): boolean; + procedure ExecuteCommand(command_id: TCefTextFieldCommands); procedure ClearEditHistory; - procedure SetPlaceholderText(const text: ustring); - function GgetPlaceholderText : ustring; + procedure SetPlaceholderText(const text_: ustring); + function GetPlaceholderText : ustring; procedure SetPlaceholderTextColor(color: TCefColor); procedure SetAccessibleName(const name: ustring); + + property PasswordInput : boolean read IsPasswordInput write SetPasswordInput; + property ReadOnly : boolean read IsReadOnly write SetReadOnly; + property Text : ustring read GetText write SetText; + property SelectedText : ustring read GetSelectedText; + property TextColor : TCefColor read GetTextColor write SetTextColor; + property SelectionTextColor : TCefColor read GetSelectionTextColor write SetSelectionTextColor; + property SelectionBackgroundColor : TCefColor read GetSelectionBackgroundColor write SetSelectionBackgroundColor; + property PlaceholderText : ustring read GetPlaceholderText write SetPlaceholderText; end; // TCefTextfieldDelegate // /include/capi/views/cef_textfield_delegate_capi.h (cef_textfield_delegate_t) ICefTextfieldDelegate = interface(ICefViewDelegate) ['{72612994-92BB-4DE9-BB38-6F49FB45F94B}'] - function OnKeyEvent(const textfield: ICefTextfield; const event: PCefKeyEvent): boolean; + procedure OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); procedure OnAfterUserAction(const textfield: ICefTextfield); end; + ICefTextfieldDelegateEvents = interface(ICefViewDelegateEvents) + ['{682480E0-C786-4E65-B950-4FF2B13B97B9}'] + procedure doOnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); + procedure doOnAfterUserAction(const textfield: ICefTextfield); + end; + // TCefScrollView // /include/capi/views/cef_scroll_view_capi.h (cef_scroll_view_t) ICefScrollView = interface(ICefView) @@ -2309,15 +2722,20 @@ type function GetHorizontalScrollbarHeight : Integer; function HasVerticalScrollbar : boolean; function GetVerticalScrollbarWidth : Integer; + + property ContentView : ICefView read GetContentView write SetContentView; + property VisibleContentRect : TCefRect read GetVisibleContentRect; + property HorizontalScrollbarHeight : Integer read GetHorizontalScrollbarHeight; + property VerticalScrollbarWidth : Integer read GetVerticalScrollbarWidth; end; // TCefPanel // /include/capi/views/cef_panel_capi.h (cef_panel_t) ICefPanel = interface(ICefView) ['{6F2F680A-3637-4438-81B8-79AD6C02252D}'] - function AsWindow : ICefWindow; + function GetAsWindow : ICefWindow; function SetToFillLayout : ICefFillLayout; - function SetToBoxLayout(const settings: PCefBoxLayoutSettings): ICefBoxLayout; + function SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout; function GetLayout : ICefLayout; procedure Layout; procedure AddChildView(const view: ICefView); @@ -2327,6 +2745,8 @@ type procedure RemoveAllChildViews; function GetChildViewCount : NativeUInt; function GetChildViewAt(index: Integer): ICefView; + + property AsWindow : ICefWindow read GetAsWindow; end; // TCefPanelDelegate @@ -2335,6 +2755,10 @@ type ['{305D453F-FEBA-48ED-AE33-5D978823EA96}'] end; + ICefPanelDelegateEvents = interface(ICefViewDelegateEvents) + ['{F1F2963F-82C3-48F0-9B9C-7C213BACB96B}'] + end; + // TCefBrowserView // /include/capi/views/cef_browser_view_capi.h (cef_browser_view_t) ICefBrowserView = interface(ICefView) @@ -2349,8 +2773,16 @@ type ['{578A0DD4-2E7D-4061-B4DB-7C3CDC7A90C0}'] procedure OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); procedure OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); - function GetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: PCefBrowserSettings; const client: ICefClient; is_devtools: boolean): ICefBrowserViewDelegate; - function OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean): boolean; + procedure OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); + procedure OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); + end; + + ICefBrowserViewDelegateEvents = interface(ICefViewDelegateEvents) + ['{AB94B875-63C6-4FEF-BB30-0816402ABA1C}'] + procedure doOnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); + procedure doOnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); + procedure doOnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); + procedure doOnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); end; // TCefButton @@ -2358,11 +2790,13 @@ type ICefButton = interface(ICefView) ['{D3D2E8A0-9F9C-4BD8-B495-655976534281}'] function AsLabelButton : ICefLabelButton; - procedure SetState(state: TCefButtonState); + procedure SetState(state_: TCefButtonState); function GetState : TCefButtonState; - procedure SetInkDropEnabled(enabled: boolean); + procedure SetInkDropEnabled(enabled_: boolean); procedure SetTooltipText(const tooltip_text: ustring); procedure SetAccessibleName(const name: ustring); + + property State : TCefButtonState read GetState write SetState; end; // TCefButtonDelegate @@ -2373,12 +2807,18 @@ type procedure OnButtonStateChanged(const button: ICefButton); end; + ICefButtonDelegateEvents = interface(ICefViewDelegateEvents) + ['{E8DF70BE-5DEB-42CF-AF86-B0FF1040498E}'] + procedure doOnButtonPressed(const button: ICefButton); + procedure doOnButtonStateChanged(const button: ICefButton); + end; + // TCefLabelButton // /include/capi/views/cef_label_button_capi.h (cef_label_button_t) ICefLabelButton = interface(ICefButton) ['{A99FD4F3-7EE6-4796-8BF6-EC367D51EED8}'] - function GetState : ICefMenuButton; - procedure SetText(const text: ustring); + function AsMenuButton : ICefMenuButton; + procedure SetText(const text_: ustring); function GetText : ustring; procedure SetImage(button_state: TCefButtonState; const image: ICefImage); function GetImage(button_state: TCefButtonState): ICefImage; @@ -2386,15 +2826,17 @@ type procedure SetEnabledTextColors(color: TCefColor); procedure SetFontList(const font_list: ustring); procedure SetHorizontalAlignment(alignment: TCefHorizontalAlignment); - procedure SetMinimumSize(const size: PCefSize); - procedure SetMaximumSize(const size: PCefSize); + procedure SetMinimumSize(const size_: TCefSize); + procedure SetMaximumSize(const size_: TCefSize); + + property Text : ustring read GetText write SetText; end; // TCefMenuButton // /include/capi/views/cef_menu_button_capi.h (cef_menu_button_t) ICefMenuButton = interface(ICefLabelButton) ['{62BFE81A-7810-400B-83C6-76D1DF133710}'] - procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: PCefPoint; anchor_position: TCefMenuAnchorPosition); + procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position: TCefMenuAnchorPosition); procedure TriggerMenu; end; @@ -2408,7 +2850,12 @@ type // /include/capi/views/cef_menu_button_delegate_capi.h (cef_menu_button_delegate_t) ICefMenuButtonDelegate = interface(ICefButtonDelegate) ['{D0E89A75-463A-4766-8701-BD8D24B11E9F}'] - procedure OnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: PCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock); + procedure OnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock); + end; + + ICefMenuButtonDelegateEvents = interface(ICefButtonDelegateEvents) + ['{DA36DD60-7609-4576-BB8E-6A55FD48C680}'] + procedure doOnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock); end; // TCefWindow @@ -2417,11 +2864,11 @@ type ['{C450C974-BF0A-4968-A6BE-153CEAD10DA6}'] procedure Show; procedure Hide; - procedure CenterWindow(const size: PCefSize); + procedure CenterWindow(const size_: TCefSize); procedure Close; function IsClosed : boolean; procedure Activate; - procedure deactivate; + procedure Deactivate; function IsActive : boolean; procedure BringToTop; procedure SetAlwaysOnTop(on_top: boolean); @@ -2433,24 +2880,31 @@ type function IsMaximized : boolean; function IsMinimized : boolean; function IsFullscreen : boolean; - procedure SetTitle(const title: ustring); + procedure SetTitle(const title_: ustring); function GetTitle : ustring; procedure SetWindowIcon(const image: ICefImage); function GetWindowIcon : ICefImage; procedure SetWindowAppIcon(const image: ICefImage); function GetWindowAppIcon : ICefImage; - procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: PCefPoint; anchor_position : TCefMenuAnchorPosition); + procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position : TCefMenuAnchorPosition); procedure CancelMenu; function GetDisplay : ICefDisplay; function GetClientAreaBoundsInScreen : TCefRect; - procedure SetDraggableRegions(regionsCount: NativeUInt; regions: PCefDraggableRegionArray); + procedure SetDraggableRegions(regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); function GetWindowHandle : TCefWindowHandle; procedure SendKeyPress(key_code: Integer; event_flags: cardinal); procedure SendMouseMove(screen_x, screen_y: Integer); - procedure SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: Integer); + procedure SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: boolean); procedure SetAccelerator(command_id, key_code : Integer; shift_pressed, ctrl_pressed, alt_pressed: boolean); procedure RemoveAccelerator(command_id: Integer); procedure RemoveAllAccelerators; + + property Title : ustring read GetTitle write SetTitle; + property WindowIcon : ICefImage read GetWindowIcon write SetWindowIcon; + property WindowAppIcon : ICefImage read GetWindowAppIcon write SetWindowAppIcon; + property Display : ICefDisplay read GetDisplay; + property ClientAreaBoundsInScreen : TCefRect read GetClientAreaBoundsInScreen; + property WindowHandle : TCefWindowHandle read GetWindowHandle; end; // TCefWindowDelegate @@ -2459,14 +2913,30 @@ type ['{52D4EE2C-303B-42B6-A35F-30D03834A23F}'] procedure OnWindowCreated(const window: ICefWindow); procedure OnWindowDestroyed(const window: ICefWindow); - function GetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean): ICefWindow; - function IsFrameless(const window: ICefWindow): boolean; - function CanResize(const window: ICefWindow): boolean; - function CanMaximize(const window: ICefWindow): boolean; - function CanMinimize(const window: ICefWindow): boolean; - function CanClose(const window: ICefWindow): boolean; - function OnAccelerator(const window: ICefWindow; command_id: Integer): boolean; - function OnKeyEvent(const window: ICefWindow; const event: PCefKeyEvent): boolean; + procedure OnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); + procedure OnGetInitialBounds(const window: ICefWindow; var aResult : TCefRect); + procedure OnIsFrameless(const window: ICefWindow; var aResult : boolean); + procedure OnCanResize(const window: ICefWindow; var aResult : boolean); + procedure OnCanMaximize(const window: ICefWindow; var aResult : boolean); + procedure OnCanMinimize(const window: ICefWindow; var aResult : boolean); + procedure OnCanClose(const window: ICefWindow; var aResult : boolean); + procedure OnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean); + procedure OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); + end; + + ICefWindowDelegateEvents = interface(ICefPanelDelegateEvents) + ['{05C19A41-E75D-459E-AD4D-C8A0CA4A49D3}'] + procedure doOnWindowCreated(const window: ICefWindow); + procedure doOnWindowDestroyed(const window: ICefWindow); + procedure doOnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); + procedure doOnGetInitialBounds(const window: ICefWindow; var aResult : TCefRect); + procedure doOnIsFrameless(const window: ICefWindow; var aResult : boolean); + procedure doOnCanResize(const window: ICefWindow; var aResult : boolean); + procedure doOnCanMaximize(const window: ICefWindow; var aResult : boolean); + procedure doOnCanMinimize(const window: ICefWindow; var aResult : boolean); + procedure doOnCanClose(const window: ICefWindow; var aResult : boolean); + procedure doOnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean); + procedure doOnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); end; implementation diff --git a/windows/src/ext/cef4delphi/source/uCEFJsDialogCallback.pas b/windows/src/ext/cef4delphi/source/uCEFJsDialogCallback.pas index 3b2fbb5c08723ee0f59d03e6ab013cbcb75b4063..76bbce2f554bd059790183109cd8676834437f4a 100644 --- a/windows/src/ext/cef4delphi/source/uCEFJsDialogCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFJsDialogCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFJsDialogCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFJsDialogHandler.pas b/windows/src/ext/cef4delphi/source/uCEFJsDialogHandler.pas index 2a8d24967414e4cab039836e3bf9b9e926e279ef..45d30a43e333b7cb7a9c14f3448781c19314adf1 100644 --- a/windows/src/ext/cef4delphi/source/uCEFJsDialogHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFJsDialogHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFJsDialogHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -79,7 +77,7 @@ type procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -211,11 +209,11 @@ end; // TCustomJsDialogHandler -constructor TCustomJsDialogHandler.Create(const events: Pointer); +constructor TCustomJsDialogHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomJsDialogHandler.Destroy; diff --git a/windows/src/ext/cef4delphi/source/uCEFJson.pas b/windows/src/ext/cef4delphi/source/uCEFJson.pas new file mode 100644 index 0000000000000000000000000000000000000000..69c725f2aee9994f71faa6372169fb1188041b81 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFJson.pas @@ -0,0 +1,383 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFJson; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFInterfaces, uCEFTypes, uCEFConstants; + +type + TCEFJson = class + public + class function ReadValue(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ICefValue) : boolean; + class function ReadBoolean(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : boolean) : boolean; + class function ReadInteger(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : integer) : boolean; + class function ReadDouble(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : double) : boolean; + class function ReadString(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ustring) : boolean; + class function ReadBinary(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ICefBinaryValue) : boolean; + class function ReadDictionary(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ICefDictionaryValue) : boolean; + class function ReadList(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ICefListValue) : boolean; + + class function Parse(const jsonString: ustring; options: TCefJsonParserOptions = JSON_PARSER_RFC): ICefValue; overload; + class function Parse(const json: Pointer; json_size: NativeUInt; options: TCefJsonParserOptions = JSON_PARSER_RFC): ICefValue; overload; + class function ParseAndReturnError(const jsonString: ustring; options: TCefJsonParserOptions; out errorMsgOut: ustring): ICefValue; + class function Write(const node: ICefValue; options: TCefJsonWriterOptions = JSON_WRITER_DEFAULT): ustring; overload; + class function Write(const node: ICefDictionaryValue; options: TCefJsonWriterOptions = JSON_WRITER_DEFAULT): ustring; overload; + class function Write(const node: ICefValue; var aRsltStrings: TStringList): boolean; overload; + class function Write(const node: ICefDictionaryValue; var aRsltStrings: TStringList): boolean; overload; + class function SaveToFile(const node: ICefValue; const aFileName: ustring): boolean; overload; + class function SaveToFile(const node: ICefDictionaryValue; const aFileName: ustring): boolean; overload; + class function LoadFromFile(const aFileName: ustring; var aRsltNode: ICefValue; {$IFDEF DELPHI12_UP}encoding: TEncoding = nil;{$ENDIF} options: TCefJsonParserOptions = JSON_PARSER_RFC): boolean; + end; + +implementation + +uses + uCEFLibFunctions, uCEFApplicationCore, uCEFMiscFunctions, uCEFValue; + +class function TCEFJson.ReadValue(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ICefValue) : boolean; +begin + Result := False; + aValue := nil; + + if (aDictionary <> nil) then + begin + aValue := aDictionary.GetValue(aKey); + Result := (aValue <> nil); + end; +end; + +class function TCEFJson.ReadBoolean(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : boolean) : boolean; +var + TempValue : ICefValue; +begin + Result := False; + aValue := False; + + if ReadValue(aDictionary, aKey, TempValue) and + (TempValue.GetType = VTYPE_BOOL) then + begin + aValue := TempValue.GetBool; + Result := True; + end; +end; + +class function TCEFJson.ReadInteger(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : integer) : boolean; +var + TempValue : ICefValue; +begin + Result := False; + aValue := 0; + + if ReadValue(aDictionary, aKey, TempValue) and + (TempValue.GetType = VTYPE_INT) then + begin + aValue := TempValue.GetInt; + Result := True; + end; +end; + +class function TCEFJson.ReadDouble(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : double) : boolean; +var + TempValue : ICefValue; +begin + Result := False; + aValue := 0; + + if ReadValue(aDictionary, aKey, TempValue) and + (TempValue.GetType = VTYPE_DOUBLE) then + begin + aValue := TempValue.GetDouble; + Result := True; + end; +end; + +class function TCEFJson.ReadString(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ustring) : boolean; +var + TempValue : ICefValue; +begin + Result := False; + aValue := ''; + + if ReadValue(aDictionary, aKey, TempValue) and + (TempValue.GetType = VTYPE_STRING) then + begin + aValue := TempValue.GetString; + Result := True; + end; +end; + +class function TCEFJson.ReadBinary(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ICefBinaryValue) : boolean; +var + TempValue : ICefValue; +begin + Result := False; + aValue := nil; + + if ReadValue(aDictionary, aKey, TempValue) and + (TempValue.GetType = VTYPE_BINARY) then + begin + aValue := TempValue.GetBinary; + Result := True; + end; +end; + +class function TCEFJson.ReadDictionary(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ICefDictionaryValue) : boolean; +var + TempValue : ICefValue; +begin + Result := False; + aValue := nil; + + if ReadValue(aDictionary, aKey, TempValue) and + (TempValue.GetType = VTYPE_DICTIONARY) then + begin + aValue := TempValue.GetDictionary; + Result := True; + end; +end; + +class function TCEFJson.ReadList(const aDictionary : ICefDictionaryValue; const aKey : string; var aValue : ICefListValue) : boolean; +var + TempValue : ICefValue; +begin + Result := False; + aValue := nil; + + if ReadValue(aDictionary, aKey, TempValue) and + (TempValue.GetType = VTYPE_LIST) then + begin + aValue := TempValue.GetList; + Result := True; + end; +end; + +class function TCEFJson.Parse(const jsonString: ustring; options: TCefJsonParserOptions): ICefValue; +var + TempJSON : TCefString; +begin + if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then + begin + TempJSON := CefString(jsonString); + Result := TCefValueRef.UnWrap(cef_parse_json(@TempJSON, options)); + end + else + Result := nil; +end; + +// json must be a pointer to a UTF8 string +class function TCEFJson.Parse(const json: Pointer; json_size: NativeUInt; options: TCefJsonParserOptions): ICefValue; +begin + if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded and (json <> nil) and (json_size > 0) then + Result := TCefValueRef.UnWrap(cef_parse_json_buffer(json, json_size, options)) + else + Result := nil; +end; + +class function TCEFJson.ParseAndReturnError(const jsonString : ustring; + options : TCefJsonParserOptions; + out errorMsgOut : ustring): ICefValue; +var + TempJSON, TempError : TCefString; +begin + if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then + begin + CefStringInitialize(@TempError); + TempJSON := CefString(jsonString); + Result := TCefValueRef.UnWrap(cef_parse_jsonand_return_error(@TempJSON, options, @TempError)); + errorMsgOut := CefStringClearAndGet(@TempError); + end + else + begin + Result := nil; + errorMsgOut := ''; + end; +end; + +class function TCEFJson.Write(const node: ICefValue; options: TCefJsonWriterOptions): ustring; +begin + if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded and (node <> nil) then + Result := CefStringFreeAndGet(cef_write_json(CefGetData(node), options)) + else + Result := ''; +end; + +class function TCEFJson.Write(const node: ICefDictionaryValue; options: TCefJsonWriterOptions): ustring; +var + TempValue : ICefValue; +begin + Result := ''; + + if (node = nil) then exit; + + try + TempValue := TCefValueRef.New; + TempValue.SetDictionary(node); + Result := Write(TempValue, options); + finally + TempValue := nil; + end; +end; + +class function TCEFJson.Write(const node: ICefValue; var aRsltStrings: TStringList): boolean; +var + TempJSON : ustring; +begin + Result := False; + + if (aRsltStrings <> nil) then + begin + TempJSON := Write(node, JSON_WRITER_PRETTY_PRINT); + + if (length(TempJSON) > 0) then + begin + aRsltStrings.SetText(@TempJSON[1]); + Result := True; + end; + end; +end; + +class function TCEFJson.Write(const node: ICefDictionaryValue; var aRsltStrings: TStringList): boolean; +var + TempJSON : ustring; +begin + Result := False; + + if (aRsltStrings <> nil) then + begin + TempJSON := Write(node, JSON_WRITER_PRETTY_PRINT); + + if (length(TempJSON) > 0) then + begin + aRsltStrings.SetText(@TempJSON[1]); + Result := True; + end; + end; +end; + +class function TCEFJson.SaveToFile(const node: ICefValue; const aFileName: ustring): boolean; +var + TempJSON : TStringList; +begin + Result := False; + TempJSON := nil; + + try + try + TempJSON := TStringList.Create; + + if Write(node, TempJSON) then + begin + TempJSON.SaveToFile(aFileName); + Result := True; + end; + except + on e : exception do + if CustomExceptionHandler('TCEFJson.SaveToFile', e) then raise; + end; + finally + if (TempJSON <> nil) then FreeAndNil(TempJSON); + end; +end; + +class function TCEFJson.SaveToFile(const node: ICefDictionaryValue; const aFileName: ustring): boolean; +var + TempJSON : TStringList; +begin + Result := False; + TempJSON := nil; + + try + try + TempJSON := TStringList.Create; + + if Write(node, TempJSON) then + begin + TempJSON.SaveToFile(aFileName); + Result := True; + end; + except + on e : exception do + if CustomExceptionHandler('TCEFJson.SaveToFile', e) then raise; + end; + finally + if (TempJSON <> nil) then FreeAndNil(TempJSON); + end; +end; + +class function TCEFJson.LoadFromFile(const aFileName: ustring; var aRsltNode: ICefValue; {$IFDEF DELPHI12_UP}encoding: TEncoding;{$ENDIF} options: TCefJsonParserOptions): boolean; +var + TempJSON : TStringList; +begin + Result := False; + TempJSON := nil; + + try + try + if (length(aFileName) > 0) and FileExists(aFileName) then + begin + TempJSON := TStringList.Create; + TempJSON.LoadFromFile(aFileName{$IFDEF DELPHI12_UP}, encoding{$ENDIF}); + aRsltNode := Parse(TempJSON.Text, options); + Result := True; + end; + except + on e : exception do + if CustomExceptionHandler('TCEFJson.LoadFromFile', e) then raise; + end; + finally + if (TempJSON <> nil) then FreeAndNil(TempJSON); + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFKeyboardHandler.pas b/windows/src/ext/cef4delphi/source/uCEFKeyboardHandler.pas index 69fe339b313df6eebc219aa889b846b80c4623da..77a56812de45628aade8704f8dc34fdb4e68e753 100644 --- a/windows/src/ext/cef4delphi/source/uCEFKeyboardHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFKeyboardHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFKeyboardHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -75,7 +73,7 @@ type procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -155,11 +153,11 @@ end; // TCustomKeyboardHandler -constructor TCustomKeyboardHandler.Create(const events: Pointer); +constructor TCustomKeyboardHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomKeyboardHandler.Destroy; diff --git a/windows/src/ext/cef4delphi/source/uCEFLabelButton.pas b/windows/src/ext/cef4delphi/source/uCEFLabelButton.pas new file mode 100644 index 0000000000000000000000000000000000000000..f6787e8ffd79f7b2df488886e2c533ee8d9e6981 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFLabelButton.pas @@ -0,0 +1,172 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLabelButton; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFButton; + +type + TCefLabelButtonRef = class(TCefButtonRef, ICefLabelButton) + protected + function AsMenuButton : ICefMenuButton; + procedure SetText(const text_: ustring); + function GetText : ustring; + procedure SetImage(button_state: TCefButtonState; const image: ICefImage); + function GetImage(button_state: TCefButtonState): ICefImage; + procedure SetTextColor(for_state: TCefButtonState; color: TCefColor); + procedure SetEnabledTextColors(color: TCefColor); + procedure SetFontList(const font_list: ustring); + procedure SetHorizontalAlignment(alignment: TCefHorizontalAlignment); + procedure SetMinimumSize(const size_: TCefSize); + procedure SetMaximumSize(const size_: TCefSize); + + public + class function UnWrap(data: Pointer): ICefLabelButton; + class function CreateLabelButton(const delegate: ICefButtonDelegate; const text: ustring): ICefLabelButton; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFMenuButton, uCEFImage; + +function TCefLabelButtonRef.AsMenuButton : ICefMenuButton; +begin + Result := TCefMenuButtonRef.UnWrap(PCefLabelButton(FData)^.as_menu_button(PCefLabelButton(FData))); +end; + +procedure TCefLabelButtonRef.SetText(const text_: ustring); +var + TempText : TCefString; +begin + TempText := CefString(text_); + PCefLabelButton(FData)^.set_text(PCefLabelButton(FData), @TempText); +end; + +function TCefLabelButtonRef.GetText : ustring; +begin + Result := CefStringFreeAndGet(PCefLabelButton(FData)^.get_text(PCefLabelButton(FData))); +end; + +procedure TCefLabelButtonRef.SetImage(button_state: TCefButtonState; const image: ICefImage); +begin + PCefLabelButton(FData)^.set_image(PCefLabelButton(FData), button_state, CefGetData(image)); +end; + +function TCefLabelButtonRef.GetImage(button_state: TCefButtonState): ICefImage; +begin + Result := TCefImageRef.UnWrap(PCefLabelButton(FData)^.get_image(PCefLabelButton(FData), button_state)); +end; + +procedure TCefLabelButtonRef.SetTextColor(for_state: TCefButtonState; color: TCefColor); +begin + PCefLabelButton(FData)^.set_text_color(PCefLabelButton(FData), for_state, color); +end; + +procedure TCefLabelButtonRef.SetEnabledTextColors(color: TCefColor); +begin + PCefLabelButton(FData)^.set_enabled_text_colors(PCefLabelButton(FData), color); +end; + +procedure TCefLabelButtonRef.SetFontList(const font_list: ustring); +var + TempFontList : TCefString; +begin + TempFontList := CefString(font_list); + PCefLabelButton(FData)^.set_font_list(PCefLabelButton(FData), @TempFontList); +end; + +procedure TCefLabelButtonRef.SetHorizontalAlignment(alignment: TCefHorizontalAlignment); +begin + PCefLabelButton(FData)^.set_horizontal_alignment(PCefLabelButton(FData), alignment); +end; + +procedure TCefLabelButtonRef.SetMinimumSize(const size_: TCefSize); +begin + PCefLabelButton(FData)^.set_minimum_size(PCefLabelButton(FData), @size_); +end; + +procedure TCefLabelButtonRef.SetMaximumSize(const size_: TCefSize); +begin + PCefLabelButton(FData)^.set_maximum_size(PCefLabelButton(FData), @size_); +end; + +class function TCefLabelButtonRef.UnWrap(data: Pointer): ICefLabelButton; +begin + if (data <> nil) then + Result := Create(data) as ICefLabelButton + else + Result := nil; +end; + +class function TCefLabelButtonRef.CreateLabelButton(const delegate : ICefButtonDelegate; + const text : ustring): ICefLabelButton; +var + TempText : TCefString; + TempButton : PCefLabelButton; +begin + Result := nil; + + if (delegate <> nil) then + begin + TempText := CefString(text); + TempButton := cef_label_button_create(CefGetData(delegate), @TempText); + + if (TempButton <> nil) then + Result := Create(TempButton) as ICefLabelButton; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFLabelButtonComponent.pas b/windows/src/ext/cef4delphi/source/uCEFLabelButtonComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..1294d527a1cc93176d40e141b4fd24f089ba64d0 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFLabelButtonComponent.pas @@ -0,0 +1,267 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLabelButtonComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents, uCEFButtonComponent; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFLabelButtonComponent = class(TCEFButtonComponent) + protected + FLabelButton : ICefLabelButton; + FText : ustring; + + procedure DestroyView; override; + procedure Initialize; override; + + function GetInitialized : boolean; override; + function GetAsView : ICefView; override; + function GetAsButton : ICefButton; override; + function GetAsLabelButton : ICefLabelButton; override; + function GetAsMenuButton : ICefMenuButton; virtual; + function GetText : ustring; + function GetImage(button_state: TCefButtonState): ICefImage; + + procedure SetText(const text_: ustring); + procedure SetImage(button_state: TCefButtonState; const image: ICefImage); + + // ICefViewDelegateEvents + procedure doCreateCustomView; override; + + public + procedure CreateLabelButton(const aText : ustring); + procedure SetTextColor(for_state: TCefButtonState; color: TCefColor); + procedure SetEnabledTextColors(color: TCefColor); + procedure SetFontList(const font_list: ustring); + procedure SetHorizontalAlignment(alignment: TCefHorizontalAlignment); + procedure SetMinimumSize(const size_: TCefSize); + procedure SetMaximumSize(const size_: TCefSize); + + property Text : ustring read GetText write SetText; + property Image[button_state : TCefButtonState] : ICefImage read GetImage write SetImage; + property AsMenuButton : ICefMenuButton read GetAsMenuButton; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + uCEFLabelButton, uCEFMiscFunctions, uCEFButtonDelegate; + +procedure TCEFLabelButtonComponent.CreateLabelButton(const aText : ustring); +begin + FText := aText; + CreateView; +end; + +procedure TCEFLabelButtonComponent.doCreateCustomView; +var + TempDelegate : ICefButtonDelegate; +begin + if (FLabelButton = nil) then + try + TempDelegate := TCustomButtonDelegate.Create(self); + FLabelButton := TCefLabelButtonRef.CreateLabelButton(TempDelegate, FText); + finally + TempDelegate := nil; + end; +end; + +procedure TCEFLabelButtonComponent.DestroyView; +begin + inherited DestroyView; + + FLabelButton := nil; +end; + +procedure TCEFLabelButtonComponent.Initialize; +begin + inherited Initialize; + + FLabelButton := nil; +end; + +function TCEFLabelButtonComponent.GetInitialized : boolean; +begin + Result := (FLabelButton <> nil); +end; + +function TCEFLabelButtonComponent.GetAsView : ICefView; +begin + if Initialized then + Result := FLabelButton as ICefView + else + Result := nil; +end; + +function TCEFLabelButtonComponent.GetAsButton : ICefButton; +begin + if Initialized then + Result := FLabelButton as ICefButton + else + Result := nil; +end; + +function TCEFLabelButtonComponent.GetAsLabelButton : ICefLabelButton; +begin + Result := FLabelButton; +end; + +function TCEFLabelButtonComponent.GetAsMenuButton : ICefMenuButton; +begin + Result := nil; +end; + +procedure TCEFLabelButtonComponent.SetText(const text_: ustring); +begin + FText := text_; + + if Initialized then + AsLabelButton.SetText(FText); +end; + +function TCEFLabelButtonComponent.GetText : ustring; +begin + if Initialized then + FText := AsLabelButton.GetText; + + Result := FText; +end; + +procedure TCEFLabelButtonComponent.SetImage(button_state: TCefButtonState; const image: ICefImage); +begin + if Initialized then AsLabelButton.SetImage(button_state, image); +end; + +function TCEFLabelButtonComponent.GetImage(button_state: TCefButtonState): ICefImage; +begin + if Initialized then + Result := AsLabelButton.GetImage(button_state) + else + Result := nil; +end; + +procedure TCEFLabelButtonComponent.SetTextColor(for_state: TCefButtonState; color: TCefColor); +begin + if Initialized then AsLabelButton.SetTextColor(for_state, color); +end; + +procedure TCEFLabelButtonComponent.SetEnabledTextColors(color: TCefColor); +begin + if Initialized then AsLabelButton.SetEnabledTextColors(color); +end; + +procedure TCEFLabelButtonComponent.SetFontList(const font_list: ustring); +begin + if Initialized then AsLabelButton.SetFontList(font_list); +end; + +procedure TCEFLabelButtonComponent.SetHorizontalAlignment(alignment: TCefHorizontalAlignment); +begin + if Initialized then AsLabelButton.SetHorizontalAlignment(alignment); +end; + +procedure TCEFLabelButtonComponent.SetMinimumSize(const size_: TCefSize); +begin + if Initialized then AsLabelButton.SetMinimumSize(size_); +end; + +procedure TCEFLabelButtonComponent.SetMaximumSize(const size_: TCefSize); +begin + if Initialized then AsLabelButton.SetMaximumSize(size_); +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tceflabelbuttoncomponent.lrs} + RegisterComponents('Chromium Views Framework', [TCEFLabelButtonComponent]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFLayout.pas b/windows/src/ext/cef4delphi/source/uCEFLayout.pas new file mode 100644 index 0000000000000000000000000000000000000000..8b0e23ff78a5f0444a322bda52f0f0c7bb784168 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFLayout.pas @@ -0,0 +1,99 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLayout; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefLayoutRef = class(TCefBaseRefCountedRef, ICefLayout) + protected + function AsBoxLayout : ICefBoxLayout; + function AsFillLayout : ICefFillLayout; + function IsValid : boolean; + + public + class function UnWrap(data: Pointer): ICefLayout; + end; + +implementation + +uses + uCEFLibFunctions, uCEFBoxLayout, uCEFFillLayout; + +function TCefLayoutRef.AsBoxLayout : ICefBoxLayout; +begin + Result := TCefBoxLayoutRef.UnWrap(PCefLayout(FData)^.as_box_layout(PCefLayout(FData))); +end; + +function TCefLayoutRef.AsFillLayout : ICefFillLayout; +begin + Result := TCefFillLayoutRef.UnWrap(PCefLayout(FData)^.as_fill_layout(PCefLayout(FData))); +end; + +function TCefLayoutRef.IsValid : boolean; +begin + Result := (PCefLayout(FData)^.is_valid(PCefLayout(FData)) <> 0); +end; + +class function TCefLayoutRef.UnWrap(data: Pointer): ICefLayout; +begin + if (data <> nil) then + Result := Create(data) as ICefLayout + else + Result := nil; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFLibFunctions.pas b/windows/src/ext/cef4delphi/source/uCEFLibFunctions.pas index 6692383763acab9ecac4b9f945f0b129c3877650..5e3524156c09aebd0d59ae6df6218f87f69c2d74 100644 --- a/windows/src/ext/cef4delphi/source/uCEFLibFunctions.pas +++ b/windows/src/ext/cef4delphi/source/uCEFLibFunctions.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFLibFunctions; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,9 +54,25 @@ uses {$ELSE} {$IFDEF MSWINDOWS}Windows,{$ENDIF} Math, {$ENDIF} + {$IFDEF LINUX} + {$IFDEF FPC}xlib,{$ENDIF} + {$IFDEF FMX}uCEFLinuxTypes,{$ENDIF} + {$ENDIF} uCEFTypes; var + // ********************************* + // *********** API HASH ************ + // ********************************* + + // /include/cef_api_hash.h + cef_api_hash : function(entry: integer): PAnsiChar; cdecl; + + + // ********************************* + // ************* CAPI ************** + // ********************************* + // /include/capi/cef_app_capi.h cef_initialize : function(const args: PCefMainArgs; const settings: PCefSettings; application: PCefApp; windows_sandbox_info: Pointer): Integer; cdecl; cef_shutdown : procedure; cdecl; @@ -70,8 +84,8 @@ var cef_enable_highdpi_support : procedure; cdecl; // /include/capi/cef_browser_capi.h - cef_browser_host_create_browser : function(const windowInfo: PCefWindowInfo; client: PCefClient; const url: PCefString; const settings: PCefBrowserSettings; request_context: PCefRequestContext): Integer; cdecl; - cef_browser_host_create_browser_sync : function(const windowInfo: PCefWindowInfo; client: PCefClient; const url: PCefString; const settings: PCefBrowserSettings; request_context: PCefRequestContext): PCefBrowser; cdecl; + cef_browser_host_create_browser : function(const windowInfo: PCefWindowInfo; client: PCefClient; const url: PCefString; const settings: PCefBrowserSettings; extra_info: PCefDictionaryValue; request_context: PCefRequestContext): Integer; cdecl; + cef_browser_host_create_browser_sync : function(const windowInfo: PCefWindowInfo; client: PCefClient; const url: PCefString; const settings: PCefBrowserSettings; extra_info: PCefDictionaryValue; request_context: PCefRequestContext): PCefBrowser; cdecl; // /include/capi/cef_command_line_capi.h cef_command_line_create : function : PCefCommandLine; cdecl; @@ -79,8 +93,6 @@ var // /include/capi/cef_cookie_capi.h cef_cookie_manager_get_global_manager : function(callback: PCefCompletionCallback): PCefCookieManager; cdecl; - cef_cookie_manager_get_blocking_manager : function : PCefCookieManager; cdecl; - cef_cookie_manager_create_manager : function(const path: PCefString; persist_session_cookies: Integer; callback: PCefCompletionCallback): PCefCookieManager; cdecl; // /include/capi/cef_crash_util.h cef_crash_reporting_enabled : function : integer; cdecl; @@ -102,6 +114,9 @@ var // /include/capi/cef_image_capi.h cef_image_create : function : PCefImage; cdecl; + // /include/capi/cef_media_router_capi.h + cef_media_router_get_global : function : PCefMediaRouter; cdecl; + // /include/capi/cef_menu_model_capi.h cef_menu_model_create : function(delegate: PCefMenuModelDelegate): PCefMenuModel; cdecl; @@ -121,7 +136,8 @@ var cef_uriencode : function(const text: PCefString; use_plus: Integer): PCefStringUserFree; cdecl; cef_uridecode : function(const text: PCefString; convert_to_utf8: Integer; unescape_rule: TCefUriUnescapeRule): PCefStringUserFree; cdecl; cef_parse_json : function(const json_string: PCefString; options: TCefJsonParserOptions): PCefValue; cdecl; - cef_parse_jsonand_return_error : function(const json_string: PCefString; options: TCefJsonParserOptions; error_code_out: PCefJsonParserError; error_msg_out: PCefString): PCefValue; cdecl; + cef_parse_json_buffer : function(const json: Pointer; json_size: NativeUInt; options: TCefJsonParserOptions): PCefValue; cdecl; + cef_parse_jsonand_return_error : function(const json_string: PCefString; options: TCefJsonParserOptions; error_msg_out: PCefString): PCefValue; cdecl; cef_write_json : function(node: PCefValue; options: TCefJsonWriterOptions): PCefStringUserFree; cdecl; // /include/capi/cef_path_util_capi.h @@ -161,7 +177,6 @@ var // /include/capi/cef_ssl_info_capi.h cef_is_cert_status_error : function(status : TCefCertStatus) : integer; cdecl; - cef_is_cert_status_minor_error : function(status : TCefCertStatus) : integer; cdecl; // /include/capi/cef_stream_capi.h cef_stream_reader_create_for_file : function(const fileName: PCefString): PCefStreamReader; cdecl; @@ -230,8 +245,14 @@ var // /include/capi/cef_zip_reader_capi.h cef_zip_reader_create : function(stream: PCefStreamReader): PCefZipReader; cdecl; + + + // ********************************* + // ********** CAPI VIEWS *********** + // ********************************* + // /include/capi/views/cef_browser_view_capi.h - cef_browser_view_create : function(client: PCefClient; const url: PCefString; const settings: PCefBrowserSettings; request_context: PCefRequestContext; delegate: PCefBrowserViewDelegate): PCefBrowserView; cdecl; + cef_browser_view_create : function(client: PCefClient; const url: PCefString; const settings: PCefBrowserSettings; extra_info: PCefDictionaryValue; request_context: PCefRequestContext; delegate: PCefBrowserViewDelegate): PCefBrowserView; cdecl; cef_browser_view_get_for_browser : function(browser: PCefBrowser): PCefBrowserView; cdecl; // /include/capi/views/cef_display_capi.h @@ -239,13 +260,13 @@ var cef_display_get_nearest_point : function(const point: PCefPoint; input_pixel_coords: Integer): PCefDisplay; cdecl; cef_display_get_matching_bounds : function(const bounds: PCefRect; input_pixel_coords: Integer): PCefDisplay; cdecl; cef_display_get_count : function : NativeUInt; cdecl; - cef_display_get_alls : procedure(var displaysCount: NativeUInt; var displays: PCefDisplay); cdecl; + cef_display_get_alls : procedure(displaysCount: PNativeUInt; displays: PPCefDisplay); cdecl; // /include/capi/views/cef_label_button_capi.h - cef_label_button_create : function(delegate: PCefButtonDelegate; const text: PCefString; with_frame: Integer): PCefLabelButton; cdecl; + cef_label_button_create : function(delegate: PCefButtonDelegate; const text: PCefString): PCefLabelButton; cdecl; // /include/capi/views/cef_menu_button_capi.h - cef_menu_button_create : function(delegate: PCefMenuButtonDelegate; const text: PCefString; with_frame, with_menu_marker: Integer): PCefMenuButton; cdecl; + cef_menu_button_create : function(delegate: PCefMenuButtonDelegate; const text: PCefString): PCefMenuButton; cdecl; // /include/capi/views/cef_panel_capi.h cef_panel_create : function(delegate: PCefPanelDelegate): PCefPanel; cdecl; @@ -259,10 +280,16 @@ var // /include/capi/views/cef_window_capi.h cef_window_create_top_level : function(delegate: PCefWindowDelegate): PCefWindow; cdecl; + + + // ********************************* + // *********** INTERNAL ************ + // ********************************* + // /include/internal/cef_logging_internal.h cef_get_min_log_level : function : Integer; cdecl; cef_get_vlog_level : function(const file_start: PAnsiChar; N: NativeInt): Integer; cdecl; - cef_log : procedure(const file_: PAnsiChar; line, severity: Integer; const message: PAnsiChar); cdecl; + cef_log : procedure(const file_: PAnsiChar; line, severity: Integer; const message_: PAnsiChar); cdecl; // /include/internal/cef_string_list.h cef_string_list_alloc : function : TCefStringList; cdecl; @@ -276,9 +303,9 @@ var // /include/internal/cef_string_map.h cef_string_map_alloc : function : TCefStringMap; cdecl; cef_string_map_size : function(map: TCefStringMap): NativeUInt; cdecl; - cef_string_map_find : function(map: TCefStringMap; const key: PCefString; var value: TCefString): Integer; cdecl; - cef_string_map_key : function(map: TCefStringMap; index: NativeUInt; var key: TCefString): Integer; cdecl; - cef_string_map_value : function(map: TCefStringMap; index: NativeUInt; var value: TCefString): Integer; cdecl; + cef_string_map_find : function(map: TCefStringMap; const key: PCefString; value: PCefString): Integer; cdecl; + cef_string_map_key : function(map: TCefStringMap; index: NativeUInt; key: PCefString): Integer; cdecl; + cef_string_map_value : function(map: TCefStringMap; index: NativeUInt; value: PCefString): Integer; cdecl; cef_string_map_append : function(map: TCefStringMap; const key, value: PCefString): Integer; cdecl; cef_string_map_clear : procedure(map: TCefStringMap); cdecl; cef_string_map_free : procedure(map: TCefStringMap); cdecl; @@ -287,9 +314,9 @@ var cef_string_multimap_alloc : function : TCefStringMultimap; cdecl; cef_string_multimap_size : function(map: TCefStringMultimap): NativeUInt; cdecl; cef_string_multimap_find_count : function(map: TCefStringMultimap; const key: PCefString): NativeUInt; cdecl; - cef_string_multimap_enumerate : function(map: TCefStringMultimap; const key: PCefString; value_index: NativeUInt; var value: TCefString): Integer; cdecl; - cef_string_multimap_key : function(map: TCefStringMultimap; index: NativeUInt; var key: TCefString): Integer; cdecl; - cef_string_multimap_value : function(map: TCefStringMultimap; index: NativeUInt; var value: TCefString): Integer; cdecl; + cef_string_multimap_enumerate : function(map: TCefStringMultimap; const key: PCefString; value_index: NativeUInt; value: PCefString): Integer; cdecl; + cef_string_multimap_key : function(map: TCefStringMultimap; index: NativeUInt; key: PCefString): Integer; cdecl; + cef_string_multimap_value : function(map: TCefStringMultimap; index: NativeUInt; value: PCefString): Integer; cdecl; cef_string_multimap_append : function(map: TCefStringMultimap; const key, value: PCefString): Integer; cdecl; cef_string_multimap_clear : procedure(map: TCefStringMultimap); cdecl; cef_string_multimap_free : procedure(map: TCefStringMultimap); cdecl; diff --git a/windows/src/ext/cef4delphi/source/uCEFLifeSpanHandler.pas b/windows/src/ext/cef4delphi/source/uCEFLifeSpanHandler.pas index 441d4c2894d8a3087a167486e144e8ce29cfec64..f1a70459b4564f073b1759201f2a8e99703b5706 100644 --- a/windows/src/ext/cef4delphi/source/uCEFLifeSpanHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFLifeSpanHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFLifeSpanHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,7 +54,7 @@ uses type TCefLifeSpanHandlerOwn = class(TCefBaseRefCountedOwn, ICefLifeSpanHandler) protected - function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean): Boolean; virtual; + function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean): Boolean; virtual; procedure OnAfterCreated(const browser: ICefBrowser); virtual; function DoClose(const browser: ICefBrowser): Boolean; virtual; procedure OnBeforeClose(const browser: ICefBrowser); virtual; @@ -71,7 +69,7 @@ type protected FEvents : Pointer; - function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var noJavascriptAccess: Boolean): Boolean; override; + function OnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean): Boolean; override; procedure OnAfterCreated(const browser: ICefBrowser); override; function DoClose(const browser: ICefBrowser): Boolean; override; procedure OnBeforeClose(const browser: ICefBrowser); override; @@ -79,7 +77,7 @@ type procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -91,7 +89,7 @@ uses {$ELSE} SysUtils, {$ENDIF} - uCEFMiscFunctions, uCEFLibFunctions, uCEFClient, uCEFBrowser, uCEFFrame; + uCEFMiscFunctions, uCEFLibFunctions, uCEFClient, uCEFBrowser, uCEFFrame, uCEFDictionaryValue; function cef_life_span_handler_on_before_popup( self : PCefLifeSpanHandler; browser : PCefBrowser; @@ -104,11 +102,13 @@ function cef_life_span_handler_on_before_popup( self : PCef windowInfo : PCefWindowInfo; var client : PCefClient; settings : PCefBrowserSettings; + var extra_info : PCefDictionaryValue; no_javascript_access : PInteger): Integer; stdcall; var - TempClient : ICefClient; - TempNoJS : Boolean; - TempObject : TObject; + TempClient : ICefClient; + TempExtraInfo : ICefDictionaryValue; + TempNoJS : boolean; + TempObject : TObject; begin try Result := Ord(False); @@ -116,19 +116,22 @@ begin if (TempObject <> nil) and (TempObject is TCefLifeSpanHandlerOwn) then begin - TempNoJS := (no_javascript_access^ <> 0); - TempClient := TCefClientRef.UnWrap(client); - Result := Ord(TCefLifeSpanHandlerOwn(TempObject).OnBeforePopup(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), - CefString(target_url), - CefString(target_frame_name), - target_disposition, - user_gesture <> 0, - popupFeatures^, - windowInfo^, - TempClient, - settings^, - TempNoJS)); + TempNoJS := (no_javascript_access^ <> 0); + TempClient := TCefClientRef.UnWrap(client); + TempExtraInfo := TCefDictionaryValueRef.UnWrap(extra_info); + + Result := Ord(TCefLifeSpanHandlerOwn(TempObject).OnBeforePopup(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + CefString(target_url), + CefString(target_frame_name), + target_disposition, + user_gesture <> 0, + popupFeatures^, + windowInfo^, + TempClient, + settings^, + TempExtraInfo, + TempNoJS)); no_javascript_access^ := Ord(TempNoJS); @@ -137,9 +140,16 @@ begin else if not(TempClient.SameAs(client)) then client := TempClient.Wrap; + + if (TempExtraInfo = nil) then + extra_info := nil + else + if not(TempExtraInfo.SameAs(extra_info)) then + extra_info := TempExtraInfo.Wrap; end; finally - TempClient := nil; + TempClient := nil; + TempExtraInfo := nil; end; end; @@ -210,6 +220,7 @@ function TCefLifeSpanHandlerOwn.OnBeforePopup(const browser : ICefBro var windowInfo : TCefWindowInfo; var client : ICefClient; var settings : TCefBrowserSettings; + var extra_info : ICefDictionaryValue; var noJavascriptAccess : Boolean): Boolean; begin Result := False; @@ -227,11 +238,11 @@ end; // TCustomLifeSpanHandler -constructor TCustomLifeSpanHandler.Create(const events: Pointer); +constructor TCustomLifeSpanHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomLifeSpanHandler.Destroy; @@ -274,16 +285,17 @@ function TCustomLifeSpanHandler.OnBeforePopup(const browser : ICefBro var windowInfo : TCefWindowInfo; var client : ICefClient; var settings : TCefBrowserSettings; + var extra_info : ICefDictionaryValue; var noJavascriptAccess : Boolean): Boolean; begin if (FEvents <> nil) then Result := IChromiumEvents(FEvents).doOnBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, - windowInfo, client, settings, noJavascriptAccess) + windowInfo, client, settings, extra_info, noJavascriptAccess) else Result := inherited OnBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, - windowInfo, client, settings, noJavascriptAccess); + windowInfo, client, settings, extra_info, noJavascriptAccess); end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFLinkedWinControlBase.pas b/windows/src/ext/cef4delphi/source/uCEFLinkedWinControlBase.pas new file mode 100644 index 0000000000000000000000000000000000000000..1e24e248f353d1af17ed0b1b299458b12f1cfbf7 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFLinkedWinControlBase.pas @@ -0,0 +1,177 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLinkedWinControlBase; + +{$I cef.inc} + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} + {$IFDEF MACOSX} + {$ModeSwitch objectivec1} + {$ENDIF} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics, + {$ELSE} + {$IFDEF MSWINDOWS}Windows, Messages,{$ENDIF} Classes, Controls, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFWinControl, uCEFChromium; + +type + + { TCEFLinkedWinControlBase } + + TCEFLinkedWinControlBase = class(TCEFWinControl) + protected + function GetChromium: TChromium; virtual; abstract; + function GetUseSetFocus: Boolean; virtual; + + {$IFDEF FPC} + procedure SetVisible(Value: Boolean); override; + {$ENDIF} + function GetChildWindowHandle : {$IFNDEF MSWINDOWS}{$IFDEF FPC}LclType.{$ENDIF}{$ENDIF}THandle; override; + {$IFDEF MSWINDOWS} + procedure WndProc(var aMessage: TMessage); override; + {$ENDIF} + + property Chromium : TChromium read GetChromium; + public + procedure UpdateSize; override; + end; + +implementation + +{ TCEFLinkedWinControlBase } + +function TCEFLinkedWinControlBase.GetUseSetFocus: Boolean; +begin + Result := True; +end; + +{$IFDEF FPC} +procedure TCEFLinkedWinControlBase.SetVisible(Value: Boolean); +{$IFDEF LINUX} +var + TempChanged : boolean; +{$ENDIF} +begin + {$IFDEF LINUX} + TempChanged := (Visible <> Value); + {$ENDIF} + + inherited SetVisible(Value); + + {$IFDEF LINUX} + if not(csDesigning in ComponentState) and + TempChanged and + (Chromium <> nil) and + Chromium.Initialized then + Chromium.UpdateXWindowVisibility(Visible); + {$ENDIF} +end; +{$ENDIF} + +function TCEFLinkedWinControlBase.GetChildWindowHandle: THandle; +begin + Result := 0; + + if (Chromium <> nil) then Result := Chromium.WindowHandle; + + if (Result = 0) then Result := inherited GetChildWindowHandle; +end; + +{$IFDEF MSWINDOWS} +procedure TCEFLinkedWinControlBase.WndProc(var aMessage: TMessage); +var + TempHandle : THandle; +begin + case aMessage.Msg of + WM_SETFOCUS: + begin + if GetUseSetFocus and (Chromium <> nil) then + Chromium.SetFocus(True) + else + begin + TempHandle := ChildWindowHandle; + if (TempHandle <> 0) then PostMessage(TempHandle, WM_SETFOCUS, aMessage.WParam, 0); + end; + + inherited WndProc(aMessage); + end; + + WM_ERASEBKGND: + if (ChildWindowHandle = 0) then inherited WndProc(aMessage); + + CM_WANTSPECIALKEY: + if not(TWMKey(aMessage).CharCode in [VK_LEFT .. VK_DOWN, VK_RETURN, VK_ESCAPE]) then + aMessage.Result := 1 + else + inherited WndProc(aMessage); + + WM_GETDLGCODE : aMessage.Result := DLGC_WANTARROWS or DLGC_WANTCHARS; + + else inherited WndProc(aMessage); + end; +end; +{$ENDIF} + +procedure TCEFLinkedWinControlBase.UpdateSize; +begin + {$IFDEF LINUX} + if not(csDesigning in ComponentState) and + (Chromium <> nil) and + Chromium.Initialized then + Chromium.UpdateBrowserSize(Left, Top, Width, Height); + {$ELSE} + inherited UpdateSize; + {$ENDIF} +end; + + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFLinkedWindowParent.pas b/windows/src/ext/cef4delphi/source/uCEFLinkedWindowParent.pas new file mode 100644 index 0000000000000000000000000000000000000000..a3f117b06b8cbf68537eec2c340dc62b2e716d36 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFLinkedWindowParent.pas @@ -0,0 +1,131 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLinkedWindowParent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, Vcl.Controls, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, + {$IFDEF LINUX}xlib, x,{$ENDIF} + {$ELSE} + Messages, + {$ENDIF} + {$ENDIF} + uCEFWinControl, uCEFTypes, uCEFInterfaces, uCEFChromium, + uCEFLinkedWinControlBase; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + + { TCEFLinkedWindowParent } + + TCEFLinkedWindowParent = class(TCEFLinkedWinControlBase) + protected + FChromium : TChromium; + + function GetChromium: TChromium; override; + procedure SetChromium(aValue : TChromium); + + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + + public + constructor Create(AOwner : TComponent); override; + + published + property Chromium : TChromium read FChromium write SetChromium; + end; + + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +implementation + +uses + uCEFMiscFunctions, uCEFClient, uCEFConstants, uCEFLibFunctions, + uCEFApplication; + +constructor TCEFLinkedWindowParent.Create(AOwner : TComponent); +begin + inherited Create(AOwner); + + FChromium := nil; +end; + +procedure TCEFLinkedWindowParent.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited Notification(AComponent, Operation); + + if (Operation = opRemove) and (AComponent = FChromium) then FChromium := nil; +end; + +function TCEFLinkedWindowParent.GetChromium: TChromium; +begin + Result := FChromium; +end; + +procedure TCEFLinkedWindowParent.SetChromium(aValue : TChromium); +begin + FChromium := aValue; + if (aValue <> nil) then aValue.FreeNotification(Self); +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tceflinkedwindowparent.lrs} + RegisterComponents('Chromium', [TCEFLinkedWindowParent]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFLinuxConstants.pas b/windows/src/ext/cef4delphi/source/uCEFLinuxConstants.pas new file mode 100644 index 0000000000000000000000000000000000000000..d7f822567850b1d2718d912ae3dfef2caaff6b5c --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFLinuxConstants.pas @@ -0,0 +1,4045 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLinuxConstants; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +{$IFDEF LINUX} +const + // These are the GDK constants included in the Lazarus gdkkeysyms.pp file + GDK_VoidSymbol = $FFFFFF; + GDK_BackSpace = $FF08; + GDK_Tab = $FF09; + GDK_Linefeed = $FF0A; + GDK_Clear_Key = $FF0B; + GDK_Return = $FF0D; + GDK_Pause = $FF13; + GDK_Scroll_Lock = $FF14; + GDK_Sys_Req = $FF15; + GDK_Escape = $FF1B; + GDK_Delete_Key = $FFFF; + GDK_Multi_key = $FF20; + GDK_SingleCandidate = $FF3C; + GDK_MultipleCandidate = $FF3D; + GDK_PreviousCandidate = $FF3E; + GDK_Kanji = $FF21; + GDK_Muhenkan = $FF22; + GDK_Henkan_Mode = $FF23; + GDK_Henkan = $FF23; + GDK_Romaji = $FF24; + GDK_Hiragana = $FF25; + GDK_Katakana = $FF26; + GDK_Hiragana_Katakana = $FF27; + GDK_Zenkaku = $FF28; + GDK_Hankaku = $FF29; + GDK_Zenkaku_Hankaku = $FF2A; + GDK_Touroku = $FF2B; + GDK_Massyo = $FF2C; + GDK_Kana_Lock = $FF2D; + GDK_Kana_Shift = $FF2E; + GDK_Eisu_Shift = $FF2F; + GDK_Eisu_toggle = $FF30; + GDK_Zen_Koho = $FF3D; + GDK_Mae_Koho = $FF3E; + GDK_Home = $FF50; + GDK_Left = $FF51; + GDK_Up = $FF52; + GDK_Right = $FF53; + GDK_Down = $FF54; + GDK_Prior = $FF55; + GDK_Page_Up = $FF55; + GDK_Next = $FF56; + GDK_Page_Down = $FF56; + GDK_End = $FF57; + GDK_Begin = $FF58; + GDK_Select = $FF60; + GDK_Print = $FF61; + GDK_Execute = $FF62; + GDK_Insert = $FF63; + GDK_Undo = $FF65; + GDK_Redo = $FF66; + GDK_Menu = $FF67; + GDK_Find = $FF68; + GDK_Cancel = $FF69; + GDK_Help = $FF6A; + GDK_Break = $FF6B; + GDK_Mode_switch = $FF7E; + GDK_script_switch = $FF7E; + GDK_Num_Lock = $FF7F; + GDK_KP_Space = $FF80; + GDK_KP_Tab = $FF89; + GDK_KP_Enter = $FF8D; + GDK_KP_F1 = $FF91; + GDK_KP_F2 = $FF92; + GDK_KP_F3 = $FF93; + GDK_KP_F4 = $FF94; + GDK_KP_Home = $FF95; + GDK_KP_Left = $FF96; + GDK_KP_Up = $FF97; + GDK_KP_Right = $FF98; + GDK_KP_Down = $FF99; + GDK_KP_Prior = $FF9A; + GDK_KP_Page_Up = $FF9A; + GDK_KP_Next = $FF9B; + GDK_KP_Page_Down = $FF9B; + GDK_KP_End = $FF9C; + GDK_KP_Begin = $FF9D; + GDK_KP_Insert = $FF9E; + GDK_KP_Delete = $FF9F; + GDK_KP_Equal = $FFBD; + GDK_KP_Multiply = $FFAA; + GDK_KP_Add = $FFAB; + GDK_KP_Separator = $FFAC; + GDK_KP_Subtract = $FFAD; + GDK_KP_Decimal = $FFAE; + GDK_KP_Divide = $FFAF; + GDK_KP_0 = $FFB0; + GDK_KP_1 = $FFB1; + GDK_KP_2 = $FFB2; + GDK_KP_3 = $FFB3; + GDK_KP_4 = $FFB4; + GDK_KP_5 = $FFB5; + GDK_KP_6 = $FFB6; + GDK_KP_7 = $FFB7; + GDK_KP_8 = $FFB8; + GDK_KP_9 = $FFB9; + GDK_F1 = $FFBE; + GDK_F2 = $FFBF; + GDK_F3 = $FFC0; + GDK_F4 = $FFC1; + GDK_F5 = $FFC2; + GDK_F6 = $FFC3; + GDK_F7 = $FFC4; + GDK_F8 = $FFC5; + GDK_F9 = $FFC6; + GDK_F10 = $FFC7; + GDK_F11 = $FFC8; + GDK_L1 = $FFC8; + GDK_F12 = $FFC9; + GDK_L2 = $FFC9; + GDK_F13 = $FFCA; + GDK_L3 = $FFCA; + GDK_F14 = $FFCB; + GDK_L4 = $FFCB; + GDK_F15 = $FFCC; + GDK_L5 = $FFCC; + GDK_F16 = $FFCD; + GDK_L6 = $FFCD; + GDK_F17 = $FFCE; + GDK_L7 = $FFCE; + GDK_F18 = $FFCF; + GDK_L8 = $FFCF; + GDK_F19 = $FFD0; + GDK_L9 = $FFD0; + GDK_F20 = $FFD1; + GDK_L10 = $FFD1; + GDK_F21 = $FFD2; + GDK_R1 = $FFD2; + GDK_F22 = $FFD3; + GDK_R2 = $FFD3; + GDK_F23 = $FFD4; + GDK_R3 = $FFD4; + GDK_F24 = $FFD5; + GDK_R4 = $FFD5; + GDK_F25 = $FFD6; + GDK_R5 = $FFD6; + GDK_F26 = $FFD7; + GDK_R6 = $FFD7; + GDK_F27 = $FFD8; + GDK_R7 = $FFD8; + GDK_F28 = $FFD9; + GDK_R8 = $FFD9; + GDK_F29 = $FFDA; + GDK_R9 = $FFDA; + GDK_F30 = $FFDB; + GDK_R10 = $FFDB; + GDK_F31 = $FFDC; + GDK_R11 = $FFDC; + GDK_F32 = $FFDD; + GDK_R12 = $FFDD; + GDK_F33 = $FFDE; + GDK_R13 = $FFDE; + GDK_F34 = $FFDF; + GDK_R14 = $FFDF; + GDK_F35 = $FFE0; + GDK_R15 = $FFE0; + GDK_Shift_L = $FFE1; + GDK_Shift_R = $FFE2; + GDK_Control_L = $FFE3; + GDK_Control_R = $FFE4; + GDK_Caps_Lock = $FFE5; + GDK_Shift_Lock = $FFE6; + GDK_Meta_L = $FFE7; + GDK_Meta_R = $FFE8; + GDK_Alt_L = $FFE9; + GDK_Alt_R = $FFEA; + GDK_Super_L = $FFEB; + GDK_Super_R = $FFEC; + GDK_Hyper_L = $FFED; + GDK_Hyper_R = $FFEE; + GDK_ISO_Lock = $FE01; + GDK_ISO_Level2_Latch = $FE02; + GDK_ISO_Level3_Shift = $FE03; + GDK_ISO_Level3_Latch = $FE04; + GDK_ISO_Level3_Lock = $FE05; + GDK_ISO_Group_Shift = $FF7E; + GDK_ISO_Group_Latch = $FE06; + GDK_ISO_Group_Lock = $FE07; + GDK_ISO_Next_Group = $FE08; + GDK_ISO_Next_Group_Lock = $FE09; + GDK_ISO_Prev_Group = $FE0A; + GDK_ISO_Prev_Group_Lock = $FE0B; + GDK_ISO_First_Group = $FE0C; + GDK_ISO_First_Group_Lock = $FE0D; + GDK_ISO_Last_Group = $FE0E; + GDK_ISO_Last_Group_Lock = $FE0F; + GDK_ISO_Left_Tab = $FE20; + GDK_ISO_Move_Line_Up = $FE21; + GDK_ISO_Move_Line_Down = $FE22; + GDK_ISO_Partial_Line_Up = $FE23; + GDK_ISO_Partial_Line_Down = $FE24; + GDK_ISO_Partial_Space_Left = $FE25; + GDK_ISO_Partial_Space_Right = $FE26; + GDK_ISO_Set_Margin_Left = $FE27; + GDK_ISO_Set_Margin_Right = $FE28; + GDK_ISO_Release_Margin_Left = $FE29; + GDK_ISO_Release_Margin_Right = $FE2A; + GDK_ISO_Release_Both_Margins = $FE2B; + GDK_ISO_Fast_Cursor_Left = $FE2C; + GDK_ISO_Fast_Cursor_Right = $FE2D; + GDK_ISO_Fast_Cursor_Up = $FE2E; + GDK_ISO_Fast_Cursor_Down = $FE2F; + GDK_ISO_Continuous_Underline = $FE30; + GDK_ISO_Discontinuous_Underline = $FE31; + GDK_ISO_Emphasize = $FE32; + GDK_ISO_Center_Object = $FE33; + GDK_ISO_Enter = $FE34; + GDK_dead_grave = $FE50; + GDK_dead_acute = $FE51; + GDK_dead_circumflex = $FE52; + GDK_dead_tilde = $FE53; + GDK_dead_macron = $FE54; + GDK_dead_breve = $FE55; + GDK_dead_abovedot = $FE56; + GDK_dead_diaeresis = $FE57; + GDK_dead_abovering = $FE58; + GDK_dead_doubleacute = $FE59; + GDK_dead_caron = $FE5A; + GDK_dead_cedilla = $FE5B; + GDK_dead_ogonek = $FE5C; + GDK_dead_iota = $FE5D; + GDK_dead_voiced_sound = $FE5E; + GDK_dead_semivoiced_sound = $FE5F; + GDK_dead_belowdot = $FE60; + GDK_First_Virtual_Screen = $FED0; + GDK_Prev_Virtual_Screen = $FED1; + GDK_Next_Virtual_Screen = $FED2; + GDK_Last_Virtual_Screen = $FED4; + GDK_Terminate_Server = $FED5; + GDK_AccessX_Enable = $FE70; + GDK_AccessX_Feedback_Enable = $FE71; + GDK_RepeatKeys_Enable = $FE72; + GDK_SlowKeys_Enable = $FE73; + GDK_BounceKeys_Enable = $FE74; + GDK_StickyKeys_Enable = $FE75; + GDK_MouseKeys_Enable = $FE76; + GDK_MouseKeys_Accel_Enable = $FE77; + GDK_Overlay1_Enable = $FE78; + GDK_Overlay2_Enable = $FE79; + GDK_AudibleBell_Enable = $FE7A; + GDK_Pointer_Left = $FEE0; + GDK_Pointer_Right = $FEE1; + GDK_Pointer_Up = $FEE2; + GDK_Pointer_Down = $FEE3; + GDK_Pointer_UpLeft = $FEE4; + GDK_Pointer_UpRight = $FEE5; + GDK_Pointer_DownLeft = $FEE6; + GDK_Pointer_DownRight = $FEE7; + GDK_Pointer_Button_Dflt = $FEE8; + GDK_Pointer_Button1 = $FEE9; + GDK_Pointer_Button2 = $FEEA; + GDK_Pointer_Button3 = $FEEB; + GDK_Pointer_Button4 = $FEEC; + GDK_Pointer_Button5 = $FEED; + GDK_Pointer_DblClick_Dflt = $FEEE; + GDK_Pointer_DblClick1 = $FEEF; + GDK_Pointer_DblClick2 = $FEF0; + GDK_Pointer_DblClick3 = $FEF1; + GDK_Pointer_DblClick4 = $FEF2; + GDK_Pointer_DblClick5 = $FEF3; + GDK_Pointer_Drag_Dflt = $FEF4; + GDK_Pointer_Drag1 = $FEF5; + GDK_Pointer_Drag2 = $FEF6; + GDK_Pointer_Drag3 = $FEF7; + GDK_Pointer_Drag4 = $FEF8; + GDK_Pointer_Drag5 = $FEFD; + GDK_Pointer_EnableKeys = $FEF9; + GDK_Pointer_Accelerate = $FEFA; + GDK_Pointer_DfltBtnNext = $FEFB; + GDK_Pointer_DfltBtnPrev = $FEFC; + GDK_3270_Duplicate = $FD01; + GDK_3270_FieldMark = $FD02; + GDK_3270_Right2 = $FD03; + GDK_3270_Left2 = $FD04; + GDK_3270_BackTab = $FD05; + GDK_3270_EraseEOF = $FD06; + GDK_3270_EraseInput = $FD07; + GDK_3270_Reset = $FD08; + GDK_3270_Quit = $FD09; + GDK_3270_PA1 = $FD0A; + GDK_3270_PA2 = $FD0B; + GDK_3270_PA3 = $FD0C; + GDK_3270_Test = $FD0D; + GDK_3270_Attn = $FD0E; + GDK_3270_CursorBlink = $FD0F; + GDK_3270_AltCursor = $FD10; + GDK_3270_KeyClick = $FD11; + GDK_3270_Jump = $FD12; + GDK_3270_Ident = $FD13; + GDK_3270_Rule = $FD14; + GDK_3270_Copy = $FD15; + GDK_3270_Play = $FD16; + GDK_3270_Setup = $FD17; + GDK_3270_Record = $FD18; + GDK_3270_ChangeScreen = $FD19; + GDK_3270_DeleteWord = $FD1A; + GDK_3270_ExSelect = $FD1B; + GDK_3270_CursorSelect = $FD1C; + GDK_3270_PrintScreen = $FD1D; + GDK_3270_Enter = $FD1E; + GDK_space = $020; + GDK_exclam = $021; + GDK_quotedbl = $022; + GDK_numbersign = $023; + GDK_dollar = $024; + GDK_percent = $025; + GDK_ampersand = $026; + GDK_apostrophe = $027; + GDK_quoteright = $027; + GDK_parenleft = $028; + GDK_parenright = $029; + GDK_asterisk = $02a; + GDK_plus_key = $02b; + GDK_comma = $02c; + GDK_minus = $02d; + GDK_period = $02e; + GDK_slash = $02f; + GDK_0 = $030; + GDK_1 = $031; + GDK_2 = $032; + GDK_3 = $033; + GDK_4 = $034; + GDK_5 = $035; + GDK_6 = $036; + GDK_7 = $037; + GDK_8 = $038; + GDK_9 = $039; + GDK_colon = $03a; + GDK_semicolon = $03b; + GDK_less = $03c; + GDK_equal = $03d; + GDK_greater = $03e; + GDK_question = $03f; + GDK_at = $040; + GDK_Capital_A = $041; + GDK_Capital_B = $042; + GDK_Capital_C = $043; + GDK_Capital_D = $044; + GDK_Capital_E = $045; + GDK_Capital_F = $046; + GDK_Capital_G = $047; + GDK_Capital_H = $048; + GDK_Capital_I = $049; + GDK_Capital_J = $04a; + GDK_Capital_K = $04b; + GDK_Capital_L = $04c; + GDK_Capital_M = $04d; + GDK_Capital_N = $04e; + GDK_Capital_O = $04f; + GDK_Capital_P = $050; + GDK_Capital_Q = $051; + GDK_Capital_R = $052; + GDK_Capital_S = $053; + GDK_Capital_T = $054; + GDK_Capital_U = $055; + GDK_Capital_V = $056; + GDK_Capital_W = $057; + GDK_Capital_X = $058; + GDK_Capital_Y = $059; + GDK_Capital_Z = $05a; + GDK_bracketleft = $05b; + GDK_backslash = $05c; + GDK_bracketright = $05d; + GDK_asciicircum = $05e; + GDK_underscore = $05f; + GDK_grave = $060; + GDK_quoteleft = $060; + GDK_a = $061; + GDK_b = $062; + GDK_c = $063; + GDK_d = $064; + GDK_e = $065; + GDK_f = $066; + GDK_g = $067; + GDK_h = $068; + GDK_i = $069; + GDK_j = $06a; + GDK_k = $06b; + GDK_l = $06c; + GDK_m = $06d; + GDK_n = $06e; + GDK_o = $06f; + GDK_p = $070; + GDK_q = $071; + GDK_r = $072; + GDK_s = $073; + GDK_t = $074; + GDK_u = $075; + GDK_v = $076; + GDK_w = $077; + GDK_x = $078; + GDK_y = $079; + GDK_z = $07a; + GDK_braceleft = $07b; + GDK_bar = $07c; + GDK_braceright = $07d; + GDK_asciitilde = $07e; + GDK_nobreakspace = $0a0; + GDK_exclamdown = $0a1; + GDK_cent = $0a2; + GDK_sterling = $0a3; + GDK_currency = $0a4; + GDK_yen = $0a5; + GDK_brokenbar = $0a6; + GDK_section = $0a7; + GDK_diaeresis = $0a8; + GDK_copyright = $0a9; + GDK_ordfeminine = $0aa; + GDK_guillemotleft = $0ab; + GDK_notsign = $0ac; + GDK_hyphen = $0ad; + GDK_registered = $0ae; + GDK_macron = $0af; + GDK_degree = $0b0; + GDK_plusminus = $0b1; + GDK_twosuperior = $0b2; + GDK_threesuperior = $0b3; + GDK_acute = $0b4; + GDK_mu = $0b5; + GDK_paragraph = $0b6; + GDK_periodcentered = $0b7; + GDK_cedilla = $0b8; + GDK_onesuperior = $0b9; + GDK_masculine = $0ba; + GDK_guillemotright = $0bb; + GDK_onequarter = $0bc; + GDK_onehalf = $0bd; + GDK_threequarters = $0be; + GDK_questiondown = $0bf; + GDK_Capital_Agrave = $0c0; + GDK_Capital_Aacute = $0c1; + GDK_Capital_Acircumflex = $0c2; + GDK_Capital_Atilde = $0c3; + GDK_Capital_Adiaeresis = $0c4; + GDK_Capital_Aring = $0c5; + GDK_Capital_AE = $0c6; + GDK_Capital_Ccedilla = $0c7; + GDK_Capital_Egrave = $0c8; + GDK_Capital_Eacute = $0c9; + GDK_Capital_Ecircumflex = $0ca; + GDK_Capital_Ediaeresis = $0cb; + GDK_Capital_Igrave = $0cc; + GDK_Capital_Iacute = $0cd; + GDK_Capital_Icircumflex = $0ce; + GDK_Capital_Idiaeresis = $0cf; + GDK_Capital_ETH = $0d0; + GDK_Capital_Ntilde = $0d1; + GDK_Capital_Ograve = $0d2; + GDK_Capital_Oacute = $0d3; + GDK_Capital_Ocircumflex = $0d4; + GDK_Capital_Otilde = $0d5; + GDK_Capital_Odiaeresis = $0d6; + GDK_Capital_multiply = $0d7; + GDK_Capital_Ooblique = $0d8; + GDK_Capital_Ugrave = $0d9; + GDK_Capital_Uacute = $0da; + GDK_Capital_Ucircumflex = $0db; + GDK_Capital_Udiaeresis = $0dc; + GDK_Capital_Yacute = $0dd; + GDK_Capital_THORN = $0de; + GDK_Thorn = $0de; + GDK_ssharp = $0df; + GDK_agrave = $0e0; + GDK_aacute = $0e1; + GDK_acircumflex = $0e2; + GDK_atilde = $0e3; + GDK_adiaeresis = $0e4; + GDK_aring = $0e5; + GDK_ae = $0e6; + GDK_ccedilla = $0e7; + GDK_egrave = $0e8; + GDK_eacute = $0e9; + GDK_ecircumflex = $0ea; + GDK_ediaeresis = $0eb; + GDK_igrave = $0ec; + GDK_iacute = $0ed; + GDK_icircumflex = $0ee; + GDK_idiaeresis = $0ef; + GDK_eth = $0f0; + GDK_ntilde = $0f1; + GDK_ograve = $0f2; + GDK_oacute = $0f3; + GDK_ocircumflex = $0f4; + GDK_otilde = $0f5; + GDK_odiaeresis = $0f6; + GDK_division = $0f7; + GDK_oslash = $0f8; + GDK_ugrave = $0f9; + GDK_uacute = $0fa; + GDK_ucircumflex = $0fb; + GDK_udiaeresis = $0fc; + GDK_yacute = $0fd; + GDK_small_thorn = $0fe; + GDK_ydiaeresis = $0ff; + GDK_Capital_Aogonek = $1a1; + GDK_Capital_breve = $1a2; + GDK_Capital_Lstroke = $1a3; + GDK_Capital_Lcaron = $1a5; + GDK_Capital_Sacute = $1a6; + GDK_Capital_Scaron = $1a9; + GDK_Capital_Scedilla = $1aa; + GDK_Capital_Tcaron = $1ab; + GDK_Capital_Zacute = $1ac; + GDK_Capital_Zcaron = $1ae; + GDK_Capital_Zabovedot = $1af; + GDK_aogonek = $1b1; + GDK_ogonek = $1b2; + GDK_lstroke = $1b3; + GDK_lcaron = $1b5; + GDK_sacute = $1b6; + GDK_caron = $1b7; + GDK_scaron = $1b9; + GDK_scedilla = $1ba; + GDK_tcaron = $1bb; + GDK_zacute = $1bc; + GDK_doubleacute = $1bd; + GDK_zcaron = $1be; + GDK_zabovedot = $1bf; + GDK_Capital_Racute = $1c0; + GDK_Capital_Abreve = $1c3; + GDK_Capital_Lacute = $1c5; + GDK_Capital_Cacute = $1c6; + GDK_Capital_Ccaron = $1c8; + GDK_Capital_Eogonek = $1ca; + GDK_Capital_Ecaron = $1cc; + GDK_Capital_Dcaron = $1cf; + GDK_Capital_Dstroke = $1d0; + GDK_Capital_Nacute = $1d1; + GDK_Capital_Ncaron = $1d2; + GDK_Capital_Odoubleacute = $1d5; + GDK_Capital_Rcaron = $1d8; + GDK_Capital_Uring = $1d9; + GDK_Capital_Udoubleacute = $1db; + GDK_Capital_Tcedilla = $1de; + GDK_racute = $1e0; + GDK_abreve = $1e3; + GDK_lacute = $1e5; + GDK_cacute = $1e6; + GDK_ccaron = $1e8; + GDK_eogonek = $1ea; + GDK_ecaron = $1ec; + GDK_dcaron = $1ef; + GDK_dstroke = $1f0; + GDK_nacute = $1f1; + GDK_ncaron = $1f2; + GDK_odoubleacute = $1f5; + GDK_udoubleacute = $1fb; + GDK_rcaron = $1f8; + GDK_uring = $1f9; + GDK_tcedilla = $1fe; + GDK_abovedot = $1ff; + GDK_Capital_Hstroke = $2a1; + GDK_Capital_Hcircumflex = $2a6; + GDK_Capital_Iabovedot = $2a9; + GDK_Capital_Gbreve = $2ab; + GDK_Capital_Jcircumflex = $2ac; + GDK_hstroke = $2b1; + GDK_hcircumflex = $2b6; + GDK_idotless = $2b9; + GDK_gbreve = $2bb; + GDK_jcircumflex = $2bc; + GDK_Capital_Cabovedot = $2c5; + GDK_Capital_Ccircumflex = $2c6; + GDK_Capital_Gabovedot = $2d5; + GDK_Capital_Gcircumflex = $2d8; + GDK_Capital_Ubreve = $2dd; + GDK_Capital_Scircumflex = $2de; + GDK_cabovedot = $2e5; + GDK_ccircumflex = $2e6; + GDK_gabovedot = $2f5; + GDK_gcircumflex = $2f8; + GDK_ubreve = $2fd; + GDK_scircumflex = $2fe; + GDK_kra = $3a2; + GDK_kappa = $3a2; + GDK_Capital_Rcedilla = $3a3; + GDK_Capital_Itilde = $3a5; + GDK_Capital_Lcedilla = $3a6; + GDK_Capital_Emacron = $3aa; + GDK_Capital_Gcedilla = $3ab; + GDK_Capital_Tslash = $3ac; + GDK_rcedilla = $3b3; + GDK_itilde = $3b5; + GDK_lcedilla = $3b6; + GDK_emacron = $3ba; + GDK_gcedilla = $3bb; + GDK_tslash = $3bc; + GDK_Capital_ENG = $3bd; + GDK_eng = $3bf; + GDK_Capital_Amacron = $3c0; + GDK_Capital_Iogonek = $3c7; + GDK_Capital_Eabovedot = $3cc; + GDK_Capital_Imacron = $3cf; + GDK_Capital_Ncedilla = $3d1; + GDK_Capital_Omacron = $3d2; + GDK_Capital_Kcedilla = $3d3; + GDK_Capital_Uogonek = $3d9; + GDK_Capital_Utilde = $3dd; + GDK_Capital_Umacron = $3de; + GDK_amacron = $3e0; + GDK_iogonek = $3e7; + GDK_eabovedot = $3ec; + GDK_imacron = $3ef; + GDK_ncedilla = $3f1; + GDK_omacron = $3f2; + GDK_kcedilla = $3f3; + GDK_uogonek = $3f9; + GDK_utilde = $3fd; + GDK_umacron = $3fe; + GDK_overline = $47e; + GDK_kana_fullstop = $4a1; + GDK_kana_openingbracket = $4a2; + GDK_kana_closingbracket = $4a3; + GDK_kana_comma = $4a4; + GDK_kana_conjunctive = $4a5; + GDK_kana_middledot = $4a5; + GDK_kana_WO = $4a6; + GDK_kana_a = $4a7; + GDK_kana_i = $4a8; + GDK_kana_u = $4a9; + GDK_kana_e = $4aa; + GDK_kana_o = $4ab; + GDK_kana_ya = $4ac; + GDK_kana_yu = $4ad; + GDK_kana_yo = $4ae; + GDK_kana_tsu = $4af; + GDK_kana_tu = $4af; + GDK_prolongedsound = $4b0; + GDK_kana_Capital__A = $4b1; + GDK_kana_Capital__I = $4b2; + GDK_kana_Capital__U = $4b3; + GDK_kana_Capital__E = $4b4; + GDK_kana_Capital__O = $4b5; + GDK_kana_Capital__KA = $4b6; + GDK_kana_Capital__KI = $4b7; + GDK_kana_Capital__KU = $4b8; + GDK_kana_Capital__KE = $4b9; + GDK_kana_Capital__KO = $4ba; + GDK_kana_Capital__SA = $4bb; + GDK_kana_Capital__SHI = $4bc; + GDK_kana_Capital__SU = $4bd; + GDK_kana_Capital__SE = $4be; + GDK_kana_Capital__SO = $4bf; + GDK_kana_Capital__TA = $4c0; + GDK_kana_Capital__CHI = $4c1; + GDK_kana_Capital__TI = $4c1; + GDK_kana_Capital__TSU = $4c2; + GDK_kana_Capital__TU = $4c2; + GDK_kana_Capital__TE = $4c3; + GDK_kana_Capital__TO = $4c4; + GDK_kana_Capital__NA = $4c5; + GDK_kana_Capital__NI = $4c6; + GDK_kana_Capital__NU = $4c7; + GDK_kana_Capital__NE = $4c8; + GDK_kana_Capital__NO = $4c9; + GDK_kana_Capital__HA = $4ca; + GDK_kana_Capital__HI = $4cb; + GDK_kana_Capital__FU = $4cc; + GDK_kana_Capital__HU = $4cc; + GDK_kana_Capital__HE = $4cd; + GDK_kana_Capital__HO = $4ce; + GDK_kana_Capital__MA = $4cf; + GDK_kana_Capital__MI = $4d0; + GDK_kana_Capital__MU = $4d1; + GDK_kana_Capital__ME = $4d2; + GDK_kana_Capital__MO = $4d3; + GDK_kana_Capital__YA = $4d4; + GDK_kana_Capital__YU = $4d5; + GDK_kana_Capital__YO = $4d6; + GDK_kana_Capital__RA = $4d7; + GDK_kana_Capital__RI = $4d8; + GDK_kana_Capital__RU = $4d9; + GDK_kana_Capital__RE = $4da; + GDK_kana_Capital__RO = $4db; + GDK_kana_Capital__WA = $4dc; + GDK_kana_Capital__N = $4dd; + GDK_voicedsound = $4de; + GDK_semivoicedsound = $4df; + GDK_kana_switch = $FF7E; + GDK_arabic_comma = $5ac; + GDK_arabic_semicolon = $5bb; + GDK_arabic_question_mark = $5bf; + GDK_arabic_hamza = $5c1; + GDK_arabic_maddaonalef = $5c2; + GDK_arabic_hamzaonalef = $5c3; + GDK_arabic_hamzaonwaw = $5c4; + GDK_arabic_hamzaunderalef = $5c5; + GDK_arabic_hamzaonyeh = $5c6; + GDK_arabic_alef = $5c7; + GDK_arabic_beh = $5c8; + GDK_arabic_tehmarbuta = $5c9; + GDK_arabic_teh = $5ca; + GDK_arabic_theh = $5cb; + GDK_arabic_jeem = $5cc; + GDK_arabic_hah = $5cd; + GDK_arabic_khah = $5ce; + GDK_arabic_dal = $5cf; + GDK_arabic_thal = $5d0; + GDK_arabic_ra = $5d1; + GDK_arabic_zain = $5d2; + GDK_arabic_seen = $5d3; + GDK_arabic_sheen = $5d4; + GDK_arabic_sad = $5d5; + GDK_arabic_dad = $5d6; + GDK_arabic_tah = $5d7; + GDK_arabic_zah = $5d8; + GDK_arabic_ain = $5d9; + GDK_arabic_ghain = $5da; + GDK_arabic_tatweel = $5e0; + GDK_arabic_feh = $5e1; + GDK_arabic_qaf = $5e2; + GDK_arabic_kaf = $5e3; + GDK_arabic_lam = $5e4; + GDK_arabic_meem = $5e5; + GDK_arabic_noon = $5e6; + GDK_arabic_ha = $5e7; + GDK_arabic_heh = $5e7; + GDK_arabic_waw = $5e8; + GDK_arabic_alefmaksura = $5e9; + GDK_arabic_yeh = $5ea; + GDK_arabic_fathatan = $5eb; + GDK_arabic_dammatan = $5ec; + GDK_arabic_kasratan = $5ed; + GDK_arabic_fatha = $5ee; + GDK_arabic_damma = $5ef; + GDK_arabic_kasra = $5f0; + GDK_arabic_shadda = $5f1; + GDK_arabic_sukun = $5f2; + GDK_arabic_switch = $FF7E; + GDK_serbian_dje = $6a1; + GDK_macedonia_gje = $6a2; + GDK_cyrillic_io = $6a3; + GDK_ukrainian_ie = $6a4; + GDK_ukrainian_je = $6a4; + GDK_macedonia_dse = $6a5; + GDK_ukrainian_i = $6a6; + GDK_ukrainian_yi = $6a7; + GDK_cyrillic_je = $6a8; + GDK_serbian_je = $6a8; + GDK_cyrillic_lje = $6a9; + GDK_serbian_lje = $6a9; + GDK_cyrillic_nje = $6aa; + GDK_serbian_nje = $6aa; + GDK_serbian_tshe = $6ab; + GDK_macedonia_kje = $6ac; + GDK_byelorussian_shortu = $6ae; + GDK_cyrillic_dzhe = $6af; + GDK_serbian_dze = $6af; + GDK_numerosign = $6b0; + GDK_serbian_Capital_DJE = $6b1; + GDK_macedonia_Capital_GJE = $6b2; + GDK_cyrillic_Capital_IO = $6b3; + GDK_ukrainian_Capital_IE = $6b4; + GDK_ukrainian_Capital_JE = $6b4; + GDK_macedonia_Capital_DSE = $6b5; + GDK_ukrainian_Capital_I = $6b6; + GDK_ukrainian_Capital_YI = $6b7; + GDK_cyrillic_Capital_JE = $6b8; + GDK_serbian_Capital_JE = $6b8; + GDK_cyrillic_Capital_LJE = $6b9; + GDK_serbian_Capital_LJE = $6b9; + GDK_cyrillic_Capital_NJE = $6ba; + GDK_serbian_Capital_NJE = $6ba; + GDK_serbian_Capital_TSHE = $6bb; + GDK_macedonia_Capital_KJE = $6bc; + GDK_byelorussian_Capital_SHORTU = $6be; + GDK_cyrillic_Capital_DZHE = $6bf; + GDK_serbian_Capital_DZE = $6bf; + GDK_cyrillic_yu = $6c0; + GDK_cyrillic_a = $6c1; + GDK_cyrillic_be = $6c2; + GDK_cyrillic_tse = $6c3; + GDK_cyrillic_de = $6c4; + GDK_cyrillic_ie = $6c5; + GDK_cyrillic_ef = $6c6; + GDK_cyrillic_ghe = $6c7; + GDK_cyrillic_ha = $6c8; + GDK_cyrillic_i = $6c9; + GDK_cyrillic_shorti = $6ca; + GDK_cyrillic_ka = $6cb; + GDK_cyrillic_el = $6cc; + GDK_cyrillic_em = $6cd; + GDK_cyrillic_en = $6ce; + GDK_cyrillic_o = $6cf; + GDK_cyrillic_pe = $6d0; + GDK_cyrillic_ya = $6d1; + GDK_cyrillic_er = $6d2; + GDK_cyrillic_es = $6d3; + GDK_cyrillic_te = $6d4; + GDK_cyrillic_u = $6d5; + GDK_cyrillic_zhe = $6d6; + GDK_cyrillic_ve = $6d7; + GDK_cyrillic_softsign = $6d8; + GDK_cyrillic_yeru = $6d9; + GDK_cyrillic_ze = $6da; + GDK_cyrillic_sha = $6db; + GDK_cyrillic_e = $6dc; + GDK_cyrillic_shcha = $6dd; + GDK_cyrillic_che = $6de; + GDK_cyrillic_hardsign = $6df; + GDK_cyrillic_Capital_YU = $6e0; + GDK_cyrillic_Capital_A = $6e1; + GDK_cyrillic_Capital_BE = $6e2; + GDK_cyrillic_Capital_TSE = $6e3; + GDK_cyrillic_Capital_DE = $6e4; + GDK_cyrillic_Capital_IE = $6e5; + GDK_cyrillic_Capital_EF = $6e6; + GDK_cyrillic_Capital_GHE = $6e7; + GDK_cyrillic_Capital_HA = $6e8; + GDK_cyrillic_Capital_I = $6e9; + GDK_cyrillic_Capital_SHORTI = $6ea; + GDK_cyrillic_Capital_KA = $6eb; + GDK_cyrillic_Capital_EL = $6ec; + GDK_cyrillic_Capital_EM = $6ed; + GDK_cyrillic_Capital_EN = $6ee; + GDK_cyrillic_Capital_O = $6ef; + GDK_cyrillic_Capital_PE = $6f0; + GDK_cyrillic_Capital_YA = $6f1; + GDK_cyrillic_Capital_ER = $6f2; + GDK_cyrillic_Capital_ES = $6f3; + GDK_cyrillic_Capital_TE = $6f4; + GDK_cyrillic_Capital_U = $6f5; + GDK_cyrillic_Capital_ZHE = $6f6; + GDK_cyrillic_Capital_VE = $6f7; + GDK_cyrillic_Capital_SOFTSIGN = $6f8; + GDK_cyrillic_Capital_YERU = $6f9; + GDK_cyrillic_Capital_ZE = $6fa; + GDK_cyrillic_Capital_SHA = $6fb; + GDK_cyrillic_Capital_E = $6fc; + GDK_cyrillic_Capital_SHCHA = $6fd; + GDK_cyrillic_Capital_CHE = $6fe; + GDK_cyrillic_Capital_HARDSIGN = $6ff; + GDK_greek_Capital_ALPHAaccent = $7a1; + GDK_greek_Capital_EPSILONaccent = $7a2; + GDK_greek_Capital_ETAaccent = $7a3; + GDK_greek_Capital_IOTAaccent = $7a4; + GDK_greek_Capital_IOTAdiaeresis = $7a5; + GDK_greek_Capital_OMICRONaccent = $7a7; + GDK_greek_Capital_UPSILONaccent = $7a8; + GDK_greek_Capital_UPSILONdieresis = $7a9; + GDK_greek_Capital_OMEGAaccent = $7ab; + GDK_greek_accentdieresis = $7ae; + GDK_greek_horizbar = $7af; + GDK_greek_alphaaccent = $7b1; + GDK_greek_epsilonaccent = $7b2; + GDK_greek_etaaccent = $7b3; + GDK_greek_iotaaccent = $7b4; + GDK_greek_iotadieresis = $7b5; + GDK_greek_iotaaccentdieresis = $7b6; + GDK_greek_omicronaccent = $7b7; + GDK_greek_upsilonaccent = $7b8; + GDK_greek_upsilondieresis = $7b9; + GDK_greek_upsilonaccentdieresis = $7ba; + GDK_greek_omegaaccent = $7bb; + GDK_greek_Capital_ALPHA = $7c1; + GDK_greek_Capital_BETA = $7c2; + GDK_greek_Capital_GAMMA = $7c3; + GDK_greek_Capital_DELTA = $7c4; + GDK_greek_Capital_EPSILON = $7c5; + GDK_greek_Capital_ZETA = $7c6; + GDK_greek_Capital_ETA = $7c7; + GDK_greek_Capital_THETA = $7c8; + GDK_greek_Capital_IOTA = $7c9; + GDK_greek_Capital_KAPPA = $7ca; + GDK_greek_Capital_LAMDA = $7cb; + GDK_greek_Capital_LAMBDA = $7cb; + GDK_greek_Capital_MU = $7cc; + GDK_greek_Capital_NU = $7cd; + GDK_greek_Capital_XI = $7ce; + GDK_greek_Capital_OMICRON = $7cf; + GDK_greek_Capital_PI = $7d0; + GDK_greek_Capital_RHO = $7d1; + GDK_greek_Capital_SIGMA = $7d2; + GDK_greek_Capital_TAU = $7d4; + GDK_greek_Capital_UPSILON = $7d5; + GDK_greek_Capital_PHI = $7d6; + GDK_greek_Capital_CHI = $7d7; + GDK_greek_Capital_PSI = $7d8; + GDK_greek_Capital_OMEGA = $7d9; + GDK_greek_alpha = $7e1; + GDK_greek_beta = $7e2; + GDK_greek_gamma = $7e3; + GDK_greek_delta = $7e4; + GDK_greek_epsilon = $7e5; + GDK_greek_zeta = $7e6; + GDK_greek_eta = $7e7; + GDK_greek_theta = $7e8; + GDK_greek_iota = $7e9; + GDK_greek_kappa = $7ea; + GDK_greek_lamda = $7eb; + GDK_greek_lambda = $7eb; + GDK_greek_mu = $7ec; + GDK_greek_nu = $7ed; + GDK_greek_xi = $7ee; + GDK_greek_omicron = $7ef; + GDK_greek_pi = $7f0; + GDK_greek_rho = $7f1; + GDK_greek_sigma = $7f2; + GDK_greek_finalsmallsigma = $7f3; + GDK_greek_tau = $7f4; + GDK_greek_upsilon = $7f5; + GDK_greek_phi = $7f6; + GDK_greek_chi = $7f7; + GDK_greek_psi = $7f8; + GDK_greek_omega = $7f9; + GDK_greek_switch = $FF7E; + GDK_leftradical = $8a1; + GDK_topleftradical = $8a2; + GDK_horizconnector = $8a3; + GDK_topintegral = $8a4; + GDK_botintegral = $8a5; + GDK_vertconnector = $8a6; + GDK_topleftsqbracket = $8a7; + GDK_botleftsqbracket = $8a8; + GDK_toprightsqbracket = $8a9; + GDK_botrightsqbracket = $8aa; + GDK_topleftparens = $8ab; + GDK_botleftparens = $8ac; + GDK_toprightparens = $8ad; + GDK_botrightparens = $8ae; + GDK_leftmiddlecurlybrace = $8af; + GDK_rightmiddlecurlybrace = $8b0; + GDK_topleftsummation = $8b1; + GDK_botleftsummation = $8b2; + GDK_topvertsummationconnector = $8b3; + GDK_botvertsummationconnector = $8b4; + GDK_toprightsummation = $8b5; + GDK_botrightsummation = $8b6; + GDK_rightmiddlesummation = $8b7; + GDK_lessthanequal = $8bc; + GDK_notequal = $8bd; + GDK_greaterthanequal = $8be; + GDK_integral = $8bf; + GDK_therefore = $8c0; + GDK_variation = $8c1; + GDK_infinity = $8c2; + GDK_nabla = $8c5; + GDK_approximate = $8c8; + GDK_similarequal = $8c9; + GDK_ifonlyif = $8cd; + GDK_implies = $8ce; + GDK_identical = $8cf; + GDK_radical = $8d6; + GDK_includedin = $8da; + GDK_includes = $8db; + GDK_intersection = $8dc; + GDK_union = $8dd; + GDK_logicaland = $8de; + GDK_logicalor = $8df; + GDK_partialderivative = $8ef; + GDK_function = $8f6; + GDK_leftarrow = $8fb; + GDK_uparrow = $8fc; + GDK_rightarrow = $8fd; + GDK_downarrow = $8fe; + GDK_blank = $9df; + GDK_soliddiamond = $9e0; + GDK_checkerboard = $9e1; + GDK_ht = $9e2; + GDK_ff = $9e3; + GDK_cr = $9e4; + GDK_lf = $9e5; + GDK_nl = $9e8; + GDK_vt = $9e9; + GDK_lowrightcorner = $9ea; + GDK_uprightcorner = $9eb; + GDK_upleftcorner = $9ec; + GDK_lowleftcorner = $9ed; + GDK_crossinglines = $9ee; + GDK_horizlinescan1 = $9ef; + GDK_horizlinescan3 = $9f0; + GDK_horizlinescan5 = $9f1; + GDK_horizlinescan7 = $9f2; + GDK_horizlinescan9 = $9f3; + GDK_leftt = $9f4; + GDK_rightt = $9f5; + GDK_bott = $9f6; + GDK_topt = $9f7; + GDK_vertbar = $9f8; + GDK_emspace = $aa1; + GDK_enspace = $aa2; + GDK_em3space = $aa3; + GDK_em4space = $aa4; + GDK_digitspace = $aa5; + GDK_punctspace = $aa6; + GDK_thinspace = $aa7; + GDK_hairspace = $aa8; + GDK_emdash = $aa9; + GDK_endash = $aaa; + GDK_signifblank = $aac; + GDK_ellipsis = $aae; + GDK_doubbaselinedot = $aaf; + GDK_onethird = $ab0; + GDK_twothirds = $ab1; + GDK_onefifth = $ab2; + GDK_twofifths = $ab3; + GDK_threefifths = $ab4; + GDK_fourfifths = $ab5; + GDK_onesixth = $ab6; + GDK_fivesixths = $ab7; + GDK_careof = $ab8; + GDK_figdash = $abb; + GDK_leftanglebracket = $abc; + GDK_decimalpoint = $abd; + GDK_rightanglebracket = $abe; + GDK_marker = $abf; + GDK_oneeighth = $ac3; + GDK_threeeighths = $ac4; + GDK_fiveeighths = $ac5; + GDK_seveneighths = $ac6; + GDK_trademark = $ac9; + GDK_signaturemark = $aca; + GDK_trademarkincircle = $acb; + GDK_leftopentriangle = $acc; + GDK_rightopentriangle = $acd; + GDK_emopencircle = $ace; + GDK_emopenrectangle = $acf; + GDK_leftsinglequotemark = $ad0; + GDK_rightsinglequotemark = $ad1; + GDK_leftdoublequotemark = $ad2; + GDK_rightdoublequotemark = $ad3; + GDK_prescription = $ad4; + GDK_minutes = $ad6; + GDK_seconds = $ad7; + GDK_latincross = $ad9; + GDK_hexagram = $ada; + GDK_filledrectbullet = $adb; + GDK_filledlefttribullet = $adc; + GDK_filledrighttribullet = $add; + GDK_emfilledcircle = $ade; + GDK_emfilledrect = $adf; + GDK_enopencircbullet = $ae0; + GDK_enopensquarebullet = $ae1; + GDK_openrectbullet = $ae2; + GDK_opentribulletup = $ae3; + GDK_opentribulletdown = $ae4; + GDK_openstar = $ae5; + GDK_enfilledcircbullet = $ae6; + GDK_enfilledsqbullet = $ae7; + GDK_filledtribulletup = $ae8; + GDK_filledtribulletdown = $ae9; + GDK_leftpointer = $aea; + GDK_rightpointer = $aeb; + GDK_club = $aec; + GDK_diamond = $aed; + GDK_heart_key = $aee; + GDK_maltesecross = $af0; + GDK_dagger = $af1; + GDK_doubledagger = $af2; + GDK_checkmark = $af3; + GDK_ballotcross = $af4; + GDK_musicalsharp = $af5; + GDK_musicalflat = $af6; + GDK_malesymbol = $af7; + GDK_femalesymbol = $af8; + GDK_telephone = $af9; + GDK_telephonerecorder = $afa; + GDK_phonographcopyright = $afb; + GDK_caret = $afc; + GDK_singlelowquotemark = $afd; + GDK_doublelowquotemark = $afe; + GDK_cursor = $aff; + GDK_leftcaret = $ba3; + GDK_rightcaret = $ba6; + GDK_downcaret = $ba8; + GDK_upcaret = $ba9; + GDK_overbar = $bc0; + GDK_downtack = $bc2; + GDK_upshoe = $bc3; + GDK_downstile = $bc4; + GDK_underbar = $bc6; + GDK_jot = $bca; + GDK_quad = $bcc; + GDK_uptack = $bce; + GDK_circle_key = $bcf; + GDK_upstile = $bd3; + GDK_downshoe = $bd6; + GDK_rightshoe = $bd8; + GDK_leftshoe = $bda; + GDK_lefttack = $bdc; + GDK_righttack = $bfc; + GDK_hebrew_doublelowline = $cdf; + GDK_hebrew_aleph = $ce0; + GDK_hebrew_bet = $ce1; + GDK_hebrew_beth = $ce1; + GDK_hebrew_gimel = $ce2; + GDK_hebrew_gimmel = $ce2; + GDK_hebrew_dalet = $ce3; + GDK_hebrew_daleth = $ce3; + GDK_hebrew_he = $ce4; + GDK_hebrew_waw = $ce5; + GDK_hebrew_zain = $ce6; + GDK_hebrew_zayin = $ce6; + GDK_hebrew_chet = $ce7; + GDK_hebrew_het = $ce7; + GDK_hebrew_tet = $ce8; + GDK_hebrew_teth = $ce8; + GDK_hebrew_yod = $ce9; + GDK_hebrew_finalkaph = $cea; + GDK_hebrew_kaph = $ceb; + GDK_hebrew_lamed = $cec; + GDK_hebrew_finalmem = $ced; + GDK_hebrew_mem = $cee; + GDK_hebrew_finalnun = $cef; + GDK_hebrew_nun = $cf0; + GDK_hebrew_samech = $cf1; + GDK_hebrew_samekh = $cf1; + GDK_hebrew_ayin = $cf2; + GDK_hebrew_finalpe = $cf3; + GDK_hebrew_pe = $cf4; + GDK_hebrew_finalzade = $cf5; + GDK_hebrew_finalzadi = $cf5; + GDK_hebrew_zade = $cf6; + GDK_hebrew_zadi = $cf6; + GDK_hebrew_qoph = $cf7; + GDK_hebrew_kuf = $cf7; + GDK_hebrew_resh = $cf8; + GDK_hebrew_shin = $cf9; + GDK_hebrew_taw = $cfa; + GDK_hebrew_taf = $cfa; + GDK_Hebrew_switch = $FF7E; + GDK_Thai_kokai = $da1; + GDK_Thai_khokhai = $da2; + GDK_Thai_khokhuat = $da3; + GDK_Thai_khokhwai = $da4; + GDK_Thai_khokhon = $da5; + GDK_Thai_khorakhang = $da6; + GDK_Thai_ngongu = $da7; + GDK_Thai_chochan = $da8; + GDK_Thai_choching = $da9; + GDK_Thai_chochang = $daa; + GDK_Thai_soso = $dab; + GDK_Thai_chochoe = $dac; + GDK_Thai_yoying = $dad; + GDK_Thai_dochada = $dae; + GDK_Thai_topatak = $daf; + GDK_Thai_thothan = $db0; + GDK_Thai_thonangmontho = $db1; + GDK_Thai_thophuthao = $db2; + GDK_Thai_nonen = $db3; + GDK_Thai_dodek = $db4; + GDK_Thai_totao = $db5; + GDK_Thai_thothung = $db6; + GDK_Thai_thothahan = $db7; + GDK_Thai_thothong = $db8; + GDK_Thai_nonu = $db9; + GDK_Thai_bobaimai = $dba; + GDK_Thai_popla = $dbb; + GDK_Thai_phophung = $dbc; + GDK_Thai_fofa = $dbd; + GDK_Thai_phophan = $dbe; + GDK_Thai_fofan = $dbf; + GDK_Thai_phosamphao = $dc0; + GDK_Thai_moma = $dc1; + GDK_Thai_yoyak = $dc2; + GDK_Thai_rorua = $dc3; + GDK_Thai_ru = $dc4; + GDK_Thai_loling = $dc5; + GDK_Thai_lu = $dc6; + GDK_Thai_wowaen = $dc7; + GDK_Thai_sosala = $dc8; + GDK_Thai_sorusi = $dc9; + GDK_Thai_sosua = $dca; + GDK_Thai_hohip = $dcb; + GDK_Thai_lochula = $dcc; + GDK_Thai_oang = $dcd; + GDK_Thai_honokhuk = $dce; + GDK_Thai_paiyannoi = $dcf; + GDK_Thai_saraa = $dd0; + GDK_Thai_maihanakat = $dd1; + GDK_Thai_saraaa = $dd2; + GDK_Thai_saraam = $dd3; + GDK_Thai_sarai = $dd4; + GDK_Thai_saraii = $dd5; + GDK_Thai_saraue = $dd6; + GDK_Thai_sarauee = $dd7; + GDK_Thai_sarau = $dd8; + GDK_Thai_sarauu = $dd9; + GDK_Thai_phinthu = $dda; + GDK_Thai_maihanakat_maitho = $dde; + GDK_Thai_baht = $ddf; + GDK_Thai_sarae = $de0; + GDK_Thai_saraae = $de1; + GDK_Thai_sarao = $de2; + GDK_Thai_saraaimaimuan = $de3; + GDK_Thai_saraaimaimalai = $de4; + GDK_Thai_lakkhangyao = $de5; + GDK_Thai_maiyamok = $de6; + GDK_Thai_maitaikhu = $de7; + GDK_Thai_maiek = $de8; + GDK_Thai_maitho = $de9; + GDK_Thai_maitri = $dea; + GDK_Thai_maichattawa = $deb; + GDK_Thai_thanthakhat = $dec; + GDK_Thai_nikhahit = $ded; + GDK_Thai_leksun = $df0; + GDK_Thai_leknung = $df1; + GDK_Thai_leksong = $df2; + GDK_Thai_leksam = $df3; + GDK_Thai_leksi = $df4; + GDK_Thai_lekha = $df5; + GDK_Thai_lekhok = $df6; + GDK_Thai_lekchet = $df7; + GDK_Thai_lekpaet = $df8; + GDK_Thai_lekkao = $df9; + GDK_Hangul = $ff31; + GDK_Hangul_Start = $ff32; + GDK_Hangul_End = $ff33; + GDK_Hangul_Hanja = $ff34; + GDK_Hangul_Jamo = $ff35; + GDK_Hangul_Romaja = $ff36; + GDK_Hangul_Codeinput = $ff37; + GDK_Hangul_Jeonja = $ff38; + GDK_Hangul_Banja = $ff39; + GDK_Hangul_PreHanja = $ff3a; + GDK_Hangul_PostHanja = $ff3b; + GDK_Hangul_SingleCandidate = $ff3c; + GDK_Hangul_MultipleCandidate = $ff3d; + GDK_Hangul_PreviousCandidate = $ff3e; + GDK_Hangul_Special = $ff3f; + GDK_Hangul_switch = $FF7E; + GDK_Hangul_Kiyeog = $ea1; + GDK_Hangul_SsangKiyeog = $ea2; + GDK_Hangul_KiyeogSios = $ea3; + GDK_Hangul_Nieun = $ea4; + GDK_Hangul_NieunJieuj = $ea5; + GDK_Hangul_NieunHieuh = $ea6; + GDK_Hangul_Dikeud = $ea7; + GDK_Hangul_SsangDikeud = $ea8; + GDK_Hangul_Rieul = $ea9; + GDK_Hangul_RieulKiyeog = $eaa; + GDK_Hangul_RieulMieum = $eab; + GDK_Hangul_RieulPieub = $eac; + GDK_Hangul_RieulSios = $ead; + GDK_Hangul_RieulTieut = $eae; + GDK_Hangul_RieulPhieuf = $eaf; + GDK_Hangul_RieulHieuh = $eb0; + GDK_Hangul_Mieum = $eb1; + GDK_Hangul_Pieub = $eb2; + GDK_Hangul_SsangPieub = $eb3; + GDK_Hangul_PieubSios = $eb4; + GDK_Hangul_Sios = $eb5; + GDK_Hangul_SsangSios = $eb6; + GDK_Hangul_Ieung = $eb7; + GDK_Hangul_Jieuj = $eb8; + GDK_Hangul_SsangJieuj = $eb9; + GDK_Hangul_Cieuc = $eba; + GDK_Hangul_Khieuq = $ebb; + GDK_Hangul_Tieut = $ebc; + GDK_Hangul_Phieuf = $ebd; + GDK_Hangul_Hieuh = $ebe; + GDK_Hangul_A = $ebf; + GDK_Hangul_AE = $ec0; + GDK_Hangul_YA = $ec1; + GDK_Hangul_YAE = $ec2; + GDK_Hangul_EO = $ec3; + GDK_Hangul_E = $ec4; + GDK_Hangul_YEO = $ec5; + GDK_Hangul_YE = $ec6; + GDK_Hangul_O = $ec7; + GDK_Hangul_WA = $ec8; + GDK_Hangul_WAE = $ec9; + GDK_Hangul_OE = $eca; + GDK_Hangul_YO = $ecb; + GDK_Hangul_U = $ecc; + GDK_Hangul_WEO = $ecd; + GDK_Hangul_WE = $ece; + GDK_Hangul_WI = $ecf; + GDK_Hangul_YU = $ed0; + GDK_Hangul_EU = $ed1; + GDK_Hangul_YI = $ed2; + GDK_Hangul_I = $ed3; + GDK_Hangul_J_Kiyeog = $ed4; + GDK_Hangul_J_SsangKiyeog = $ed5; + GDK_Hangul_J_KiyeogSios = $ed6; + GDK_Hangul_J_Nieun = $ed7; + GDK_Hangul_J_NieunJieuj = $ed8; + GDK_Hangul_J_NieunHieuh = $ed9; + GDK_Hangul_J_Dikeud = $eda; + GDK_Hangul_J_Rieul = $edb; + GDK_Hangul_J_RieulKiyeog = $edc; + GDK_Hangul_J_RieulMieum = $edd; + GDK_Hangul_J_RieulPieub = $ede; + GDK_Hangul_J_RieulSios = $edf; + GDK_Hangul_J_RieulTieut = $ee0; + GDK_Hangul_J_RieulPhieuf = $ee1; + GDK_Hangul_J_RieulHieuh = $ee2; + GDK_Hangul_J_Mieum = $ee3; + GDK_Hangul_J_Pieub = $ee4; + GDK_Hangul_J_PieubSios = $ee5; + GDK_Hangul_J_Sios = $ee6; + GDK_Hangul_J_SsangSios = $ee7; + GDK_Hangul_J_Ieung = $ee8; + GDK_Hangul_J_Jieuj = $ee9; + GDK_Hangul_J_Cieuc = $eea; + GDK_Hangul_J_Khieuq = $eeb; + GDK_Hangul_J_Tieut = $eec; + GDK_Hangul_J_Phieuf = $eed; + GDK_Hangul_J_Hieuh = $eee; + GDK_Hangul_RieulYeorinHieuh = $eef; + GDK_Hangul_SunkyeongeumMieum = $ef0; + GDK_Hangul_SunkyeongeumPieub = $ef1; + GDK_Hangul_PanSios = $ef2; + GDK_Hangul_KkogjiDalrinIeung = $ef3; + GDK_Hangul_SunkyeongeumPhieuf = $ef4; + GDK_Hangul_YeorinHieuh = $ef5; + GDK_Hangul_AraeA = $ef6; + GDK_Hangul_AraeAE = $ef7; + GDK_Hangul_J_PanSios = $ef8; + GDK_Hangul_J_KkogjiDalrinIeung = $ef9; + GDK_Hangul_J_YeorinHieuh = $efa; + GDK_Korean_Won = $eff; + + {$IFNDEF FPC} + // Copied from keysym.pp in Lazarus + XK_VoidSymbol = $FFFFFF; { void symbol } + + XK_BackSpace = $FF08; { back space, back char } + XK_Tab = $FF09; + XK_Linefeed = $FF0A; { Linefeed, LF } + XK_Clear = $FF0B; + XK_Return = $FF0D; { Return, enter } + XK_Pause = $FF13; { Pause, hold } + XK_Scroll_Lock = $FF14; + XK_Sys_Req = $FF15; + XK_Escape = $FF1B; + XK_Delete = $FFFF; { Delete, rubout } + + XK_Multi_key = $FF20; { Multi-key character compose } + XK_Codeinput = $FF37; + XK_SingleCandidate = $FF3C; + XK_MultipleCandidate = $FF3D; + XK_PreviousCandidate = $FF3E; + + XK_Kanji = $FF21; { Kanji, Kanji convert } + XK_Muhenkan = $FF22; { Cancel Conversion } + XK_Henkan_Mode = $FF23; { Start/Stop Conversion } + XK_Henkan = $FF23; { Alias for Henkan_Mode } + XK_Romaji = $FF24; { to Romaji } + XK_Hiragana = $FF25; { to Hiragana } + XK_Katakana = $FF26; { to Katakana } + XK_Hiragana_Katakana = $FF27; { Hiragana/Katakana toggle } + XK_Zenkaku = $FF28; { to Zenkaku } + XK_Hankaku = $FF29; { to Hankaku } + XK_Zenkaku_Hankaku = $FF2A; { Zenkaku/Hankaku toggle } + XK_Touroku = $FF2B; { Add to Dictionary } + XK_Massyo = $FF2C; { Delete from Dictionary } + XK_Kana_Lock = $FF2D; { Kana Lock } + XK_Kana_Shift = $FF2E; { Kana Shift } + XK_Eisu_Shift = $FF2F; { Alphanumeric Shift } + XK_Eisu_toggle = $FF30; { Alphanumeric toggle } + XK_Kanji_Bangou = $FF37; { Codeinput } + XK_Zen_Koho = $FF3D; { Multiple/All Candidate(s) } + XK_Mae_Koho = $FF3E; { Previous Candidate } + + XK_Home = $FF50; + XK_Left = $FF51; { Move left, left arrow } + XK_Up = $FF52; { Move up, up arrow } + XK_Right = $FF53; { Move right, right arrow } + XK_Down = $FF54; { Move down, down arrow } + XK_Prior = $FF55; { Prior, previous } + XK_Page_Up = $FF55; + XK_Next = $FF56; { Next } + XK_Page_Down = $FF56; + XK_End = $FF57; { EOL } + XK_Begin = $FF58; { BOL } + + XK_Select = $FF60; { Select, mark } + XK_Print = $FF61; + XK_Execute = $FF62; { Execute, run, do } + XK_Insert = $FF63; { Insert, insert here } + XK_Undo = $FF65; { Undo, oops } + XK_Redo = $FF66; { redo, again } + XK_Menu = $FF67; + XK_Find = $FF68; { Find, search } + XK_Cancel = $FF69; { Cancel, stop, abort, exit } + XK_Help = $FF6A; { Help } + XK_Break = $FF6B; + XK_Mode_switch = $FF7E; { Character set switch } + XK_script_switch = $FF7E; { Alias for mode_switch } + XK_Num_Lock = $FF7F; + + XK_KP_Space = $FF80; { space } + XK_KP_Tab = $FF89; + XK_KP_Enter = $FF8D; { enter } + XK_KP_F1 = $FF91; { PF1, KP_A, ... } + XK_KP_F2 = $FF92; + XK_KP_F3 = $FF93; + XK_KP_F4 = $FF94; + XK_KP_Home = $FF95; + XK_KP_Left = $FF96; + XK_KP_Up = $FF97; + XK_KP_Right = $FF98; + XK_KP_Down = $FF99; + XK_KP_Prior = $FF9A; + XK_KP_Page_Up = $FF9A; + XK_KP_Next = $FF9B; + XK_KP_Page_Down = $FF9B; + XK_KP_End = $FF9C; + XK_KP_Begin = $FF9D; + XK_KP_Insert = $FF9E; + XK_KP_Delete = $FF9F; + XK_KP_Equal = $FFBD; { equals } + XK_KP_Multiply = $FFAA; + XK_KP_Add = $FFAB; + XK_KP_Separator = $FFAC; { separator, often comma } + XK_KP_Subtract = $FFAD; + XK_KP_Decimal = $FFAE; + XK_KP_Divide = $FFAF; + + XK_KP_0 = $FFB0; + XK_KP_1 = $FFB1; + XK_KP_2 = $FFB2; + XK_KP_3 = $FFB3; + XK_KP_4 = $FFB4; + XK_KP_5 = $FFB5; + XK_KP_6 = $FFB6; + XK_KP_7 = $FFB7; + XK_KP_8 = $FFB8; + XK_KP_9 = $FFB9; + + XK_F1 = $FFBE; + XK_F2 = $FFBF; + XK_F3 = $FFC0; + XK_F4 = $FFC1; + XK_F5 = $FFC2; + XK_F6 = $FFC3; + XK_F7 = $FFC4; + XK_F8 = $FFC5; + XK_F9 = $FFC6; + XK_F10 = $FFC7; + XK_F11 = $FFC8; + XK_L1 = $FFC8; + XK_F12 = $FFC9; + XK_L2 = $FFC9; + XK_F13 = $FFCA; + XK_L3 = $FFCA; + XK_F14 = $FFCB; + XK_L4 = $FFCB; + XK_F15 = $FFCC; + XK_L5 = $FFCC; + XK_F16 = $FFCD; + XK_L6 = $FFCD; + XK_F17 = $FFCE; + XK_L7 = $FFCE; + XK_F18 = $FFCF; + XK_L8 = $FFCF; + XK_F19 = $FFD0; + XK_L9 = $FFD0; + XK_F20 = $FFD1; + XK_L10 = $FFD1; + XK_F21 = $FFD2; + XK_R1 = $FFD2; + XK_F22 = $FFD3; + XK_R2 = $FFD3; + XK_F23 = $FFD4; + XK_R3 = $FFD4; + XK_F24 = $FFD5; + XK_R4 = $FFD5; + XK_F25 = $FFD6; + XK_R5 = $FFD6; + XK_F26 = $FFD7; + XK_R6 = $FFD7; + XK_F27 = $FFD8; + XK_R7 = $FFD8; + XK_F28 = $FFD9; + XK_R8 = $FFD9; + XK_F29 = $FFDA; + XK_R9 = $FFDA; + XK_F30 = $FFDB; + XK_R10 = $FFDB; + XK_F31 = $FFDC; + XK_R11 = $FFDC; + XK_F32 = $FFDD; + XK_R12 = $FFDD; + XK_F33 = $FFDE; + XK_R13 = $FFDE; + XK_F34 = $FFDF; + XK_R14 = $FFDF; + XK_F35 = $FFE0; + XK_R15 = $FFE0; + + XK_Shift_L = $FFE1; { Left shift } + XK_Shift_R = $FFE2; { Right shift } + XK_Control_L = $FFE3; { Left control } + XK_Control_R = $FFE4; { Right control } + XK_Caps_Lock = $FFE5; { Caps lock } + XK_Shift_Lock = $FFE6; { Shift lock } + + XK_Meta_L = $FFE7; { Left meta } + XK_Meta_R = $FFE8; { Right meta } + XK_Alt_L = $FFE9; { Left alt } + XK_Alt_R = $FFEA; { Right alt } + XK_Super_L = $FFEB; { Left super } + XK_Super_R = $FFEC; { Right super } + XK_Hyper_L = $FFED; { Left hyper } + XK_Hyper_R = $FFEE; { Right hyper } + + XK_ISO_Lock = $FE01; + XK_ISO_Level2_Latch = $FE02; + XK_ISO_Level3_Shift = $FE03; + XK_ISO_Level3_Latch = $FE04; + XK_ISO_Level3_Lock = $FE05; + XK_ISO_Level5_Shift = $FE11; + XK_ISO_Level5_Latch = $FE12; + XK_ISO_Level5_Lock = $FE13; + XK_ISO_Group_Shift = $FF7E; { Alias for mode_switch } + XK_ISO_Group_Latch = $FE06; + XK_ISO_Group_Lock = $FE07; + XK_ISO_Next_Group = $FE08; + XK_ISO_Next_Group_Lock = $FE09; + XK_ISO_Prev_Group = $FE0A; + XK_ISO_Prev_Group_Lock = $FE0B; + XK_ISO_First_Group = $FE0C; + XK_ISO_First_Group_Lock = $FE0D; + XK_ISO_Last_Group = $FE0E; + XK_ISO_Last_Group_Lock = $FE0F; + + XK_ISO_Left_Tab = $FE20; + XK_ISO_Move_Line_Up = $FE21; + XK_ISO_Move_Line_Down = $FE22; + XK_ISO_Partial_Line_Up = $FE23; + XK_ISO_Partial_Line_Down = $FE24; + XK_ISO_Partial_Space_Left = $FE25; + XK_ISO_Partial_Space_Right = $FE26; + XK_ISO_Set_Margin_Left = $FE27; + XK_ISO_Set_Margin_Right = $FE28; + XK_ISO_Release_Margin_Left = $FE29; + XK_ISO_Release_Margin_Right = $FE2A; + XK_ISO_Release_Both_Margins = $FE2B; + XK_ISO_Fast_Cursor_Left = $FE2C; + XK_ISO_Fast_Cursor_Right = $FE2D; + XK_ISO_Fast_Cursor_Up = $FE2E; + XK_ISO_Fast_Cursor_Down = $FE2F; + XK_ISO_Continuous_Underline = $FE30; + XK_ISO_Discontinuous_Underline = $FE31; + XK_ISO_Emphasize = $FE32; + XK_ISO_Center_Object = $FE33; + XK_ISO_Enter = $FE34; + + XK_dead_grave = $FE50; + XK_dead_acute = $FE51; + XK_dead_circumflex = $FE52; + XK_dead_tilde = $FE53; + XK_dead_perispomeni = $FE53; { alias for dead_tilde } + XK_dead_macron = $FE54; + XK_dead_breve = $FE55; + XK_dead_abovedot = $FE56; + XK_dead_diaeresis = $FE57; + XK_dead_abovering = $FE58; + XK_dead_doubleacute = $FE59; + XK_dead_caron = $FE5A; + XK_dead_cedilla = $FE5B; + XK_dead_ogonek = $FE5C; + XK_dead_iota = $FE5D; + XK_dead_voiced_sound = $FE5E; + XK_dead_semivoiced_sound = $FE5F; + XK_dead_belowdot = $FE60; + XK_dead_hook = $FE61; + XK_dead_horn = $FE62; + XK_dead_stroke = $FE63; + XK_dead_abovecomma = $FE64; + XK_dead_psili = $FE64; { alias for dead_abovecomma } + XK_dead_abovereversedcomma = $FE65; + XK_dead_dasia = $FE65; { alias for dead_abovereversedcomma } + XK_dead_doublegrave = $FE66; + XK_dead_belowring = $FE67; + XK_dead_belowmacron = $FE68; + XK_dead_belowcircumflex = $FE69; + XK_dead_belowtilde = $FE6A; + XK_dead_belowbreve = $FE6B; + XK_dead_belowdiaeresis = $FE6C; + XK_dead_invertedbreve = $FE6D; + XK_dead_belowcomma = $FE6E; + XK_dead_currency = $FE6F; + + XK_dead_lowline = $FE90; + XK_dead_aboveverticalline = $FE91; + XK_dead_belowverticalline = $FE92; + XK_dead_longsolidusoverlay = $FE93; + + XK_dead_a = $FE80; + XKc_dead_A = $FE81; + XK_dead_e = $FE82; + XKc_dead_E = $FE83; + XK_dead_i = $FE84; + XKc_dead_I = $FE85; + XK_dead_o = $FE86; + XKc_dead_O = $FE87; + XK_dead_u = $FE88; + XKc_dead_U = $FE89; + XK_dead_small_schwa = $FE8A; + XK_dead_capital_schwa = $FE8B; + + XK_dead_greek = $FE8C; + + XK_First_Virtual_Screen = $FED0; + XK_Prev_Virtual_Screen = $FED1; + XK_Next_Virtual_Screen = $FED2; + XK_Last_Virtual_Screen = $FED4; + XK_Terminate_Server = $FED5; + + XK_AccessX_Enable = $FE70; + XK_AccessX_Feedback_Enable = $FE71; + XK_RepeatKeys_Enable = $FE72; + XK_SlowKeys_Enable = $FE73; + XK_BounceKeys_Enable = $FE74; + XK_StickyKeys_Enable = $FE75; + XK_MouseKeys_Enable = $FE76; + XK_MouseKeys_Accel_Enable = $FE77; + XK_Overlay1_Enable = $FE78; + XK_Overlay2_Enable = $FE79; + XK_AudibleBell_Enable = $FE7A; + + XK_Pointer_Left = $FEE0; + XK_Pointer_Right = $FEE1; + XK_Pointer_Up = $FEE2; + XK_Pointer_Down = $FEE3; + XK_Pointer_UpLeft = $FEE4; + XK_Pointer_UpRight = $FEE5; + XK_Pointer_DownLeft = $FEE6; + XK_Pointer_DownRight = $FEE7; + XK_Pointer_Button_Dflt = $FEE8; + XK_Pointer_Button1 = $FEE9; + XK_Pointer_Button2 = $FEEA; + XK_Pointer_Button3 = $FEEB; + XK_Pointer_Button4 = $FEEC; + XK_Pointer_Button5 = $FEED; + XK_Pointer_DblClick_Dflt = $FEEE; + XK_Pointer_DblClick1 = $FEEF; + XK_Pointer_DblClick2 = $FEF0; + XK_Pointer_DblClick3 = $FEF1; + XK_Pointer_DblClick4 = $FEF2; + XK_Pointer_DblClick5 = $FEF3; + XK_Pointer_Drag_Dflt = $FEF4; + XK_Pointer_Drag1 = $FEF5; + XK_Pointer_Drag2 = $FEF6; + XK_Pointer_Drag3 = $FEF7; + XK_Pointer_Drag4 = $FEF8; + XK_Pointer_Drag5 = $FEFD; + + XK_Pointer_EnableKeys = $FEF9; + XK_Pointer_Accelerate = $FEFA; + XK_Pointer_DfltBtnNext = $FEFB; + XK_Pointer_DfltBtnPrev = $FEFC; + + XKll_ch = $FEA0; + XKcl_Ch = $FEA1; + XKcc_CH = $FEA2; + XKll_c_h = $FEA3; + XKcl_C_h = $FEA4; + XKcc_C_H = $FEA5; + + XK_3270_Duplicate = $FD01; + XK_3270_FieldMark = $FD02; + XK_3270_Right2 = $FD03; + XK_3270_Left2 = $FD04; + XK_3270_BackTab = $FD05; + XK_3270_EraseEOF = $FD06; + XK_3270_EraseInput = $FD07; + XK_3270_Reset = $FD08; + XK_3270_Quit = $FD09; + XK_3270_PA1 = $FD0A; + XK_3270_PA2 = $FD0B; + XK_3270_PA3 = $FD0C; + XK_3270_Test = $FD0D; + XK_3270_Attn = $FD0E; + XK_3270_CursorBlink = $FD0F; + XK_3270_AltCursor = $FD10; + XK_3270_KeyClick = $FD11; + XK_3270_Jump = $FD12; + XK_3270_Ident = $FD13; + XK_3270_Rule = $FD14; + XK_3270_Copy = $FD15; + XK_3270_Play = $FD16; + XK_3270_Setup = $FD17; + XK_3270_Record = $FD18; + XK_3270_ChangeScreen = $FD19; + XK_3270_DeleteWord = $FD1A; + XK_3270_ExSelect = $FD1B; + XK_3270_CursorSelect = $FD1C; + XK_3270_PrintScreen = $FD1D; + XK_3270_Enter = $FD1E; + + XK_space = $0020; { U+0020 SPACE } + XK_exclam = $0021; { U+0021 EXCLAMATION MARK } + XK_quotedbl = $0022; { U+0022 QUOTATION MARK } + XK_numbersign = $0023; { U+0023 NUMBER SIGN } + XK_dollar = $0024; { U+0024 DOLLAR SIGN } + XK_percent = $0025; { U+0025 PERCENT SIGN } + XK_ampersand = $0026; { U+0026 AMPERSAND } + XK_apostrophe = $0027; { U+0027 APOSTROPHE } + XK_quoteright = $0027; { deprecated } + XK_parenleft = $0028; { U+0028 LEFT PARENTHESIS } + XK_parenright = $0029; { U+0029 RIGHT PARENTHESIS } + XK_asterisk = $002a; { U+002A ASTERISK } + XK_plus = $002b; { U+002B PLUS SIGN } + XK_comma = $002c; { U+002C COMMA } + XK_minus = $002d; { U+002D HYPHEN-MINUS } + XK_period = $002e; { U+002E FULL STOP } + XK_slash = $002f; { U+002F SOLIDUS } + XK_0 = $0030; { U+0030 DIGIT ZERO } + XK_1 = $0031; { U+0031 DIGIT ONE } + XK_2 = $0032; { U+0032 DIGIT TWO } + XK_3 = $0033; { U+0033 DIGIT THREE } + XK_4 = $0034; { U+0034 DIGIT FOUR } + XK_5 = $0035; { U+0035 DIGIT FIVE } + XK_6 = $0036; { U+0036 DIGIT SIX } + XK_7 = $0037; { U+0037 DIGIT SEVEN } + XK_8 = $0038; { U+0038 DIGIT EIGHT } + XK_9 = $0039; { U+0039 DIGIT NINE } + XK_colon = $003a; { U+003A COLON } + XK_semicolon = $003b; { U+003B SEMICOLON } + XK_less = $003c; { U+003C LESS-THAN SIGN } + XK_equal = $003d; { U+003D EQUALS SIGN } + XK_greater = $003e; { U+003E GREATER-THAN SIGN } + XK_question = $003f; { U+003F QUESTION MARK } + XK_at = $0040; { U+0040 COMMERCIAL AT } + XKc_A = $0041; { U+0041 LATIN CAPITAL LETTER A } + XKc_B = $0042; { U+0042 LATIN CAPITAL LETTER B } + XKc_C = $0043; { U+0043 LATIN CAPITAL LETTER C } + XKc_D = $0044; { U+0044 LATIN CAPITAL LETTER D } + XKc_E = $0045; { U+0045 LATIN CAPITAL LETTER E } + XKc_F = $0046; { U+0046 LATIN CAPITAL LETTER F } + XKc_G = $0047; { U+0047 LATIN CAPITAL LETTER G } + XKc_H = $0048; { U+0048 LATIN CAPITAL LETTER H } + XKc_I = $0049; { U+0049 LATIN CAPITAL LETTER I } + XKc_J = $004a; { U+004A LATIN CAPITAL LETTER J } + XKc_K = $004b; { U+004B LATIN CAPITAL LETTER K } + XKc_L = $004c; { U+004C LATIN CAPITAL LETTER L } + XKc_M = $004d; { U+004D LATIN CAPITAL LETTER M } + XKc_N = $004e; { U+004E LATIN CAPITAL LETTER N } + XKc_O = $004f; { U+004F LATIN CAPITAL LETTER O } + XKc_P = $0050; { U+0050 LATIN CAPITAL LETTER P } + XKc_Q = $0051; { U+0051 LATIN CAPITAL LETTER Q } + XKc_R = $0052; { U+0052 LATIN CAPITAL LETTER R } + XKc_S = $0053; { U+0053 LATIN CAPITAL LETTER S } + XKc_T = $0054; { U+0054 LATIN CAPITAL LETTER T } + XKc_U = $0055; { U+0055 LATIN CAPITAL LETTER U } + XKc_V = $0056; { U+0056 LATIN CAPITAL LETTER V } + XKc_W = $0057; { U+0057 LATIN CAPITAL LETTER W } + XKc_X = $0058; { U+0058 LATIN CAPITAL LETTER X } + XKc_Y = $0059; { U+0059 LATIN CAPITAL LETTER Y } + XKc_Z = $005a; { U+005A LATIN CAPITAL LETTER Z } + XK_bracketleft = $005b; { U+005B LEFT SQUARE BRACKET } + XK_backslash = $005c; { U+005C REVERSE SOLIDUS } + XK_bracketright = $005d; { U+005D RIGHT SQUARE BRACKET } + XK_asciicircum = $005e; { U+005E CIRCUMFLEX ACCENT } + XK_underscore = $005f; { U+005F LOW LINE } + XK_grave = $0060; { U+0060 GRAVE ACCENT } + XK_quoteleft = $0060; { deprecated } + XK_a = $0061; { U+0061 LATIN SMALL LETTER A } + XK_b = $0062; { U+0062 LATIN SMALL LETTER B } + XK_c = $0063; { U+0063 LATIN SMALL LETTER C } + XK_d = $0064; { U+0064 LATIN SMALL LETTER D } + XK_e = $0065; { U+0065 LATIN SMALL LETTER E } + XK_f = $0066; { U+0066 LATIN SMALL LETTER F } + XK_g = $0067; { U+0067 LATIN SMALL LETTER G } + XK_h = $0068; { U+0068 LATIN SMALL LETTER H } + XK_i = $0069; { U+0069 LATIN SMALL LETTER I } + XK_j = $006a; { U+006A LATIN SMALL LETTER J } + XK_k = $006b; { U+006B LATIN SMALL LETTER K } + XK_l = $006c; { U+006C LATIN SMALL LETTER L } + XK_m = $006d; { U+006D LATIN SMALL LETTER M } + XK_n = $006e; { U+006E LATIN SMALL LETTER N } + XK_o = $006f; { U+006F LATIN SMALL LETTER O } + XK_p = $0070; { U+0070 LATIN SMALL LETTER P } + XK_q = $0071; { U+0071 LATIN SMALL LETTER Q } + XK_r = $0072; { U+0072 LATIN SMALL LETTER R } + XK_s = $0073; { U+0073 LATIN SMALL LETTER S } + XK_t = $0074; { U+0074 LATIN SMALL LETTER T } + XK_u = $0075; { U+0075 LATIN SMALL LETTER U } + XK_v = $0076; { U+0076 LATIN SMALL LETTER V } + XK_w = $0077; { U+0077 LATIN SMALL LETTER W } + XK_x = $0078; { U+0078 LATIN SMALL LETTER X } + XK_y = $0079; { U+0079 LATIN SMALL LETTER Y } + XK_z = $007a; { U+007A LATIN SMALL LETTER Z } + XK_braceleft = $007b; { U+007B LEFT CURLY BRACKET } + XK_bar = $007c; { U+007C VERTICAL LINE } + XK_braceright = $007d; { U+007D RIGHT CURLY BRACKET } + XK_asciitilde = $007e; { U+007E TILDE } + + XK_nobreakspace = $00a0; { U+00A0 NO-BREAK SPACE } + XK_exclamdown = $00a1; { U+00A1 INVERTED EXCLAMATION MARK } + XK_cent = $00a2; { U+00A2 CENT SIGN } + XK_sterling = $00a3; { U+00A3 POUND SIGN } + XK_currency = $00a4; { U+00A4 CURRENCY SIGN } + XK_yen = $00a5; { U+00A5 YEN SIGN } + XK_brokenbar = $00a6; { U+00A6 BROKEN BAR } + XK_section = $00a7; { U+00A7 SECTION SIGN } + XK_diaeresis = $00a8; { U+00A8 DIAERESIS } + XK_copyright = $00a9; { U+00A9 COPYRIGHT SIGN } + XK_ordfeminine = $00aa; { U+00AA FEMININE ORDINAL INDICATOR } + XK_guillemotleft = $00ab; { U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK } + XK_notsign = $00ac; { U+00AC NOT SIGN } + XK_hyphen = $00ad; { U+00AD SOFT HYPHEN } + XK_registered = $00ae; { U+00AE REGISTERED SIGN } + XK_macron = $00af; { U+00AF MACRON } + XK_degree = $00b0; { U+00B0 DEGREE SIGN } + XK_plusminus = $00b1; { U+00B1 PLUS-MINUS SIGN } + XK_twosuperior = $00b2; { U+00B2 SUPERSCRIPT TWO } + XK_threesuperior = $00b3; { U+00B3 SUPERSCRIPT THREE } + XK_acute = $00b4; { U+00B4 ACUTE ACCENT } + XK_mu = $00b5; { U+00B5 MICRO SIGN } + XK_paragraph = $00b6; { U+00B6 PILCROW SIGN } + XK_periodcentered = $00b7; { U+00B7 MIDDLE DOT } + XK_cedilla = $00b8; { U+00B8 CEDILLA } + XK_onesuperior = $00b9; { U+00B9 SUPERSCRIPT ONE } + XK_masculine = $00ba; { U+00BA MASCULINE ORDINAL INDICATOR } + XK_guillemotright = $00bb; { U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK } + XK_onequarter = $00bc; { U+00BC VULGAR FRACTION ONE QUARTER } + XK_onehalf = $00bd; { U+00BD VULGAR FRACTION ONE HALF } + XK_threequarters = $00be; { U+00BE VULGAR FRACTION THREE QUARTERS } + XK_questiondown = $00bf; { U+00BF INVERTED QUESTION MARK } + XKc_Agrave = $00c0; { U+00C0 LATIN CAPITAL LETTER A WITH GRAVE } + XKc_Aacute = $00c1; { U+00C1 LATIN CAPITAL LETTER A WITH ACUTE } + XKc_Acircumflex = $00c2; { U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX } + XKc_Atilde = $00c3; { U+00C3 LATIN CAPITAL LETTER A WITH TILDE } + XKc_Adiaeresis = $00c4; { U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS } + XKc_Aring = $00c5; { U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE } + XKc_AE = $00c6; { U+00C6 LATIN CAPITAL LETTER AE } + XKc_Ccedilla = $00c7; { U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA } + XKc_Egrave = $00c8; { U+00C8 LATIN CAPITAL LETTER E WITH GRAVE } + XKc_Eacute = $00c9; { U+00C9 LATIN CAPITAL LETTER E WITH ACUTE } + XKc_Ecircumflex = $00ca; { U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX } + XKc_Ediaeresis = $00cb; { U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS } + XKc_Igrave = $00cc; { U+00CC LATIN CAPITAL LETTER I WITH GRAVE } + XKc_Iacute = $00cd; { U+00CD LATIN CAPITAL LETTER I WITH ACUTE } + XKc_Icircumflex = $00ce; { U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX } + XKc_Idiaeresis = $00cf; { U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS } + XKc_ETH = $00d0; { U+00D0 LATIN CAPITAL LETTER ETH } + XKc_Ntilde = $00d1; { U+00D1 LATIN CAPITAL LETTER N WITH TILDE } + XKc_Ograve = $00d2; { U+00D2 LATIN CAPITAL LETTER O WITH GRAVE } + XKc_Oacute = $00d3; { U+00D3 LATIN CAPITAL LETTER O WITH ACUTE } + XKc_Ocircumflex = $00d4; { U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX } + XKc_Otilde = $00d5; { U+00D5 LATIN CAPITAL LETTER O WITH TILDE } + XKc_Odiaeresis = $00d6; { U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS } + XK_multiply = $00d7; { U+00D7 MULTIPLICATION SIGN } + XKc_Oslash = $00d8; { U+00D8 LATIN CAPITAL LETTER O WITH STROKE } + XKc_Ooblique = $00d8; { U+00D8 LATIN CAPITAL LETTER O WITH STROKE } + XKc_Ugrave = $00d9; { U+00D9 LATIN CAPITAL LETTER U WITH GRAVE } + XKc_Uacute = $00da; { U+00DA LATIN CAPITAL LETTER U WITH ACUTE } + XKc_Ucircumflex = $00db; { U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX } + XKc_Udiaeresis = $00dc; { U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS } + XKc_Yacute = $00dd; { U+00DD LATIN CAPITAL LETTER Y WITH ACUTE } + XKc_THORN = $00de; { U+00DE LATIN CAPITAL LETTER THORN } + XK_ssharp = $00df; { U+00DF LATIN SMALL LETTER SHARP S } + XK_agrave = $00e0; { U+00E0 LATIN SMALL LETTER A WITH GRAVE } + XK_aacute = $00e1; { U+00E1 LATIN SMALL LETTER A WITH ACUTE } + XK_acircumflex = $00e2; { U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX } + XK_atilde = $00e3; { U+00E3 LATIN SMALL LETTER A WITH TILDE } + XK_adiaeresis = $00e4; { U+00E4 LATIN SMALL LETTER A WITH DIAERESIS } + XK_aring = $00e5; { U+00E5 LATIN SMALL LETTER A WITH RING ABOVE } + XK_ae = $00e6; { U+00E6 LATIN SMALL LETTER AE } + XK_ccedilla = $00e7; { U+00E7 LATIN SMALL LETTER C WITH CEDILLA } + XK_egrave = $00e8; { U+00E8 LATIN SMALL LETTER E WITH GRAVE } + XK_eacute = $00e9; { U+00E9 LATIN SMALL LETTER E WITH ACUTE } + XK_ecircumflex = $00ea; { U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX } + XK_ediaeresis = $00eb; { U+00EB LATIN SMALL LETTER E WITH DIAERESIS } + XK_igrave = $00ec; { U+00EC LATIN SMALL LETTER I WITH GRAVE } + XK_iacute = $00ed; { U+00ED LATIN SMALL LETTER I WITH ACUTE } + XK_icircumflex = $00ee; { U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX } + XK_idiaeresis = $00ef; { U+00EF LATIN SMALL LETTER I WITH DIAERESIS } + XK_eth = $00f0; { U+00F0 LATIN SMALL LETTER ETH } + XK_ntilde = $00f1; { U+00F1 LATIN SMALL LETTER N WITH TILDE } + XK_ograve = $00f2; { U+00F2 LATIN SMALL LETTER O WITH GRAVE } + XK_oacute = $00f3; { U+00F3 LATIN SMALL LETTER O WITH ACUTE } + XK_ocircumflex = $00f4; { U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX } + XK_otilde = $00f5; { U+00F5 LATIN SMALL LETTER O WITH TILDE } + XK_odiaeresis = $00f6; { U+00F6 LATIN SMALL LETTER O WITH DIAERESIS } + XK_division = $00f7; { U+00F7 DIVISION SIGN } + XK_oslash = $00f8; { U+00F8 LATIN SMALL LETTER O WITH STROKE } + XK_ooblique = $00f8; { U+00F8 LATIN SMALL LETTER O WITH STROKE } + XK_ugrave = $00f9; { U+00F9 LATIN SMALL LETTER U WITH GRAVE } + XK_uacute = $00fa; { U+00FA LATIN SMALL LETTER U WITH ACUTE } + XK_ucircumflex = $00fb; { U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX } + XK_udiaeresis = $00fc; { U+00FC LATIN SMALL LETTER U WITH DIAERESIS } + XK_yacute = $00fd; { U+00FD LATIN SMALL LETTER Y WITH ACUTE } + XK_thorn = $00fe; { U+00FE LATIN SMALL LETTER THORN } + XK_ydiaeresis = $00ff; { U+00FF LATIN SMALL LETTER Y WITH DIAERESIS } + + XKc_Aogonek = $01a1; { U+0104 LATIN CAPITAL LETTER A WITH OGONEK } + XK_breve = $01a2; { U+02D8 BREVE } + XKc_Lstroke = $01a3; { U+0141 LATIN CAPITAL LETTER L WITH STROKE } + XKc_Lcaron = $01a5; { U+013D LATIN CAPITAL LETTER L WITH CARON } + XKc_Sacute = $01a6; { U+015A LATIN CAPITAL LETTER S WITH ACUTE } + XKc_Scaron = $01a9; { U+0160 LATIN CAPITAL LETTER S WITH CARON } + XKc_Scedilla = $01aa; { U+015E LATIN CAPITAL LETTER S WITH CEDILLA } + XKc_Tcaron = $01ab; { U+0164 LATIN CAPITAL LETTER T WITH CARON } + XKc_Zacute = $01ac; { U+0179 LATIN CAPITAL LETTER Z WITH ACUTE } + XKc_Zcaron = $01ae; { U+017D LATIN CAPITAL LETTER Z WITH CARON } + XKc_Zabovedot = $01af; { U+017B LATIN CAPITAL LETTER Z WITH DOT ABOVE } + XK_aogonek = $01b1; { U+0105 LATIN SMALL LETTER A WITH OGONEK } + XK_ogonek = $01b2; { U+02DB OGONEK } + XK_lstroke = $01b3; { U+0142 LATIN SMALL LETTER L WITH STROKE } + XK_lcaron = $01b5; { U+013E LATIN SMALL LETTER L WITH CARON } + XK_sacute = $01b6; { U+015B LATIN SMALL LETTER S WITH ACUTE } + XK_caron = $01b7; { U+02C7 CARON } + XK_scaron = $01b9; { U+0161 LATIN SMALL LETTER S WITH CARON } + XK_scedilla = $01ba; { U+015F LATIN SMALL LETTER S WITH CEDILLA } + XK_tcaron = $01bb; { U+0165 LATIN SMALL LETTER T WITH CARON } + XK_zacute = $01bc; { U+017A LATIN SMALL LETTER Z WITH ACUTE } + XK_doubleacute = $01bd; { U+02DD DOUBLE ACUTE ACCENT } + XK_zcaron = $01be; { U+017E LATIN SMALL LETTER Z WITH CARON } + XK_zabovedot = $01bf; { U+017C LATIN SMALL LETTER Z WITH DOT ABOVE } + XKc_Racute = $01c0; { U+0154 LATIN CAPITAL LETTER R WITH ACUTE } + XKc_Abreve = $01c3; { U+0102 LATIN CAPITAL LETTER A WITH BREVE } + XKc_Lacute = $01c5; { U+0139 LATIN CAPITAL LETTER L WITH ACUTE } + XKc_Cacute = $01c6; { U+0106 LATIN CAPITAL LETTER C WITH ACUTE } + XKc_Ccaron = $01c8; { U+010C LATIN CAPITAL LETTER C WITH CARON } + XKc_Eogonek = $01ca; { U+0118 LATIN CAPITAL LETTER E WITH OGONEK } + XKc_Ecaron = $01cc; { U+011A LATIN CAPITAL LETTER E WITH CARON } + XKc_Dcaron = $01cf; { U+010E LATIN CAPITAL LETTER D WITH CARON } + XKc_Dstroke = $01d0; { U+0110 LATIN CAPITAL LETTER D WITH STROKE } + XKc_Nacute = $01d1; { U+0143 LATIN CAPITAL LETTER N WITH ACUTE } + XKc_Ncaron = $01d2; { U+0147 LATIN CAPITAL LETTER N WITH CARON } + XKc_Odoubleacute = $01d5; { U+0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE } + XKc_Rcaron = $01d8; { U+0158 LATIN CAPITAL LETTER R WITH CARON } + XKc_Uring = $01d9; { U+016E LATIN CAPITAL LETTER U WITH RING ABOVE } + XKc_Udoubleacute = $01db; { U+0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE } + XKc_Tcedilla = $01de; { U+0162 LATIN CAPITAL LETTER T WITH CEDILLA } + XK_racute = $01e0; { U+0155 LATIN SMALL LETTER R WITH ACUTE } + XK_abreve = $01e3; { U+0103 LATIN SMALL LETTER A WITH BREVE } + XK_lacute = $01e5; { U+013A LATIN SMALL LETTER L WITH ACUTE } + XK_cacute = $01e6; { U+0107 LATIN SMALL LETTER C WITH ACUTE } + XK_ccaron = $01e8; { U+010D LATIN SMALL LETTER C WITH CARON } + XK_eogonek = $01ea; { U+0119 LATIN SMALL LETTER E WITH OGONEK } + XK_ecaron = $01ec; { U+011B LATIN SMALL LETTER E WITH CARON } + XK_dcaron = $01ef; { U+010F LATIN SMALL LETTER D WITH CARON } + XK_dstroke = $01f0; { U+0111 LATIN SMALL LETTER D WITH STROKE } + XK_nacute = $01f1; { U+0144 LATIN SMALL LETTER N WITH ACUTE } + XK_ncaron = $01f2; { U+0148 LATIN SMALL LETTER N WITH CARON } + XK_odoubleacute = $01f5; { U+0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE } + XK_rcaron = $01f8; { U+0159 LATIN SMALL LETTER R WITH CARON } + XK_uring = $01f9; { U+016F LATIN SMALL LETTER U WITH RING ABOVE } + XK_udoubleacute = $01fb; { U+0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE } + XK_tcedilla = $01fe; { U+0163 LATIN SMALL LETTER T WITH CEDILLA } + XK_abovedot = $01ff; { U+02D9 DOT ABOVE } + + XKc_Hstroke = $02a1; { U+0126 LATIN CAPITAL LETTER H WITH STROKE } + XKc_Hcircumflex = $02a6; { U+0124 LATIN CAPITAL LETTER H WITH CIRCUMFLEX } + XKc_Iabovedot = $02a9; { U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE } + XKc_Gbreve = $02ab; { U+011E LATIN CAPITAL LETTER G WITH BREVE } + XKc_Jcircumflex = $02ac; { U+0134 LATIN CAPITAL LETTER J WITH CIRCUMFLEX } + XK_hstroke = $02b1; { U+0127 LATIN SMALL LETTER H WITH STROKE } + XK_hcircumflex = $02b6; { U+0125 LATIN SMALL LETTER H WITH CIRCUMFLEX } + XK_idotless = $02b9; { U+0131 LATIN SMALL LETTER DOTLESS I } + XK_gbreve = $02bb; { U+011F LATIN SMALL LETTER G WITH BREVE } + XK_jcircumflex = $02bc; { U+0135 LATIN SMALL LETTER J WITH CIRCUMFLEX } + XKc_Cabovedot = $02c5; { U+010A LATIN CAPITAL LETTER C WITH DOT ABOVE } + XKc_Ccircumflex = $02c6; { U+0108 LATIN CAPITAL LETTER C WITH CIRCUMFLEX } + XKc_Gabovedot = $02d5; { U+0120 LATIN CAPITAL LETTER G WITH DOT ABOVE } + XKc_Gcircumflex = $02d8; { U+011C LATIN CAPITAL LETTER G WITH CIRCUMFLEX } + XKc_Ubreve = $02dd; { U+016C LATIN CAPITAL LETTER U WITH BREVE } + XKc_Scircumflex = $02de; { U+015C LATIN CAPITAL LETTER S WITH CIRCUMFLEX } + XK_cabovedot = $02e5; { U+010B LATIN SMALL LETTER C WITH DOT ABOVE } + XK_ccircumflex = $02e6; { U+0109 LATIN SMALL LETTER C WITH CIRCUMFLEX } + XK_gabovedot = $02f5; { U+0121 LATIN SMALL LETTER G WITH DOT ABOVE } + XK_gcircumflex = $02f8; { U+011D LATIN SMALL LETTER G WITH CIRCUMFLEX } + XK_ubreve = $02fd; { U+016D LATIN SMALL LETTER U WITH BREVE } + XK_scircumflex = $02fe; { U+015D LATIN SMALL LETTER S WITH CIRCUMFLEX } + + XK_kra = $03a2; { U+0138 LATIN SMALL LETTER KRA } + XK_kappa = $03a2; { deprecated } + XKc_Rcedilla = $03a3; { U+0156 LATIN CAPITAL LETTER R WITH CEDILLA } + XKc_Itilde = $03a5; { U+0128 LATIN CAPITAL LETTER I WITH TILDE } + XKc_Lcedilla = $03a6; { U+013B LATIN CAPITAL LETTER L WITH CEDILLA } + XKc_Emacron = $03aa; { U+0112 LATIN CAPITAL LETTER E WITH MACRON } + XKc_Gcedilla = $03ab; { U+0122 LATIN CAPITAL LETTER G WITH CEDILLA } + XKc_Tslash = $03ac; { U+0166 LATIN CAPITAL LETTER T WITH STROKE } + XK_rcedilla = $03b3; { U+0157 LATIN SMALL LETTER R WITH CEDILLA } + XK_itilde = $03b5; { U+0129 LATIN SMALL LETTER I WITH TILDE } + XK_lcedilla = $03b6; { U+013C LATIN SMALL LETTER L WITH CEDILLA } + XK_emacron = $03ba; { U+0113 LATIN SMALL LETTER E WITH MACRON } + XK_gcedilla = $03bb; { U+0123 LATIN SMALL LETTER G WITH CEDILLA } + XK_tslash = $03bc; { U+0167 LATIN SMALL LETTER T WITH STROKE } + XKc_ENG = $03bd; { U+014A LATIN CAPITAL LETTER ENG } + XK_eng = $03bf; { U+014B LATIN SMALL LETTER ENG } + XKc_Amacron = $03c0; { U+0100 LATIN CAPITAL LETTER A WITH MACRON } + XKc_Iogonek = $03c7; { U+012E LATIN CAPITAL LETTER I WITH OGONEK } + XKc_Eabovedot = $03cc; { U+0116 LATIN CAPITAL LETTER E WITH DOT ABOVE } + XKc_Imacron = $03cf; { U+012A LATIN CAPITAL LETTER I WITH MACRON } + XKc_Ncedilla = $03d1; { U+0145 LATIN CAPITAL LETTER N WITH CEDILLA } + XKc_Omacron = $03d2; { U+014C LATIN CAPITAL LETTER O WITH MACRON } + XKc_Kcedilla = $03d3; { U+0136 LATIN CAPITAL LETTER K WITH CEDILLA } + XKc_Uogonek = $03d9; { U+0172 LATIN CAPITAL LETTER U WITH OGONEK } + XKc_Utilde = $03dd; { U+0168 LATIN CAPITAL LETTER U WITH TILDE } + XKc_Umacron = $03de; { U+016A LATIN CAPITAL LETTER U WITH MACRON } + XK_amacron = $03e0; { U+0101 LATIN SMALL LETTER A WITH MACRON } + XK_iogonek = $03e7; { U+012F LATIN SMALL LETTER I WITH OGONEK } + XK_eabovedot = $03ec; { U+0117 LATIN SMALL LETTER E WITH DOT ABOVE } + XK_imacron = $03ef; { U+012B LATIN SMALL LETTER I WITH MACRON } + XK_ncedilla = $03f1; { U+0146 LATIN SMALL LETTER N WITH CEDILLA } + XK_omacron = $03f2; { U+014D LATIN SMALL LETTER O WITH MACRON } + XK_kcedilla = $03f3; { U+0137 LATIN SMALL LETTER K WITH CEDILLA } + XK_uogonek = $03f9; { U+0173 LATIN SMALL LETTER U WITH OGONEK } + XK_utilde = $03fd; { U+0169 LATIN SMALL LETTER U WITH TILDE } + XK_umacron = $03fe; { U+016B LATIN SMALL LETTER U WITH MACRON } + + XKc_Wcircumflex = $1000174; { U+0174 LATIN CAPITAL LETTER W WITH CIRCUMFLEX } + XK_wcircumflex = $1000175; { U+0175 LATIN SMALL LETTER W WITH CIRCUMFLEX } + XKc_Ycircumflex = $1000176; { U+0176 LATIN CAPITAL LETTER Y WITH CIRCUMFLEX } + XK_ycircumflex = $1000177; { U+0177 LATIN SMALL LETTER Y WITH CIRCUMFLEX } + XKc_Babovedot = $1001e02; { U+1E02 LATIN CAPITAL LETTER B WITH DOT ABOVE } + XK_babovedot = $1001e03; { U+1E03 LATIN SMALL LETTER B WITH DOT ABOVE } + XKc_Dabovedot = $1001e0a; { U+1E0A LATIN CAPITAL LETTER D WITH DOT ABOVE } + XK_dabovedot = $1001e0b; { U+1E0B LATIN SMALL LETTER D WITH DOT ABOVE } + XKc_Fabovedot = $1001e1e; { U+1E1E LATIN CAPITAL LETTER F WITH DOT ABOVE } + XK_fabovedot = $1001e1f; { U+1E1F LATIN SMALL LETTER F WITH DOT ABOVE } + XKc_Mabovedot = $1001e40; { U+1E40 LATIN CAPITAL LETTER M WITH DOT ABOVE } + XK_mabovedot = $1001e41; { U+1E41 LATIN SMALL LETTER M WITH DOT ABOVE } + XKc_Pabovedot = $1001e56; { U+1E56 LATIN CAPITAL LETTER P WITH DOT ABOVE } + XK_pabovedot = $1001e57; { U+1E57 LATIN SMALL LETTER P WITH DOT ABOVE } + XKc_Sabovedot = $1001e60; { U+1E60 LATIN CAPITAL LETTER S WITH DOT ABOVE } + XK_sabovedot = $1001e61; { U+1E61 LATIN SMALL LETTER S WITH DOT ABOVE } + XKc_Tabovedot = $1001e6a; { U+1E6A LATIN CAPITAL LETTER T WITH DOT ABOVE } + XK_tabovedot = $1001e6b; { U+1E6B LATIN SMALL LETTER T WITH DOT ABOVE } + XKc_Wgrave = $1001e80; { U+1E80 LATIN CAPITAL LETTER W WITH GRAVE } + XK_wgrave = $1001e81; { U+1E81 LATIN SMALL LETTER W WITH GRAVE } + XKc_Wacute = $1001e82; { U+1E82 LATIN CAPITAL LETTER W WITH ACUTE } + XK_wacute = $1001e83; { U+1E83 LATIN SMALL LETTER W WITH ACUTE } + XKc_Wdiaeresis = $1001e84; { U+1E84 LATIN CAPITAL LETTER W WITH DIAERESIS } + XK_wdiaeresis = $1001e85; { U+1E85 LATIN SMALL LETTER W WITH DIAERESIS } + XKc_Ygrave = $1001ef2; { U+1EF2 LATIN CAPITAL LETTER Y WITH GRAVE } + XK_ygrave = $1001ef3; { U+1EF3 LATIN SMALL LETTER Y WITH GRAVE } + + XKc_OE = $13bc; { U+0152 LATIN CAPITAL LIGATURE OE } + XK_oe = $13bd; { U+0153 LATIN SMALL LIGATURE OE } + XKc_Ydiaeresis = $13be; { U+0178 LATIN CAPITAL LETTER Y WITH DIAERESIS } + + XK_overline = $047e; { U+203E OVERLINE } + XK_kana_fullstop = $04a1; { U+3002 IDEOGRAPHIC FULL STOP } + XK_kana_openingbracket = $04a2; { U+300C LEFT CORNER BRACKET } + XK_kana_closingbracket = $04a3; { U+300D RIGHT CORNER BRACKET } + XK_kana_comma = $04a4; { U+3001 IDEOGRAPHIC COMMA } + XK_kana_conjunctive = $04a5; { U+30FB KATAKANA MIDDLE DOT } + XK_kana_middledot = $04a5; { deprecated } + XKc_kana_WO = $04a6; { U+30F2 KATAKANA LETTER WO } + XK_kana_a = $04a7; { U+30A1 KATAKANA LETTER SMALL A } + XK_kana_i = $04a8; { U+30A3 KATAKANA LETTER SMALL I } + XK_kana_u = $04a9; { U+30A5 KATAKANA LETTER SMALL U } + XK_kana_e = $04aa; { U+30A7 KATAKANA LETTER SMALL E } + XK_kana_o = $04ab; { U+30A9 KATAKANA LETTER SMALL O } + XK_kana_ya = $04ac; { U+30E3 KATAKANA LETTER SMALL YA } + XK_kana_yu = $04ad; { U+30E5 KATAKANA LETTER SMALL YU } + XK_kana_yo = $04ae; { U+30E7 KATAKANA LETTER SMALL YO } + XK_kana_tsu = $04af; { U+30C3 KATAKANA LETTER SMALL TU } + XK_kana_tu = $04af; { deprecated } + XK_prolongedsound = $04b0; { U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK } + XKc_kana_A = $04b1; { U+30A2 KATAKANA LETTER A } + XKc_kana_I = $04b2; { U+30A4 KATAKANA LETTER I } + XKc_kana_U = $04b3; { U+30A6 KATAKANA LETTER U } + XKc_kana_E = $04b4; { U+30A8 KATAKANA LETTER E } + XKc_kana_O = $04b5; { U+30AA KATAKANA LETTER O } + XKc_kana_KA = $04b6; { U+30AB KATAKANA LETTER KA } + XKc_kana_KI = $04b7; { U+30AD KATAKANA LETTER KI } + XKc_kana_KU = $04b8; { U+30AF KATAKANA LETTER KU } + XKc_kana_KE = $04b9; { U+30B1 KATAKANA LETTER KE } + XKc_kana_KO = $04ba; { U+30B3 KATAKANA LETTER KO } + XKc_kana_SA = $04bb; { U+30B5 KATAKANA LETTER SA } + XKc_kana_SHI = $04bc; { U+30B7 KATAKANA LETTER SI } + XKc_kana_SU = $04bd; { U+30B9 KATAKANA LETTER SU } + XKc_kana_SE = $04be; { U+30BB KATAKANA LETTER SE } + XKc_kana_SO = $04bf; { U+30BD KATAKANA LETTER SO } + XKc_kana_TA = $04c0; { U+30BF KATAKANA LETTER TA } + XKc_kana_CHI = $04c1; { U+30C1 KATAKANA LETTER TI } + XKc_kana_TI = $04c1; { deprecated } + XKc_kana_TSU = $04c2; { U+30C4 KATAKANA LETTER TU } + XKc_kana_TU = $04c2; { deprecated } + XKc_kana_TE = $04c3; { U+30C6 KATAKANA LETTER TE } + XKc_kana_TO = $04c4; { U+30C8 KATAKANA LETTER TO } + XKc_kana_NA = $04c5; { U+30CA KATAKANA LETTER NA } + XKc_kana_NI = $04c6; { U+30CB KATAKANA LETTER NI } + XKc_kana_NU = $04c7; { U+30CC KATAKANA LETTER NU } + XKc_kana_NE = $04c8; { U+30CD KATAKANA LETTER NE } + XKc_kana_NO = $04c9; { U+30CE KATAKANA LETTER NO } + XKc_kana_HA = $04ca; { U+30CF KATAKANA LETTER HA } + XKc_kana_HI = $04cb; { U+30D2 KATAKANA LETTER HI } + XKc_kana_FU = $04cc; { U+30D5 KATAKANA LETTER HU } + XKc_kana_HU = $04cc; { deprecated } + XKc_kana_HE = $04cd; { U+30D8 KATAKANA LETTER HE } + XKc_kana_HO = $04ce; { U+30DB KATAKANA LETTER HO } + XKc_kana_MA = $04cf; { U+30DE KATAKANA LETTER MA } + XKc_kana_MI = $04d0; { U+30DF KATAKANA LETTER MI } + XKc_kana_MU = $04d1; { U+30E0 KATAKANA LETTER MU } + XKc_kana_ME = $04d2; { U+30E1 KATAKANA LETTER ME } + XKc_kana_MO = $04d3; { U+30E2 KATAKANA LETTER MO } + XKc_kana_YA = $04d4; { U+30E4 KATAKANA LETTER YA } + XKc_kana_YU = $04d5; { U+30E6 KATAKANA LETTER YU } + XKc_kana_YO = $04d6; { U+30E8 KATAKANA LETTER YO } + XKc_kana_RA = $04d7; { U+30E9 KATAKANA LETTER RA } + XKc_kana_RI = $04d8; { U+30EA KATAKANA LETTER RI } + XKc_kana_RU = $04d9; { U+30EB KATAKANA LETTER RU } + XKc_kana_RE = $04da; { U+30EC KATAKANA LETTER RE } + XKc_kana_RO = $04db; { U+30ED KATAKANA LETTER RO } + XKc_kana_WA = $04dc; { U+30EF KATAKANA LETTER WA } + XKc_kana_N = $04dd; { U+30F3 KATAKANA LETTER N } + XK_voicedsound = $04de; { U+309B KATAKANA-HIRAGANA VOICED SOUND MARK } + XK_semivoicedsound = $04df; { U+309C KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK } + XK_kana_switch = $ff7e; { Alias for mode_switch } + + XK_Farsi_0 = $10006f0; { U+06F0 EXTENDED ARABIC-INDIC DIGIT ZERO } + XK_Farsi_1 = $10006f1; { U+06F1 EXTENDED ARABIC-INDIC DIGIT ONE } + XK_Farsi_2 = $10006f2; { U+06F2 EXTENDED ARABIC-INDIC DIGIT TWO } + XK_Farsi_3 = $10006f3; { U+06F3 EXTENDED ARABIC-INDIC DIGIT THREE } + XK_Farsi_4 = $10006f4; { U+06F4 EXTENDED ARABIC-INDIC DIGIT FOUR } + XK_Farsi_5 = $10006f5; { U+06F5 EXTENDED ARABIC-INDIC DIGIT FIVE } + XK_Farsi_6 = $10006f6; { U+06F6 EXTENDED ARABIC-INDIC DIGIT SIX } + XK_Farsi_7 = $10006f7; { U+06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN } + XK_Farsi_8 = $10006f8; { U+06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT } + XK_Farsi_9 = $10006f9; { U+06F9 EXTENDED ARABIC-INDIC DIGIT NINE } + XK_Arabic_percent = $100066a; { U+066A ARABIC PERCENT SIGN } + XK_Arabic_superscript_alef = $1000670; { U+0670 ARABIC LETTER SUPERSCRIPT ALEF } + XK_Arabic_tteh = $1000679; { U+0679 ARABIC LETTER TTEH } + XK_Arabic_peh = $100067e; { U+067E ARABIC LETTER PEH } + XK_Arabic_tcheh = $1000686; { U+0686 ARABIC LETTER TCHEH } + XK_Arabic_ddal = $1000688; { U+0688 ARABIC LETTER DDAL } + XK_Arabic_rreh = $1000691; { U+0691 ARABIC LETTER RREH } + XK_Arabic_comma = $05ac; { U+060C ARABIC COMMA } + XK_Arabic_fullstop = $10006d4; { U+06D4 ARABIC FULL STOP } + XK_Arabic_0 = $1000660; { U+0660 ARABIC-INDIC DIGIT ZERO } + XK_Arabic_1 = $1000661; { U+0661 ARABIC-INDIC DIGIT ONE } + XK_Arabic_2 = $1000662; { U+0662 ARABIC-INDIC DIGIT TWO } + XK_Arabic_3 = $1000663; { U+0663 ARABIC-INDIC DIGIT THREE } + XK_Arabic_4 = $1000664; { U+0664 ARABIC-INDIC DIGIT FOUR } + XK_Arabic_5 = $1000665; { U+0665 ARABIC-INDIC DIGIT FIVE } + XK_Arabic_6 = $1000666; { U+0666 ARABIC-INDIC DIGIT SIX } + XK_Arabic_7 = $1000667; { U+0667 ARABIC-INDIC DIGIT SEVEN } + XK_Arabic_8 = $1000668; { U+0668 ARABIC-INDIC DIGIT EIGHT } + XK_Arabic_9 = $1000669; { U+0669 ARABIC-INDIC DIGIT NINE } + XK_Arabic_semicolon = $05bb; { U+061B ARABIC SEMICOLON } + XK_Arabic_question_mark = $05bf; { U+061F ARABIC QUESTION MARK } + XK_Arabic_hamza = $05c1; { U+0621 ARABIC LETTER HAMZA } + XK_Arabic_maddaonalef = $05c2; { U+0622 ARABIC LETTER ALEF WITH MADDA ABOVE } + XK_Arabic_hamzaonalef = $05c3; { U+0623 ARABIC LETTER ALEF WITH HAMZA ABOVE } + XK_Arabic_hamzaonwaw = $05c4; { U+0624 ARABIC LETTER WAW WITH HAMZA ABOVE } + XK_Arabic_hamzaunderalef = $05c5; { U+0625 ARABIC LETTER ALEF WITH HAMZA BELOW } + XK_Arabic_hamzaonyeh = $05c6; { U+0626 ARABIC LETTER YEH WITH HAMZA ABOVE } + XK_Arabic_alef = $05c7; { U+0627 ARABIC LETTER ALEF } + XK_Arabic_beh = $05c8; { U+0628 ARABIC LETTER BEH } + XK_Arabic_tehmarbuta = $05c9; { U+0629 ARABIC LETTER TEH MARBUTA } + XK_Arabic_teh = $05ca; { U+062A ARABIC LETTER TEH } + XK_Arabic_theh = $05cb; { U+062B ARABIC LETTER THEH } + XK_Arabic_jeem = $05cc; { U+062C ARABIC LETTER JEEM } + XK_Arabic_hah = $05cd; { U+062D ARABIC LETTER HAH } + XK_Arabic_khah = $05ce; { U+062E ARABIC LETTER KHAH } + XK_Arabic_dal = $05cf; { U+062F ARABIC LETTER DAL } + XK_Arabic_thal = $05d0; { U+0630 ARABIC LETTER THAL } + XK_Arabic_ra = $05d1; { U+0631 ARABIC LETTER REH } + XK_Arabic_zain = $05d2; { U+0632 ARABIC LETTER ZAIN } + XK_Arabic_seen = $05d3; { U+0633 ARABIC LETTER SEEN } + XK_Arabic_sheen = $05d4; { U+0634 ARABIC LETTER SHEEN } + XK_Arabic_sad = $05d5; { U+0635 ARABIC LETTER SAD } + XK_Arabic_dad = $05d6; { U+0636 ARABIC LETTER DAD } + XK_Arabic_tah = $05d7; { U+0637 ARABIC LETTER TAH } + XK_Arabic_zah = $05d8; { U+0638 ARABIC LETTER ZAH } + XK_Arabic_ain = $05d9; { U+0639 ARABIC LETTER AIN } + XK_Arabic_ghain = $05da; { U+063A ARABIC LETTER GHAIN } + XK_Arabic_tatweel = $05e0; { U+0640 ARABIC TATWEEL } + XK_Arabic_feh = $05e1; { U+0641 ARABIC LETTER FEH } + XK_Arabic_qaf = $05e2; { U+0642 ARABIC LETTER QAF } + XK_Arabic_kaf = $05e3; { U+0643 ARABIC LETTER KAF } + XK_Arabic_lam = $05e4; { U+0644 ARABIC LETTER LAM } + XK_Arabic_meem = $05e5; { U+0645 ARABIC LETTER MEEM } + XK_Arabic_noon = $05e6; { U+0646 ARABIC LETTER NOON } + XK_Arabic_ha = $05e7; { U+0647 ARABIC LETTER HEH } + XK_Arabic_heh = $05e7; { deprecated } + XK_Arabic_waw = $05e8; { U+0648 ARABIC LETTER WAW } + XK_Arabic_alefmaksura = $05e9; { U+0649 ARABIC LETTER ALEF MAKSURA } + XK_Arabic_yeh = $05ea; { U+064A ARABIC LETTER YEH } + XK_Arabic_fathatan = $05eb; { U+064B ARABIC FATHATAN } + XK_Arabic_dammatan = $05ec; { U+064C ARABIC DAMMATAN } + XK_Arabic_kasratan = $05ed; { U+064D ARABIC KASRATAN } + XK_Arabic_fatha = $05ee; { U+064E ARABIC FATHA } + XK_Arabic_damma = $05ef; { U+064F ARABIC DAMMA } + XK_Arabic_kasra = $05f0; { U+0650 ARABIC KASRA } + XK_Arabic_shadda = $05f1; { U+0651 ARABIC SHADDA } + XK_Arabic_sukun = $05f2; { U+0652 ARABIC SUKUN } + XK_Arabic_madda_above = $1000653; { U+0653 ARABIC MADDAH ABOVE } + XK_Arabic_hamza_above = $1000654; { U+0654 ARABIC HAMZA ABOVE } + XK_Arabic_hamza_below = $1000655; { U+0655 ARABIC HAMZA BELOW } + XK_Arabic_jeh = $1000698; { U+0698 ARABIC LETTER JEH } + XK_Arabic_veh = $10006a4; { U+06A4 ARABIC LETTER VEH } + XK_Arabic_keheh = $10006a9; { U+06A9 ARABIC LETTER KEHEH } + XK_Arabic_gaf = $10006af; { U+06AF ARABIC LETTER GAF } + XK_Arabic_noon_ghunna = $10006ba; { U+06BA ARABIC LETTER NOON GHUNNA } + XK_Arabic_heh_doachashmee = $10006be; { U+06BE ARABIC LETTER HEH DOACHASHMEE } + XK_Farsi_yeh = $10006cc; { U+06CC ARABIC LETTER FARSI YEH } + XK_Arabic_farsi_yeh = $10006cc; { U+06CC ARABIC LETTER FARSI YEH } + XK_Arabic_yeh_baree = $10006d2; { U+06D2 ARABIC LETTER YEH BARREE } + XK_Arabic_heh_goal = $10006c1; { U+06C1 ARABIC LETTER HEH GOAL } + XK_Arabic_switch = $ff7e; { Alias for mode_switch } + + XKc_Cyrillic_GHE_bar = $1000492; { U+0492 CYRILLIC CAPITAL LETTER GHE WITH STROKE } + XK_Cyrillic_ghe_bar = $1000493; { U+0493 CYRILLIC SMALL LETTER GHE WITH STROKE } + XKc_Cyrillic_ZHE_descender = $1000496; { U+0496 CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER } + XK_Cyrillic_zhe_descender = $1000497; { U+0497 CYRILLIC SMALL LETTER ZHE WITH DESCENDER } + XKc_Cyrillic_KA_descender = $100049a; { U+049A CYRILLIC CAPITAL LETTER KA WITH DESCENDER } + XK_Cyrillic_ka_descender = $100049b; { U+049B CYRILLIC SMALL LETTER KA WITH DESCENDER } + XKc_Cyrillic_KA_vertstroke = $100049c; { U+049C CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE } + XK_Cyrillic_ka_vertstroke = $100049d; { U+049D CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE } + XKc_Cyrillic_EN_descender = $10004a2; { U+04A2 CYRILLIC CAPITAL LETTER EN WITH DESCENDER } + XK_Cyrillic_en_descender = $10004a3; { U+04A3 CYRILLIC SMALL LETTER EN WITH DESCENDER } + XKc_Cyrillic_U_straight = $10004ae; { U+04AE CYRILLIC CAPITAL LETTER STRAIGHT U } + XK_Cyrillic_u_straight = $10004af; { U+04AF CYRILLIC SMALL LETTER STRAIGHT U } + XKc_Cyrillic_U_straight_bar = $10004b0; { U+04B0 CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE } + XK_Cyrillic_u_straight_bar = $10004b1; { U+04B1 CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE } + XKc_Cyrillic_HA_descender = $10004b2; { U+04B2 CYRILLIC CAPITAL LETTER HA WITH DESCENDER } + XK_Cyrillic_ha_descender = $10004b3; { U+04B3 CYRILLIC SMALL LETTER HA WITH DESCENDER } + XKc_Cyrillic_CHE_descender = $10004b6; { U+04B6 CYRILLIC CAPITAL LETTER CHE WITH DESCENDER } + XK_Cyrillic_che_descender = $10004b7; { U+04B7 CYRILLIC SMALL LETTER CHE WITH DESCENDER } + XKc_Cyrillic_CHE_vertstroke = $10004b8; { U+04B8 CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE } + XK_Cyrillic_che_vertstroke = $10004b9; { U+04B9 CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE } + XKc_Cyrillic_SHHA = $10004ba; { U+04BA CYRILLIC CAPITAL LETTER SHHA } + XK_Cyrillic_shha = $10004bb; { U+04BB CYRILLIC SMALL LETTER SHHA } + + XKc_Cyrillic_SCHWA = $10004d8; { U+04D8 CYRILLIC CAPITAL LETTER SCHWA } + XK_Cyrillic_schwa = $10004d9; { U+04D9 CYRILLIC SMALL LETTER SCHWA } + XKc_Cyrillic_I_macron = $10004e2; { U+04E2 CYRILLIC CAPITAL LETTER I WITH MACRON } + XK_Cyrillic_i_macron = $10004e3; { U+04E3 CYRILLIC SMALL LETTER I WITH MACRON } + XKc_Cyrillic_O_bar = $10004e8; { U+04E8 CYRILLIC CAPITAL LETTER BARRED O } + XK_Cyrillic_o_bar = $10004e9; { U+04E9 CYRILLIC SMALL LETTER BARRED O } + XKc_Cyrillic_U_macron = $10004ee; { U+04EE CYRILLIC CAPITAL LETTER U WITH MACRON } + XK_Cyrillic_u_macron = $10004ef; { U+04EF CYRILLIC SMALL LETTER U WITH MACRON } + + XK_Serbian_dje = $06a1; { U+0452 CYRILLIC SMALL LETTER DJE } + XK_Macedonia_gje = $06a2; { U+0453 CYRILLIC SMALL LETTER GJE } + XK_Cyrillic_io = $06a3; { U+0451 CYRILLIC SMALL LETTER IO } + XK_Ukrainian_ie = $06a4; { U+0454 CYRILLIC SMALL LETTER UKRAINIAN IE } + XK_Ukranian_je = $06a4; { deprecated } + XK_Macedonia_dse = $06a5; { U+0455 CYRILLIC SMALL LETTER DZE } + XK_Ukrainian_i = $06a6; { U+0456 CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I } + XK_Ukranian_i = $06a6; { deprecated } + XK_Ukrainian_yi = $06a7; { U+0457 CYRILLIC SMALL LETTER YI } + XK_Ukranian_yi = $06a7; { deprecated } + XK_Cyrillic_je = $06a8; { U+0458 CYRILLIC SMALL LETTER JE } + XK_Serbian_je = $06a8; { deprecated } + XK_Cyrillic_lje = $06a9; { U+0459 CYRILLIC SMALL LETTER LJE } + XK_Serbian_lje = $06a9; { deprecated } + XK_Cyrillic_nje = $06aa; { U+045A CYRILLIC SMALL LETTER NJE } + XK_Serbian_nje = $06aa; { deprecated } + XK_Serbian_tshe = $06ab; { U+045B CYRILLIC SMALL LETTER TSHE } + XK_Macedonia_kje = $06ac; { U+045C CYRILLIC SMALL LETTER KJE } + XK_Ukrainian_ghe_with_upturn = $06ad; { U+0491 CYRILLIC SMALL LETTER GHE WITH UPTURN } + XK_Byelorussian_shortu = $06ae; { U+045E CYRILLIC SMALL LETTER SHORT U } + XK_Cyrillic_dzhe = $06af; { U+045F CYRILLIC SMALL LETTER DZHE } + XK_Serbian_dze = $06af; { deprecated } + XK_numerosign = $06b0; { U+2116 NUMERO SIGN } + XKc_Serbian_DJE = $06b1; { U+0402 CYRILLIC CAPITAL LETTER DJE } + XKc_Macedonia_GJE = $06b2; { U+0403 CYRILLIC CAPITAL LETTER GJE } + XKc_Cyrillic_IO = $06b3; { U+0401 CYRILLIC CAPITAL LETTER IO } + XKc_Ukrainian_IE = $06b4; { U+0404 CYRILLIC CAPITAL LETTER UKRAINIAN IE } + XKc_Ukranian_JE = $06b4; { deprecated } + XKc_Macedonia_DSE = $06b5; { U+0405 CYRILLIC CAPITAL LETTER DZE } + XKc_Ukrainian_I = $06b6; { U+0406 CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I } + XKc_Ukranian_I = $06b6; { deprecated } + XKc_Ukrainian_YI = $06b7; { U+0407 CYRILLIC CAPITAL LETTER YI } + XKc_Ukranian_YI = $06b7; { deprecated } + XKc_Cyrillic_JE = $06b8; { U+0408 CYRILLIC CAPITAL LETTER JE } + XKc_Serbian_JE = $06b8; { deprecated } + XKc_Cyrillic_LJE = $06b9; { U+0409 CYRILLIC CAPITAL LETTER LJE } + XKc_Serbian_LJE = $06b9; { deprecated } + XKc_Cyrillic_NJE = $06ba; { U+040A CYRILLIC CAPITAL LETTER NJE } + XKc_Serbian_NJE = $06ba; { deprecated } + XKc_Serbian_TSHE = $06bb; { U+040B CYRILLIC CAPITAL LETTER TSHE } + XKc_Macedonia_KJE = $06bc; { U+040C CYRILLIC CAPITAL LETTER KJE } + XKc_Ukrainian_GHE_WITH_UPTURN = $06bd; { U+0490 CYRILLIC CAPITAL LETTER GHE WITH UPTURN } + XKc_Byelorussian_SHORTU = $06be; { U+040E CYRILLIC CAPITAL LETTER SHORT U } + XKc_Cyrillic_DZHE = $06bf; { U+040F CYRILLIC CAPITAL LETTER DZHE } + XKc_Serbian_DZE = $06bf; { deprecated } + XK_Cyrillic_yu = $06c0; { U+044E CYRILLIC SMALL LETTER YU } + XK_Cyrillic_a = $06c1; { U+0430 CYRILLIC SMALL LETTER A } + XK_Cyrillic_be = $06c2; { U+0431 CYRILLIC SMALL LETTER BE } + XK_Cyrillic_tse = $06c3; { U+0446 CYRILLIC SMALL LETTER TSE } + XK_Cyrillic_de = $06c4; { U+0434 CYRILLIC SMALL LETTER DE } + XK_Cyrillic_ie = $06c5; { U+0435 CYRILLIC SMALL LETTER IE } + XK_Cyrillic_ef = $06c6; { U+0444 CYRILLIC SMALL LETTER EF } + XK_Cyrillic_ghe = $06c7; { U+0433 CYRILLIC SMALL LETTER GHE } + XK_Cyrillic_ha = $06c8; { U+0445 CYRILLIC SMALL LETTER HA } + XK_Cyrillic_i = $06c9; { U+0438 CYRILLIC SMALL LETTER I } + XK_Cyrillic_shorti = $06ca; { U+0439 CYRILLIC SMALL LETTER SHORT I } + XK_Cyrillic_ka = $06cb; { U+043A CYRILLIC SMALL LETTER KA } + XK_Cyrillic_el = $06cc; { U+043B CYRILLIC SMALL LETTER EL } + XK_Cyrillic_em = $06cd; { U+043C CYRILLIC SMALL LETTER EM } + XK_Cyrillic_en = $06ce; { U+043D CYRILLIC SMALL LETTER EN } + XK_Cyrillic_o = $06cf; { U+043E CYRILLIC SMALL LETTER O } + XK_Cyrillic_pe = $06d0; { U+043F CYRILLIC SMALL LETTER PE } + XK_Cyrillic_ya = $06d1; { U+044F CYRILLIC SMALL LETTER YA } + XK_Cyrillic_er = $06d2; { U+0440 CYRILLIC SMALL LETTER ER } + XK_Cyrillic_es = $06d3; { U+0441 CYRILLIC SMALL LETTER ES } + XK_Cyrillic_te = $06d4; { U+0442 CYRILLIC SMALL LETTER TE } + XK_Cyrillic_u = $06d5; { U+0443 CYRILLIC SMALL LETTER U } + XK_Cyrillic_zhe = $06d6; { U+0436 CYRILLIC SMALL LETTER ZHE } + XK_Cyrillic_ve = $06d7; { U+0432 CYRILLIC SMALL LETTER VE } + XK_Cyrillic_softsign = $06d8; { U+044C CYRILLIC SMALL LETTER SOFT SIGN } + XK_Cyrillic_yeru = $06d9; { U+044B CYRILLIC SMALL LETTER YERU } + XK_Cyrillic_ze = $06da; { U+0437 CYRILLIC SMALL LETTER ZE } + XK_Cyrillic_sha = $06db; { U+0448 CYRILLIC SMALL LETTER SHA } + XK_Cyrillic_e = $06dc; { U+044D CYRILLIC SMALL LETTER E } + XK_Cyrillic_shcha = $06dd; { U+0449 CYRILLIC SMALL LETTER SHCHA } + XK_Cyrillic_che = $06de; { U+0447 CYRILLIC SMALL LETTER CHE } + XK_Cyrillic_hardsign = $06df; { U+044A CYRILLIC SMALL LETTER HARD SIGN } + XKc_Cyrillic_YU = $06e0; { U+042E CYRILLIC CAPITAL LETTER YU } + XKc_Cyrillic_A = $06e1; { U+0410 CYRILLIC CAPITAL LETTER A } + XKc_Cyrillic_BE = $06e2; { U+0411 CYRILLIC CAPITAL LETTER BE } + XKc_Cyrillic_TSE = $06e3; { U+0426 CYRILLIC CAPITAL LETTER TSE } + XKc_Cyrillic_DE = $06e4; { U+0414 CYRILLIC CAPITAL LETTER DE } + XKc_Cyrillic_IE = $06e5; { U+0415 CYRILLIC CAPITAL LETTER IE } + XKc_Cyrillic_EF = $06e6; { U+0424 CYRILLIC CAPITAL LETTER EF } + XKc_Cyrillic_GHE = $06e7; { U+0413 CYRILLIC CAPITAL LETTER GHE } + XKc_Cyrillic_HA = $06e8; { U+0425 CYRILLIC CAPITAL LETTER HA } + XKc_Cyrillic_I = $06e9; { U+0418 CYRILLIC CAPITAL LETTER I } + XKc_Cyrillic_SHORTI = $06ea; { U+0419 CYRILLIC CAPITAL LETTER SHORT I } + XKc_Cyrillic_KA = $06eb; { U+041A CYRILLIC CAPITAL LETTER KA } + XKc_Cyrillic_EL = $06ec; { U+041B CYRILLIC CAPITAL LETTER EL } + XKc_Cyrillic_EM = $06ed; { U+041C CYRILLIC CAPITAL LETTER EM } + XKc_Cyrillic_EN = $06ee; { U+041D CYRILLIC CAPITAL LETTER EN } + XKc_Cyrillic_O = $06ef; { U+041E CYRILLIC CAPITAL LETTER O } + XKc_Cyrillic_PE = $06f0; { U+041F CYRILLIC CAPITAL LETTER PE } + XKc_Cyrillic_YA = $06f1; { U+042F CYRILLIC CAPITAL LETTER YA } + XKc_Cyrillic_ER = $06f2; { U+0420 CYRILLIC CAPITAL LETTER ER } + XKc_Cyrillic_ES = $06f3; { U+0421 CYRILLIC CAPITAL LETTER ES } + XKc_Cyrillic_TE = $06f4; { U+0422 CYRILLIC CAPITAL LETTER TE } + XKc_Cyrillic_U = $06f5; { U+0423 CYRILLIC CAPITAL LETTER U } + XKc_Cyrillic_ZHE = $06f6; { U+0416 CYRILLIC CAPITAL LETTER ZHE } + XKc_Cyrillic_VE = $06f7; { U+0412 CYRILLIC CAPITAL LETTER VE } + XKc_Cyrillic_SOFTSIGN = $06f8; { U+042C CYRILLIC CAPITAL LETTER SOFT SIGN } + XKc_Cyrillic_YERU = $06f9; { U+042B CYRILLIC CAPITAL LETTER YERU } + XKc_Cyrillic_ZE = $06fa; { U+0417 CYRILLIC CAPITAL LETTER ZE } + XKc_Cyrillic_SHA = $06fb; { U+0428 CYRILLIC CAPITAL LETTER SHA } + XKc_Cyrillic_E = $06fc; { U+042D CYRILLIC CAPITAL LETTER E } + XKc_Cyrillic_SHCHA = $06fd; { U+0429 CYRILLIC CAPITAL LETTER SHCHA } + XKc_Cyrillic_CHE = $06fe; { U+0427 CYRILLIC CAPITAL LETTER CHE } + XKc_Cyrillic_HARDSIGN = $06ff; { U+042A CYRILLIC CAPITAL LETTER HARD SIGN } + + XKc_Greek_ALPHAaccent = $07a1; { U+0386 GREEK CAPITAL LETTER ALPHA WITH TONOS } + XKc_Greek_EPSILONaccent = $07a2; { U+0388 GREEK CAPITAL LETTER EPSILON WITH TONOS } + XKc_Greek_ETAaccent = $07a3; { U+0389 GREEK CAPITAL LETTER ETA WITH TONOS } + XKc_Greek_IOTAaccent = $07a4; { U+038A GREEK CAPITAL LETTER IOTA WITH TONOS } + XKc_Greek_IOTAdieresis = $07a5; { U+03AA GREEK CAPITAL LETTER IOTA WITH DIALYTIKA } + XKc_Greek_IOTAdiaeresis = $07a5; { old typo } + XKc_Greek_OMICRONaccent = $07a7; { U+038C GREEK CAPITAL LETTER OMICRON WITH TONOS } + XKc_Greek_UPSILONaccent = $07a8; { U+038E GREEK CAPITAL LETTER UPSILON WITH TONOS } + XKc_Greek_UPSILONdieresis = $07a9; { U+03AB GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA } + XKc_Greek_OMEGAaccent = $07ab; { U+038F GREEK CAPITAL LETTER OMEGA WITH TONOS } + XK_Greek_accentdieresis = $07ae; { U+0385 GREEK DIALYTIKA TONOS } + XK_Greek_horizbar = $07af; { U+2015 HORIZONTAL BAR } + XK_Greek_alphaaccent = $07b1; { U+03AC GREEK SMALL LETTER ALPHA WITH TONOS } + XK_Greek_epsilonaccent = $07b2; { U+03AD GREEK SMALL LETTER EPSILON WITH TONOS } + XK_Greek_etaaccent = $07b3; { U+03AE GREEK SMALL LETTER ETA WITH TONOS } + XK_Greek_iotaaccent = $07b4; { U+03AF GREEK SMALL LETTER IOTA WITH TONOS } + XK_Greek_iotadieresis = $07b5; { U+03CA GREEK SMALL LETTER IOTA WITH DIALYTIKA } + XK_Greek_iotaaccentdieresis = $07b6; { U+0390 GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS } + XK_Greek_omicronaccent = $07b7; { U+03CC GREEK SMALL LETTER OMICRON WITH TONOS } + XK_Greek_upsilonaccent = $07b8; { U+03CD GREEK SMALL LETTER UPSILON WITH TONOS } + XK_Greek_upsilondieresis = $07b9; { U+03CB GREEK SMALL LETTER UPSILON WITH DIALYTIKA } + XK_Greek_upsilonaccentdieresis = $07ba; { U+03B0 GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS } + XK_Greek_omegaaccent = $07bb; { U+03CE GREEK SMALL LETTER OMEGA WITH TONOS } + XKc_Greek_ALPHA = $07c1; { U+0391 GREEK CAPITAL LETTER ALPHA } + XKc_Greek_BETA = $07c2; { U+0392 GREEK CAPITAL LETTER BETA } + XKc_Greek_GAMMA = $07c3; { U+0393 GREEK CAPITAL LETTER GAMMA } + XKc_Greek_DELTA = $07c4; { U+0394 GREEK CAPITAL LETTER DELTA } + XKc_Greek_EPSILON = $07c5; { U+0395 GREEK CAPITAL LETTER EPSILON } + XKc_Greek_ZETA = $07c6; { U+0396 GREEK CAPITAL LETTER ZETA } + XKc_Greek_ETA = $07c7; { U+0397 GREEK CAPITAL LETTER ETA } + XKc_Greek_THETA = $07c8; { U+0398 GREEK CAPITAL LETTER THETA } + XKc_Greek_IOTA = $07c9; { U+0399 GREEK CAPITAL LETTER IOTA } + XKc_Greek_KAPPA = $07ca; { U+039A GREEK CAPITAL LETTER KAPPA } + XKc_Greek_LAMDA = $07cb; { U+039B GREEK CAPITAL LETTER LAMDA } + XKc_Greek_LAMBDA = $07cb; { U+039B GREEK CAPITAL LETTER LAMDA } + XKc_Greek_MU = $07cc; { U+039C GREEK CAPITAL LETTER MU } + XKc_Greek_NU = $07cd; { U+039D GREEK CAPITAL LETTER NU } + XKc_Greek_XI = $07ce; { U+039E GREEK CAPITAL LETTER XI } + XKc_Greek_OMICRON = $07cf; { U+039F GREEK CAPITAL LETTER OMICRON } + XKc_Greek_PI = $07d0; { U+03A0 GREEK CAPITAL LETTER PI } + XKc_Greek_RHO = $07d1; { U+03A1 GREEK CAPITAL LETTER RHO } + XKc_Greek_SIGMA = $07d2; { U+03A3 GREEK CAPITAL LETTER SIGMA } + XKc_Greek_TAU = $07d4; { U+03A4 GREEK CAPITAL LETTER TAU } + XKc_Greek_UPSILON = $07d5; { U+03A5 GREEK CAPITAL LETTER UPSILON } + XKc_Greek_PHI = $07d6; { U+03A6 GREEK CAPITAL LETTER PHI } + XKc_Greek_CHI = $07d7; { U+03A7 GREEK CAPITAL LETTER CHI } + XKc_Greek_PSI = $07d8; { U+03A8 GREEK CAPITAL LETTER PSI } + XKc_Greek_OMEGA = $07d9; { U+03A9 GREEK CAPITAL LETTER OMEGA } + XK_Greek_alpha = $07e1; { U+03B1 GREEK SMALL LETTER ALPHA } + XK_Greek_beta = $07e2; { U+03B2 GREEK SMALL LETTER BETA } + XK_Greek_gamma = $07e3; { U+03B3 GREEK SMALL LETTER GAMMA } + XK_Greek_delta = $07e4; { U+03B4 GREEK SMALL LETTER DELTA } + XK_Greek_epsilon = $07e5; { U+03B5 GREEK SMALL LETTER EPSILON } + XK_Greek_zeta = $07e6; { U+03B6 GREEK SMALL LETTER ZETA } + XK_Greek_eta = $07e7; { U+03B7 GREEK SMALL LETTER ETA } + XK_Greek_theta = $07e8; { U+03B8 GREEK SMALL LETTER THETA } + XK_Greek_iota = $07e9; { U+03B9 GREEK SMALL LETTER IOTA } + XK_Greek_kappa = $07ea; { U+03BA GREEK SMALL LETTER KAPPA } + XK_Greek_lamda = $07eb; { U+03BB GREEK SMALL LETTER LAMDA } + XK_Greek_lambda = $07eb; { U+03BB GREEK SMALL LETTER LAMDA } + XK_Greek_mu = $07ec; { U+03BC GREEK SMALL LETTER MU } + XK_Greek_nu = $07ed; { U+03BD GREEK SMALL LETTER NU } + XK_Greek_xi = $07ee; { U+03BE GREEK SMALL LETTER XI } + XK_Greek_omicron = $07ef; { U+03BF GREEK SMALL LETTER OMICRON } + XK_Greek_pi = $07f0; { U+03C0 GREEK SMALL LETTER PI } + XK_Greek_rho = $07f1; { U+03C1 GREEK SMALL LETTER RHO } + XK_Greek_sigma = $07f2; { U+03C3 GREEK SMALL LETTER SIGMA } + XK_Greek_finalsmallsigma = $07f3; { U+03C2 GREEK SMALL LETTER FINAL SIGMA } + XK_Greek_tau = $07f4; { U+03C4 GREEK SMALL LETTER TAU } + XK_Greek_upsilon = $07f5; { U+03C5 GREEK SMALL LETTER UPSILON } + XK_Greek_phi = $07f6; { U+03C6 GREEK SMALL LETTER PHI } + XK_Greek_chi = $07f7; { U+03C7 GREEK SMALL LETTER CHI } + XK_Greek_psi = $07f8; { U+03C8 GREEK SMALL LETTER PSI } + XK_Greek_omega = $07f9; { U+03C9 GREEK SMALL LETTER OMEGA } + XK_Greek_switch = $ff7e; { Alias for mode_switch } + + XK_leftradical = $08a1; { U+23B7 RADICAL SYMBOL BOTTOM } + XK_topleftradical = $08a2; {(U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT)} + XK_horizconnector = $08a3; {(U+2500 BOX DRAWINGS LIGHT HORIZONTAL)} + XK_topintegral = $08a4; { U+2320 TOP HALF INTEGRAL } + XK_botintegral = $08a5; { U+2321 BOTTOM HALF INTEGRAL } + XK_vertconnector = $08a6; {(U+2502 BOX DRAWINGS LIGHT VERTICAL)} + XK_topleftsqbracket = $08a7; { U+23A1 LEFT SQUARE BRACKET UPPER CORNER } + XK_botleftsqbracket = $08a8; { U+23A3 LEFT SQUARE BRACKET LOWER CORNER } + XK_toprightsqbracket = $08a9; { U+23A4 RIGHT SQUARE BRACKET UPPER CORNER } + XK_botrightsqbracket = $08aa; { U+23A6 RIGHT SQUARE BRACKET LOWER CORNER } + XK_topleftparens = $08ab; { U+239B LEFT PARENTHESIS UPPER HOOK } + XK_botleftparens = $08ac; { U+239D LEFT PARENTHESIS LOWER HOOK } + XK_toprightparens = $08ad; { U+239E RIGHT PARENTHESIS UPPER HOOK } + XK_botrightparens = $08ae; { U+23A0 RIGHT PARENTHESIS LOWER HOOK } + XK_leftmiddlecurlybrace = $08af; { U+23A8 LEFT CURLY BRACKET MIDDLE PIECE } + XK_rightmiddlecurlybrace = $08b0; { U+23AC RIGHT CURLY BRACKET MIDDLE PIECE } + XK_topleftsummation = $08b1; + XK_botleftsummation = $08b2; + XK_topvertsummationconnector = $08b3; + XK_botvertsummationconnector = $08b4; + XK_toprightsummation = $08b5; + XK_botrightsummation = $08b6; + XK_rightmiddlesummation = $08b7; + XK_lessthanequal = $08bc; { U+2264 LESS-THAN OR EQUAL TO } + XK_notequal = $08bd; { U+2260 NOT EQUAL TO } + XK_greaterthanequal = $08be; { U+2265 GREATER-THAN OR EQUAL TO } + XK_integral = $08bf; { U+222B INTEGRAL } + XK_therefore = $08c0; { U+2234 THEREFORE } + XK_variation = $08c1; { U+221D PROPORTIONAL TO } + XK_infinity = $08c2; { U+221E INFINITY } + XK_nabla = $08c5; { U+2207 NABLA } + XK_approximate = $08c8; { U+223C TILDE OPERATOR } + XK_similarequal = $08c9; { U+2243 ASYMPTOTICALLY EQUAL TO } + XK_ifonlyif = $08cd; { U+21D4 LEFT RIGHT DOUBLE ARROW } + XK_implies = $08ce; { U+21D2 RIGHTWARDS DOUBLE ARROW } + XK_identical = $08cf; { U+2261 IDENTICAL TO } + XK_radical = $08d6; { U+221A SQUARE ROOT } + XK_includedin = $08da; { U+2282 SUBSET OF } + XK_includes = $08db; { U+2283 SUPERSET OF } + XK_intersection = $08dc; { U+2229 INTERSECTION } + XK_union = $08dd; { U+222A UNION } + XK_logicaland = $08de; { U+2227 LOGICAL AND } + XK_logicalor = $08df; { U+2228 LOGICAL OR } + XK_partialderivative = $08ef; { U+2202 PARTIAL DIFFERENTIAL } + XK_function = $08f6; { U+0192 LATIN SMALL LETTER F WITH HOOK } + XK_leftarrow = $08fb; { U+2190 LEFTWARDS ARROW } + XK_uparrow = $08fc; { U+2191 UPWARDS ARROW } + XK_rightarrow = $08fd; { U+2192 RIGHTWARDS ARROW } + XK_downarrow = $08fe; { U+2193 DOWNWARDS ARROW } + + XK_blank = $09df; + XK_soliddiamond = $09e0; { U+25C6 BLACK DIAMOND } + XK_checkerboard = $09e1; { U+2592 MEDIUM SHADE } + XK_ht = $09e2; { U+2409 SYMBOL FOR HORIZONTAL TABULATION } + XK_ff = $09e3; { U+240C SYMBOL FOR FORM FEED } + XK_cr = $09e4; { U+240D SYMBOL FOR CARRIAGE RETURN } + XK_lf = $09e5; { U+240A SYMBOL FOR LINE FEED } + XK_nl = $09e8; { U+2424 SYMBOL FOR NEWLINE } + XK_vt = $09e9; { U+240B SYMBOL FOR VERTICAL TABULATION } + XK_lowrightcorner = $09ea; { U+2518 BOX DRAWINGS LIGHT UP AND LEFT } + XK_uprightcorner = $09eb; { U+2510 BOX DRAWINGS LIGHT DOWN AND LEFT } + XK_upleftcorner = $09ec; { U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT } + XK_lowleftcorner = $09ed; { U+2514 BOX DRAWINGS LIGHT UP AND RIGHT } + XK_crossinglines = $09ee; { U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL } + XK_horizlinescan1 = $09ef; { U+23BA HORIZONTAL SCAN LINE-1 } + XK_horizlinescan3 = $09f0; { U+23BB HORIZONTAL SCAN LINE-3 } + XK_horizlinescan5 = $09f1; { U+2500 BOX DRAWINGS LIGHT HORIZONTAL } + XK_horizlinescan7 = $09f2; { U+23BC HORIZONTAL SCAN LINE-7 } + XK_horizlinescan9 = $09f3; { U+23BD HORIZONTAL SCAN LINE-9 } + XK_leftt = $09f4; { U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT } + XK_rightt = $09f5; { U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT } + XK_bott = $09f6; { U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL } + XK_topt = $09f7; { U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL } + XK_vertbar = $09f8; { U+2502 BOX DRAWINGS LIGHT VERTICAL } + + XK_emspace = $0aa1; { U+2003 EM SPACE } + XK_enspace = $0aa2; { U+2002 EN SPACE } + XK_em3space = $0aa3; { U+2004 THREE-PER-EM SPACE } + XK_em4space = $0aa4; { U+2005 FOUR-PER-EM SPACE } + XK_digitspace = $0aa5; { U+2007 FIGURE SPACE } + XK_punctspace = $0aa6; { U+2008 PUNCTUATION SPACE } + XK_thinspace = $0aa7; { U+2009 THIN SPACE } + XK_hairspace = $0aa8; { U+200A HAIR SPACE } + XK_emdash = $0aa9; { U+2014 EM DASH } + XK_endash = $0aaa; { U+2013 EN DASH } + XK_signifblank = $0aac; {(U+2423 OPEN BOX)} + XK_ellipsis = $0aae; { U+2026 HORIZONTAL ELLIPSIS } + XK_doubbaselinedot = $0aaf; { U+2025 TWO DOT LEADER } + XK_onethird = $0ab0; { U+2153 VULGAR FRACTION ONE THIRD } + XK_twothirds = $0ab1; { U+2154 VULGAR FRACTION TWO THIRDS } + XK_onefifth = $0ab2; { U+2155 VULGAR FRACTION ONE FIFTH } + XK_twofifths = $0ab3; { U+2156 VULGAR FRACTION TWO FIFTHS } + XK_threefifths = $0ab4; { U+2157 VULGAR FRACTION THREE FIFTHS } + XK_fourfifths = $0ab5; { U+2158 VULGAR FRACTION FOUR FIFTHS } + XK_onesixth = $0ab6; { U+2159 VULGAR FRACTION ONE SIXTH } + XK_fivesixths = $0ab7; { U+215A VULGAR FRACTION FIVE SIXTHS } + XK_careof = $0ab8; { U+2105 CARE OF } + XK_figdash = $0abb; { U+2012 FIGURE DASH } + XK_leftanglebracket = $0abc; {(U+27E8 MATHEMATICAL LEFT ANGLE BRACKET)} + XK_decimalpoint = $0abd; {(U+002E FULL STOP)} + XK_rightanglebracket = $0abe; {(U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET)} + XK_marker = $0abf; + XK_oneeighth = $0ac3; { U+215B VULGAR FRACTION ONE EIGHTH } + XK_threeeighths = $0ac4; { U+215C VULGAR FRACTION THREE EIGHTHS } + XK_fiveeighths = $0ac5; { U+215D VULGAR FRACTION FIVE EIGHTHS } + XK_seveneighths = $0ac6; { U+215E VULGAR FRACTION SEVEN EIGHTHS } + XK_trademark = $0ac9; { U+2122 TRADE MARK SIGN } + XK_signaturemark = $0aca; {(U+2613 SALTIRE)} + XK_trademarkincircle = $0acb; + XK_leftopentriangle = $0acc; {(U+25C1 WHITE LEFT-POINTING TRIANGLE)} + XK_rightopentriangle = $0acd; {(U+25B7 WHITE RIGHT-POINTING TRIANGLE)} + XK_emopencircle = $0ace; {(U+25CB WHITE CIRCLE)} + XK_emopenrectangle = $0acf; {(U+25AF WHITE VERTICAL RECTANGLE)} + XK_leftsinglequotemark = $0ad0; { U+2018 LEFT SINGLE QUOTATION MARK } + XK_rightsinglequotemark = $0ad1; { U+2019 RIGHT SINGLE QUOTATION MARK } + XK_leftdoublequotemark = $0ad2; { U+201C LEFT DOUBLE QUOTATION MARK } + XK_rightdoublequotemark = $0ad3; { U+201D RIGHT DOUBLE QUOTATION MARK } + XK_prescription = $0ad4; { U+211E PRESCRIPTION TAKE } + XK_permille = $0ad5; { U+2030 PER MILLE SIGN } + XK_minutes = $0ad6; { U+2032 PRIME } + XK_seconds = $0ad7; { U+2033 DOUBLE PRIME } + XK_latincross = $0ad9; { U+271D LATIN CROSS } + XK_hexagram = $0ada; + XK_filledrectbullet = $0adb; {(U+25AC BLACK RECTANGLE)} + XK_filledlefttribullet = $0adc; {(U+25C0 BLACK LEFT-POINTING TRIANGLE)} + XK_filledrighttribullet = $0add; {(U+25B6 BLACK RIGHT-POINTING TRIANGLE)} + XK_emfilledcircle = $0ade; {(U+25CF BLACK CIRCLE)} + XK_emfilledrect = $0adf; {(U+25AE BLACK VERTICAL RECTANGLE)} + XK_enopencircbullet = $0ae0; {(U+25E6 WHITE BULLET)} + XK_enopensquarebullet = $0ae1; {(U+25AB WHITE SMALL SQUARE)} + XK_openrectbullet = $0ae2; {(U+25AD WHITE RECTANGLE)} + XK_opentribulletup = $0ae3; {(U+25B3 WHITE UP-POINTING TRIANGLE)} + XK_opentribulletdown = $0ae4; {(U+25BD WHITE DOWN-POINTING TRIANGLE)} + XK_openstar = $0ae5; {(U+2606 WHITE STAR)} + XK_enfilledcircbullet = $0ae6; {(U+2022 BULLET)} + XK_enfilledsqbullet = $0ae7; {(U+25AA BLACK SMALL SQUARE)} + XK_filledtribulletup = $0ae8; {(U+25B2 BLACK UP-POINTING TRIANGLE)} + XK_filledtribulletdown = $0ae9; {(U+25BC BLACK DOWN-POINTING TRIANGLE)} + XK_leftpointer = $0aea; {(U+261C WHITE LEFT POINTING INDEX)} + XK_rightpointer = $0aeb; {(U+261E WHITE RIGHT POINTING INDEX)} + XK_club = $0aec; { U+2663 BLACK CLUB SUIT } + XK_diamond = $0aed; { U+2666 BLACK DIAMOND SUIT } + XK_heart = $0aee; { U+2665 BLACK HEART SUIT } + XK_maltesecross = $0af0; { U+2720 MALTESE CROSS } + XK_dagger = $0af1; { U+2020 DAGGER } + XK_doubledagger = $0af2; { U+2021 DOUBLE DAGGER } + XK_checkmark = $0af3; { U+2713 CHECK MARK } + XK_ballotcross = $0af4; { U+2717 BALLOT X } + XK_musicalsharp = $0af5; { U+266F MUSIC SHARP SIGN } + XK_musicalflat = $0af6; { U+266D MUSIC FLAT SIGN } + XK_malesymbol = $0af7; { U+2642 MALE SIGN } + XK_femalesymbol = $0af8; { U+2640 FEMALE SIGN } + XK_telephone = $0af9; { U+260E BLACK TELEPHONE } + XK_telephonerecorder = $0afa; { U+2315 TELEPHONE RECORDER } + XK_phonographcopyright = $0afb; { U+2117 SOUND RECORDING COPYRIGHT } + XK_caret = $0afc; { U+2038 CARET } + XK_singlelowquotemark = $0afd; { U+201A SINGLE LOW-9 QUOTATION MARK } + XK_doublelowquotemark = $0afe; { U+201E DOUBLE LOW-9 QUOTATION MARK } + XK_cursor = $0aff; + + XK_leftcaret = $0ba3; {(U+003C LESS-THAN SIGN)} + XK_rightcaret = $0ba6; {(U+003E GREATER-THAN SIGN)} + XK_downcaret = $0ba8; {(U+2228 LOGICAL OR)} + XK_upcaret = $0ba9; {(U+2227 LOGICAL AND)} + XK_overbar = $0bc0; {(U+00AF MACRON)} + XK_downtack = $0bc2; { U+22A4 DOWN TACK } + XK_upshoe = $0bc3; {(U+2229 INTERSECTION)} + XK_downstile = $0bc4; { U+230A LEFT FLOOR } + XK_underbar = $0bc6; {(U+005F LOW LINE)} + XK_jot = $0bca; { U+2218 RING OPERATOR } + XK_quad = $0bcc; { U+2395 APL FUNCTIONAL SYMBOL QUAD } + XK_uptack = $0bce; { U+22A5 UP TACK } + XK_circle = $0bcf; { U+25CB WHITE CIRCLE } + XK_upstile = $0bd3; { U+2308 LEFT CEILING } + XK_downshoe = $0bd6; {(U+222A UNION)} + XK_rightshoe = $0bd8; {(U+2283 SUPERSET OF)} + XK_leftshoe = $0bda; {(U+2282 SUBSET OF)} + XK_lefttack = $0bdc; { U+22A3 LEFT TACK } + XK_righttack = $0bfc; { U+22A2 RIGHT TACK } + + XK_hebrew_doublelowline = $0cdf; { U+2017 DOUBLE LOW LINE } + XK_hebrew_aleph = $0ce0; { U+05D0 HEBREW LETTER ALEF } + XK_hebrew_bet = $0ce1; { U+05D1 HEBREW LETTER BET } + XK_hebrew_beth = $0ce1; { deprecated } + XK_hebrew_gimel = $0ce2; { U+05D2 HEBREW LETTER GIMEL } + XK_hebrew_gimmel = $0ce2; { deprecated } + XK_hebrew_dalet = $0ce3; { U+05D3 HEBREW LETTER DALET } + XK_hebrew_daleth = $0ce3; { deprecated } + XK_hebrew_he = $0ce4; { U+05D4 HEBREW LETTER HE } + XK_hebrew_waw = $0ce5; { U+05D5 HEBREW LETTER VAV } + XK_hebrew_zain = $0ce6; { U+05D6 HEBREW LETTER ZAYIN } + XK_hebrew_zayin = $0ce6; { deprecated } + XK_hebrew_chet = $0ce7; { U+05D7 HEBREW LETTER HET } + XK_hebrew_het = $0ce7; { deprecated } + XK_hebrew_tet = $0ce8; { U+05D8 HEBREW LETTER TET } + XK_hebrew_teth = $0ce8; { deprecated } + XK_hebrew_yod = $0ce9; { U+05D9 HEBREW LETTER YOD } + XK_hebrew_finalkaph = $0cea; { U+05DA HEBREW LETTER FINAL KAF } + XK_hebrew_kaph = $0ceb; { U+05DB HEBREW LETTER KAF } + XK_hebrew_lamed = $0cec; { U+05DC HEBREW LETTER LAMED } + XK_hebrew_finalmem = $0ced; { U+05DD HEBREW LETTER FINAL MEM } + XK_hebrew_mem = $0cee; { U+05DE HEBREW LETTER MEM } + XK_hebrew_finalnun = $0cef; { U+05DF HEBREW LETTER FINAL NUN } + XK_hebrew_nun = $0cf0; { U+05E0 HEBREW LETTER NUN } + XK_hebrew_samech = $0cf1; { U+05E1 HEBREW LETTER SAMEKH } + XK_hebrew_samekh = $0cf1; { deprecated } + XK_hebrew_ayin = $0cf2; { U+05E2 HEBREW LETTER AYIN } + XK_hebrew_finalpe = $0cf3; { U+05E3 HEBREW LETTER FINAL PE } + XK_hebrew_pe = $0cf4; { U+05E4 HEBREW LETTER PE } + XK_hebrew_finalzade = $0cf5; { U+05E5 HEBREW LETTER FINAL TSADI } + XK_hebrew_finalzadi = $0cf5; { deprecated } + XK_hebrew_zade = $0cf6; { U+05E6 HEBREW LETTER TSADI } + XK_hebrew_zadi = $0cf6; { deprecated } + XK_hebrew_qoph = $0cf7; { U+05E7 HEBREW LETTER QOF } + XK_hebrew_kuf = $0cf7; { deprecated } + XK_hebrew_resh = $0cf8; { U+05E8 HEBREW LETTER RESH } + XK_hebrew_shin = $0cf9; { U+05E9 HEBREW LETTER SHIN } + XK_hebrew_taw = $0cfa; { U+05EA HEBREW LETTER TAV } + XK_hebrew_taf = $0cfa; { deprecated } + XK_Hebrew_switch = $ff7e; { Alias for mode_switch } + + XK_Thai_kokai = $0da1; { U+0E01 THAI CHARACTER KO KAI } + XK_Thai_khokhai = $0da2; { U+0E02 THAI CHARACTER KHO KHAI } + XK_Thai_khokhuat = $0da3; { U+0E03 THAI CHARACTER KHO KHUAT } + XK_Thai_khokhwai = $0da4; { U+0E04 THAI CHARACTER KHO KHWAI } + XK_Thai_khokhon = $0da5; { U+0E05 THAI CHARACTER KHO KHON } + XK_Thai_khorakhang = $0da6; { U+0E06 THAI CHARACTER KHO RAKHANG } + XK_Thai_ngongu = $0da7; { U+0E07 THAI CHARACTER NGO NGU } + XK_Thai_chochan = $0da8; { U+0E08 THAI CHARACTER CHO CHAN } + XK_Thai_choching = $0da9; { U+0E09 THAI CHARACTER CHO CHING } + XK_Thai_chochang = $0daa; { U+0E0A THAI CHARACTER CHO CHANG } + XK_Thai_soso = $0dab; { U+0E0B THAI CHARACTER SO SO } + XK_Thai_chochoe = $0dac; { U+0E0C THAI CHARACTER CHO CHOE } + XK_Thai_yoying = $0dad; { U+0E0D THAI CHARACTER YO YING } + XK_Thai_dochada = $0dae; { U+0E0E THAI CHARACTER DO CHADA } + XK_Thai_topatak = $0daf; { U+0E0F THAI CHARACTER TO PATAK } + XK_Thai_thothan = $0db0; { U+0E10 THAI CHARACTER THO THAN } + XK_Thai_thonangmontho = $0db1; { U+0E11 THAI CHARACTER THO NANGMONTHO } + XK_Thai_thophuthao = $0db2; { U+0E12 THAI CHARACTER THO PHUTHAO } + XK_Thai_nonen = $0db3; { U+0E13 THAI CHARACTER NO NEN } + XK_Thai_dodek = $0db4; { U+0E14 THAI CHARACTER DO DEK } + XK_Thai_totao = $0db5; { U+0E15 THAI CHARACTER TO TAO } + XK_Thai_thothung = $0db6; { U+0E16 THAI CHARACTER THO THUNG } + XK_Thai_thothahan = $0db7; { U+0E17 THAI CHARACTER THO THAHAN } + XK_Thai_thothong = $0db8; { U+0E18 THAI CHARACTER THO THONG } + XK_Thai_nonu = $0db9; { U+0E19 THAI CHARACTER NO NU } + XK_Thai_bobaimai = $0dba; { U+0E1A THAI CHARACTER BO BAIMAI } + XK_Thai_popla = $0dbb; { U+0E1B THAI CHARACTER PO PLA } + XK_Thai_phophung = $0dbc; { U+0E1C THAI CHARACTER PHO PHUNG } + XK_Thai_fofa = $0dbd; { U+0E1D THAI CHARACTER FO FA } + XK_Thai_phophan = $0dbe; { U+0E1E THAI CHARACTER PHO PHAN } + XK_Thai_fofan = $0dbf; { U+0E1F THAI CHARACTER FO FAN } + XK_Thai_phosamphao = $0dc0; { U+0E20 THAI CHARACTER PHO SAMPHAO } + XK_Thai_moma = $0dc1; { U+0E21 THAI CHARACTER MO MA } + XK_Thai_yoyak = $0dc2; { U+0E22 THAI CHARACTER YO YAK } + XK_Thai_rorua = $0dc3; { U+0E23 THAI CHARACTER RO RUA } + XK_Thai_ru = $0dc4; { U+0E24 THAI CHARACTER RU } + XK_Thai_loling = $0dc5; { U+0E25 THAI CHARACTER LO LING } + XK_Thai_lu = $0dc6; { U+0E26 THAI CHARACTER LU } + XK_Thai_wowaen = $0dc7; { U+0E27 THAI CHARACTER WO WAEN } + XK_Thai_sosala = $0dc8; { U+0E28 THAI CHARACTER SO SALA } + XK_Thai_sorusi = $0dc9; { U+0E29 THAI CHARACTER SO RUSI } + XK_Thai_sosua = $0dca; { U+0E2A THAI CHARACTER SO SUA } + XK_Thai_hohip = $0dcb; { U+0E2B THAI CHARACTER HO HIP } + XK_Thai_lochula = $0dcc; { U+0E2C THAI CHARACTER LO CHULA } + XK_Thai_oang = $0dcd; { U+0E2D THAI CHARACTER O ANG } + XK_Thai_honokhuk = $0dce; { U+0E2E THAI CHARACTER HO NOKHUK } + XK_Thai_paiyannoi = $0dcf; { U+0E2F THAI CHARACTER PAIYANNOI } + XK_Thai_saraa = $0dd0; { U+0E30 THAI CHARACTER SARA A } + XK_Thai_maihanakat = $0dd1; { U+0E31 THAI CHARACTER MAI HAN-AKAT } + XK_Thai_saraaa = $0dd2; { U+0E32 THAI CHARACTER SARA AA } + XK_Thai_saraam = $0dd3; { U+0E33 THAI CHARACTER SARA AM } + XK_Thai_sarai = $0dd4; { U+0E34 THAI CHARACTER SARA I } + XK_Thai_saraii = $0dd5; { U+0E35 THAI CHARACTER SARA II } + XK_Thai_saraue = $0dd6; { U+0E36 THAI CHARACTER SARA UE } + XK_Thai_sarauee = $0dd7; { U+0E37 THAI CHARACTER SARA UEE } + XK_Thai_sarau = $0dd8; { U+0E38 THAI CHARACTER SARA U } + XK_Thai_sarauu = $0dd9; { U+0E39 THAI CHARACTER SARA UU } + XK_Thai_phinthu = $0dda; { U+0E3A THAI CHARACTER PHINTHU } + XK_Thai_maihanakat_maitho = $0dde; + XK_Thai_baht = $0ddf; { U+0E3F THAI CURRENCY SYMBOL BAHT } + XK_Thai_sarae = $0de0; { U+0E40 THAI CHARACTER SARA E } + XK_Thai_saraae = $0de1; { U+0E41 THAI CHARACTER SARA AE } + XK_Thai_sarao = $0de2; { U+0E42 THAI CHARACTER SARA O } + XK_Thai_saraaimaimuan = $0de3; { U+0E43 THAI CHARACTER SARA AI MAIMUAN } + XK_Thai_saraaimaimalai = $0de4; { U+0E44 THAI CHARACTER SARA AI MAIMALAI } + XK_Thai_lakkhangyao = $0de5; { U+0E45 THAI CHARACTER LAKKHANGYAO } + XK_Thai_maiyamok = $0de6; { U+0E46 THAI CHARACTER MAIYAMOK } + XK_Thai_maitaikhu = $0de7; { U+0E47 THAI CHARACTER MAITAIKHU } + XK_Thai_maiek = $0de8; { U+0E48 THAI CHARACTER MAI EK } + XK_Thai_maitho = $0de9; { U+0E49 THAI CHARACTER MAI THO } + XK_Thai_maitri = $0dea; { U+0E4A THAI CHARACTER MAI TRI } + XK_Thai_maichattawa = $0deb; { U+0E4B THAI CHARACTER MAI CHATTAWA } + XK_Thai_thanthakhat = $0dec; { U+0E4C THAI CHARACTER THANTHAKHAT } + XK_Thai_nikhahit = $0ded; { U+0E4D THAI CHARACTER NIKHAHIT } + XK_Thai_leksun = $0df0; { U+0E50 THAI DIGIT ZERO } + XK_Thai_leknung = $0df1; { U+0E51 THAI DIGIT ONE } + XK_Thai_leksong = $0df2; { U+0E52 THAI DIGIT TWO } + XK_Thai_leksam = $0df3; { U+0E53 THAI DIGIT THREE } + XK_Thai_leksi = $0df4; { U+0E54 THAI DIGIT FOUR } + XK_Thai_lekha = $0df5; { U+0E55 THAI DIGIT FIVE } + XK_Thai_lekhok = $0df6; { U+0E56 THAI DIGIT SIX } + XK_Thai_lekchet = $0df7; { U+0E57 THAI DIGIT SEVEN } + XK_Thai_lekpaet = $0df8; { U+0E58 THAI DIGIT EIGHT } + XK_Thai_lekkao = $0df9; { U+0E59 THAI DIGIT NINE } + + XK_Hangul = $ff31; { Hangul start/stop(toggle) } + XK_Hangul_Start = $ff32; { Hangul start } + XK_Hangul_End = $ff33; { Hangul end, English start } + XK_Hangul_Hanja = $ff34; { Start Hangul->Hanja Conversion } + XK_Hangul_Jamo = $ff35; { Hangul Jamo mode } + XK_Hangul_Romaja = $ff36; { Hangul Romaja mode } + XK_Hangul_Codeinput = $ff37; { Hangul code input mode } + XK_Hangul_Jeonja = $ff38; { Jeonja mode } + XK_Hangul_Banja = $ff39; { Banja mode } + XK_Hangul_PreHanja = $ff3a; { Pre Hanja conversion } + XK_Hangul_PostHanja = $ff3b; { Post Hanja conversion } + XK_Hangul_SingleCandidate = $ff3c; { Single candidate } + XK_Hangul_MultipleCandidate = $ff3d; { Multiple candidate } + XK_Hangul_PreviousCandidate = $ff3e; { Previous candidate } + XK_Hangul_Special = $ff3f; { Special symbols } + XK_Hangul_switch = $ff7e; { Alias for mode_switch } + + XK_Hangul_Kiyeog = $0ea1; + XK_Hangul_SsangKiyeog = $0ea2; + XK_Hangul_KiyeogSios = $0ea3; + XK_Hangul_Nieun = $0ea4; + XK_Hangul_NieunJieuj = $0ea5; + XK_Hangul_NieunHieuh = $0ea6; + XK_Hangul_Dikeud = $0ea7; + XK_Hangul_SsangDikeud = $0ea8; + XK_Hangul_Rieul = $0ea9; + XK_Hangul_RieulKiyeog = $0eaa; + XK_Hangul_RieulMieum = $0eab; + XK_Hangul_RieulPieub = $0eac; + XK_Hangul_RieulSios = $0ead; + XK_Hangul_RieulTieut = $0eae; + XK_Hangul_RieulPhieuf = $0eaf; + XK_Hangul_RieulHieuh = $0eb0; + XK_Hangul_Mieum = $0eb1; + XK_Hangul_Pieub = $0eb2; + XK_Hangul_SsangPieub = $0eb3; + XK_Hangul_PieubSios = $0eb4; + XK_Hangul_Sios = $0eb5; + XK_Hangul_SsangSios = $0eb6; + XK_Hangul_Ieung = $0eb7; + XK_Hangul_Jieuj = $0eb8; + XK_Hangul_SsangJieuj = $0eb9; + XK_Hangul_Cieuc = $0eba; + XK_Hangul_Khieuq = $0ebb; + XK_Hangul_Tieut = $0ebc; + XK_Hangul_Phieuf = $0ebd; + XK_Hangul_Hieuh = $0ebe; + + XK_Hangul_A = $0ebf; + XK_Hangul_AE = $0ec0; + XK_Hangul_YA = $0ec1; + XK_Hangul_YAE = $0ec2; + XK_Hangul_EO = $0ec3; + XK_Hangul_E = $0ec4; + XK_Hangul_YEO = $0ec5; + XK_Hangul_YE = $0ec6; + XK_Hangul_O = $0ec7; + XK_Hangul_WA = $0ec8; + XK_Hangul_WAE = $0ec9; + XK_Hangul_OE = $0eca; + XK_Hangul_YO = $0ecb; + XK_Hangul_U = $0ecc; + XK_Hangul_WEO = $0ecd; + XK_Hangul_WE = $0ece; + XK_Hangul_WI = $0ecf; + XK_Hangul_YU = $0ed0; + XK_Hangul_EU = $0ed1; + XK_Hangul_YI = $0ed2; + XK_Hangul_I = $0ed3; + + XK_Hangul_J_Kiyeog = $0ed4; + XK_Hangul_J_SsangKiyeog = $0ed5; + XK_Hangul_J_KiyeogSios = $0ed6; + XK_Hangul_J_Nieun = $0ed7; + XK_Hangul_J_NieunJieuj = $0ed8; + XK_Hangul_J_NieunHieuh = $0ed9; + XK_Hangul_J_Dikeud = $0eda; + XK_Hangul_J_Rieul = $0edb; + XK_Hangul_J_RieulKiyeog = $0edc; + XK_Hangul_J_RieulMieum = $0edd; + XK_Hangul_J_RieulPieub = $0ede; + XK_Hangul_J_RieulSios = $0edf; + XK_Hangul_J_RieulTieut = $0ee0; + XK_Hangul_J_RieulPhieuf = $0ee1; + XK_Hangul_J_RieulHieuh = $0ee2; + XK_Hangul_J_Mieum = $0ee3; + XK_Hangul_J_Pieub = $0ee4; + XK_Hangul_J_PieubSios = $0ee5; + XK_Hangul_J_Sios = $0ee6; + XK_Hangul_J_SsangSios = $0ee7; + XK_Hangul_J_Ieung = $0ee8; + XK_Hangul_J_Jieuj = $0ee9; + XK_Hangul_J_Cieuc = $0eea; + XK_Hangul_J_Khieuq = $0eeb; + XK_Hangul_J_Tieut = $0eec; + XK_Hangul_J_Phieuf = $0eed; + XK_Hangul_J_Hieuh = $0eee; + + XK_Hangul_RieulYeorinHieuh = $0eef; + XK_Hangul_SunkyeongeumMieum = $0ef0; + XK_Hangul_SunkyeongeumPieub = $0ef1; + XK_Hangul_PanSios = $0ef2; + XK_Hangul_KkogjiDalrinIeung = $0ef3; + XK_Hangul_SunkyeongeumPhieuf = $0ef4; + XK_Hangul_YeorinHieuh = $0ef5; + + XK_Hangul_AraeA = $0ef6; + XK_Hangul_AraeAE = $0ef7; + + XK_Hangul_J_PanSios = $0ef8; + XK_Hangul_J_KkogjiDalrinIeung = $0ef9; + XK_Hangul_J_YeorinHieuh = $0efa; + + XK_Korean_Won = $0eff; {(U+20A9 WON SIGN)} + + XK_Armenian_ligature_ew = $1000587; { U+0587 ARMENIAN SMALL LIGATURE ECH YIWN } + XK_Armenian_full_stop = $1000589; { U+0589 ARMENIAN FULL STOP } + XK_Armenian_verjaket = $1000589; { U+0589 ARMENIAN FULL STOP } + XK_Armenian_separation_mark = $100055d; { U+055D ARMENIAN COMMA } + XK_Armenian_but = $100055d; { U+055D ARMENIAN COMMA } + XK_Armenian_hyphen = $100058a; { U+058A ARMENIAN HYPHEN } + XK_Armenian_yentamna = $100058a; { U+058A ARMENIAN HYPHEN } + XK_Armenian_exclam = $100055c; { U+055C ARMENIAN EXCLAMATION MARK } + XK_Armenian_amanak = $100055c; { U+055C ARMENIAN EXCLAMATION MARK } + XK_Armenian_accent = $100055b; { U+055B ARMENIAN EMPHASIS MARK } + XK_Armenian_shesht = $100055b; { U+055B ARMENIAN EMPHASIS MARK } + XK_Armenian_question = $100055e; { U+055E ARMENIAN QUESTION MARK } + XK_Armenian_paruyk = $100055e; { U+055E ARMENIAN QUESTION MARK } + XKc_Armenian_AYB = $1000531; { U+0531 ARMENIAN CAPITAL LETTER AYB } + XK_Armenian_ayb = $1000561; { U+0561 ARMENIAN SMALL LETTER AYB } + XKc_Armenian_BEN = $1000532; { U+0532 ARMENIAN CAPITAL LETTER BEN } + XK_Armenian_ben = $1000562; { U+0562 ARMENIAN SMALL LETTER BEN } + XKc_Armenian_GIM = $1000533; { U+0533 ARMENIAN CAPITAL LETTER GIM } + XK_Armenian_gim = $1000563; { U+0563 ARMENIAN SMALL LETTER GIM } + XKc_Armenian_DA = $1000534; { U+0534 ARMENIAN CAPITAL LETTER DA } + XK_Armenian_da = $1000564; { U+0564 ARMENIAN SMALL LETTER DA } + XKc_Armenian_YECH = $1000535; { U+0535 ARMENIAN CAPITAL LETTER ECH } + XK_Armenian_yech = $1000565; { U+0565 ARMENIAN SMALL LETTER ECH } + XKc_Armenian_ZA = $1000536; { U+0536 ARMENIAN CAPITAL LETTER ZA } + XK_Armenian_za = $1000566; { U+0566 ARMENIAN SMALL LETTER ZA } + XKc_Armenian_E = $1000537; { U+0537 ARMENIAN CAPITAL LETTER EH } + XK_Armenian_e = $1000567; { U+0567 ARMENIAN SMALL LETTER EH } + XKc_Armenian_AT = $1000538; { U+0538 ARMENIAN CAPITAL LETTER ET } + XK_Armenian_at = $1000568; { U+0568 ARMENIAN SMALL LETTER ET } + XKc_Armenian_TO = $1000539; { U+0539 ARMENIAN CAPITAL LETTER TO } + XK_Armenian_to = $1000569; { U+0569 ARMENIAN SMALL LETTER TO } + XKc_Armenian_ZHE = $100053a; { U+053A ARMENIAN CAPITAL LETTER ZHE } + XK_Armenian_zhe = $100056a; { U+056A ARMENIAN SMALL LETTER ZHE } + XKc_Armenian_INI = $100053b; { U+053B ARMENIAN CAPITAL LETTER INI } + XK_Armenian_ini = $100056b; { U+056B ARMENIAN SMALL LETTER INI } + XKc_Armenian_LYUN = $100053c; { U+053C ARMENIAN CAPITAL LETTER LIWN } + XK_Armenian_lyun = $100056c; { U+056C ARMENIAN SMALL LETTER LIWN } + XKc_Armenian_KHE = $100053d; { U+053D ARMENIAN CAPITAL LETTER XEH } + XK_Armenian_khe = $100056d; { U+056D ARMENIAN SMALL LETTER XEH } + XKc_Armenian_TSA = $100053e; { U+053E ARMENIAN CAPITAL LETTER CA } + XK_Armenian_tsa = $100056e; { U+056E ARMENIAN SMALL LETTER CA } + XKc_Armenian_KEN = $100053f; { U+053F ARMENIAN CAPITAL LETTER KEN } + XK_Armenian_ken = $100056f; { U+056F ARMENIAN SMALL LETTER KEN } + XKc_Armenian_HO = $1000540; { U+0540 ARMENIAN CAPITAL LETTER HO } + XK_Armenian_ho = $1000570; { U+0570 ARMENIAN SMALL LETTER HO } + XKc_Armenian_DZA = $1000541; { U+0541 ARMENIAN CAPITAL LETTER JA } + XK_Armenian_dza = $1000571; { U+0571 ARMENIAN SMALL LETTER JA } + XKc_Armenian_GHAT = $1000542; { U+0542 ARMENIAN CAPITAL LETTER GHAD } + XK_Armenian_ghat = $1000572; { U+0572 ARMENIAN SMALL LETTER GHAD } + XKc_Armenian_TCHE = $1000543; { U+0543 ARMENIAN CAPITAL LETTER CHEH } + XK_Armenian_tche = $1000573; { U+0573 ARMENIAN SMALL LETTER CHEH } + XKc_Armenian_MEN = $1000544; { U+0544 ARMENIAN CAPITAL LETTER MEN } + XK_Armenian_men = $1000574; { U+0574 ARMENIAN SMALL LETTER MEN } + XKc_Armenian_HI = $1000545; { U+0545 ARMENIAN CAPITAL LETTER YI } + XK_Armenian_hi = $1000575; { U+0575 ARMENIAN SMALL LETTER YI } + XKc_Armenian_NU = $1000546; { U+0546 ARMENIAN CAPITAL LETTER NOW } + XK_Armenian_nu = $1000576; { U+0576 ARMENIAN SMALL LETTER NOW } + XKc_Armenian_SHA = $1000547; { U+0547 ARMENIAN CAPITAL LETTER SHA } + XK_Armenian_sha = $1000577; { U+0577 ARMENIAN SMALL LETTER SHA } + XKc_Armenian_VO = $1000548; { U+0548 ARMENIAN CAPITAL LETTER VO } + XK_Armenian_vo = $1000578; { U+0578 ARMENIAN SMALL LETTER VO } + XKc_Armenian_CHA = $1000549; { U+0549 ARMENIAN CAPITAL LETTER CHA } + XK_Armenian_cha = $1000579; { U+0579 ARMENIAN SMALL LETTER CHA } + XKc_Armenian_PE = $100054a; { U+054A ARMENIAN CAPITAL LETTER PEH } + XK_Armenian_pe = $100057a; { U+057A ARMENIAN SMALL LETTER PEH } + XKc_Armenian_JE = $100054b; { U+054B ARMENIAN CAPITAL LETTER JHEH } + XK_Armenian_je = $100057b; { U+057B ARMENIAN SMALL LETTER JHEH } + XKc_Armenian_RA = $100054c; { U+054C ARMENIAN CAPITAL LETTER RA } + XK_Armenian_ra = $100057c; { U+057C ARMENIAN SMALL LETTER RA } + XKc_Armenian_SE = $100054d; { U+054D ARMENIAN CAPITAL LETTER SEH } + XK_Armenian_se = $100057d; { U+057D ARMENIAN SMALL LETTER SEH } + XKc_Armenian_VEV = $100054e; { U+054E ARMENIAN CAPITAL LETTER VEW } + XK_Armenian_vev = $100057e; { U+057E ARMENIAN SMALL LETTER VEW } + XKc_Armenian_TYUN = $100054f; { U+054F ARMENIAN CAPITAL LETTER TIWN } + XK_Armenian_tyun = $100057f; { U+057F ARMENIAN SMALL LETTER TIWN } + XKc_Armenian_RE = $1000550; { U+0550 ARMENIAN CAPITAL LETTER REH } + XK_Armenian_re = $1000580; { U+0580 ARMENIAN SMALL LETTER REH } + XKc_Armenian_TSO = $1000551; { U+0551 ARMENIAN CAPITAL LETTER CO } + XK_Armenian_tso = $1000581; { U+0581 ARMENIAN SMALL LETTER CO } + XKc_Armenian_VYUN = $1000552; { U+0552 ARMENIAN CAPITAL LETTER YIWN } + XK_Armenian_vyun = $1000582; { U+0582 ARMENIAN SMALL LETTER YIWN } + XKc_Armenian_PYUR = $1000553; { U+0553 ARMENIAN CAPITAL LETTER PIWR } + XK_Armenian_pyur = $1000583; { U+0583 ARMENIAN SMALL LETTER PIWR } + XKc_Armenian_KE = $1000554; { U+0554 ARMENIAN CAPITAL LETTER KEH } + XK_Armenian_ke = $1000584; { U+0584 ARMENIAN SMALL LETTER KEH } + XKc_Armenian_O = $1000555; { U+0555 ARMENIAN CAPITAL LETTER OH } + XK_Armenian_o = $1000585; { U+0585 ARMENIAN SMALL LETTER OH } + XKc_Armenian_FE = $1000556; { U+0556 ARMENIAN CAPITAL LETTER FEH } + XK_Armenian_fe = $1000586; { U+0586 ARMENIAN SMALL LETTER FEH } + XK_Armenian_apostrophe = $100055a; { U+055A ARMENIAN APOSTROPHE } + + XK_Georgian_an = $10010d0; { U+10D0 GEORGIAN LETTER AN } + XK_Georgian_ban = $10010d1; { U+10D1 GEORGIAN LETTER BAN } + XK_Georgian_gan = $10010d2; { U+10D2 GEORGIAN LETTER GAN } + XK_Georgian_don = $10010d3; { U+10D3 GEORGIAN LETTER DON } + XK_Georgian_en = $10010d4; { U+10D4 GEORGIAN LETTER EN } + XK_Georgian_vin = $10010d5; { U+10D5 GEORGIAN LETTER VIN } + XK_Georgian_zen = $10010d6; { U+10D6 GEORGIAN LETTER ZEN } + XK_Georgian_tan = $10010d7; { U+10D7 GEORGIAN LETTER TAN } + XK_Georgian_in = $10010d8; { U+10D8 GEORGIAN LETTER IN } + XK_Georgian_kan = $10010d9; { U+10D9 GEORGIAN LETTER KAN } + XK_Georgian_las = $10010da; { U+10DA GEORGIAN LETTER LAS } + XK_Georgian_man = $10010db; { U+10DB GEORGIAN LETTER MAN } + XK_Georgian_nar = $10010dc; { U+10DC GEORGIAN LETTER NAR } + XK_Georgian_on = $10010dd; { U+10DD GEORGIAN LETTER ON } + XK_Georgian_par = $10010de; { U+10DE GEORGIAN LETTER PAR } + XK_Georgian_zhar = $10010df; { U+10DF GEORGIAN LETTER ZHAR } + XK_Georgian_rae = $10010e0; { U+10E0 GEORGIAN LETTER RAE } + XK_Georgian_san = $10010e1; { U+10E1 GEORGIAN LETTER SAN } + XK_Georgian_tar = $10010e2; { U+10E2 GEORGIAN LETTER TAR } + XK_Georgian_un = $10010e3; { U+10E3 GEORGIAN LETTER UN } + XK_Georgian_phar = $10010e4; { U+10E4 GEORGIAN LETTER PHAR } + XK_Georgian_khar = $10010e5; { U+10E5 GEORGIAN LETTER KHAR } + XK_Georgian_ghan = $10010e6; { U+10E6 GEORGIAN LETTER GHAN } + XK_Georgian_qar = $10010e7; { U+10E7 GEORGIAN LETTER QAR } + XK_Georgian_shin = $10010e8; { U+10E8 GEORGIAN LETTER SHIN } + XK_Georgian_chin = $10010e9; { U+10E9 GEORGIAN LETTER CHIN } + XK_Georgian_can = $10010ea; { U+10EA GEORGIAN LETTER CAN } + XK_Georgian_jil = $10010eb; { U+10EB GEORGIAN LETTER JIL } + XK_Georgian_cil = $10010ec; { U+10EC GEORGIAN LETTER CIL } + XK_Georgian_char = $10010ed; { U+10ED GEORGIAN LETTER CHAR } + XK_Georgian_xan = $10010ee; { U+10EE GEORGIAN LETTER XAN } + XK_Georgian_jhan = $10010ef; { U+10EF GEORGIAN LETTER JHAN } + XK_Georgian_hae = $10010f0; { U+10F0 GEORGIAN LETTER HAE } + XK_Georgian_he = $10010f1; { U+10F1 GEORGIAN LETTER HE } + XK_Georgian_hie = $10010f2; { U+10F2 GEORGIAN LETTER HIE } + XK_Georgian_we = $10010f3; { U+10F3 GEORGIAN LETTER WE } + XK_Georgian_har = $10010f4; { U+10F4 GEORGIAN LETTER HAR } + XK_Georgian_hoe = $10010f5; { U+10F5 GEORGIAN LETTER HOE } + XK_Georgian_fi = $10010f6; { U+10F6 GEORGIAN LETTER FI } + + XKc_Xabovedot = $1001e8a; { U+1E8A LATIN CAPITAL LETTER X WITH DOT ABOVE } + XKc_Ibreve = $100012c; { U+012C LATIN CAPITAL LETTER I WITH BREVE } + XKc_Zstroke = $10001b5; { U+01B5 LATIN CAPITAL LETTER Z WITH STROKE } + XKc_Gcaron = $10001e6; { U+01E6 LATIN CAPITAL LETTER G WITH CARON } + XKc_Ocaron = $10001d1; { U+01D2 LATIN CAPITAL LETTER O WITH CARON } + XKc_Obarred = $100019f; { U+019F LATIN CAPITAL LETTER O WITH MIDDLE TILDE } + XK_xabovedot = $1001e8b; { U+1E8B LATIN SMALL LETTER X WITH DOT ABOVE } + XK_ibreve = $100012d; { U+012D LATIN SMALL LETTER I WITH BREVE } + XK_zstroke = $10001b6; { U+01B6 LATIN SMALL LETTER Z WITH STROKE } + XK_gcaron = $10001e7; { U+01E7 LATIN SMALL LETTER G WITH CARON } + XK_ocaron = $10001d2; { U+01D2 LATIN SMALL LETTER O WITH CARON } + XK_obarred = $1000275; { U+0275 LATIN SMALL LETTER BARRED O } + XKc_SCHWA = $100018f; { U+018F LATIN CAPITAL LETTER SCHWA } + XK_schwa = $1000259; { U+0259 LATIN SMALL LETTER SCHWA } + XKc_EZH = $10001b7; { U+01B7 LATIN CAPITAL LETTER EZH } + XK_ezh = $1000292; { U+0292 LATIN SMALL LETTER EZH } + + XKc_Lbelowdot = $1001e36; { U+1E36 LATIN CAPITAL LETTER L WITH DOT BELOW } + XK_lbelowdot = $1001e37; { U+1E37 LATIN SMALL LETTER L WITH DOT BELOW } + + XKc_Abelowdot = $1001ea0; { U+1EA0 LATIN CAPITAL LETTER A WITH DOT BELOW } + XK_abelowdot = $1001ea1; { U+1EA1 LATIN SMALL LETTER A WITH DOT BELOW } + XKc_Ahook = $1001ea2; { U+1EA2 LATIN CAPITAL LETTER A WITH HOOK ABOVE } + XK_ahook = $1001ea3; { U+1EA3 LATIN SMALL LETTER A WITH HOOK ABOVE } + XKc_Acircumflexacute = $1001ea4; { U+1EA4 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE } + XK_acircumflexacute = $1001ea5; { U+1EA5 LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE } + XKc_Acircumflexgrave = $1001ea6; { U+1EA6 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE } + XK_acircumflexgrave = $1001ea7; { U+1EA7 LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE } + XKc_Acircumflexhook = $1001ea8; { U+1EA8 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE } + XK_acircumflexhook = $1001ea9; { U+1EA9 LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE } + XKc_Acircumflextilde = $1001eaa; { U+1EAA LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE } + XK_acircumflextilde = $1001eab; { U+1EAB LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE } + XKc_Acircumflexbelowdot = $1001eac; { U+1EAC LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW } + XK_acircumflexbelowdot = $1001ead; { U+1EAD LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW } + XKc_Abreveacute = $1001eae; { U+1EAE LATIN CAPITAL LETTER A WITH BREVE AND ACUTE } + XK_abreveacute = $1001eaf; { U+1EAF LATIN SMALL LETTER A WITH BREVE AND ACUTE } + XKc_Abrevegrave = $1001eb0; { U+1EB0 LATIN CAPITAL LETTER A WITH BREVE AND GRAVE } + XK_abrevegrave = $1001eb1; { U+1EB1 LATIN SMALL LETTER A WITH BREVE AND GRAVE } + XKc_Abrevehook = $1001eb2; { U+1EB2 LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE } + XK_abrevehook = $1001eb3; { U+1EB3 LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE } + XKc_Abrevetilde = $1001eb4; { U+1EB4 LATIN CAPITAL LETTER A WITH BREVE AND TILDE } + XK_abrevetilde = $1001eb5; { U+1EB5 LATIN SMALL LETTER A WITH BREVE AND TILDE } + XKc_Abrevebelowdot = $1001eb6; { U+1EB6 LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW } + XK_abrevebelowdot = $1001eb7; { U+1EB7 LATIN SMALL LETTER A WITH BREVE AND DOT BELOW } + XKc_Ebelowdot = $1001eb8; { U+1EB8 LATIN CAPITAL LETTER E WITH DOT BELOW } + XK_ebelowdot = $1001eb9; { U+1EB9 LATIN SMALL LETTER E WITH DOT BELOW } + XKc_Ehook = $1001eba; { U+1EBA LATIN CAPITAL LETTER E WITH HOOK ABOVE } + XK_ehook = $1001ebb; { U+1EBB LATIN SMALL LETTER E WITH HOOK ABOVE } + XKc_Etilde = $1001ebc; { U+1EBC LATIN CAPITAL LETTER E WITH TILDE } + XK_etilde = $1001ebd; { U+1EBD LATIN SMALL LETTER E WITH TILDE } + XKc_Ecircumflexacute = $1001ebe; { U+1EBE LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE } + XK_ecircumflexacute = $1001ebf; { U+1EBF LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE } + XKc_Ecircumflexgrave = $1001ec0; { U+1EC0 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE } + XK_ecircumflexgrave = $1001ec1; { U+1EC1 LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE } + XKc_Ecircumflexhook = $1001ec2; { U+1EC2 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE } + XK_ecircumflexhook = $1001ec3; { U+1EC3 LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE } + XKc_Ecircumflextilde = $1001ec4; { U+1EC4 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE } + XK_ecircumflextilde = $1001ec5; { U+1EC5 LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE } + XKc_Ecircumflexbelowdot = $1001ec6; { U+1EC6 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW } + XK_ecircumflexbelowdot = $1001ec7; { U+1EC7 LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW } + XKc_Ihook = $1001ec8; { U+1EC8 LATIN CAPITAL LETTER I WITH HOOK ABOVE } + XK_ihook = $1001ec9; { U+1EC9 LATIN SMALL LETTER I WITH HOOK ABOVE } + XKc_Ibelowdot = $1001eca; { U+1ECA LATIN CAPITAL LETTER I WITH DOT BELOW } + XK_ibelowdot = $1001ecb; { U+1ECB LATIN SMALL LETTER I WITH DOT BELOW } + XKc_Obelowdot = $1001ecc; { U+1ECC LATIN CAPITAL LETTER O WITH DOT BELOW } + XK_obelowdot = $1001ecd; { U+1ECD LATIN SMALL LETTER O WITH DOT BELOW } + XKc_Ohook = $1001ece; { U+1ECE LATIN CAPITAL LETTER O WITH HOOK ABOVE } + XK_ohook = $1001ecf; { U+1ECF LATIN SMALL LETTER O WITH HOOK ABOVE } + XKc_Ocircumflexacute = $1001ed0; { U+1ED0 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE } + XK_ocircumflexacute = $1001ed1; { U+1ED1 LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE } + XKc_Ocircumflexgrave = $1001ed2; { U+1ED2 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE } + XK_ocircumflexgrave = $1001ed3; { U+1ED3 LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE } + XKc_Ocircumflexhook = $1001ed4; { U+1ED4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE } + XK_ocircumflexhook = $1001ed5; { U+1ED5 LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE } + XKc_Ocircumflextilde = $1001ed6; { U+1ED6 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE } + XK_ocircumflextilde = $1001ed7; { U+1ED7 LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE } + XKc_Ocircumflexbelowdot = $1001ed8; { U+1ED8 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW } + XK_ocircumflexbelowdot = $1001ed9; { U+1ED9 LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW } + XKc_Ohornacute = $1001eda; { U+1EDA LATIN CAPITAL LETTER O WITH HORN AND ACUTE } + XK_ohornacute = $1001edb; { U+1EDB LATIN SMALL LETTER O WITH HORN AND ACUTE } + XKc_Ohorngrave = $1001edc; { U+1EDC LATIN CAPITAL LETTER O WITH HORN AND GRAVE } + XK_ohorngrave = $1001edd; { U+1EDD LATIN SMALL LETTER O WITH HORN AND GRAVE } + XKc_Ohornhook = $1001ede; { U+1EDE LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE } + XK_ohornhook = $1001edf; { U+1EDF LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE } + XKc_Ohorntilde = $1001ee0; { U+1EE0 LATIN CAPITAL LETTER O WITH HORN AND TILDE } + XK_ohorntilde = $1001ee1; { U+1EE1 LATIN SMALL LETTER O WITH HORN AND TILDE } + XKc_Ohornbelowdot = $1001ee2; { U+1EE2 LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW } + XK_ohornbelowdot = $1001ee3; { U+1EE3 LATIN SMALL LETTER O WITH HORN AND DOT BELOW } + XKc_Ubelowdot = $1001ee4; { U+1EE4 LATIN CAPITAL LETTER U WITH DOT BELOW } + XK_ubelowdot = $1001ee5; { U+1EE5 LATIN SMALL LETTER U WITH DOT BELOW } + XKc_Uhook = $1001ee6; { U+1EE6 LATIN CAPITAL LETTER U WITH HOOK ABOVE } + XK_uhook = $1001ee7; { U+1EE7 LATIN SMALL LETTER U WITH HOOK ABOVE } + XKc_Uhornacute = $1001ee8; { U+1EE8 LATIN CAPITAL LETTER U WITH HORN AND ACUTE } + XK_uhornacute = $1001ee9; { U+1EE9 LATIN SMALL LETTER U WITH HORN AND ACUTE } + XKc_Uhorngrave = $1001eea; { U+1EEA LATIN CAPITAL LETTER U WITH HORN AND GRAVE } + XK_uhorngrave = $1001eeb; { U+1EEB LATIN SMALL LETTER U WITH HORN AND GRAVE } + XKc_Uhornhook = $1001eec; { U+1EEC LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE } + XK_uhornhook = $1001eed; { U+1EED LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE } + XKc_Uhorntilde = $1001eee; { U+1EEE LATIN CAPITAL LETTER U WITH HORN AND TILDE } + XK_uhorntilde = $1001eef; { U+1EEF LATIN SMALL LETTER U WITH HORN AND TILDE } + XKc_Uhornbelowdot = $1001ef0; { U+1EF0 LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW } + XK_uhornbelowdot = $1001ef1; { U+1EF1 LATIN SMALL LETTER U WITH HORN AND DOT BELOW } + XKc_Ybelowdot = $1001ef4; { U+1EF4 LATIN CAPITAL LETTER Y WITH DOT BELOW } + XK_ybelowdot = $1001ef5; { U+1EF5 LATIN SMALL LETTER Y WITH DOT BELOW } + XKc_Yhook = $1001ef6; { U+1EF6 LATIN CAPITAL LETTER Y WITH HOOK ABOVE } + XK_yhook = $1001ef7; { U+1EF7 LATIN SMALL LETTER Y WITH HOOK ABOVE } + XKc_Ytilde = $1001ef8; { U+1EF8 LATIN CAPITAL LETTER Y WITH TILDE } + XK_ytilde = $1001ef9; { U+1EF9 LATIN SMALL LETTER Y WITH TILDE } + XKc_Ohorn = $10001a0; { U+01A0 LATIN CAPITAL LETTER O WITH HORN } + XK_ohorn = $10001a1; { U+01A1 LATIN SMALL LETTER O WITH HORN } + XKc_Uhorn = $10001af; { U+01AF LATIN CAPITAL LETTER U WITH HORN } + XK_uhorn = $10001b0; { U+01B0 LATIN SMALL LETTER U WITH HORN } + + XK_EcuSign = $10020a0; { U+20A0 EURO-CURRENCY SIGN } + XK_ColonSign = $10020a1; { U+20A1 COLON SIGN } + XK_CruzeiroSign = $10020a2; { U+20A2 CRUZEIRO SIGN } + XK_FFrancSign = $10020a3; { U+20A3 FRENCH FRANC SIGN } + XK_LiraSign = $10020a4; { U+20A4 LIRA SIGN } + XK_MillSign = $10020a5; { U+20A5 MILL SIGN } + XK_NairaSign = $10020a6; { U+20A6 NAIRA SIGN } + XK_PesetaSign = $10020a7; { U+20A7 PESETA SIGN } + XK_RupeeSign = $10020a8; { U+20A8 RUPEE SIGN } + XK_WonSign = $10020a9; { U+20A9 WON SIGN } + XK_NewSheqelSign = $10020aa; { U+20AA NEW SHEQEL SIGN } + XK_DongSign = $10020ab; { U+20AB DONG SIGN } + XK_EuroSign = $20ac; { U+20AC EURO SIGN } + + XK_zerosuperior = $1002070; { U+2070 SUPERSCRIPT ZERO } + XK_foursuperior = $1002074; { U+2074 SUPERSCRIPT FOUR } + XK_fivesuperior = $1002075; { U+2075 SUPERSCRIPT FIVE } + XK_sixsuperior = $1002076; { U+2076 SUPERSCRIPT SIX } + XK_sevensuperior = $1002077; { U+2077 SUPERSCRIPT SEVEN } + XK_eightsuperior = $1002078; { U+2078 SUPERSCRIPT EIGHT } + XK_ninesuperior = $1002079; { U+2079 SUPERSCRIPT NINE } + XK_zerosubscript = $1002080; { U+2080 SUBSCRIPT ZERO } + XK_onesubscript = $1002081; { U+2081 SUBSCRIPT ONE } + XK_twosubscript = $1002082; { U+2082 SUBSCRIPT TWO } + XK_threesubscript = $1002083; { U+2083 SUBSCRIPT THREE } + XK_foursubscript = $1002084; { U+2084 SUBSCRIPT FOUR } + XK_fivesubscript = $1002085; { U+2085 SUBSCRIPT FIVE } + XK_sixsubscript = $1002086; { U+2086 SUBSCRIPT SIX } + XK_sevensubscript = $1002087; { U+2087 SUBSCRIPT SEVEN } + XK_eightsubscript = $1002088; { U+2088 SUBSCRIPT EIGHT } + XK_ninesubscript = $1002089; { U+2089 SUBSCRIPT NINE } + XK_partdifferential = $1002202; { U+2202 PARTIAL DIFFERENTIAL } + XK_emptyset = $1002205; { U+2205 NULL SET } + XK_elementof = $1002208; { U+2208 ELEMENT OF } + XK_notelementof = $1002209; { U+2209 NOT AN ELEMENT OF } + XK_containsas = $100220B; { U+220B CONTAINS AS MEMBER } + XK_squareroot = $100221A; { U+221A SQUARE ROOT } + XK_cuberoot = $100221B; { U+221B CUBE ROOT } + XK_fourthroot = $100221C; { U+221C FOURTH ROOT } + XK_dintegral = $100222C; { U+222C DOUBLE INTEGRAL } + XK_tintegral = $100222D; { U+222D TRIPLE INTEGRAL } + XK_because = $1002235; { U+2235 BECAUSE } + XK_approxeq = $1002248; { U+2245 ALMOST EQUAL TO } + XK_notapproxeq = $1002247; { U+2247 NOT ALMOST EQUAL TO } + XK_notidentical = $1002262; { U+2262 NOT IDENTICAL TO } + XK_stricteq = $1002263; { U+2263 STRICTLY EQUIVALENT TO } + + XK_braille_dot_1 = $fff1; + XK_braille_dot_2 = $fff2; + XK_braille_dot_3 = $fff3; + XK_braille_dot_4 = $fff4; + XK_braille_dot_5 = $fff5; + XK_braille_dot_6 = $fff6; + XK_braille_dot_7 = $fff7; + XK_braille_dot_8 = $fff8; + XK_braille_dot_9 = $fff9; + XK_braille_dot_10 = $fffa; + XK_braille_blank = $1002800; { U+2800 BRAILLE PATTERN BLANK } + XK_braille_dots_1 = $1002801; { U+2801 BRAILLE PATTERN DOTS-1 } + XK_braille_dots_2 = $1002802; { U+2802 BRAILLE PATTERN DOTS-2 } + XK_braille_dots_12 = $1002803; { U+2803 BRAILLE PATTERN DOTS-12 } + XK_braille_dots_3 = $1002804; { U+2804 BRAILLE PATTERN DOTS-3 } + XK_braille_dots_13 = $1002805; { U+2805 BRAILLE PATTERN DOTS-13 } + XK_braille_dots_23 = $1002806; { U+2806 BRAILLE PATTERN DOTS-23 } + XK_braille_dots_123 = $1002807; { U+2807 BRAILLE PATTERN DOTS-123 } + XK_braille_dots_4 = $1002808; { U+2808 BRAILLE PATTERN DOTS-4 } + XK_braille_dots_14 = $1002809; { U+2809 BRAILLE PATTERN DOTS-14 } + XK_braille_dots_24 = $100280a; { U+280a BRAILLE PATTERN DOTS-24 } + XK_braille_dots_124 = $100280b; { U+280b BRAILLE PATTERN DOTS-124 } + XK_braille_dots_34 = $100280c; { U+280c BRAILLE PATTERN DOTS-34 } + XK_braille_dots_134 = $100280d; { U+280d BRAILLE PATTERN DOTS-134 } + XK_braille_dots_234 = $100280e; { U+280e BRAILLE PATTERN DOTS-234 } + XK_braille_dots_1234 = $100280f; { U+280f BRAILLE PATTERN DOTS-1234 } + XK_braille_dots_5 = $1002810; { U+2810 BRAILLE PATTERN DOTS-5 } + XK_braille_dots_15 = $1002811; { U+2811 BRAILLE PATTERN DOTS-15 } + XK_braille_dots_25 = $1002812; { U+2812 BRAILLE PATTERN DOTS-25 } + XK_braille_dots_125 = $1002813; { U+2813 BRAILLE PATTERN DOTS-125 } + XK_braille_dots_35 = $1002814; { U+2814 BRAILLE PATTERN DOTS-35 } + XK_braille_dots_135 = $1002815; { U+2815 BRAILLE PATTERN DOTS-135 } + XK_braille_dots_235 = $1002816; { U+2816 BRAILLE PATTERN DOTS-235 } + XK_braille_dots_1235 = $1002817; { U+2817 BRAILLE PATTERN DOTS-1235 } + XK_braille_dots_45 = $1002818; { U+2818 BRAILLE PATTERN DOTS-45 } + XK_braille_dots_145 = $1002819; { U+2819 BRAILLE PATTERN DOTS-145 } + XK_braille_dots_245 = $100281a; { U+281a BRAILLE PATTERN DOTS-245 } + XK_braille_dots_1245 = $100281b; { U+281b BRAILLE PATTERN DOTS-1245 } + XK_braille_dots_345 = $100281c; { U+281c BRAILLE PATTERN DOTS-345 } + XK_braille_dots_1345 = $100281d; { U+281d BRAILLE PATTERN DOTS-1345 } + XK_braille_dots_2345 = $100281e; { U+281e BRAILLE PATTERN DOTS-2345 } + XK_braille_dots_12345 = $100281f; { U+281f BRAILLE PATTERN DOTS-12345 } + XK_braille_dots_6 = $1002820; { U+2820 BRAILLE PATTERN DOTS-6 } + XK_braille_dots_16 = $1002821; { U+2821 BRAILLE PATTERN DOTS-16 } + XK_braille_dots_26 = $1002822; { U+2822 BRAILLE PATTERN DOTS-26 } + XK_braille_dots_126 = $1002823; { U+2823 BRAILLE PATTERN DOTS-126 } + XK_braille_dots_36 = $1002824; { U+2824 BRAILLE PATTERN DOTS-36 } + XK_braille_dots_136 = $1002825; { U+2825 BRAILLE PATTERN DOTS-136 } + XK_braille_dots_236 = $1002826; { U+2826 BRAILLE PATTERN DOTS-236 } + XK_braille_dots_1236 = $1002827; { U+2827 BRAILLE PATTERN DOTS-1236 } + XK_braille_dots_46 = $1002828; { U+2828 BRAILLE PATTERN DOTS-46 } + XK_braille_dots_146 = $1002829; { U+2829 BRAILLE PATTERN DOTS-146 } + XK_braille_dots_246 = $100282a; { U+282a BRAILLE PATTERN DOTS-246 } + XK_braille_dots_1246 = $100282b; { U+282b BRAILLE PATTERN DOTS-1246 } + XK_braille_dots_346 = $100282c; { U+282c BRAILLE PATTERN DOTS-346 } + XK_braille_dots_1346 = $100282d; { U+282d BRAILLE PATTERN DOTS-1346 } + XK_braille_dots_2346 = $100282e; { U+282e BRAILLE PATTERN DOTS-2346 } + XK_braille_dots_12346 = $100282f; { U+282f BRAILLE PATTERN DOTS-12346 } + XK_braille_dots_56 = $1002830; { U+2830 BRAILLE PATTERN DOTS-56 } + XK_braille_dots_156 = $1002831; { U+2831 BRAILLE PATTERN DOTS-156 } + XK_braille_dots_256 = $1002832; { U+2832 BRAILLE PATTERN DOTS-256 } + XK_braille_dots_1256 = $1002833; { U+2833 BRAILLE PATTERN DOTS-1256 } + XK_braille_dots_356 = $1002834; { U+2834 BRAILLE PATTERN DOTS-356 } + XK_braille_dots_1356 = $1002835; { U+2835 BRAILLE PATTERN DOTS-1356 } + XK_braille_dots_2356 = $1002836; { U+2836 BRAILLE PATTERN DOTS-2356 } + XK_braille_dots_12356 = $1002837; { U+2837 BRAILLE PATTERN DOTS-12356 } + XK_braille_dots_456 = $1002838; { U+2838 BRAILLE PATTERN DOTS-456 } + XK_braille_dots_1456 = $1002839; { U+2839 BRAILLE PATTERN DOTS-1456 } + XK_braille_dots_2456 = $100283a; { U+283a BRAILLE PATTERN DOTS-2456 } + XK_braille_dots_12456 = $100283b; { U+283b BRAILLE PATTERN DOTS-12456 } + XK_braille_dots_3456 = $100283c; { U+283c BRAILLE PATTERN DOTS-3456 } + XK_braille_dots_13456 = $100283d; { U+283d BRAILLE PATTERN DOTS-13456 } + XK_braille_dots_23456 = $100283e; { U+283e BRAILLE PATTERN DOTS-23456 } + XK_braille_dots_123456 = $100283f; { U+283f BRAILLE PATTERN DOTS-123456 } + XK_braille_dots_7 = $1002840; { U+2840 BRAILLE PATTERN DOTS-7 } + XK_braille_dots_17 = $1002841; { U+2841 BRAILLE PATTERN DOTS-17 } + XK_braille_dots_27 = $1002842; { U+2842 BRAILLE PATTERN DOTS-27 } + XK_braille_dots_127 = $1002843; { U+2843 BRAILLE PATTERN DOTS-127 } + XK_braille_dots_37 = $1002844; { U+2844 BRAILLE PATTERN DOTS-37 } + XK_braille_dots_137 = $1002845; { U+2845 BRAILLE PATTERN DOTS-137 } + XK_braille_dots_237 = $1002846; { U+2846 BRAILLE PATTERN DOTS-237 } + XK_braille_dots_1237 = $1002847; { U+2847 BRAILLE PATTERN DOTS-1237 } + XK_braille_dots_47 = $1002848; { U+2848 BRAILLE PATTERN DOTS-47 } + XK_braille_dots_147 = $1002849; { U+2849 BRAILLE PATTERN DOTS-147 } + XK_braille_dots_247 = $100284a; { U+284a BRAILLE PATTERN DOTS-247 } + XK_braille_dots_1247 = $100284b; { U+284b BRAILLE PATTERN DOTS-1247 } + XK_braille_dots_347 = $100284c; { U+284c BRAILLE PATTERN DOTS-347 } + XK_braille_dots_1347 = $100284d; { U+284d BRAILLE PATTERN DOTS-1347 } + XK_braille_dots_2347 = $100284e; { U+284e BRAILLE PATTERN DOTS-2347 } + XK_braille_dots_12347 = $100284f; { U+284f BRAILLE PATTERN DOTS-12347 } + XK_braille_dots_57 = $1002850; { U+2850 BRAILLE PATTERN DOTS-57 } + XK_braille_dots_157 = $1002851; { U+2851 BRAILLE PATTERN DOTS-157 } + XK_braille_dots_257 = $1002852; { U+2852 BRAILLE PATTERN DOTS-257 } + XK_braille_dots_1257 = $1002853; { U+2853 BRAILLE PATTERN DOTS-1257 } + XK_braille_dots_357 = $1002854; { U+2854 BRAILLE PATTERN DOTS-357 } + XK_braille_dots_1357 = $1002855; { U+2855 BRAILLE PATTERN DOTS-1357 } + XK_braille_dots_2357 = $1002856; { U+2856 BRAILLE PATTERN DOTS-2357 } + XK_braille_dots_12357 = $1002857; { U+2857 BRAILLE PATTERN DOTS-12357 } + XK_braille_dots_457 = $1002858; { U+2858 BRAILLE PATTERN DOTS-457 } + XK_braille_dots_1457 = $1002859; { U+2859 BRAILLE PATTERN DOTS-1457 } + XK_braille_dots_2457 = $100285a; { U+285a BRAILLE PATTERN DOTS-2457 } + XK_braille_dots_12457 = $100285b; { U+285b BRAILLE PATTERN DOTS-12457 } + XK_braille_dots_3457 = $100285c; { U+285c BRAILLE PATTERN DOTS-3457 } + XK_braille_dots_13457 = $100285d; { U+285d BRAILLE PATTERN DOTS-13457 } + XK_braille_dots_23457 = $100285e; { U+285e BRAILLE PATTERN DOTS-23457 } + XK_braille_dots_123457 = $100285f; { U+285f BRAILLE PATTERN DOTS-123457 } + XK_braille_dots_67 = $1002860; { U+2860 BRAILLE PATTERN DOTS-67 } + XK_braille_dots_167 = $1002861; { U+2861 BRAILLE PATTERN DOTS-167 } + XK_braille_dots_267 = $1002862; { U+2862 BRAILLE PATTERN DOTS-267 } + XK_braille_dots_1267 = $1002863; { U+2863 BRAILLE PATTERN DOTS-1267 } + XK_braille_dots_367 = $1002864; { U+2864 BRAILLE PATTERN DOTS-367 } + XK_braille_dots_1367 = $1002865; { U+2865 BRAILLE PATTERN DOTS-1367 } + XK_braille_dots_2367 = $1002866; { U+2866 BRAILLE PATTERN DOTS-2367 } + XK_braille_dots_12367 = $1002867; { U+2867 BRAILLE PATTERN DOTS-12367 } + XK_braille_dots_467 = $1002868; { U+2868 BRAILLE PATTERN DOTS-467 } + XK_braille_dots_1467 = $1002869; { U+2869 BRAILLE PATTERN DOTS-1467 } + XK_braille_dots_2467 = $100286a; { U+286a BRAILLE PATTERN DOTS-2467 } + XK_braille_dots_12467 = $100286b; { U+286b BRAILLE PATTERN DOTS-12467 } + XK_braille_dots_3467 = $100286c; { U+286c BRAILLE PATTERN DOTS-3467 } + XK_braille_dots_13467 = $100286d; { U+286d BRAILLE PATTERN DOTS-13467 } + XK_braille_dots_23467 = $100286e; { U+286e BRAILLE PATTERN DOTS-23467 } + XK_braille_dots_123467 = $100286f; { U+286f BRAILLE PATTERN DOTS-123467 } + XK_braille_dots_567 = $1002870; { U+2870 BRAILLE PATTERN DOTS-567 } + XK_braille_dots_1567 = $1002871; { U+2871 BRAILLE PATTERN DOTS-1567 } + XK_braille_dots_2567 = $1002872; { U+2872 BRAILLE PATTERN DOTS-2567 } + XK_braille_dots_12567 = $1002873; { U+2873 BRAILLE PATTERN DOTS-12567 } + XK_braille_dots_3567 = $1002874; { U+2874 BRAILLE PATTERN DOTS-3567 } + XK_braille_dots_13567 = $1002875; { U+2875 BRAILLE PATTERN DOTS-13567 } + XK_braille_dots_23567 = $1002876; { U+2876 BRAILLE PATTERN DOTS-23567 } + XK_braille_dots_123567 = $1002877; { U+2877 BRAILLE PATTERN DOTS-123567 } + XK_braille_dots_4567 = $1002878; { U+2878 BRAILLE PATTERN DOTS-4567 } + XK_braille_dots_14567 = $1002879; { U+2879 BRAILLE PATTERN DOTS-14567 } + XK_braille_dots_24567 = $100287a; { U+287a BRAILLE PATTERN DOTS-24567 } + XK_braille_dots_124567 = $100287b; { U+287b BRAILLE PATTERN DOTS-124567 } + XK_braille_dots_34567 = $100287c; { U+287c BRAILLE PATTERN DOTS-34567 } + XK_braille_dots_134567 = $100287d; { U+287d BRAILLE PATTERN DOTS-134567 } + XK_braille_dots_234567 = $100287e; { U+287e BRAILLE PATTERN DOTS-234567 } + XK_braille_dots_1234567 = $100287f; { U+287f BRAILLE PATTERN DOTS-1234567 } + XK_braille_dots_8 = $1002880; { U+2880 BRAILLE PATTERN DOTS-8 } + XK_braille_dots_18 = $1002881; { U+2881 BRAILLE PATTERN DOTS-18 } + XK_braille_dots_28 = $1002882; { U+2882 BRAILLE PATTERN DOTS-28 } + XK_braille_dots_128 = $1002883; { U+2883 BRAILLE PATTERN DOTS-128 } + XK_braille_dots_38 = $1002884; { U+2884 BRAILLE PATTERN DOTS-38 } + XK_braille_dots_138 = $1002885; { U+2885 BRAILLE PATTERN DOTS-138 } + XK_braille_dots_238 = $1002886; { U+2886 BRAILLE PATTERN DOTS-238 } + XK_braille_dots_1238 = $1002887; { U+2887 BRAILLE PATTERN DOTS-1238 } + XK_braille_dots_48 = $1002888; { U+2888 BRAILLE PATTERN DOTS-48 } + XK_braille_dots_148 = $1002889; { U+2889 BRAILLE PATTERN DOTS-148 } + XK_braille_dots_248 = $100288a; { U+288a BRAILLE PATTERN DOTS-248 } + XK_braille_dots_1248 = $100288b; { U+288b BRAILLE PATTERN DOTS-1248 } + XK_braille_dots_348 = $100288c; { U+288c BRAILLE PATTERN DOTS-348 } + XK_braille_dots_1348 = $100288d; { U+288d BRAILLE PATTERN DOTS-1348 } + XK_braille_dots_2348 = $100288e; { U+288e BRAILLE PATTERN DOTS-2348 } + XK_braille_dots_12348 = $100288f; { U+288f BRAILLE PATTERN DOTS-12348 } + XK_braille_dots_58 = $1002890; { U+2890 BRAILLE PATTERN DOTS-58 } + XK_braille_dots_158 = $1002891; { U+2891 BRAILLE PATTERN DOTS-158 } + XK_braille_dots_258 = $1002892; { U+2892 BRAILLE PATTERN DOTS-258 } + XK_braille_dots_1258 = $1002893; { U+2893 BRAILLE PATTERN DOTS-1258 } + XK_braille_dots_358 = $1002894; { U+2894 BRAILLE PATTERN DOTS-358 } + XK_braille_dots_1358 = $1002895; { U+2895 BRAILLE PATTERN DOTS-1358 } + XK_braille_dots_2358 = $1002896; { U+2896 BRAILLE PATTERN DOTS-2358 } + XK_braille_dots_12358 = $1002897; { U+2897 BRAILLE PATTERN DOTS-12358 } + XK_braille_dots_458 = $1002898; { U+2898 BRAILLE PATTERN DOTS-458 } + XK_braille_dots_1458 = $1002899; { U+2899 BRAILLE PATTERN DOTS-1458 } + XK_braille_dots_2458 = $100289a; { U+289a BRAILLE PATTERN DOTS-2458 } + XK_braille_dots_12458 = $100289b; { U+289b BRAILLE PATTERN DOTS-12458 } + XK_braille_dots_3458 = $100289c; { U+289c BRAILLE PATTERN DOTS-3458 } + XK_braille_dots_13458 = $100289d; { U+289d BRAILLE PATTERN DOTS-13458 } + XK_braille_dots_23458 = $100289e; { U+289e BRAILLE PATTERN DOTS-23458 } + XK_braille_dots_123458 = $100289f; { U+289f BRAILLE PATTERN DOTS-123458 } + XK_braille_dots_68 = $10028a0; { U+28a0 BRAILLE PATTERN DOTS-68 } + XK_braille_dots_168 = $10028a1; { U+28a1 BRAILLE PATTERN DOTS-168 } + XK_braille_dots_268 = $10028a2; { U+28a2 BRAILLE PATTERN DOTS-268 } + XK_braille_dots_1268 = $10028a3; { U+28a3 BRAILLE PATTERN DOTS-1268 } + XK_braille_dots_368 = $10028a4; { U+28a4 BRAILLE PATTERN DOTS-368 } + XK_braille_dots_1368 = $10028a5; { U+28a5 BRAILLE PATTERN DOTS-1368 } + XK_braille_dots_2368 = $10028a6; { U+28a6 BRAILLE PATTERN DOTS-2368 } + XK_braille_dots_12368 = $10028a7; { U+28a7 BRAILLE PATTERN DOTS-12368 } + XK_braille_dots_468 = $10028a8; { U+28a8 BRAILLE PATTERN DOTS-468 } + XK_braille_dots_1468 = $10028a9; { U+28a9 BRAILLE PATTERN DOTS-1468 } + XK_braille_dots_2468 = $10028aa; { U+28aa BRAILLE PATTERN DOTS-2468 } + XK_braille_dots_12468 = $10028ab; { U+28ab BRAILLE PATTERN DOTS-12468 } + XK_braille_dots_3468 = $10028ac; { U+28ac BRAILLE PATTERN DOTS-3468 } + XK_braille_dots_13468 = $10028ad; { U+28ad BRAILLE PATTERN DOTS-13468 } + XK_braille_dots_23468 = $10028ae; { U+28ae BRAILLE PATTERN DOTS-23468 } + XK_braille_dots_123468 = $10028af; { U+28af BRAILLE PATTERN DOTS-123468 } + XK_braille_dots_568 = $10028b0; { U+28b0 BRAILLE PATTERN DOTS-568 } + XK_braille_dots_1568 = $10028b1; { U+28b1 BRAILLE PATTERN DOTS-1568 } + XK_braille_dots_2568 = $10028b2; { U+28b2 BRAILLE PATTERN DOTS-2568 } + XK_braille_dots_12568 = $10028b3; { U+28b3 BRAILLE PATTERN DOTS-12568 } + XK_braille_dots_3568 = $10028b4; { U+28b4 BRAILLE PATTERN DOTS-3568 } + XK_braille_dots_13568 = $10028b5; { U+28b5 BRAILLE PATTERN DOTS-13568 } + XK_braille_dots_23568 = $10028b6; { U+28b6 BRAILLE PATTERN DOTS-23568 } + XK_braille_dots_123568 = $10028b7; { U+28b7 BRAILLE PATTERN DOTS-123568 } + XK_braille_dots_4568 = $10028b8; { U+28b8 BRAILLE PATTERN DOTS-4568 } + XK_braille_dots_14568 = $10028b9; { U+28b9 BRAILLE PATTERN DOTS-14568 } + XK_braille_dots_24568 = $10028ba; { U+28ba BRAILLE PATTERN DOTS-24568 } + XK_braille_dots_124568 = $10028bb; { U+28bb BRAILLE PATTERN DOTS-124568 } + XK_braille_dots_34568 = $10028bc; { U+28bc BRAILLE PATTERN DOTS-34568 } + XK_braille_dots_134568 = $10028bd; { U+28bd BRAILLE PATTERN DOTS-134568 } + XK_braille_dots_234568 = $10028be; { U+28be BRAILLE PATTERN DOTS-234568 } + XK_braille_dots_1234568 = $10028bf; { U+28bf BRAILLE PATTERN DOTS-1234568 } + XK_braille_dots_78 = $10028c0; { U+28c0 BRAILLE PATTERN DOTS-78 } + XK_braille_dots_178 = $10028c1; { U+28c1 BRAILLE PATTERN DOTS-178 } + XK_braille_dots_278 = $10028c2; { U+28c2 BRAILLE PATTERN DOTS-278 } + XK_braille_dots_1278 = $10028c3; { U+28c3 BRAILLE PATTERN DOTS-1278 } + XK_braille_dots_378 = $10028c4; { U+28c4 BRAILLE PATTERN DOTS-378 } + XK_braille_dots_1378 = $10028c5; { U+28c5 BRAILLE PATTERN DOTS-1378 } + XK_braille_dots_2378 = $10028c6; { U+28c6 BRAILLE PATTERN DOTS-2378 } + XK_braille_dots_12378 = $10028c7; { U+28c7 BRAILLE PATTERN DOTS-12378 } + XK_braille_dots_478 = $10028c8; { U+28c8 BRAILLE PATTERN DOTS-478 } + XK_braille_dots_1478 = $10028c9; { U+28c9 BRAILLE PATTERN DOTS-1478 } + XK_braille_dots_2478 = $10028ca; { U+28ca BRAILLE PATTERN DOTS-2478 } + XK_braille_dots_12478 = $10028cb; { U+28cb BRAILLE PATTERN DOTS-12478 } + XK_braille_dots_3478 = $10028cc; { U+28cc BRAILLE PATTERN DOTS-3478 } + XK_braille_dots_13478 = $10028cd; { U+28cd BRAILLE PATTERN DOTS-13478 } + XK_braille_dots_23478 = $10028ce; { U+28ce BRAILLE PATTERN DOTS-23478 } + XK_braille_dots_123478 = $10028cf; { U+28cf BRAILLE PATTERN DOTS-123478 } + XK_braille_dots_578 = $10028d0; { U+28d0 BRAILLE PATTERN DOTS-578 } + XK_braille_dots_1578 = $10028d1; { U+28d1 BRAILLE PATTERN DOTS-1578 } + XK_braille_dots_2578 = $10028d2; { U+28d2 BRAILLE PATTERN DOTS-2578 } + XK_braille_dots_12578 = $10028d3; { U+28d3 BRAILLE PATTERN DOTS-12578 } + XK_braille_dots_3578 = $10028d4; { U+28d4 BRAILLE PATTERN DOTS-3578 } + XK_braille_dots_13578 = $10028d5; { U+28d5 BRAILLE PATTERN DOTS-13578 } + XK_braille_dots_23578 = $10028d6; { U+28d6 BRAILLE PATTERN DOTS-23578 } + XK_braille_dots_123578 = $10028d7; { U+28d7 BRAILLE PATTERN DOTS-123578 } + XK_braille_dots_4578 = $10028d8; { U+28d8 BRAILLE PATTERN DOTS-4578 } + XK_braille_dots_14578 = $10028d9; { U+28d9 BRAILLE PATTERN DOTS-14578 } + XK_braille_dots_24578 = $10028da; { U+28da BRAILLE PATTERN DOTS-24578 } + XK_braille_dots_124578 = $10028db; { U+28db BRAILLE PATTERN DOTS-124578 } + XK_braille_dots_34578 = $10028dc; { U+28dc BRAILLE PATTERN DOTS-34578 } + XK_braille_dots_134578 = $10028dd; { U+28dd BRAILLE PATTERN DOTS-134578 } + XK_braille_dots_234578 = $10028de; { U+28de BRAILLE PATTERN DOTS-234578 } + XK_braille_dots_1234578 = $10028df; { U+28df BRAILLE PATTERN DOTS-1234578 } + XK_braille_dots_678 = $10028e0; { U+28e0 BRAILLE PATTERN DOTS-678 } + XK_braille_dots_1678 = $10028e1; { U+28e1 BRAILLE PATTERN DOTS-1678 } + XK_braille_dots_2678 = $10028e2; { U+28e2 BRAILLE PATTERN DOTS-2678 } + XK_braille_dots_12678 = $10028e3; { U+28e3 BRAILLE PATTERN DOTS-12678 } + XK_braille_dots_3678 = $10028e4; { U+28e4 BRAILLE PATTERN DOTS-3678 } + XK_braille_dots_13678 = $10028e5; { U+28e5 BRAILLE PATTERN DOTS-13678 } + XK_braille_dots_23678 = $10028e6; { U+28e6 BRAILLE PATTERN DOTS-23678 } + XK_braille_dots_123678 = $10028e7; { U+28e7 BRAILLE PATTERN DOTS-123678 } + XK_braille_dots_4678 = $10028e8; { U+28e8 BRAILLE PATTERN DOTS-4678 } + XK_braille_dots_14678 = $10028e9; { U+28e9 BRAILLE PATTERN DOTS-14678 } + XK_braille_dots_24678 = $10028ea; { U+28ea BRAILLE PATTERN DOTS-24678 } + XK_braille_dots_124678 = $10028eb; { U+28eb BRAILLE PATTERN DOTS-124678 } + XK_braille_dots_34678 = $10028ec; { U+28ec BRAILLE PATTERN DOTS-34678 } + XK_braille_dots_134678 = $10028ed; { U+28ed BRAILLE PATTERN DOTS-134678 } + XK_braille_dots_234678 = $10028ee; { U+28ee BRAILLE PATTERN DOTS-234678 } + XK_braille_dots_1234678 = $10028ef; { U+28ef BRAILLE PATTERN DOTS-1234678 } + XK_braille_dots_5678 = $10028f0; { U+28f0 BRAILLE PATTERN DOTS-5678 } + XK_braille_dots_15678 = $10028f1; { U+28f1 BRAILLE PATTERN DOTS-15678 } + XK_braille_dots_25678 = $10028f2; { U+28f2 BRAILLE PATTERN DOTS-25678 } + XK_braille_dots_125678 = $10028f3; { U+28f3 BRAILLE PATTERN DOTS-125678 } + XK_braille_dots_35678 = $10028f4; { U+28f4 BRAILLE PATTERN DOTS-35678 } + XK_braille_dots_135678 = $10028f5; { U+28f5 BRAILLE PATTERN DOTS-135678 } + XK_braille_dots_235678 = $10028f6; { U+28f6 BRAILLE PATTERN DOTS-235678 } + XK_braille_dots_1235678 = $10028f7; { U+28f7 BRAILLE PATTERN DOTS-1235678 } + XK_braille_dots_45678 = $10028f8; { U+28f8 BRAILLE PATTERN DOTS-45678 } + XK_braille_dots_145678 = $10028f9; { U+28f9 BRAILLE PATTERN DOTS-145678 } + XK_braille_dots_245678 = $10028fa; { U+28fa BRAILLE PATTERN DOTS-245678 } + XK_braille_dots_1245678 = $10028fb; { U+28fb BRAILLE PATTERN DOTS-1245678 } + XK_braille_dots_345678 = $10028fc; { U+28fc BRAILLE PATTERN DOTS-345678 } + XK_braille_dots_1345678 = $10028fd; { U+28fd BRAILLE PATTERN DOTS-1345678 } + XK_braille_dots_2345678 = $10028fe; { U+28fe BRAILLE PATTERN DOTS-2345678 } + XK_braille_dots_12345678 = $10028ff; { U+28ff BRAILLE PATTERN DOTS-12345678 } + + XK_Sinh_ng = $1000d82; { U+0D82 SINHALA ANUSVARAYA } + XK_Sinh_h2 = $1000d83; { U+0D83 SINHALA VISARGAYA } + XK_Sinh_a = $1000d85; { U+0D85 SINHALA AYANNA } + XK_Sinh_aa = $1000d86; { U+0D86 SINHALA AAYANNA } + XK_Sinh_ae = $1000d87; { U+0D87 SINHALA AEYANNA } + XK_Sinh_aee = $1000d88; { U+0D88 SINHALA AEEYANNA } + XK_Sinh_i = $1000d89; { U+0D89 SINHALA IYANNA } + XK_Sinh_ii = $1000d8a; { U+0D8A SINHALA IIYANNA } + XK_Sinh_u = $1000d8b; { U+0D8B SINHALA UYANNA } + XK_Sinh_uu = $1000d8c; { U+0D8C SINHALA UUYANNA } + XK_Sinh_ri = $1000d8d; { U+0D8D SINHALA IRUYANNA } + XK_Sinh_rii = $1000d8e; { U+0D8E SINHALA IRUUYANNA } + XK_Sinh_lu = $1000d8f; { U+0D8F SINHALA ILUYANNA } + XK_Sinh_luu = $1000d90; { U+0D90 SINHALA ILUUYANNA } + XK_Sinh_e = $1000d91; { U+0D91 SINHALA EYANNA } + XK_Sinh_ee = $1000d92; { U+0D92 SINHALA EEYANNA } + XK_Sinh_ai = $1000d93; { U+0D93 SINHALA AIYANNA } + XK_Sinh_o = $1000d94; { U+0D94 SINHALA OYANNA } + XK_Sinh_oo = $1000d95; { U+0D95 SINHALA OOYANNA } + XK_Sinh_au = $1000d96; { U+0D96 SINHALA AUYANNA } + XK_Sinh_ka = $1000d9a; { U+0D9A SINHALA KAYANNA } + XK_Sinh_kha = $1000d9b; { U+0D9B SINHALA MAHA. KAYANNA } + XK_Sinh_ga = $1000d9c; { U+0D9C SINHALA GAYANNA } + XK_Sinh_gha = $1000d9d; { U+0D9D SINHALA MAHA. GAYANNA } + XK_Sinh_ng2 = $1000d9e; { U+0D9E SINHALA KANTAJA NAASIKYAYA } + XK_Sinh_nga = $1000d9f; { U+0D9F SINHALA SANYAKA GAYANNA } + XK_Sinh_ca = $1000da0; { U+0DA0 SINHALA CAYANNA } + XK_Sinh_cha = $1000da1; { U+0DA1 SINHALA MAHA. CAYANNA } + XK_Sinh_ja = $1000da2; { U+0DA2 SINHALA JAYANNA } + XK_Sinh_jha = $1000da3; { U+0DA3 SINHALA MAHA. JAYANNA } + XK_Sinh_nya = $1000da4; { U+0DA4 SINHALA TAALUJA NAASIKYAYA } + XK_Sinh_jnya = $1000da5; { U+0DA5 SINHALA TAALUJA SANYOOGA NAASIKYAYA } + XK_Sinh_nja = $1000da6; { U+0DA6 SINHALA SANYAKA JAYANNA } + XK_Sinh_tta = $1000da7; { U+0DA7 SINHALA TTAYANNA } + XK_Sinh_ttha = $1000da8; { U+0DA8 SINHALA MAHA. TTAYANNA } + XK_Sinh_dda = $1000da9; { U+0DA9 SINHALA DDAYANNA } + XK_Sinh_ddha = $1000daa; { U+0DAA SINHALA MAHA. DDAYANNA } + XK_Sinh_nna = $1000dab; { U+0DAB SINHALA MUURDHAJA NAYANNA } + XK_Sinh_ndda = $1000dac; { U+0DAC SINHALA SANYAKA DDAYANNA } + XK_Sinh_tha = $1000dad; { U+0DAD SINHALA TAYANNA } + XK_Sinh_thha = $1000dae; { U+0DAE SINHALA MAHA. TAYANNA } + XK_Sinh_dha = $1000daf; { U+0DAF SINHALA DAYANNA } + XK_Sinh_dhha = $1000db0; { U+0DB0 SINHALA MAHA. DAYANNA } + XK_Sinh_na = $1000db1; { U+0DB1 SINHALA DANTAJA NAYANNA } + XK_Sinh_ndha = $1000db3; { U+0DB3 SINHALA SANYAKA DAYANNA } + XK_Sinh_pa = $1000db4; { U+0DB4 SINHALA PAYANNA } + XK_Sinh_pha = $1000db5; { U+0DB5 SINHALA MAHA. PAYANNA } + XK_Sinh_ba = $1000db6; { U+0DB6 SINHALA BAYANNA } + XK_Sinh_bha = $1000db7; { U+0DB7 SINHALA MAHA. BAYANNA } + XK_Sinh_ma = $1000db8; { U+0DB8 SINHALA MAYANNA } + XK_Sinh_mba = $1000db9; { U+0DB9 SINHALA AMBA BAYANNA } + XK_Sinh_ya = $1000dba; { U+0DBA SINHALA YAYANNA } + XK_Sinh_ra = $1000dbb; { U+0DBB SINHALA RAYANNA } + XK_Sinh_la = $1000dbd; { U+0DBD SINHALA DANTAJA LAYANNA } + XK_Sinh_va = $1000dc0; { U+0DC0 SINHALA VAYANNA } + XK_Sinh_sha = $1000dc1; { U+0DC1 SINHALA TAALUJA SAYANNA } + XK_Sinh_ssha = $1000dc2; { U+0DC2 SINHALA MUURDHAJA SAYANNA } + XK_Sinh_sa = $1000dc3; { U+0DC3 SINHALA DANTAJA SAYANNA } + XK_Sinh_ha = $1000dc4; { U+0DC4 SINHALA HAYANNA } + XK_Sinh_lla = $1000dc5; { U+0DC5 SINHALA MUURDHAJA LAYANNA } + XK_Sinh_fa = $1000dc6; { U+0DC6 SINHALA FAYANNA } + XK_Sinh_al = $1000dca; { U+0DCA SINHALA AL-LAKUNA } + XK_Sinh_aa2 = $1000dcf; { U+0DCF SINHALA AELA-PILLA } + XK_Sinh_ae2 = $1000dd0; { U+0DD0 SINHALA AEDA-PILLA } + XK_Sinh_aee2 = $1000dd1; { U+0DD1 SINHALA DIGA AEDA-PILLA } + XK_Sinh_i2 = $1000dd2; { U+0DD2 SINHALA IS-PILLA } + XK_Sinh_ii2 = $1000dd3; { U+0DD3 SINHALA DIGA IS-PILLA } + XK_Sinh_u2 = $1000dd4; { U+0DD4 SINHALA PAA-PILLA } + XK_Sinh_uu2 = $1000dd6; { U+0DD6 SINHALA DIGA PAA-PILLA } + XK_Sinh_ru2 = $1000dd8; { U+0DD8 SINHALA GAETTA-PILLA } + XK_Sinh_e2 = $1000dd9; { U+0DD9 SINHALA KOMBUVA } + XK_Sinh_ee2 = $1000dda; { U+0DDA SINHALA DIGA KOMBUVA } + XK_Sinh_ai2 = $1000ddb; { U+0DDB SINHALA KOMBU DEKA } + XK_Sinh_o2 = $1000ddc; { U+0DDC SINHALA KOMBUVA HAA AELA-PILLA} + XK_Sinh_oo2 = $1000ddd; { U+0DDD SINHALA KOMBUVA HAA DIGA AELA-PILLA} + XK_Sinh_au2 = $1000dde; { U+0DDE SINHALA KOMBUVA HAA GAYANUKITTA } + XK_Sinh_lu2 = $1000ddf; { U+0DDF SINHALA GAYANUKITTA } + XK_Sinh_ruu2 = $1000df2; { U+0DF2 SINHALA DIGA GAETTA-PILLA } + XK_Sinh_luu2 = $1000df3; { U+0DF3 SINHALA DIGA GAYANUKITTA } + XK_Sinh_kunddaliya = $1000df4; { U+0DF4 SINHALA KUNDDALIYA } + + // Copied from xf86keysym.pp in Lazarus + XF86XK_ModeLock = $1008FF01; { Mode Switch Lock } + + XF86XK_MonBrightnessUp = $1008FF02; { Monitor/panel brightness } + XF86XK_MonBrightnessDown = $1008FF03; { Monitor/panel brightness } + XF86XK_KbdLightOnOff = $1008FF04; { Keyboards may be lit } + XF86XK_KbdBrightnessUp = $1008FF05; { Keyboards may be lit } + XF86XK_KbdBrightnessDown = $1008FF06; { Keyboards may be lit } + + XF86XK_Standby = $1008FF10; { System into standby mode } + XF86XK_AudioLowerVolume = $1008FF11; { Volume control down } + XF86XK_AudioMute = $1008FF12; { Mute sound from the system } + XF86XK_AudioRaiseVolume = $1008FF13; { Volume control up } + XF86XK_AudioPlay = $1008FF14; { Start playing of audio > } + XF86XK_AudioStop = $1008FF15; { Stop playing audio } + XF86XK_AudioPrev = $1008FF16; { Previous track } + XF86XK_AudioNext = $1008FF17; { Next track } + XF86XK_HomePage = $1008FF18; { Display user's home page } + XF86XK_Mail = $1008FF19; { Invoke user's mail program } + XF86XK_Start = $1008FF1A; { Start application } + XF86XK_Search = $1008FF1B; { Search } + XF86XK_AudioRecord = $1008FF1C; { Record audio application } + + XF86XK_Calculator = $1008FF1D; { Invoke calculator program } + XF86XK_Memo = $1008FF1E; { Invoke Memo taking program } + XF86XK_ToDoList = $1008FF1F; { Invoke To Do List program } + XF86XK_Calendar = $1008FF20; { Invoke Calendar program } + XF86XK_PowerDown = $1008FF21; { Deep sleep the system } + XF86XK_ContrastAdjust = $1008FF22; { Adjust screen contrast } + XF86XK_RockerUp = $1008FF23; { Rocker switches exist up } + XF86XK_RockerDown = $1008FF24; { and down } + XF86XK_RockerEnter = $1008FF25; { and let you press them } + + XF86XK_Back = $1008FF26; { Like back on a browser } + XF86XK_Forward = $1008FF27; { Like forward on a browser } + XF86XK_Stop = $1008FF28; { Stop current operation } + XF86XK_Refresh = $1008FF29; { Refresh the page } + XF86XK_PowerOff = $1008FF2A; { Power off system entirely } + XF86XK_WakeUp = $1008FF2B; { Wake up system from sleep } + XF86XK_Eject = $1008FF2C; { Eject device (e.g. DVD) } + XF86XK_ScreenSaver = $1008FF2D; { Invoke screensaver } + XF86XK_WWW = $1008FF2E; { Invoke web browser } + XF86XK_Sleep = $1008FF2F; { Put system to sleep } + XF86XK_Favorites = $1008FF30; { Show favorite locations } + XF86XK_AudioPause = $1008FF31; { Pause audio playing } + XF86XK_AudioMedia = $1008FF32; { Launch media collection app } + XF86XK_MyComputer = $1008FF33; { Display "My Computer" window } + XF86XK_VendorHome = $1008FF34; { Display vendor home web site } + XF86XK_LightBulb = $1008FF35; { Light bulb keys exist } + XF86XK_Shop = $1008FF36; { Display shopping web site } + XF86XK_History = $1008FF37; { Show history of web surfing } + XF86XK_OpenURL = $1008FF38; { Open selected URL } + XF86XK_AddFavorite = $1008FF39; { Add URL to favorites list } + XF86XK_HotLinks = $1008FF3A; { Show "hot" links } + XF86XK_BrightnessAdjust = $1008FF3B; { Invoke brightness adj. UI } + XF86XK_Finance = $1008FF3C; { Display financial site } + XF86XK_Community = $1008FF3D; { Display user's community } + XF86XK_AudioRewind = $1008FF3E; { "rewind" audio track } + XF86XK_BackForward = $1008FF3F; { ??? } + XF86XK_Launch0 = $1008FF40; { Launch Application } + XF86XK_Launch1 = $1008FF41; { Launch Application } + XF86XK_Launch2 = $1008FF42; { Launch Application } + XF86XK_Launch3 = $1008FF43; { Launch Application } + XF86XK_Launch4 = $1008FF44; { Launch Application } + XF86XK_Launch5 = $1008FF45; { Launch Application } + XF86XK_Launch6 = $1008FF46; { Launch Application } + XF86XK_Launch7 = $1008FF47; { Launch Application } + XF86XK_Launch8 = $1008FF48; { Launch Application } + XF86XK_Launch9 = $1008FF49; { Launch Application } + XF86XK_LaunchA = $1008FF4A; { Launch Application } + XF86XK_LaunchB = $1008FF4B; { Launch Application } + XF86XK_LaunchC = $1008FF4C; { Launch Application } + XF86XK_LaunchD = $1008FF4D; { Launch Application } + XF86XK_LaunchE = $1008FF4E; { Launch Application } + XF86XK_LaunchF = $1008FF4F; { Launch Application } + + XF86XK_ApplicationLeft = $1008FF50; { switch to application, left } + XF86XK_ApplicationRight = $1008FF51; { switch to application, right} + XF86XK_Book = $1008FF52; { Launch bookreader } + XF86XK_CD = $1008FF53; { Launch CD/DVD player } + XF86XK_Calculater = $1008FF54; { Launch Calculater } + XF86XK_Clear = $1008FF55; { Clear window, screen } + XF86XK_Close = $1008FF56; { Close window } + XF86XK_Copy = $1008FF57; { Copy selection } + XF86XK_Cut = $1008FF58; { Cut selection } + XF86XK_Display = $1008FF59; { Output switch key } + XF86XK_DOS = $1008FF5A; { Launch DOS (emulation) } + XF86XK_Documents = $1008FF5B; { Open documents window } + XF86XK_Excel = $1008FF5C; { Launch spread sheet } + XF86XK_Explorer = $1008FF5D; { Launch file explorer } + XF86XK_Game = $1008FF5E; { Launch game } + XF86XK_Go = $1008FF5F; { Go to URL } + XF86XK_iTouch = $1008FF60; { Logitch iTouch- don't use } + XF86XK_LogOff = $1008FF61; { Log off system } + XF86XK_Market = $1008FF62; { ?? } + XF86XK_Meeting = $1008FF63; { enter meeting in calendar } + XF86XK_MenuKB = $1008FF65; { distingush keyboard from PB } + XF86XK_MenuPB = $1008FF66; { distinuish PB from keyboard } + XF86XK_MySites = $1008FF67; { Favourites } + XF86XK_New = $1008FF68; { New (folder, document... } + XF86XK_News = $1008FF69; { News } + XF86XK_OfficeHome = $1008FF6A; { Office home (old Staroffice)} + XF86XK_Open = $1008FF6B; { Open } + XF86XK_Option = $1008FF6C; { ?? } + XF86XK_Paste = $1008FF6D; { Paste } + XF86XK_Phone = $1008FF6E; { Launch phone; dial number } + XF86XK_Q = $1008FF70; { Compaq's Q - don't use } + XF86XK_Reply = $1008FF72; { Reply e.g., mail } + XF86XK_Reload = $1008FF73; { Reload web page, file, etc. } + XF86XK_RotateWindows = $1008FF74; { Rotate windows e.g. xrandr } + XF86XK_RotationPB = $1008FF75; { don't use } + XF86XK_RotationKB = $1008FF76; { don't use } + XF86XK_Save = $1008FF77; { Save (file, document, state } + XF86XK_ScrollUp = $1008FF78; { Scroll window/contents up } + XF86XK_ScrollDown = $1008FF79; { Scrool window/contentd down } + XF86XK_ScrollClick = $1008FF7A; { Use XKB mousekeys instead } + XF86XK_Send = $1008FF7B; { Send mail, file, object } + XF86XK_Spell = $1008FF7C; { Spell checker } + XF86XK_SplitScreen = $1008FF7D; { Split window or screen } + XF86XK_Support = $1008FF7E; { Get support (??) } + XF86XK_TaskPane = $1008FF7F; { Show tasks } + XF86XK_Terminal = $1008FF80; { Launch terminal emulator } + XF86XK_Tools = $1008FF81; { toolbox of desktop/app. } + XF86XK_Travel = $1008FF82; { ?? } + XF86XK_UserPB = $1008FF84; { ?? } + XF86XK_User1KB = $1008FF85; { ?? } + XF86XK_User2KB = $1008FF86; { ?? } + XF86XK_Video = $1008FF87; { Launch video player } + XF86XK_WheelButton = $1008FF88; { button from a mouse wheel } + XF86XK_Word = $1008FF89; { Launch word processor } + XF86XK_Xfer = $1008FF8A; + XF86XK_ZoomIn = $1008FF8B; { zoom in view, map, etc. } + XF86XK_ZoomOut = $1008FF8C; { zoom out view, map, etc. } + + XF86XK_Away = $1008FF8D; { mark yourself as away } + XF86XK_Messenger = $1008FF8E; { as in instant messaging } + XF86XK_WebCam = $1008FF8F; { Launch web camera app. } + XF86XK_MailForward = $1008FF90; { Forward in mail } + XF86XK_Pictures = $1008FF91; { Show pictures } + XF86XK_Music = $1008FF92; { Launch music application } + + XF86XK_Battery = $1008FF93; { Display battery information } + XF86XK_Bluetooth = $1008FF94; { Enable/disable Bluetooth } + XF86XK_WLAN = $1008FF95; { Enable/disable WLAN } + XF86XK_UWB = $1008FF96; { Enable/disable UWB } + + XF86XK_AudioForward = $1008FF97; { fast-forward audio track } + XF86XK_AudioRepeat = $1008FF98; { toggle repeat mode } + XF86XK_AudioRandomPlay = $1008FF99; { toggle shuffle mode } + XF86XK_Subtitle = $1008FF9A; { cycle through subtitle } + XF86XK_AudioCycleTrack = $1008FF9B; { cycle through audio tracks } + XF86XK_CycleAngle = $1008FF9C; { cycle through angles } + XF86XK_FrameBack = $1008FF9D; { video: go one frame back } + XF86XK_FrameForward = $1008FF9E; { video: go one frame forward } + XF86XK_Time = $1008FF9F; { display, or shows an entry for time seeking } + XF86XK_Select = $1008FFA0; { Select button on joypads and remotes } + XF86XK_View = $1008FFA1; { Show a view options/properties } + XF86XK_TopMenu = $1008FFA2; { Go to a top-level menu in a video } + + XF86XK_Red = $1008FFA3; { Red button } + XF86XK_Green = $1008FFA4; { Green button } + XF86XK_Yellow = $1008FFA5; { Yellow button } + XF86XK_Blue = $1008FFA6; { Blue button } + + XF86XK_Suspend = $1008FFA7; { Sleep to RAM } + XF86XK_Hibernate = $1008FFA8; { Sleep to disk } + XF86XK_TouchpadToggle = $1008FFA9; { Toggle between touchpad/trackstick } + XF86XK_TouchpadOn = $1008FFB0; { The touchpad got switched on } + XF86XK_TouchpadOff = $1008FFB1; { The touchpad got switched off } + + XF86XK_AudioMicMute = $1008FFB2; { Mute the Mic from the system } + + XF86XK_Switch_VT_1 = $1008FE01; + XF86XK_Switch_VT_2 = $1008FE02; + XF86XK_Switch_VT_3 = $1008FE03; + XF86XK_Switch_VT_4 = $1008FE04; + XF86XK_Switch_VT_5 = $1008FE05; + XF86XK_Switch_VT_6 = $1008FE06; + XF86XK_Switch_VT_7 = $1008FE07; + XF86XK_Switch_VT_8 = $1008FE08; + XF86XK_Switch_VT_9 = $1008FE09; + XF86XK_Switch_VT_10 = $1008FE0A; + XF86XK_Switch_VT_11 = $1008FE0B; + XF86XK_Switch_VT_12 = $1008FE0C; + + XF86XK_Ungrab = $1008FE20; { force ungrab } + XF86XK_ClearGrab = $1008FE21; { kill application with grab } + XF86XK_Next_VMode = $1008FE22; { next video mode available } + XF86XK_Prev_VMode = $1008FE23; { prev. video mode available } + XF86XK_LogWindowTree = $1008FE24; { print window tree to log } + XF86XK_LogGrabInfo = $1008FE25; { print all active grabs to log } + + // Copied from gdktypes.inc in Lazarus + GDK_SHIFT_MASK = 1 shl 0; + GDK_LOCK_MASK = 1 shl 1; + GDK_CONTROL_MASK = 1 shl 2; + GDK_MOD1_MASK = 1 shl 3; + GDK_MOD2_MASK = 1 shl 4; + GDK_MOD3_MASK = 1 shl 5; + GDK_MOD4_MASK = 1 shl 6; + GDK_MOD5_MASK = 1 shl 7; + GDK_BUTTON1_MASK = 1 shl 8; + GDK_BUTTON2_MASK = 1 shl 9; + GDK_BUTTON3_MASK = 1 shl 10; + GDK_BUTTON4_MASK = 1 shl 11; + GDK_BUTTON5_MASK = 1 shl 12; + + // Copied from gdkevents.inc in Lazarus + GDK_KEY_PRESS = 8; + {$ENDIF} + + // Keyboard codes copied from this Chromium source unit : + // ui/events/keycodes/keyboard_codes_posix.h. + VKEY_BACK = $08; + VKEY_TAB = $09; + VKEY_BACKTAB = $0A; + VKEY_CLEAR = $0C; + VKEY_RETURN = $0D; + VKEY_SHIFT = $10; + VKEY_CONTROL = $11; + VKEY_MENU = $12; + VKEY_PAUSE = $13; + VKEY_CAPITAL = $14; + VKEY_KANA = $15; + VKEY_HANGUL = $15; + VKEY_JUNJA = $17; + VKEY_FINAL = $18; + VKEY_HANJA = $19; + VKEY_KANJI = $19; + VKEY_ESCAPE = $1B; + VKEY_CONVERT = $1C; + VKEY_NONCONVERT = $1D; + VKEY_ACCEPT = $1E; + VKEY_MODECHANGE = $1F; + VKEY_SPACE = $20; + VKEY_PRIOR = $21; + VKEY_NEXT = $22; + VKEY_END = $23; + VKEY_HOME = $24; + VKEY_LEFT = $25; + VKEY_UP = $26; + VKEY_RIGHT = $27; + VKEY_DOWN = $28; + VKEY_SELECT = $29; + VKEY_PRINT = $2A; + VKEY_EXECUTE = $2B; + VKEY_SNAPSHOT = $2C; + VKEY_INSERT = $2D; + VKEY_DELETE = $2E; + VKEY_HELP = $2F; + VKEY_0 = $30; + VKEY_1 = $31; + VKEY_2 = $32; + VKEY_3 = $33; + VKEY_4 = $34; + VKEY_5 = $35; + VKEY_6 = $36; + VKEY_7 = $37; + VKEY_8 = $38; + VKEY_9 = $39; + VKEY_A = $41; + VKEY_B = $42; + VKEY_C = $43; + VKEY_D = $44; + VKEY_E = $45; + VKEY_F = $46; + VKEY_G = $47; + VKEY_H = $48; + VKEY_I = $49; + VKEY_J = $4A; + VKEY_K = $4B; + VKEY_L = $4C; + VKEY_M = $4D; + VKEY_N = $4E; + VKEY_O = $4F; + VKEY_P = $50; + VKEY_Q = $51; + VKEY_R = $52; + VKEY_S = $53; + VKEY_T = $54; + VKEY_U = $55; + VKEY_V = $56; + VKEY_W = $57; + VKEY_X = $58; + VKEY_Y = $59; + VKEY_Z = $5A; + VKEY_LWIN = $5B; + VKEY_COMMAND = VKEY_LWIN; + VKEY_RWIN = $5C; + VKEY_APPS = $5D; + VKEY_SLEEP = $5F; + VKEY_NUMPAD0 = $60; + VKEY_NUMPAD1 = $61; + VKEY_NUMPAD2 = $62; + VKEY_NUMPAD3 = $63; + VKEY_NUMPAD4 = $64; + VKEY_NUMPAD5 = $65; + VKEY_NUMPAD6 = $66; + VKEY_NUMPAD7 = $67; + VKEY_NUMPAD8 = $68; + VKEY_NUMPAD9 = $69; + VKEY_MULTIPLY = $6A; + VKEY_ADD = $6B; + VKEY_SEPARATOR = $6C; + VKEY_SUBTRACT = $6D; + VKEY_DECIMAL = $6E; + VKEY_DIVIDE = $6F; + VKEY_F1 = $70; + VKEY_F2 = $71; + VKEY_F3 = $72; + VKEY_F4 = $73; + VKEY_F5 = $74; + VKEY_F6 = $75; + VKEY_F7 = $76; + VKEY_F8 = $77; + VKEY_F9 = $78; + VKEY_F10 = $79; + VKEY_F11 = $7A; + VKEY_F12 = $7B; + VKEY_F13 = $7C; + VKEY_F14 = $7D; + VKEY_F15 = $7E; + VKEY_F16 = $7F; + VKEY_F17 = $80; + VKEY_F18 = $81; + VKEY_F19 = $82; + VKEY_F20 = $83; + VKEY_F21 = $84; + VKEY_F22 = $85; + VKEY_F23 = $86; + VKEY_F24 = $87; + VKEY_NUMLOCK = $90; + VKEY_SCROLL = $91; + VKEY_LSHIFT = $A0; + VKEY_RSHIFT = $A1; + VKEY_LCONTROL = $A2; + VKEY_RCONTROL = $A3; + VKEY_LMENU = $A4; + VKEY_RMENU = $A5; + VKEY_BROWSER_BACK = $A6; + VKEY_BROWSER_FORWARD = $A7; + VKEY_BROWSER_REFRESH = $A8; + VKEY_BROWSER_STOP = $A9; + VKEY_BROWSER_SEARCH = $AA; + VKEY_BROWSER_FAVORITES = $AB; + VKEY_BROWSER_HOME = $AC; + VKEY_VOLUME_MUTE = $AD; + VKEY_VOLUME_DOWN = $AE; + VKEY_VOLUME_UP = $AF; + VKEY_MEDIA_NEXT_TRACK = $B0; + VKEY_MEDIA_PREV_TRACK = $B1; + VKEY_MEDIA_STOP = $B2; + VKEY_MEDIA_PLAY_PAUSE = $B3; + VKEY_MEDIA_LAUNCH_MAIL = $B4; + VKEY_MEDIA_LAUNCH_MEDIA_SELECT = $B5; + VKEY_MEDIA_LAUNCH_APP1 = $B6; + VKEY_MEDIA_LAUNCH_APP2 = $B7; + VKEY_OEM_1 = $BA; + VKEY_OEM_PLUS = $BB; + VKEY_OEM_COMMA = $BC; + VKEY_OEM_MINUS = $BD; + VKEY_OEM_PERIOD = $BE; + VKEY_OEM_2 = $BF; + VKEY_OEM_3 = $C0; + VKEY_OEM_4 = $DB; + VKEY_OEM_5 = $DC; + VKEY_OEM_6 = $DD; + VKEY_OEM_7 = $DE; + VKEY_OEM_8 = $DF; + VKEY_OEM_102 = $E2; + VKEY_OEM_103 = $E3; + VKEY_OEM_104 = $E4; + VKEY_PROCESSKEY = $E5; + VKEY_PACKET = $E7; + VKEY_DBE_SBCSCHAR = $F3; + VKEY_DBE_DBCSCHAR = $F4; + VKEY_ATTN = $F6; + VKEY_CRSEL = $F7; + VKEY_EXSEL = $F8; + VKEY_EREOF = $F9; + VKEY_PLAY = $FA; + VKEY_ZOOM = $FB; + VKEY_NONAME = $FC; + VKEY_PA1 = $FD; + VKEY_OEM_CLEAR = $FE; + VKEY_UNKNOWN = 0; + VKEY_WLAN = $97; + VKEY_POWER = $98; + VKEY_BRIGHTNESS_DOWN = $D8; + VKEY_BRIGHTNESS_UP = $D9; + VKEY_KBD_BRIGHTNESS_DOWN = $DA; + VKEY_KBD_BRIGHTNESS_UP = $E8; + VKEY_ALTGR = $E1; + VKEY_COMPOSE = $E6; + + // kHardwareCodeToGDKKeyval is defined in this CEF source unit : + // tests/cefclient/browser/browser_window_osr_gtk.cc + kHardwareCodeToGDKKeyval : array[0..116] of integer = ( + 0, // 0x00: + 0, // 0x01: + 0, // 0x02: + 0, // 0x03: + 0, // 0x04: + 0, // 0x05: + 0, // 0x06: + 0, // 0x07: + 0, // 0x08: + 0, // 0x09: GDK_Escape + GDK_1, // 0x0A: GDK_1 + GDK_2, // 0x0B: GDK_2 + GDK_3, // 0x0C: GDK_3 + GDK_4, // 0x0D: GDK_4 + GDK_5, // 0x0E: GDK_5 + GDK_6, // 0x0F: GDK_6 + GDK_7, // 0x10: GDK_7 + GDK_8, // 0x11: GDK_8 + GDK_9, // 0x12: GDK_9 + GDK_0, // 0x13: GDK_0 + GDK_minus, // 0x14: GDK_minus + GDK_equal, // 0x15: GDK_equal + 0, // 0x16: GDK_BackSpace + 0, // 0x17: GDK_Tab + GDK_q, // 0x18: GDK_q + GDK_w, // 0x19: GDK_w + GDK_e, // 0x1A: GDK_e + GDK_r, // 0x1B: GDK_r + GDK_t, // 0x1C: GDK_t + GDK_y, // 0x1D: GDK_y + GDK_u, // 0x1E: GDK_u + GDK_i, // 0x1F: GDK_i + GDK_o, // 0x20: GDK_o + GDK_p, // 0x21: GDK_p + GDK_bracketleft, // 0x22: GDK_bracketleft + GDK_bracketright, // 0x23: GDK_bracketright + 0, // 0x24: GDK_Return + 0, // 0x25: GDK_Control_L + GDK_a, // 0x26: GDK_a + GDK_s, // 0x27: GDK_s + GDK_d, // 0x28: GDK_d + GDK_f, // 0x29: GDK_f + GDK_g, // 0x2A: GDK_g + GDK_h, // 0x2B: GDK_h + GDK_j, // 0x2C: GDK_j + GDK_k, // 0x2D: GDK_k + GDK_l, // 0x2E: GDK_l + GDK_semicolon, // 0x2F: GDK_semicolon + GDK_apostrophe, // 0x30: GDK_apostrophe + GDK_grave, // 0x31: GDK_grave + 0, // 0x32: GDK_Shift_L + GDK_backslash, // 0x33: GDK_backslash + GDK_z, // 0x34: GDK_z + GDK_x, // 0x35: GDK_x + GDK_c, // 0x36: GDK_c + GDK_v, // 0x37: GDK_v + GDK_b, // 0x38: GDK_b + GDK_n, // 0x39: GDK_n + GDK_m, // 0x3A: GDK_m + GDK_comma, // 0x3B: GDK_comma + GDK_period, // 0x3C: GDK_period + GDK_slash, // 0x3D: GDK_slash + 0, // 0x3E: GDK_Shift_R + 0, // 0x3F: + 0, // 0x40: + 0, // 0x41: + 0, // 0x42: + 0, // 0x43: + 0, // 0x44: + 0, // 0x45: + 0, // 0x46: + 0, // 0x47: + 0, // 0x48: + 0, // 0x49: + 0, // 0x4A: + 0, // 0x4B: + 0, // 0x4C: + 0, // 0x4D: + 0, // 0x4E: + 0, // 0x4F: + 0, // 0x50: + 0, // 0x51: + 0, // 0x52: + 0, // 0x53: + 0, // 0x54: + 0, // 0x55: + 0, // 0x56: + 0, // 0x57: + 0, // 0x58: + 0, // 0x59: + 0, // 0x5A: + 0, // 0x5B: + 0, // 0x5C: + 0, // 0x5D: + 0, // 0x5E: + 0, // 0x5F: + 0, // 0x60: + 0, // 0x61: + 0, // 0x62: + 0, // 0x63: + 0, // 0x64: + 0, // 0x65: + 0, // 0x66: + 0, // 0x67: + 0, // 0x68: + 0, // 0x69: + 0, // 0x6A: + 0, // 0x6B: + 0, // 0x6C: + 0, // 0x6D: + 0, // 0x6E: + 0, // 0x6F: + 0, // 0x70: + 0, // 0x71: + 0, // 0x72: + GDK_Super_L, // 0x73: GDK_Super_L + GDK_Super_R // 0x74: GDK_Super_R + ); +{$ENDIF} + +implementation + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFLinuxFunctions.pas b/windows/src/ext/cef4delphi/source/uCEFLinuxFunctions.pas new file mode 100644 index 0000000000000000000000000000000000000000..3a863c2f0e4aa03510e23e4f94b424045ec1092d --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFLinuxFunctions.pas @@ -0,0 +1,640 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLinuxFunctions; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF LINUX} + {$IFDEF FPC} + ctypes, keysym, xf86keysym, x, xlib, + {$IFDEF LCLGTK2}gtk2, glib2, gdk2, gtk2proc, gtk2int, Gtk2Def, gdk2x, Gtk2Extra,{$ENDIF} + {$ENDIF} + {$ENDIF} + uCEFLinuxTypes, uCEFTypes; + +{$IFDEF LINUX} +procedure GdkEventKeyToCEFKeyEvent(GdkEvent: PGdkEventKey; var aCEFKeyEvent : TCEFKeyEvent); +function KeyboardCodeFromXKeysym(keysym : uint32) : integer; +function GetCefStateModifiers(state : uint32) : integer; +function GdkEventToWindowsKeyCode(Event: PGdkEventKey) : integer; +function GetWindowsKeyCodeWithoutLocation(key_code : integer) : integer; +function GetControlCharacter(windows_key_code : integer; shift : boolean) : integer; +{$IFDEF FMX} +function gdk_keyval_to_unicode(keyval: guint): guint32; cdecl; external 'libgdk-3.so'; +function g_signal_connect_data(instance: gpointer; detailed_signal: Pgchar; c_handler: TGCallback; data: gpointer; destroy_data: TGClosureNotify; connect_flags: TGConnectFlags): gulong; cdecl; external 'libgobject-2.0.so'; +function g_signal_connect(instance: gpointer; detailed_signal: Pgchar; c_handler: TGCallback; data: gpointer): gulong; overload; +function g_signal_connect(instance: gpointer; const detailed_signal: AnsiString; c_handler: TGCallback; data: gpointer): gulong; overload; +{$ENDIF} +{$IFDEF FPC} +procedure ShowX11Message(const aMessage : string); +{$ENDIF}{$ENDIF} + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFLinuxConstants, uCEFConstants; + +{$IFDEF LINUX} +function KeyboardCodeFromXKeysym(keysym : uint32) : integer; +begin + case keysym of + XK_BackSpace: + Result := VKEY_BACK; + XK_Delete, + XK_KP_Delete: + Result := VKEY_DELETE; + XK_Tab, + XK_KP_Tab, + XK_ISO_Left_Tab, + XK_3270_BackTab: + Result := VKEY_TAB; + XK_Linefeed, + XK_Return, + XK_KP_Enter, + XK_ISO_Enter: + Result := VKEY_Return; + XK_Clear, + XK_KP_Begin: + Result := VKEY_CLEAR; + XK_KP_Space, + XK_space: + Result := VKEY_SPACE; + XK_Home, + XK_KP_Home: + Result := VKEY_HOME; + XK_End, + XK_KP_End: + Result := VKEY_END; + XK_Page_Up, + XK_KP_Page_Up: + Result := VKEY_PRIOR; + XK_Page_Down, + XK_KP_Page_Down: + Result := VKEY_NEXT; + XK_Left, + XK_KP_Left: + Result := VKEY_LEFT; + XK_Right, + XK_KP_Right: + Result := VKEY_RIGHT; + XK_Down, + XK_KP_Down: + Result := VKEY_DOWN; + XK_Up, + XK_KP_Up: + Result := VKEY_UP; + XK_Escape: + Result := VKEY_ESCAPE; + XK_Kana_Lock, + XK_Kana_Shift: + Result := VKEY_KANA; + XK_Hangul: + Result := VKEY_HANGUL; + XK_Hangul_Hanja: + Result := VKEY_HANJA; + XK_Kanji: + Result := VKEY_KANJI; + XK_Henkan: + Result := VKEY_CONVERT; + XK_Muhenkan: + Result := VKEY_NONCONVERT; + XK_Zenkaku_Hankaku: + Result := VKEY_DBE_DBCSCHAR; + XKc_A, + XK_a: + Result := VKEY_A; + XKc_B, + XK_b: + Result := VKEY_B; + XKc_C, + XK_c: + Result := VKEY_C; + XKc_D, + XK_d: + Result := VKEY_D; + XKc_E, + XK_e: + Result := VKEY_E; + XKc_F, + XK_f: + Result := VKEY_F; + XKc_G, + XK_g: + Result := VKEY_G; + XKc_H, + XK_h: + Result := VKEY_H; + XKc_I, + XK_i: + Result := VKEY_I; + XKc_J, + XK_j: + Result := VKEY_J; + XKc_K, + XK_k: + Result := VKEY_K; + XKc_L, + XK_l: + Result := VKEY_L; + XKc_M, + XK_m: + Result := VKEY_M; + XKc_N, + XK_n: + Result := VKEY_N; + XKc_O, + XK_o: + Result := VKEY_O; + XKc_P, + XK_p: + Result := VKEY_P; + XKc_Q, + XK_q: + Result := VKEY_Q; + XKc_R, + XK_r: + Result := VKEY_R; + XKc_S, + XK_s: + Result := VKEY_S; + XKc_T, + XK_t: + Result := VKEY_T; + XKc_U, + XK_u: + Result := VKEY_U; + XKc_V, + XK_v: + Result := VKEY_V; + XKc_W, + XK_w: + Result := VKEY_W; + XKc_X, + XK_x: + Result := VKEY_X; + XKc_Y, + XK_y: + Result := VKEY_Y; + XKc_Z, + XK_z: + Result := VKEY_Z; + XK_0, + XK_1, + XK_2, + XK_3, + XK_4, + XK_5, + XK_6, + XK_7, + XK_8, + XK_9: + Result := VKEY_0 + (keysym - XK_0); + XK_parenright: + Result := VKEY_0; + XK_exclam: + Result := VKEY_1; + XK_at: + Result := VKEY_2; + XK_numbersign: + Result := VKEY_3; + XK_dollar: + Result := VKEY_4; + XK_percent: + Result := VKEY_5; + XK_asciicircum: + Result := VKEY_6; + XK_ampersand: + Result := VKEY_7; + XK_asterisk: + Result := VKEY_8; + XK_parenleft: + Result := VKEY_9; + XK_KP_0, + XK_KP_1, + XK_KP_2, + XK_KP_3, + XK_KP_4, + XK_KP_5, + XK_KP_6, + XK_KP_7, + XK_KP_8, + XK_KP_9: + Result := VKEY_NUMPAD0 + (keysym - XK_KP_0); + XK_multiply, + XK_KP_Multiply: + Result := VKEY_MULTIPLY; + XK_KP_Add: + Result := VKEY_ADD; + XK_KP_Separator: + Result := VKEY_SEPARATOR; + XK_KP_Subtract: + Result := VKEY_SUBTRACT; + XK_KP_Decimal: + Result := VKEY_DECIMAL; + XK_KP_Divide: + Result := VKEY_DIVIDE; + XK_KP_Equal, + XK_equal, + XK_plus: + Result := VKEY_OEM_PLUS; + XK_comma, + XK_less: + Result := VKEY_OEM_COMMA; + XK_minus, + XK_underscore: + Result := VKEY_OEM_MINUS; + XK_greater, + XK_period: + Result := VKEY_OEM_PERIOD; + XK_colon, + XK_semicolon: + Result := VKEY_OEM_1; + XK_question, + XK_slash: + Result := VKEY_OEM_2; + XK_asciitilde, + XK_quoteleft: + Result := VKEY_OEM_3; + XK_bracketleft, + XK_braceleft: + Result := VKEY_OEM_4; + XK_backslash, + XK_bar: + Result := VKEY_OEM_5; + XK_bracketright, + XK_braceright: + Result := VKEY_OEM_6; + XK_quoteright, + XK_quotedbl: + Result := VKEY_OEM_7; + XK_ISO_Level5_Shift: + Result := VKEY_OEM_8; + XK_Shift_L, + XK_Shift_R: + Result := VKEY_SHIFT; + XK_Control_L, + XK_Control_R: + Result := VKEY_CONTROL; + XK_Meta_L, + XK_Meta_R, + XK_Alt_L, + XK_Alt_R: + Result := VKEY_MENU; + XK_ISO_Level3_Shift: + Result := VKEY_ALTGR; + XK_Multi_key: + Result := VKEY_COMPOSE; + XK_Pause: + Result := VKEY_PAUSE; + XK_Caps_Lock: + Result := VKEY_CAPITAL; + XK_Num_Lock: + Result := VKEY_NUMLOCK; + XK_Scroll_Lock: + Result := VKEY_SCROLL; + XK_Select: + Result := VKEY_SELECT; + XK_Print: + Result := VKEY_PRINT; + XK_Execute: + Result := VKEY_EXECUTE; + XK_Insert, + XK_KP_Insert: + Result := VKEY_INSERT; + XK_Help: + Result := VKEY_HELP; + XK_Super_L: + Result := VKEY_LWIN; + XK_Super_R: + Result := VKEY_RWIN; + XK_Menu: + Result := VKEY_APPS; + XK_F1, + XK_F2, + XK_F3, + XK_F4, + XK_F5, + XK_F6, + XK_F7, + XK_F8, + XK_F9, + XK_F10, + XK_F11, + XK_F12, + XK_F13, + XK_F14, + XK_F15, + XK_F16, + XK_F17, + XK_F18, + XK_F19, + XK_F20, + XK_F21, + XK_F22, + XK_F23, + XK_F24: + Result := VKEY_F1 + (keysym - XK_F1); + XK_KP_F1, + XK_KP_F2, + XK_KP_F3, + XK_KP_F4: + Result := VKEY_F1 + (keysym - XK_KP_F1); + XK_guillemotleft, + XK_guillemotright, + XK_degree, + XK_ugrave, + XKc_Ugrave, + XK_brokenbar: + Result := VKEY_OEM_102; + XF86XK_Tools: + Result := VKEY_F13; + XF86XK_Launch5: + Result := VKEY_F14; + XF86XK_Launch6: + Result := VKEY_F15; + XF86XK_Launch7: + Result := VKEY_F16; + XF86XK_Launch8: + Result := VKEY_F17; + XF86XK_Launch9: + Result := VKEY_F18; + XF86XK_Refresh, + XF86XK_History, + XF86XK_OpenURL, + XF86XK_AddFavorite, + XF86XK_Go, + XF86XK_ZoomIn, + XF86XK_ZoomOut: + Result := VKEY_UNKNOWN; + XF86XK_Back: + Result := VKEY_BROWSER_BACK; + XF86XK_Forward: + Result := VKEY_BROWSER_FORWARD; + XF86XK_Reload: + Result := VKEY_BROWSER_REFRESH; + XF86XK_Stop: + Result := VKEY_BROWSER_STOP; + XF86XK_Search: + Result := VKEY_BROWSER_SEARCH; + XF86XK_Favorites: + Result := VKEY_BROWSER_FAVORITES; + XF86XK_HomePage: + Result := VKEY_BROWSER_HOME; + XF86XK_AudioMute: + Result := VKEY_VOLUME_MUTE; + XF86XK_AudioLowerVolume: + Result := VKEY_VOLUME_DOWN; + XF86XK_AudioRaiseVolume: + Result := VKEY_VOLUME_UP; + XF86XK_AudioNext: + Result := VKEY_MEDIA_NEXT_TRACK; + XF86XK_AudioPrev: + Result := VKEY_MEDIA_PREV_TRACK; + XF86XK_AudioStop: + Result := VKEY_MEDIA_STOP; + XF86XK_AudioPlay: + Result := VKEY_MEDIA_PLAY_PAUSE; + XF86XK_Mail: + Result := VKEY_MEDIA_LAUNCH_MAIL; + XF86XK_LaunchA: + Result := VKEY_MEDIA_LAUNCH_APP1; + XF86XK_LaunchB, + XF86XK_Calculator: + Result := VKEY_MEDIA_LAUNCH_APP2; + XF86XK_WLAN: + Result := VKEY_WLAN; + XF86XK_PowerOff: + Result := VKEY_POWER; + XF86XK_MonBrightnessDown: + Result := VKEY_BRIGHTNESS_DOWN; + XF86XK_MonBrightnessUp: + Result := VKEY_BRIGHTNESS_UP; + XF86XK_KbdBrightnessDown: + Result := VKEY_KBD_BRIGHTNESS_DOWN; + XF86XK_KbdBrightnessUp: + Result := VKEY_KBD_BRIGHTNESS_UP; + else Result := VKEY_UNKNOWN; + end; +end; + +function GetCefStateModifiers(state : uint32) : integer; +begin + Result := EVENTFLAG_NONE; + + if ((state and GDK_SHIFT_MASK) <> 0) then + Result := Result or EVENTFLAG_SHIFT_DOWN; + + if ((state and GDK_LOCK_MASK) <> 0) then + Result := Result or EVENTFLAG_CAPS_LOCK_ON; + + if ((state and GDK_CONTROL_MASK) <> 0) then + Result := Result or EVENTFLAG_CONTROL_DOWN; + + if ((state and GDK_MOD1_MASK) <> 0) then + Result := Result or EVENTFLAG_ALT_DOWN; + + if ((state and GDK_BUTTON1_MASK) <> 0) then + Result := Result or EVENTFLAG_LEFT_MOUSE_BUTTON; + + if ((state and GDK_BUTTON2_MASK) <> 0) then + Result := Result or EVENTFLAG_MIDDLE_MOUSE_BUTTON; + + if ((state and GDK_BUTTON3_MASK) <> 0) then + Result := Result or EVENTFLAG_RIGHT_MOUSE_BUTTON; +end; + +function GdkEventToWindowsKeyCode(event: PGdkEventKey) : integer; +var + windows_key_code, keyval : integer; +begin + windows_key_code := KeyboardCodeFromXKeysym(event^.keyval); + if (windows_key_code <> 0) then + begin + Result := windows_key_code; + exit; + end; + + if (event^.hardware_keycode < length(kHardwareCodeToGDKKeyval)) then + begin + keyval := kHardwareCodeToGDKKeyval[event^.hardware_keycode]; + if (keyval <> 0) then + begin + Result := KeyboardCodeFromXKeysym(keyval); + exit; + end; + end; + + Result := KeyboardCodeFromXKeysym(event^.keyval); +end; + +function GetWindowsKeyCodeWithoutLocation(key_code : integer) : integer; +begin + case key_code of + VKEY_LCONTROL, VKEY_RCONTROL : Result := VKEY_CONTROL; + VKEY_LSHIFT, VKEY_RSHIFT : Result := VKEY_SHIFT; + VKEY_LMENU, VKEY_RMENU : Result := VKEY_MENU; + else Result := key_code; + end; +end; + +function GetControlCharacter(windows_key_code : integer; shift : boolean) : integer; +begin + if (windows_key_code >= VKEY_A) and (windows_key_code <= VKEY_Z) then + Result := windows_key_code - VKEY_A + 1 + else + if shift then + case windows_key_code of + VKEY_2 : Result := 0; + VKEY_6 : Result := $1E; + VKEY_OEM_MINUS : Result := $1F; + else Result := 0; + end + else + case windows_key_code of + VKEY_OEM_4 : Result := $1B; + VKEY_OEM_5 : Result := $1C; + VKEY_OEM_6 : Result := $1D; + VKEY_RETURN : Result := $0A; + else Result := 0; + end; +end; + +procedure GdkEventKeyToCEFKeyEvent(GdkEvent: PGdkEventKey; var aCEFKeyEvent : TCEFKeyEvent); +var + windows_key_code : integer; +begin + windows_key_code := GdkEventToWindowsKeyCode(GdkEvent); + aCEFKeyEvent.windows_key_code := GetWindowsKeyCodeWithoutLocation(windows_key_code); + aCEFKeyEvent.native_key_code := GdkEvent^.hardware_keycode; + aCEFKeyEvent.modifiers := GetCefStateModifiers(GdkEvent^.state); + aCEFKeyEvent.focus_on_editable_field := 0; + + if (GdkEvent^.keyval >= GDK_KP_Space) and (GdkEvent^.keyval <= GDK_KP_9) then + aCEFKeyEvent.modifiers := aCEFKeyEvent.modifiers or EVENTFLAG_IS_KEY_PAD; + + aCEFKeyEvent.is_system_key := ord((aCEFKeyEvent.modifiers and EVENTFLAG_ALT_DOWN) <> 0); + + if (windows_key_code = VKEY_RETURN) then + aCEFKeyEvent.unmodified_character := #13 + else + aCEFKeyEvent.unmodified_character := WideChar(gdk_keyval_to_unicode(GdkEvent^.keyval)); + + if ((aCEFKeyEvent.modifiers and EVENTFLAG_CONTROL_DOWN) <> 0) then + aCEFKeyEvent.character := WideChar(GetControlCharacter(windows_key_code, ((aCEFKeyEvent.modifiers and EVENTFLAG_SHIFT_DOWN) <> 0))) + else + aCEFKeyEvent.character := aCEFKeyEvent.unmodified_character; +end; + +{$IFDEF FMX} +function g_signal_connect(instance: gpointer; detailed_signal: Pgchar; c_handler: TGCallback; data: gpointer): gulong; +begin + Result := g_signal_connect_data(instance, detailed_signal, c_handler, data, nil, TGConnectFlags(0)); +end; + +function g_signal_connect(instance: gpointer; const detailed_signal: AnsiString; c_handler: TGCallback; data: gpointer): gulong; +begin + Result := g_signal_connect(instance, @detailed_signal[1], c_handler, data); +end; +{$ENDIF} + +{$IFDEF FPC} +// This function is almost an identical copy of "ModalShowX11Window" available +// at https://wiki.lazarus.freepascal.org/X11 +procedure ShowX11Message(const aMessage : string); +var + TempDisplay : PDisplay; + TempWindow : TWindow; + TempEvent : TXEvent; + TempMessage : PChar; + TempScreen : cint; +begin + TempMessage := PChar(trim(copy(aMessage, 1, pred(pos(#13, aMessage))))); + TempDisplay := XOpenDisplay(nil); + + if (TempDisplay = nil) then + begin + WriteLn(aMessage); + exit; + end; + + TempScreen := DefaultScreen(TempDisplay); + TempWindow := XCreateSimpleWindow(TempDisplay, + RootWindow(TempDisplay, TempScreen), + 10, 10, 200, 100, 1, + BlackPixel(TempDisplay, TempScreen), + WhitePixel(TempDisplay, TempScreen)); + + XSelectInput(TempDisplay, TempWindow, ExposureMask or KeyPressMask); + + XMapWindow(TempDisplay, TempWindow); + + while (True) do + begin + XNextEvent(TempDisplay, @TempEvent); + + if (TempEvent._type = Expose) then + XDrawString(TempDisplay, + TempWindow, + DefaultGC(TempDisplay, TempScreen), + 40, 50, + TempMessage, + strlen(TempMessage)); + + if (TempEvent._type = KeyPress) then Break; + end; + + XCloseDisplay(TempDisplay); +end; +{$ENDIF}{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFLinuxTypes.pas b/windows/src/ext/cef4delphi/source/uCEFLinuxTypes.pas new file mode 100644 index 0000000000000000000000000000000000000000..13350cc0a2e130e6275f2f946594253467c052cc --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFLinuxTypes.pas @@ -0,0 +1,133 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFLinuxTypes; + +interface + +{$IFDEF LINUX} +type + PXEvent = pointer; + + {$IFDEF FMX} + // https://developer.gnome.org/glib/stable/glib-Basic-Types.htm + gboolean = longbool; + gpointer = pointer; + gconstpointer = pointer; + gchar = ansichar; + guchar = byte; + gint = integer; + guint = cardinal; + gshort = smallint; + gushort = word; + gulong = uint64; + glong = int64; + gint8 = shortint; + guint8 = byte; + gint16 = int16; + guint16 = uint16; + gint32 = int32; + guint32 = uint32; + gint64 = int64; + guint64 = uint64; + gfloat = single; + gdouble = double; + gsize = NativeUInt; + gssize = NativeInt; + goffset = gint64; + gintptr = NativeInt; + guintptr = NativeUInt; + Pgchar = ^gchar; + PGData = pointer; + PGClosure = pointer; + TGConnectFlags = integer; + GType = gulong; + PGtkWidget = pointer; + TGdkEventType = int32; + PGdkEventKey = ^TGdkEventKey; + PXDisplay = pointer; + + PGTypeClass = ^TGTypeClass; + TGTypeClass = record + g_type : GType; + end; + + TGTypeInstance = record + g_class : PGTypeClass; + end; + + TGObject = record + g_type_instance : TGTypeInstance; + ref_count : guint; + qdata : PGData; + end; + + TGdkDrawable = record + parent_instance : TGObject; + end; + + PGdkWindow = ^TGdkWindow; + TGdkWindow = TGdkDrawable; + TGdkEventKey = record + _type : TGdkEventType; + window : PGdkWindow; + send_event : gint8; + time : guint32; + state : guint; + keyval : guint; + length : gint; + _string : Pgchar; + hardware_keycode : guint16; + group : guint8; + end; + + TGCallBackProcedure = procedure; + TGCallback = procedure (para1: TGCallBackProcedure); cdecl; + TGClosureNotify = procedure(data: gpointer; closure: PGClosure); cdecl; + + TRGBQuad = record + rgbBlue : Byte; + rgbGreen : Byte; + rgbRed : Byte; + rgbReserved : Byte; + end; +{$ENDIF} +{$ENDIF} + +implementation + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFListValue.pas b/windows/src/ext/cef4delphi/source/uCEFListValue.pas index 39781c671bc859ea30e9649bf4c53aab1785a191..eebcd605b07125b123cd7c7af66a6bbae9c25a0d 100644 --- a/windows/src/ext/cef4delphi/source/uCEFListValue.pas +++ b/windows/src/ext/cef4delphi/source/uCEFListValue.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFListValue; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFLoadHandler.pas b/windows/src/ext/cef4delphi/source/uCEFLoadHandler.pas index 07633f6c9ac8d94ec866adc4577e7f2999eee8e6..9798cb944e208098732c8a93c0d8006342c02bd8 100644 --- a/windows/src/ext/cef4delphi/source/uCEFLoadHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFLoadHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,17 +41,15 @@ unit uCEFLoadHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} interface uses - uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplicationCore; type TCefLoadHandlerOwn = class(TCefBaseRefCountedOwn, ICefLoadHandler) @@ -79,7 +77,23 @@ type procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; + destructor Destroy; override; + end; + + TCustomRenderLoadHandler = class(TCefLoadHandlerOwn) + protected + FCefApp : TCefApplicationCore; + + procedure OnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); override; + procedure OnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); override; + procedure OnLoadEnd(const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer); override; + procedure OnLoadError(const browser: ICefBrowser; const frame: ICefFrame; errorCode: TCefErrorCode; const errorText, failedUrl: ustring); override; + + procedure RemoveReferences; override; + + public + constructor Create(const aCefApp : TCefApplicationCore); reintroduce; virtual; destructor Destroy; override; end; @@ -199,11 +213,11 @@ end; // TCustomLoadHandler -constructor TCustomLoadHandler.Create(const events : Pointer); +constructor TCustomLoadHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomLoadHandler.Destroy; @@ -249,4 +263,78 @@ begin if (FEvents <> nil) then IChromiumEvents(FEvents).doOnLoadStart(browser, frame, transitionType); end; + +// TCustomRenderLoadHandler + +constructor TCustomRenderLoadHandler.Create(const aCefApp : TCefApplicationCore); +begin + inherited Create; + + FCefApp := aCefApp; +end; + +destructor TCustomRenderLoadHandler.Destroy; +begin + RemoveReferences; + + inherited Destroy; +end; + +procedure TCustomRenderLoadHandler.RemoveReferences; +begin + FCefApp := nil; +end; + +procedure TCustomRenderLoadHandler.OnLoadEnd(const browser : ICefBrowser; + const frame : ICefFrame; + httpStatusCode : Integer); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnLoadEnd(browser, frame, httpStatusCode); + except + on e : exception do + if CustomExceptionHandler('TCustomRenderLoadHandler.OnLoadEnd', e) then raise; + end; +end; + +procedure TCustomRenderLoadHandler.OnLoadError(const browser : ICefBrowser; + const frame : ICefFrame; + errorCode : TCefErrorCode; + const errorText : ustring; + const failedUrl : ustring); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnLoadError(browser, frame, errorCode, errorText, failedUrl); + except + on e : exception do + if CustomExceptionHandler('TCustomRenderLoadHandler.OnLoadError', e) then raise; + end; +end; + +procedure TCustomRenderLoadHandler.OnLoadingStateChange(const browser : ICefBrowser; + isLoading : Boolean; + canGoBack : Boolean; + canGoForward : Boolean); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnLoadingStateChange(browser, isLoading, canGoBack, canGoForward); + except + on e : exception do + if CustomExceptionHandler('TCustomRenderLoadHandler.OnLoadingStateChange', e) then raise; + end; +end; + +procedure TCustomRenderLoadHandler.OnLoadStart(const browser : ICefBrowser; + const frame : ICefFrame; + transitionType : TCefTransitionType); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnLoadStart(browser, frame, transitionType); + except + on e : exception do + if CustomExceptionHandler('TCustomRenderLoadHandler.OnLoadStart', e) then raise; + end; +end; + + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFMediaObserver.pas b/windows/src/ext/cef4delphi/source/uCEFMediaObserver.pas new file mode 100644 index 0000000000000000000000000000000000000000..7bfa24e567970c718f47bafa8a3a1ad1b2b8b8ea --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMediaObserver.pas @@ -0,0 +1,319 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMediaObserver; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefMediaObserverOwn = class(TCefBaseRefCountedOwn, ICefMediaObserver) + protected + procedure OnSinks(const sinks: TCefMediaSinkArray); virtual; + procedure OnRoutes(const routes: TCefMediaRouteArray); virtual; + procedure OnRouteStateChanged(const route: ICefMediaRoute; state: TCefMediaRouteConnectionState); virtual; + procedure OnRouteMessageReceived(const route: ICefMediaRoute; const message_: ustring); virtual; + + public + constructor Create; virtual; + end; + + TCustomMediaObserver = class(TCefMediaObserverOwn) + protected + FEvents : Pointer; + + procedure OnSinks(const sinks: TCefMediaSinkArray); override; + procedure OnRoutes(const routes: TCefMediaRouteArray); override; + procedure OnRouteStateChanged(const route: ICefMediaRoute; state: TCefMediaRouteConnectionState); override; + procedure OnRouteMessageReceived(const route: ICefMediaRoute; const message_: ustring); override; + + public + constructor Create(const events: IChromiumEvents); reintroduce; + destructor Destroy; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFMediaSource, uCEFMediaSink, + uCEFMediaRoute; + +// ************************************************** +// ************** TCefMediaObserverOwn ************** +// ************************************************** + +procedure cef_media_observer_on_sinks( self : PCefMediaObserver; + sinksCount : NativeUInt; + const sinks : PPCefMediaSink); stdcall; +type + TSinkArray = array of PCefMediaSink; +var + TempObject : TObject; + TempArray : TCefMediaSinkArray; + i : NativeUInt; +begin + TempArray := nil; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefMediaObserverOwn) then + try + if (sinksCount > 0) and (sinks <> nil) then + begin + SetLength(TempArray, sinksCount); + + i := 0; + while (i < sinksCount) do + begin + TempArray[i] := TCefMediaSinkRef.UnWrap(TSinkArray(sinks)[i]); + inc(i); + end; + end; + + TCefMediaObserverOwn(TempObject).OnSinks(TempArray); + finally + if (TempArray <> nil) then + begin + i := 0; + while (i < sinksCount) do + begin + TempArray[i] := nil; + inc(i); + end; + + Finalize(TempArray); + TempArray := nil; + end; + end; +end; + +procedure cef_media_observer_on_routes( self : PCefMediaObserver; + routesCount : NativeUInt; + const routes : PPCefMediaRoute); stdcall; +type + TRouteArray = array of PCefMediaRoute; +var + TempObject : TObject; + TempArray : TCefMediaRouteArray; + i : NativeUInt; +begin + TempArray := nil; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefMediaObserverOwn) then + try + if (routesCount > 0) and (routes <> nil) then + begin + SetLength(TempArray, routesCount); + + i := 0; + while (i < routesCount) do + begin + TempArray[i] := TCefMediaRouteRef.UnWrap(TRouteArray(routes)[i]); + inc(i); + end; + end; + + TCefMediaObserverOwn(TempObject).OnRoutes(TempArray); + finally + if (TempArray <> nil) then + begin + i := 0; + while (i < routesCount) do + begin + TempArray[i] := nil; + inc(i); + end; + + Finalize(TempArray); + TempArray := nil; + end; + end; +end; + +procedure cef_media_observer_on_route_state_changed(self : PCefMediaObserver; + route : PCefMediaRoute; + state : TCefMediaRouteConnectionState); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefMediaObserverOwn) then + TCefMediaObserverOwn(TempObject).OnRouteStateChanged(TCefMediaRouteRef.UnWrap(route), state); +end; + +procedure cef_media_observer_on_route_message_received( self : PCefMediaObserver; + route : PCefMediaRoute; + const message_ : Pointer; + message_size : NativeUInt); stdcall; +var + TempObject : TObject; + TempAnsiMsg : Ansistring; + TempMsg : ustring; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefMediaObserverOwn) then + begin + if (message_size > 0) and (message_ <> nil) then + begin + SetString(TempAnsiMsg, PAnsiChar(message_), message_size); + {$IFDEF DELPHI12_UP} + TempMsg := Utf8ToString(TempAnsiMsg); + {$ELSE} + TempMsg := Utf8Decode(TempAnsiMsg); + {$ENDIF} + end; + + TCefMediaObserverOwn(TempObject).OnRouteMessageReceived(TCefMediaRouteRef.UnWrap(route), + TempMsg); + end; +end; + +constructor TCefMediaObserverOwn.Create; +begin + inherited CreateData(SizeOf(TCefMediaObserver)); + + with PCefMediaObserver(FData)^ do + begin + on_sinks := {$IFDEF FPC}@{$ENDIF}cef_media_observer_on_sinks; + on_routes := {$IFDEF FPC}@{$ENDIF}cef_media_observer_on_routes; + on_route_state_changed := {$IFDEF FPC}@{$ENDIF}cef_media_observer_on_route_state_changed; + on_route_message_received := {$IFDEF FPC}@{$ENDIF}cef_media_observer_on_route_message_received; + end; +end; + +procedure TCefMediaObserverOwn.OnSinks(const sinks: TCefMediaSinkArray); +begin + // +end; + +procedure TCefMediaObserverOwn.OnRoutes(const routes: TCefMediaRouteArray); +begin + // +end; + +procedure TCefMediaObserverOwn.OnRouteStateChanged(const route: ICefMediaRoute; state: TCefMediaRouteConnectionState); +begin + // +end; + +procedure TCefMediaObserverOwn.OnRouteMessageReceived(const route: ICefMediaRoute; const message_: ustring); +begin + // +end; + +// ************************************************** +// ************** TCustomMediaObserver ************** +// ************************************************** + +constructor TCustomMediaObserver.Create(const events: IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +destructor TCustomMediaObserver.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + +procedure TCustomMediaObserver.OnSinks(const sinks: TCefMediaSinkArray); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnSinks(sinks); + except + on e : exception do + if CustomExceptionHandler('TCustomMediaObserver.OnSinks', e) then raise; + end; +end; + +procedure TCustomMediaObserver.OnRoutes(const routes: TCefMediaRouteArray); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnRoutes(routes); + except + on e : exception do + if CustomExceptionHandler('TCustomMediaObserver.OnRoutes', e) then raise; + end; +end; + +procedure TCustomMediaObserver.OnRouteStateChanged(const route: ICefMediaRoute; state: TCefMediaRouteConnectionState); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnRouteStateChanged(route, state); + except + on e : exception do + if CustomExceptionHandler('TCustomMediaObserver.OnRouteStateChanged', e) then raise; + end; +end; + +procedure TCustomMediaObserver.OnRouteMessageReceived(const route: ICefMediaRoute; const message_: ustring); +begin + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnRouteMessageReceived(route, message_); + except + on e : exception do + if CustomExceptionHandler('TCustomMediaObserver.OnRouteMessageReceived', e) then raise; + end; +end; + + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFMediaRoute.pas b/windows/src/ext/cef4delphi/source/uCEFMediaRoute.pas new file mode 100644 index 0000000000000000000000000000000000000000..912682824221cd723ee726fef4aae6d591e610e2 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMediaRoute.pas @@ -0,0 +1,120 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMediaRoute; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefMediaRouteRef = class(TCefBaseRefCountedRef, ICefMediaRoute) + protected + function GetId: ustring; + function GetSource: ICefMediaSource; + function GetSink: ICefMediaSink; + procedure SendRouteMessage(const message_: ustring); + procedure Terminate; + public + class function UnWrap(data: Pointer): ICefMediaRoute; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFMediaSource, uCEFMediaSink; + +function TCefMediaRouteRef.GetId: ustring; +begin + Result := CefStringFreeAndGet(PCefMediaRoute(FData)^.get_id(PCefMediaRoute(FData))); +end; + +function TCefMediaRouteRef.GetSource: ICefMediaSource; +begin + Result := TCefMediaSourceRef.UnWrap(PCefMediaRoute(FData)^.get_source(PCefMediaRoute(FData))); +end; + +function TCefMediaRouteRef.GetSink: ICefMediaSink; +begin + Result := TCefMediaSinkRef.UnWrap(PCefMediaRoute(FData)^.get_sink(PCefMediaRoute(FData))); +end; + +procedure TCefMediaRouteRef.SendRouteMessage(const message_: ustring); +var + TempMsgPtr : pointer; + TempMsg : AnsiString; + TempSize : NativeUInt; +begin + TempSize := length(message_); + + if (TempSize > 0) then + begin + TempMsg := Utf8Encode(message_); + TempMsgPtr := @TempMsg[1]; + end + else + TempMsgPtr := nil; + + PCefMediaRoute(FData)^.send_route_message(PCefMediaRoute(FData), + TempMsgPtr, + TempSize); +end; + +procedure TCefMediaRouteRef.Terminate; +begin + PCefMediaRoute(FData)^.terminate(PCefMediaRoute(FData)); +end; + +class function TCefMediaRouteRef.UnWrap(data: Pointer): ICefMediaRoute; +begin + if (data <> nil) then + Result := Create(data) as ICefMediaRoute + else + Result := nil; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFMediaRouteCreateCallback.pas b/windows/src/ext/cef4delphi/source/uCEFMediaRouteCreateCallback.pas new file mode 100644 index 0000000000000000000000000000000000000000..a1879db93cde55f81fa3e106beb73c5fd79b8751 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMediaRouteCreateCallback.pas @@ -0,0 +1,183 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMediaRouteCreateCallback; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefMediaRouteCreateCallbackOwn = class(TCefBaseRefCountedOwn, ICefMediaRouteCreateCallback) + protected + procedure OnMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); virtual; abstract; + public + constructor Create; virtual; + end; + + TCefFastMediaRouteCreateCallback = class(TCefMediaRouteCreateCallbackOwn) + protected + FCallback: TCefMediaRouteCreateCallbackProc; + + procedure OnMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); override; + public + constructor Create(const callback: TCefMediaRouteCreateCallbackProc); reintroduce; + destructor Destroy; override; + end; + + TCefCustomMediaRouteCreateCallback = class(TCefMediaRouteCreateCallbackOwn) + protected + FEvents : Pointer; + + procedure OnMediaRouteCreateFinished(result: TCefMediaRouterCreateResult; const error: ustring; const route: ICefMediaRoute); override; + public + constructor Create(const aEvents : IChromiumEvents); reintroduce; + destructor Destroy; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFMediaRoute; + +procedure cef_media_route_create_callback_on_media_route_create_finished( self : PCefMediaRouteCreateCallback; + result : TCefMediaRouterCreateResult; + const error : PCefString; + route : PCefMediaRoute); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefMediaRouteCreateCallbackOwn) then + TCefMediaRouteCreateCallbackOwn(TempObject).OnMediaRouteCreateFinished(result, + CefString(error), + TCefMediaRouteRef.UnWrap(route)); +end; + + +// ************************************************************* +// ************** TCefMediaRouteCreateCallbackOwn ************** +// ************************************************************* + +constructor TCefMediaRouteCreateCallbackOwn.Create; +begin + inherited CreateData(SizeOf(TCefMediaRouteCreateCallback)); + + PCefMediaRouteCreateCallback(FData)^.on_media_route_create_finished := + {$IFDEF FPC}@{$ENDIF}cef_media_route_create_callback_on_media_route_create_finished; +end; + + +// ************************************************************** +// ************** TCefFastMediaRouteCreateCallback ************** +// ************************************************************** + +constructor TCefFastMediaRouteCreateCallback.Create(const callback: TCefMediaRouteCreateCallbackProc); +begin + inherited Create; + + FCallback := callback; +end; + +procedure TCefFastMediaRouteCreateCallback.OnMediaRouteCreateFinished( result : TCefMediaRouterCreateResult; + const error : ustring; + const route : ICefMediaRoute); +begin + if assigned(FCallback) then + FCallback(result, error, route); +end; + +destructor TCefFastMediaRouteCreateCallback.Destroy; +begin + FCallback := nil; + + inherited Destroy; +end; + + +// **************************************************************** +// ************** TCefCustomMediaRouteCreateCallback ************** +// **************************************************************** + +constructor TCefCustomMediaRouteCreateCallback.Create(const aEvents : IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(aEvents); +end; + +destructor TCefCustomMediaRouteCreateCallback.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + +procedure TCefCustomMediaRouteCreateCallback.OnMediaRouteCreateFinished( result : TCefMediaRouterCreateResult; + const error : ustring; + const route : ICefMediaRoute); +begin + try + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doMediaRouteCreateFinished(result, error, route); + except + on e : exception do + if CustomExceptionHandler('TCefCustomMediaRouteCreateCallback.OnMediaRouteCreateFinished', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFMediaRouter.pas b/windows/src/ext/cef4delphi/source/uCEFMediaRouter.pas new file mode 100644 index 0000000000000000000000000000000000000000..9aad99b9dbdf00b07ef687aa507395092bdbac16 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMediaRouter.pas @@ -0,0 +1,121 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMediaRouter; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefMediaRouterRef = class(TCefBaseRefCountedRef, ICefMediaRouter) + protected + function AddObserver(const observer: ICefMediaObserver): ICefRegistration; + function GetSource(const urn: ustring): ICefMediaSource; + procedure NotifyCurrentSinks; + procedure CreateRoute(const source: ICefMediaSource; const sink: ICefMediaSink; const callback: ICefMediaRouteCreateCallback); + procedure NotifyCurrentRoutes; + public + class function UnWrap(data: Pointer): ICefMediaRouter; + class function Global: ICefMediaRouter; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions, uCEFMediaSource, uCEFRegistration, + uCEFMediaRouteCreateCallback; + +function TCefMediaRouterRef.AddObserver(const observer: ICefMediaObserver): ICefRegistration; +begin + Result := TCefRegistrationRef.UnWrap(PCefMediaRouter(FData)^.add_observer(PCefMediaRouter(FData), + CefGetData(observer))); +end; + +function TCefMediaRouterRef.GetSource(const urn: ustring): ICefMediaSource; +var + TempURN : TCefString; +begin + TempURN := CefString(urn); + Result := TCefMediaSourceRef.UnWrap(PCefMediaRouter(FData)^.get_source(PCefMediaRouter(FData), + @TempURN)); +end; + +procedure TCefMediaRouterRef.NotifyCurrentSinks; +begin + PCefMediaRouter(FData)^.notify_current_sinks(PCefMediaRouter(FData)); +end; + +procedure TCefMediaRouterRef.CreateRoute(const source : ICefMediaSource; + const sink : ICefMediaSink; + const callback : ICefMediaRouteCreateCallback); +begin + PCefMediaRouter(FData)^.create_route(PCefMediaRouter(FData), + CefGetData(source), + CefGetData(sink), + CefGetData(callback)); +end; + +procedure TCefMediaRouterRef.NotifyCurrentRoutes; +begin + PCefMediaRouter(FData)^.notify_current_routes(PCefMediaRouter(FData)); +end; + +class function TCefMediaRouterRef.UnWrap(data: Pointer): ICefMediaRouter; +begin + if (data <> nil) then + Result := Create(data) as ICefMediaRouter + else + Result := nil; +end; + +class function TCefMediaRouterRef.Global: ICefMediaRouter; +begin + Result := UnWrap(cef_media_router_get_global()); +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFMediaSink.pas b/windows/src/ext/cef4delphi/source/uCEFMediaSink.pas new file mode 100644 index 0000000000000000000000000000000000000000..77f8a33a5cb9ac6067dd7f1a620de7240c0848cb --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMediaSink.pas @@ -0,0 +1,122 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMediaSink; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefMediaSinkRef = class(TCefBaseRefCountedRef, ICefMediaSink) + protected + function GetId: ustring; + function GetName: ustring; + function GetDescription: ustring; + function GetIconType: TCefMediaSinkIconType; + procedure GetDeviceInfo(const callback: ICefMediaSinkDeviceInfoCallback); + function IsCastSink: boolean; + function IsDialSink: boolean; + function IsCompatibleWith(const source: ICefMediaSource): boolean; + public + class function UnWrap(data: Pointer): ICefMediaSink; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +function TCefMediaSinkRef.GetId: ustring; +begin + Result := CefStringFreeAndGet(PCefMediaSink(FData)^.get_id(PCefMediaSink(FData))); +end; + +function TCefMediaSinkRef.GetName: ustring; +begin + Result := CefStringFreeAndGet(PCefMediaSink(FData)^.get_name(PCefMediaSink(FData))); +end; + +function TCefMediaSinkRef.GetDescription: ustring; +begin + Result := CefStringFreeAndGet(PCefMediaSink(FData)^.get_description(PCefMediaSink(FData))); +end; + +function TCefMediaSinkRef.GetIconType: TCefMediaSinkIconType; +begin + Result := PCefMediaSink(FData)^.get_icon_type(PCefMediaSink(FData)); +end; + +procedure TCefMediaSinkRef.GetDeviceInfo(const callback: ICefMediaSinkDeviceInfoCallback); +begin + PCefMediaSink(FData)^.get_device_info(PCefMediaSink(FData), CefGetData(callback)); +end; + +function TCefMediaSinkRef.IsCastSink: Boolean; +begin + Result := PCefMediaSink(FData)^.is_cast_sink(PCefMediaSink(FData)) <> 0; +end; + +function TCefMediaSinkRef.IsDialSink: Boolean; +begin + Result := PCefMediaSink(FData)^.is_dial_sink(PCefMediaSink(FData)) <> 0; +end; + +function TCefMediaSinkRef.IsCompatibleWith(const source: ICefMediaSource): boolean; +begin + Result := PCefMediaSink(FData)^.is_compatible_with(PCefMediaSink(FData), CefGetData(source)) <> 0; +end; + +class function TCefMediaSinkRef.UnWrap(data: Pointer): ICefMediaSink; +begin + if (data <> nil) then + Result := Create(data) as ICefMediaSink + else + Result := nil; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFMediaSinkDeviceInfoCallback.pas b/windows/src/ext/cef4delphi/source/uCEFMediaSinkDeviceInfoCallback.pas new file mode 100644 index 0000000000000000000000000000000000000000..098556cd30a7ffe7e0288f2f61a06d83d1e327a2 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMediaSinkDeviceInfoCallback.pas @@ -0,0 +1,177 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMediaSinkDeviceInfoCallback; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefMediaSinkDeviceInfoCallbackOwn = class(TCefBaseRefCountedOwn, ICefMediaSinkDeviceInfoCallback) + protected + procedure OnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); virtual; abstract; + public + constructor Create; virtual; + end; + + TCefFastMediaSinkDeviceInfoCallback = class(TCefMediaSinkDeviceInfoCallbackOwn) + protected + FCallback: TCefMediaSinkDeviceInfoCallbackProc; + + procedure OnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); override; + public + constructor Create(const callback: TCefMediaSinkDeviceInfoCallbackProc); reintroduce; + destructor Destroy; override; + end; + + TCefCustomMediaSinkDeviceInfoCallback = class(TCefMediaSinkDeviceInfoCallbackOwn) + protected + FEvents : Pointer; + + procedure OnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); override; + public + constructor Create(const aEvents : IChromiumEvents); reintroduce; + destructor Destroy; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFMediaSink; + +procedure cef_media_sink_device_info_callback_on_media_sink_device_info(self : PCefMediaSinkDeviceInfoCallback; + device_info : PCefMediaSinkDeviceInfo); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefMediaSinkDeviceInfoCallbackOwn) then + TCefMediaSinkDeviceInfoCallbackOwn(TempObject).OnMediaSinkDeviceInfo(CefString(@device_info^.ip_address), + device_info^.port, + CefString(@device_info^.model_name)); +end; + + +// **************************************************************** +// ************** TCefMediaSinkDeviceInfoCallbackOwn ************** +// **************************************************************** + +constructor TCefMediaSinkDeviceInfoCallbackOwn.Create; +begin + inherited CreateData(SizeOf(TCefMediaSinkDeviceInfoCallback)); + + PCefMediaSinkDeviceInfoCallback(FData)^.on_media_sink_device_info := + {$IFDEF FPC}@{$ENDIF}cef_media_sink_device_info_callback_on_media_sink_device_info; +end; + + +// ***************************************************************** +// ************** TCefFastMediaSinkDeviceInfoCallback ************** +// ***************************************************************** + +constructor TCefFastMediaSinkDeviceInfoCallback.Create(const callback: TCefMediaSinkDeviceInfoCallbackProc); +begin + inherited Create; + + FCallback := callback; +end; + +procedure TCefFastMediaSinkDeviceInfoCallback.OnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); +begin + if assigned(FCallback) then + FCallback(ip_address, port, model_name); +end; + +destructor TCefFastMediaSinkDeviceInfoCallback.Destroy; +begin + FCallback := nil; + + inherited Destroy; +end; + + +// ******************************************************************* +// ************** TCefCustomMediaSinkDeviceInfoCallback ************** +// ******************************************************************* + +constructor TCefCustomMediaSinkDeviceInfoCallback.Create(const aEvents : IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(aEvents); +end; + +destructor TCefCustomMediaSinkDeviceInfoCallback.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + +procedure TCefCustomMediaSinkDeviceInfoCallback.OnMediaSinkDeviceInfo(const ip_address: ustring; port: integer; const model_name: ustring); +begin + try + try + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnMediaSinkDeviceInfo(ip_address, port, model_name); + except + on e : exception do + if CustomExceptionHandler('TCefCustomMediaSinkDeviceInfoCallback.OnMediaSinkDeviceInfo', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFMediaSource.pas b/windows/src/ext/cef4delphi/source/uCEFMediaSource.pas new file mode 100644 index 0000000000000000000000000000000000000000..0829162626e93f6beafd7829130b974d87d25ec5 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMediaSource.pas @@ -0,0 +1,92 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMediaSource; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefMediaSourceRef = class(TCefBaseRefCountedRef, ICefMediaSource) + protected + function GetId : ustring; + function IsCastSource : boolean; + function IsDialSource : boolean; + public + class function UnWrap(data: Pointer): ICefMediaSource; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +function TCefMediaSourceRef.GetId: ustring; +begin + Result := CefStringFreeAndGet(PCefMediaSource(FData)^.get_id(PCefMediaSource(FData))); +end; + +function TCefMediaSourceRef.IsCastSource: Boolean; +begin + Result := PCefMediaSource(FData)^.is_cast_source(PCefMediaSource(FData)) <> 0; +end; + +function TCefMediaSourceRef.IsDialSource: Boolean; +begin + Result := PCefMediaSource(FData)^.is_dial_source(PCefMediaSource(FData)) <> 0; +end; + +class function TCefMediaSourceRef.UnWrap(data: Pointer): ICefMediaSource; +begin + if (data <> nil) then + Result := Create(data) as ICefMediaSource + else + Result := nil; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFMenuButton.pas b/windows/src/ext/cef4delphi/source/uCEFMenuButton.pas new file mode 100644 index 0000000000000000000000000000000000000000..b261462a5fabe08c68308e143f446cab81df12c8 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMenuButton.pas @@ -0,0 +1,117 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMenuButton; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFLabelButton; + +type + TCefMenuButtonRef = class(TCefLabelButtonRef, ICefMenuButton) + protected + procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position: TCefMenuAnchorPosition); + procedure TriggerMenu; + + public + class function UnWrap(data: Pointer): ICefMenuButton; + class function CreateMenuButton(const delegate: ICefMenuButtonDelegate; const text: ustring): ICefMenuButton; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions; + +procedure TCefMenuButtonRef.ShowMenu(const menu_model : ICefMenuModel; + const screen_point : TCefPoint; + anchor_position : TCefMenuAnchorPosition); +begin + PCefMenuButton(FData)^.show_menu(PCefMenuButton(FData), + CefGetData(menu_model), + @screen_point, + anchor_position); +end; + +procedure TCefMenuButtonRef.TriggerMenu; +begin + PCefMenuButton(FData)^.trigger_menu(PCefMenuButton(FData)); +end; + +class function TCefMenuButtonRef.UnWrap(data: Pointer): ICefMenuButton; +begin + if (data <> nil) then + Result := Create(data) as ICefMenuButton + else + Result := nil; +end; + +class function TCefMenuButtonRef.CreateMenuButton(const delegate : ICefMenuButtonDelegate; + const text : ustring): ICefMenuButton; +var + TempText : TCefString; + TempButton : PCefMenuButton; +begin + Result := nil; + + if (delegate <> nil) then + begin + TempText := CefString(text); + TempButton := cef_menu_button_create(CefGetData(delegate), @TempText); + + if (TempButton <> nil) then + Result := Create(TempButton) as ICefMenuButton; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFMenuButtonComponent.pas b/windows/src/ext/cef4delphi/source/uCEFMenuButtonComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..dbcfb2d0f8776a13dcdd6d20194898bb580c222c --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMenuButtonComponent.pas @@ -0,0 +1,223 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMenuButtonComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents, uCEFLabelButtonComponent; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFMenuButtonComponent = class(TCEFLabelButtonComponent, ICefMenuButtonDelegateEvents) + protected + FMenuButton : ICefMenuButton; + + // ICefMenuButtonDelegateEvents + FOnMenuButtonPressed : TOnMenuButtonPressedEvent; + + procedure DestroyView; override; + procedure Initialize; override; + + function GetInitialized : boolean; override; + function GetAsView : ICefView; override; + function GetAsButton : ICefButton; override; + function GetAsLabelButton : ICefLabelButton; override; + function GetAsMenuButton : ICefMenuButton; override; + + // ICefMenuButtonDelegateEvents + procedure doOnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock); + + // ICefViewDelegateEvents + procedure doCreateCustomView; override; + + public + procedure CreateMenuButton(const aText : ustring); + procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position: TCefMenuAnchorPosition); + procedure TriggerMenu; + + published + property OnMenuButtonPressed : TOnMenuButtonPressedEvent read FOnMenuButtonPressed write FOnMenuButtonPressed; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + uCEFMenuButtonDelegate, uCEFMenuButton; + +procedure TCEFMenuButtonComponent.CreateMenuButton(const aText : ustring); +begin + CreateLabelButton(aText); +end; + +procedure TCEFMenuButtonComponent.doCreateCustomView; +var + TempDelegate : ICefMenuButtonDelegate; +begin + if (FMenuButton = nil) then + try + TempDelegate := TCustomMenuButtonDelegate.Create(self); + FMenuButton := TCefMenuButtonRef.CreateMenuButton(TempDelegate, FText); + finally + TempDelegate := nil; + end; +end; + +procedure TCEFMenuButtonComponent.Initialize; +begin + inherited Initialize; + + FMenuButton := nil; + FOnMenuButtonPressed := nil; +end; + +procedure TCEFMenuButtonComponent.DestroyView; +begin + FMenuButton := nil; +end; + +function TCEFMenuButtonComponent.GetInitialized : boolean; +begin + Result := (FMenuButton <> nil); +end; + +function TCEFMenuButtonComponent.GetAsView : ICefView; +begin + Result := FMenuButton as ICefView; +end; + +function TCEFMenuButtonComponent.GetAsButton : ICefButton; +begin + if Initialized then + Result := FMenuButton as ICefButton + else + Result := nil; +end; + +function TCEFMenuButtonComponent.GetAsLabelButton : ICefLabelButton; +begin + if Initialized then + Result := FMenuButton as ICefLabelButton + else + Result := nil; +end; + +function TCEFMenuButtonComponent.GetAsMenuButton : ICefMenuButton; +begin + Result := FMenuButton; +end; + +procedure TCEFMenuButtonComponent.doOnMenuButtonPressed(const menu_button : ICefMenuButton; + const screen_point : TCefPoint; + const button_pressed_lock : ICefMenuButtonPressedLock); +begin + if assigned(FOnMenuButtonPressed) then + FOnMenuButtonPressed(self, menu_button, screen_point, button_pressed_lock); +end; + +procedure TCEFMenuButtonComponent.ShowMenu(const menu_model : ICefMenuModel; + const screen_point : TCefPoint; + anchor_position : TCefMenuAnchorPosition); +begin + if Initialized then + FMenuButton.ShowMenu(menu_model, screen_point, anchor_position); +end; + +procedure TCEFMenuButtonComponent.TriggerMenu; +begin + if Initialized then + FMenuButton.TriggerMenu; +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tcefmenubuttoncomponent.lrs} + RegisterComponents('Chromium Views Framework', [TCEFMenuButtonComponent]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFMenuButtonDelegate.pas b/windows/src/ext/cef4delphi/source/uCEFMenuButtonDelegate.pas new file mode 100644 index 0000000000000000000000000000000000000000..d5a84d6ce1e73cda49bff33485320c313a21ba36 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMenuButtonDelegate.pas @@ -0,0 +1,308 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMenuButtonDelegate; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFButtonDelegate; + +type + TCefMenuButtonDelegateRef = class(TCefButtonDelegateRef, ICefMenuButtonDelegate) + protected + procedure OnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock); + + public + class function UnWrap(data: Pointer): ICefMenuButtonDelegate; + end; + + TCefMenuButtonDelegateOwn = class(TCefButtonDelegateOwn, ICefMenuButtonDelegate) + protected + procedure OnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock); virtual; + + procedure InitializeCEFMethods; override; + public + constructor Create; override; + end; + + TCustomMenuButtonDelegate = class(TCefMenuButtonDelegateOwn) + protected + FEvents : Pointer; + + // ICefViewDelegate + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); override; + procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); override; + procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); override; + procedure OnFocus(const view: ICefView); override; + procedure OnBlur(const view: ICefView); override; + + // ICefButtonDelegate + procedure OnButtonPressed(const button: ICefButton); override; + procedure OnButtonStateChanged(const button: ICefButton); override; + + // ICefMenuButtonDelegate + procedure OnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock); override; + + public + constructor Create(const events: ICefMenuButtonDelegateEvents); reintroduce; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFMenuButton, uCEFMenuButtonPressedLock; + + +// ************************************************************** +// **************** TCefMenuButtonDelegateRef ******************* +// ************************************************************** + +procedure TCefMenuButtonDelegateRef.OnMenuButtonPressed(const menu_button : ICefMenuButton; + const screen_point : TCefPoint; + const button_pressed_lock : ICefMenuButtonPressedLock); +begin + PCefMenuButtonDelegate(FData)^.on_menu_button_pressed(PCefMenuButtonDelegate(FData), + CefGetData(menu_button), + @screen_point, + CefGetData(button_pressed_lock)); +end; + +class function TCefMenuButtonDelegateRef.UnWrap(data: Pointer): ICefMenuButtonDelegate; +begin + if (data <> nil) then + Result := Create(data) as ICefMenuButtonDelegate + else + Result := nil; +end; + + +// ************************************************************** +// **************** TCefMenuButtonDelegateOwn ******************* +// ************************************************************** + +procedure cef_menubutton_delegate_on_menu_button_pressed( self : PCefMenuButtonDelegate; + menu_button : PCefMenuButton; + const screen_point : PCefPoint; + button_pressed_lock : PCefMenuButtonPressedLock); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefMenuButtonDelegateOwn) then + TCefMenuButtonDelegateOwn(TempObject).OnMenuButtonPressed(TCefMenuButtonRef.UnWrap(menu_button), + screen_point^, + TCefMenuButtonPressedLockRef.UnWrap(button_pressed_lock)); +end; + +constructor TCefMenuButtonDelegateOwn.Create; +begin + inherited CreateData(SizeOf(TCefMenuButtonDelegate)); + + InitializeCEFMethods; +end; + +procedure TCefMenuButtonDelegateOwn.InitializeCEFMethods; +begin + inherited InitializeCEFMethods; + + with PCefMenuButtonDelegate(FData)^ do + on_menu_button_pressed := {$IFDEF FPC}@{$ENDIF}cef_menubutton_delegate_on_menu_button_pressed; +end; + +procedure TCefMenuButtonDelegateOwn.OnMenuButtonPressed(const menu_button : ICefMenuButton; + const screen_point : TCefPoint; + const button_pressed_lock : ICefMenuButtonPressedLock); +begin + // +end; + + +// ************************************************************** +// **************** TCustomMenuButtonDelegate ******************* +// ************************************************************** + +constructor TCustomMenuButtonDelegate.Create(const events: ICefMenuButtonDelegateEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +procedure TCustomMenuButtonDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnGetPreferredSize', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnGetMinimumSize', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnGetMaximumSize', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnGetHeightForWidth', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnParentViewChanged', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnChildViewChanged(view, added, child); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnChildViewChanged', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnFocus(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnFocus(view); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnFocus', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnBlur(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnBlur(view); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnBlur', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnButtonPressed(const button: ICefButton); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnButtonPressed(button); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnButtonPressed', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnButtonStateChanged(const button: ICefButton); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnButtonStateChanged(button); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnButtonStateChanged', e) then raise; + end; +end; + +procedure TCustomMenuButtonDelegate.OnMenuButtonPressed(const menu_button : ICefMenuButton; + const screen_point : TCefPoint; + const button_pressed_lock : ICefMenuButtonPressedLock); +begin + try + if (FEvents <> nil) then + ICefMenuButtonDelegateEvents(FEvents).doOnMenuButtonPressed(menu_button, screen_point, button_pressed_lock); + except + on e : exception do + if CustomExceptionHandler('TCustomMenuButtonDelegate.OnMenuButtonPressed', e) then raise; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFMenuButtonPressedLock.pas b/windows/src/ext/cef4delphi/source/uCEFMenuButtonPressedLock.pas new file mode 100644 index 0000000000000000000000000000000000000000..c9cde6e9d81048f1e1a9c14f25a46a20307f391a --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFMenuButtonPressedLock.pas @@ -0,0 +1,76 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFMenuButtonPressedLock; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefMenuButtonPressedLockRef = class(TCefBaseRefCountedRef, ICefMenuButtonPressedLock) + public + class function UnWrap(data: Pointer): ICefMenuButtonPressedLock; + end; + +implementation + +class function TCefMenuButtonPressedLockRef.UnWrap(data: Pointer): ICefMenuButtonPressedLock; +begin + if (data <> nil) then + Result := Create(data) as ICefMenuButtonPressedLock + else + Result := nil; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFMenuModel.pas b/windows/src/ext/cef4delphi/source/uCEFMenuModel.pas index 90655408556d31e844a877a4cdb67a867e2d27d2..6bb752d6c21172413b5ff3141365d1349b8f815d 100644 --- a/windows/src/ext/cef4delphi/source/uCEFMenuModel.pas +++ b/windows/src/ext/cef4delphi/source/uCEFMenuModel.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFMenuModel; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFMenuModelDelegate.pas b/windows/src/ext/cef4delphi/source/uCEFMenuModelDelegate.pas index b21bf29f4331c63006659ecf62b9d018e6491f5e..15b9879542da9804f21c681f62650b3128208c0c 100644 --- a/windows/src/ext/cef4delphi/source/uCEFMenuModelDelegate.pas +++ b/windows/src/ext/cef4delphi/source/uCEFMenuModelDelegate.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFMenuModelDelegate; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -62,7 +60,7 @@ type procedure UnhandledCloseSubmenu(const menuModel: ICefMenuModel; isRTL: boolean); virtual; procedure MenuWillShow(const menuModel: ICefMenuModel); virtual; procedure MenuClosed(const menuModel: ICefMenuModel); virtual; - function FormatLabel(const menuModel: ICefMenuModel; const label_ : uString) : boolean; virtual; + function FormatLabel(const menuModel: ICefMenuModel; var label_ : ustring) : boolean; virtual; public constructor Create; virtual; end; @@ -152,13 +150,17 @@ function cef_menu_model_delegate_format_label(self : PCefMenuModelDelegate label_ : PCefString) : integer; stdcall; var TempObject : TObject; + TempLabel : ustring; begin Result := Ord(False); TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefMenuModelDelegateOwn) then - Result := Ord(TCefMenuModelDelegateOwn(TempObject).FormatLabel(TCefMenuModelRef.UnWrap(menu_model), - CefString(label_))); + begin + TempLabel := CefStringClearAndGet(label_); + Result := Ord(TCefMenuModelDelegateOwn(TempObject).FormatLabel(TCefMenuModelRef.UnWrap(menu_model), TempLabel)); + if (label_ <> nil) then label_^ := CefStringAlloc(TempLabel); + end; end; constructor TCefMenuModelDelegateOwn.Create; @@ -209,7 +211,7 @@ begin // end; -function TCefMenuModelDelegateOwn.FormatLabel(const menuModel: ICefMenuModel; const label_ : uString) : boolean; +function TCefMenuModelDelegateOwn.FormatLabel(const menuModel: ICefMenuModel; var label_ : ustring) : boolean; begin Result := False; end; diff --git a/windows/src/ext/cef4delphi/source/uCEFMiscFunctions.pas b/windows/src/ext/cef4delphi/source/uCEFMiscFunctions.pas index f8d8d0552f93e426cd2216d084157ae6d338856c..2625039f24d96c5614b1cea027b85ec389c7a3cb 100644 --- a/windows/src/ext/cef4delphi/source/uCEFMiscFunctions.pas +++ b/windows/src/ext/cef4delphi/source/uCEFMiscFunctions.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,27 +41,43 @@ unit uCEFMiscFunctions; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} +{$IFNDEF FPC}{$IFNDEF DELPHI12_UP} + // Workaround for "Internal error" in old Delphi versions caused by uint64 handling + {$R-} +{$ENDIF}{$ENDIF} + interface uses {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.ActiveX,{$ENDIF} System.Classes, System.SysUtils, System.UITypes, System.Math, + {$IFDEF MSWINDOWS} + WinApi.Windows, WinApi.ActiveX, {$IFDEF FMX}FMX.Types,{$ENDIF} + {$ELSE} + {$IFDEF MACOSX}Macapi.Foundation, FMX.Helpers.Mac,{$ENDIF} + {$ENDIF} + System.Types, System.IOUtils, System.Classes, System.SysUtils, System.UITypes, System.Math, {$ELSE} - {$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} Classes, SysUtils, Controls, Graphics, Math, + {$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} + {$IFDEF DELPHI14_UP}Types, IOUtils,{$ENDIF} Classes, SysUtils, Math, + {$IFDEF FPC}LCLType, LazFileUtils,{$IFNDEF MSWINDOWS}InterfaceBase, Forms,{$ENDIF}{$ENDIF} + {$IFDEF LINUX}{$IFDEF FPC} + ctypes, keysym, xf86keysym, x, xlib, + {$IFDEF LCLGTK2}gtk2, glib2, gdk2, gtk2proc, gtk2int, Gtk2Def, gdk2x, Gtk2Extra,{$ENDIF} + {$ENDIF}{$ENDIF} {$ENDIF} uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFResourceHandler, - uCEFRegisterCDMCallback; + uCEFRegisterCDMCallback, uCEFConstants; const Kernel32DLL = 'kernel32.dll'; SHLWAPIDLL = 'shlwapi.dll'; + NTDLL = 'ntdll.dll'; + User32DLL = 'User32.dll'; function CefColorGetA(color: TCefColor): Byte; function CefColorGetR(color: TCefColor): byte; @@ -75,11 +91,11 @@ function CefInt64Set(int32_low, int32_high: Integer): Int64; function CefInt64GetLow(const int64_val: Int64): Integer; function CefInt64GetHigh(const int64_val: Int64): Integer; -function CefGetObject(ptr: Pointer): TObject; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} -function CefGetData(const i: ICefBaseRefCounted): Pointer; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +function CefGetObject(ptr: Pointer): TObject; {$IFDEF SUPPORTS_INLINE}inline;{$ENDIF} +function CefGetData(const i: ICefBaseRefCounted): Pointer; {$IFDEF SUPPORTS_INLINE}inline;{$ENDIF} function CefStringAlloc(const str: ustring): TCefString; -function CefStringClearAndGet(var str: TCefString): ustring; +function CefStringClearAndGet(str: PCefString): ustring; function CefString(const str: ustring): TCefString; overload; function CefString(const str: PCefString): ustring; overload; @@ -87,13 +103,27 @@ function CefUserFreeString(const str: ustring): PCefStringUserFree; procedure CefStringFree(const str: PCefString); function CefStringFreeAndGet(const str: PCefStringUserFree): ustring; procedure CefStringSet(const str: PCefString; const value: ustring); +procedure CefStringInitialize(const aCefString : PCefString); {$IFDEF SUPPORTS_INLINE}inline;{$ENDIF} + +function CefRegisterExtension(const name, code: ustring; const Handler: ICefv8Handler): Boolean; -function CefRegisterExtension(const name, code: ustring; const Handler: ICefv8Handler): Boolean; -procedure CefPostTask(ThreadId: TCefThreadId; const task: ICefTask); -procedure CefPostDelayedTask(ThreadId: TCefThreadId; const task: ICefTask; delayMs: Int64); +function CefPostTask(aThreadId : TCefThreadId; const aTask: ICefTask) : boolean; +function CefPostDelayedTask(aThreadId : TCefThreadId; const aTask : ICefTask; aDelayMs : Int64) : boolean; +function CefCurrentlyOn(aThreadId : TCefThreadId) : boolean; +{$IFDEF MSWINDOWS} function CefTimeToSystemTime(const dt: TCefTime): TSystemTime; function SystemTimeToCefTime(const dt: TSystemTime): TCefTime; +{$ELSE} + {$IFDEF LINUX} + {$IFDEF FPC} + function CefTimeToSystemTime(const dt: TCefTime): TSystemTime; + function SystemTimeToCefTime(const dt: TSystemTime): TCefTime; + {$ENDIF} + {$ENDIF} +{$ENDIF} + +function FixCefTime(const dt : TCefTime): TCefTime; function CefTimeToDateTime(const dt: TCefTime): TDateTime; function DateTimeToCefTime(dt: TDateTime): TCefTime; @@ -103,31 +133,39 @@ function cef_string_utf16_copy(const src: PChar16; src_len: NativeUInt; output: function cef_string_copy(const src: PCefChar; src_len: NativeUInt; output: PCefString): Integer; {$IFDEF MSWINDOWS} -procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : THandle; aRect : TRect; const aWindowName : ustring = ''); -procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : THandle; const aWindowName : ustring = ''); -procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : THandle; const aWindowName : ustring = ''); +procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; const aWindowName : ustring = ''; aExStyle : DWORD = 0); +procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring = ''; aExStyle : DWORD = 0); +procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring = ''; aExStyle : DWORD = 0); {$ENDIF} -{$IFDEF MACOS} -procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; aHidden : boolean = False; const aWindowName : ustring = ''); -procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aHidden : boolean = False; const aWindowName : ustring = ''); -procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aHidden : boolean = False; const aWindowName : ustring = ''); +{$IFDEF MACOSX} +procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; const aWindowName : ustring = ''; aHidden : boolean = False); +procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring = ''; aHidden : boolean = False); +procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring = ''; aHidden : boolean = False); {$ENDIF} {$IFDEF LINUX} -procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect); -procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle); -procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle); +procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; const aWindowName : ustring = ''); +procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring = ''); +procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring = ''); {$ENDIF} {$IFDEF MSWINDOWS} -function TzSpecificLocalTimeToSystemTime(lpTimeZoneInformation: PTimeZoneInformation; lpLocalTime, lpUniversalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL; -function SystemTimeToTzSpecificLocalTime(lpTimeZoneInformation: PTimeZoneInformation; lpUniversalTime, lpLocalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL; - +function ProcessUnderWow64(hProcess: THandle; var Wow64Process: BOOL): BOOL; stdcall; external Kernel32DLL name 'IsWow64Process'; function PathIsRelativeAnsi(pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeA'; function PathIsRelativeUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeW'; +function GetGlobalMemoryStatusEx(var Buffer: TMyMemoryStatusEx): BOOL; stdcall; external Kernel32DLL name 'GlobalMemoryStatusEx'; +function PathCanonicalizeAnsi(pszBuf: LPSTR; pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathCanonicalizeA'; +function PathCanonicalizeUnicode(pszBuf: LPWSTR; pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathCanonicalizeW'; +function PathIsUNCAnsi(pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsUNCA'; +function PathIsUNCUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsUNCW'; +function PathIsURLAnsi(pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsURLA'; +function PathIsURLUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsURLW'; {$IFNDEF DELPHI12_UP} +const + GWLP_WNDPROC = GWL_WNDPROC; + GWLP_HWNDPARENT = GWL_HWNDPARENT; {$IFDEF WIN64} function SetWindowLongPtr(hWnd: HWND; nIndex: Integer; dwNewLong: int64): int64; stdcall; external user32 name 'SetWindowLongPtrW'; {$ELSE} @@ -138,16 +176,21 @@ function PathIsRelativeUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAP {$ENDIF} function CustomPathIsRelative(const aPath : string) : boolean; +function CustomPathCanonicalize(const aOriginalPath : string; var aCanonicalPath : string) : boolean; +function CustomAbsolutePath(const aPath : string; aMustExist : boolean = False) : string; +function CustomPathIsURL(const aPath : string) : boolean; +function CustomPathIsUNC(const aPath : string) : boolean; function GetModulePath : string; function CefIsCertStatusError(Status : TCefCertStatus) : boolean; -function CefIsCertStatusMinorError(Status : TCefCertStatus) : boolean; function CefCrashReportingEnabled : boolean; procedure CefSetCrashKeyValue(const aKey, aValue : ustring); procedure CefLog(const aFile : string; aLine, aSeverity : integer; const aMessage : string); -procedure CefDebugLog(const aMessage : string); +procedure CefDebugLog(const aMessage : string; aSeverity : integer = CEF_LOG_SEVERITY_ERROR); +procedure CefKeyEventLog(const aEvent : TCefKeyEvent); +procedure CefMouseEventLog(const aEvent : TCefMouseEvent); procedure OutputDebugMessage(const aMessage : string); function CustomExceptionHandler(const aFunctionName : string; const aException : exception) : boolean; @@ -159,18 +202,25 @@ function CefRemoveCrossOriginWhitelistEntry(const SourceOrigin, TargetProtocol, function CefClearCrossOriginWhitelist: Boolean; procedure UInt64ToFileVersionInfo(const aVersion : uint64; var aVersionInfo : TFileVersionInfo); -function GetExtendedFileVersion(const aFileName : string) : uint64; -function GetStringFileInfo(const aFileName, aField : string; var aValue : string) : boolean; -function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersionInfo) : boolean; +{$IFDEF MSWINDOWS} +function GetExtendedFileVersion(const aFileName : ustring) : uint64; +function GetDLLVersion(const aDLLFile : ustring; var aVersionInfo : TFileVersionInfo) : boolean; +procedure OutputLastErrorMessage; +{$ENDIF} function SplitLongString(aSrcString : string) : string; function GetAbsoluteDirPath(const aSrcPath : string; var aRsltPath : string) : boolean; +function CheckSubprocessPath(const aSubprocessPath : string; var aMissingFiles : string) : boolean; function CheckLocales(const aLocalesDirPath : string; var aMissingFiles : string; const aLocalesRequired : string = '') : boolean; -function CheckResources(const aResourcesDirPath : string; var aMissingFiles : string; aCheckDevResources: boolean = True) : boolean; +function CheckResources(const aResourcesDirPath : string; var aMissingFiles : string; aCheckDevResources: boolean = True; aCheckExtensions: boolean = True) : boolean; function CheckDLLs(const aFrameworkDirPath : string; var aMissingFiles : string) : boolean; -function CheckDLLVersion(const aDLLFile : string; aMajor, aMinor, aRelease, aBuild : uint16) : boolean; +{$IFDEF MSWINDOWS} +function CheckDLLVersion(const aDLLFile : ustring; aMajor, aMinor, aRelease, aBuild : uint16) : boolean; +function GetDLLHeaderMachine(const aDLLFile : ustring; var aMachine : integer) : boolean; +{$ENDIF} function FileVersionInfoToString(const aVersionInfo : TFileVersionInfo) : string; function CheckFilesExist(var aList : TStringList; var aMissingFiles : string) : boolean; +function Is32BitProcess : boolean; function CefParseUrl(const url: ustring; var parts: TUrlParts): Boolean; function CefCreateUrl(var parts: TUrlParts): ustring; @@ -183,12 +233,7 @@ function CefBase64Decode(const data: ustring): ICefBinaryValue; function CefUriEncode(const text: ustring; usePlus: Boolean): ustring; function CefUriDecode(const text: ustring; convertToUtf8: Boolean; unescapeRule: TCefUriUnescapeRule): ustring; -function CefParseJson(const jsonString: ustring; options: TCefJsonParserOptions): ICefValue; -function CefParseJsonAndReturnError(const jsonString : ustring; - options : TCefJsonParserOptions; - out errorCodeOut : TCefJsonParserError; - out errorMsgOut : ustring): ICefValue; -function CefWriteJson(const node: ICefValue; options: TCefJsonWriterOptions): ustring; +function CefGetPath(const aPathKey : TCefPathKey) : ustring; function CefCreateDirectory(const fullPath: ustring): Boolean; function CefGetTempDirectory(out tempDir: ustring): Boolean; @@ -199,18 +244,32 @@ function CefDeleteFile(const path: ustring; recursive: Boolean): Boolean; function CefZipDirectory(const srcDir, destFile: ustring; includeHiddenFiles: Boolean): Boolean; procedure CefLoadCRLSetsFile(const path : ustring); -function CefIsKeyDown(aWparam : WPARAM) : boolean; -function CefIsKeyToggled(aWparam : WPARAM) : boolean; -function GetCefMouseModifiers(awparam : WPARAM) : TCefEventFlags; overload; -function GetCefMouseModifiers : TCefEventFlags; overload; -function GetCefKeyboardModifiers(aWparam : WPARAM; aLparam : LPARAM) : TCefEventFlags; -function GefCursorToWindowsCursor(aCefCursor : TCefCursorType) : TCursor; +{$IFDEF MSWINDOWS} +function CefIsKeyDown(aWparam : WPARAM) : boolean; +function CefIsKeyToggled(aWparam : WPARAM) : boolean; +function GetCefMouseModifiers : TCefEventFlags; overload; +function GetCefMouseModifiers(awparam : WPARAM) : TCefEventFlags; overload; +function GetCefKeyboardModifiers(aWparam : WPARAM; aLparam : LPARAM) : TCefEventFlags; +procedure CefCheckAltGrPressed(aWparam : WPARAM; var aEvent : TCefKeyEvent); procedure DropEffectToDragOperation(aEffect : Longint; var aAllowedOps : TCefDragOperations); procedure DragOperationToDropEffect(const aDragOperations : TCefDragOperations; var aEffect: Longint); +function GetWindowsMajorMinorVersion(var wMajorVersion, wMinorVersion : DWORD) : boolean; +function RunningWindows10OrNewer : boolean; +function GetDPIForHandle(aHandle : HWND; var aDPI : UINT) : boolean; +function GetDefaultCEFUserAgent : string; +{$IFDEF DELPHI14_UP} +function TouchPointToPoint(aHandle : HWND; const TouchPoint: TTouchInput): TPoint; +function GetDigitizerStatus(var aDigitizerStatus : TDigitizerStatus; aDPI : cardinal = 0) : boolean; +function HasTouchOrPen(aDPI : cardinal = 0) : boolean; +{$ENDIF} +{$ENDIF} + function DeviceToLogical(aValue : integer; const aDeviceScaleFactor : double) : integer; overload; +function DeviceToLogical(aValue : single; const aDeviceScaleFactor : double) : single; overload; procedure DeviceToLogical(var aEvent : TCEFMouseEvent; const aDeviceScaleFactor : double); overload; +procedure DeviceToLogical(var aEvent : TCefTouchEvent; const aDeviceScaleFactor : double); overload; procedure DeviceToLogical(var aPoint : TPoint; const aDeviceScaleFactor : double); overload; function LogicalToDevice(aValue : integer; const aDeviceScaleFactor : double) : integer; overload; procedure LogicalToDevice(var aRect : TCEFRect; const aDeviceScaleFactor : double); overload; @@ -218,10 +277,22 @@ procedure LogicalToDevice(var aRect : TCEFRect; const aDeviceScaleFactor : doubl function GetScreenDPI : integer; function GetDeviceScaleFactor : single; +function DeleteDirContents(const aDirectory : string; const aExcludeFiles : TStringList = nil) : boolean; +function DeleteFileList(const aFileList : TStringList) : boolean; +function MoveFileList(const aFileList : TStringList; const aSrcDirectory, aDstDirectory : string) : boolean; + +function CefGetDataURI(const aString, aMimeType : ustring) : ustring; overload; +function CefGetDataURI(aData : pointer; aSize : integer; const aMimeType : ustring; const aCharset : ustring = '') : ustring; overload; + +function ValidCefWindowHandle(aHandle : TCefWindowHandle) : boolean; +procedure InitializeWindowHandle(var aHandle : TCefWindowHandle); + implementation uses - uCEFConstants, uCEFApplication, uCEFSchemeHandlerFactory, uCEFValue, + {$IFDEF LINUX}{$IFDEF FMX}Posix.Unistd, Posix.Stdio,{$ENDIF}{$ENDIF} + {$IFDEF MACOS}Posix.Unistd, Posix.Stdio,{$ENDIF} + uCEFApplicationCore, uCEFSchemeHandlerFactory, uCEFValue, uCEFBinaryValue, uCEFStringList; function CefColorGetA(color: TCefColor): Byte; @@ -264,12 +335,12 @@ begin Result := (int64_val shr 32) and $FFFFFFFF; end; -function CefStringClearAndGet(var str: TCefString): ustring; +function CefStringClearAndGet(str: PCefString): ustring; begin - if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then + if (str <> nil) and (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then begin - Result := CefString(@str); - cef_string_utf16_clear(@str); + Result := CefString(str); + cef_string_utf16_clear(str); end else Result := ''; @@ -296,7 +367,7 @@ end; function CefString(const str: PCefString): ustring; begin - if (str <> nil) then + if (str <> nil) and (str^.str <> nil) and (str^.length > 0) and (str^.length < nativeuint(high(integer))) then SetString(Result, str^.str, str^.length) else Result := ''; @@ -318,7 +389,17 @@ end; procedure CefStringSet(const str: PCefString; const value: ustring); begin if (str <> nil) and (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then - cef_string_utf16_set(PWideChar(value), Length(value), str, 1); + cef_string_utf16_set(PWideChar(value), Length(value), str, Ord(True)); +end; + +procedure CefStringInitialize(const aCefString : PCefString); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} +begin + if (aCefString <> nil) then + begin + aCefString^.str := nil; + aCefString^.length := 0; + aCefString^.dtor := nil; + end; end; function CefStringFreeAndGet(const str: PCefStringUserFree): ustring; @@ -334,11 +415,13 @@ end; function CefStringAlloc(const str: ustring): TCefString; begin - FillChar(Result, SizeOf(Result), 0); + CefStringInitialize(@Result); + if (str <> '') and (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then cef_string_wide_to_utf16(PWideChar(str), Length(str), @Result); end; + procedure _free_string(str: PChar16); stdcall; begin if (str <> nil) then FreeMem(str); @@ -362,7 +445,11 @@ function CefRegisterExtension(const name, code: ustring; const Handler: ICefv8Ha var TempName, TempCode : TCefString; begin - if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then + if (GlobalCEFApp <> nil) and + GlobalCEFApp.LibLoaded and + ((GlobalCEFApp.ProcessType = ptRenderer) or GlobalCEFApp.SingleProcess) and + (length(name) > 0) and + (length(code) > 0) then begin TempName := CefString(name); TempCode := CefString(code); @@ -372,18 +459,31 @@ begin Result := False; end; -procedure CefPostTask(ThreadId: TCefThreadId; const task: ICefTask); +function CefPostTask(aThreadId : TCefThreadId; const aTask : ICefTask) : boolean; begin - if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then - cef_post_task(ThreadId, CefGetData(task)); + if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded and (aTask <> nil) then + Result := cef_post_task(aThreadId, aTask.Wrap) <> 0 + else + Result := False; end; -procedure CefPostDelayedTask(ThreadId: TCefThreadId; const task: ICefTask; delayMs: Int64); +function CefPostDelayedTask(aThreadId : TCefThreadId; const aTask : ICefTask; aDelayMs : Int64) : boolean; +begin + if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded and (aTask <> nil) then + Result := cef_post_delayed_task(aThreadId, aTask.Wrap, aDelayMs) <> 0 + else + Result := False; +end; + +function CefCurrentlyOn(aThreadId : TCefThreadId) : boolean; begin if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then - cef_post_delayed_task(ThreadId, CefGetData(task), delayMs); + Result := cef_currently_on(aThreadId) <> 0 + else + Result := False; end; +{$IFDEF MSWINDOWS} function CefTimeToSystemTime(const dt: TCefTime): TSystemTime; begin Result.wYear := dt.year; @@ -407,23 +507,77 @@ begin Result.second := dt.wSecond; Result.millisecond := dt.wMilliseconds; end; +{$ELSE} + {$IFDEF LINUX} + {$IFDEF FPC} +function CefTimeToSystemTime(const dt: TCefTime): TSystemTime; +begin + Result.Year := dt.year; + Result.Month := dt.month; + Result.DayOfWeek := dt.day_of_week; + Result.Day := dt.day_of_month; + Result.Hour := dt.hour; + Result.Minute := dt.minute; + Result.Second := dt.second; + Result.Millisecond := dt.millisecond; +end; + +function SystemTimeToCefTime(const dt: TSystemTime): TCefTime; +begin + Result.year := dt.Year; + Result.month := dt.Month; + Result.day_of_week := dt.DayOfWeek; + Result.day_of_month := dt.Day; + Result.hour := dt.Hour; + Result.minute := dt.Minute; + Result.second := dt.Second; + Result.millisecond := dt.Millisecond; +end; + {$ENDIF} + {$ENDIF} +{$ENDIF} + +function FixCefTime(const dt : TCefTime): TCefTime; +var + DayTable : PDayTable; +begin + Result := dt; + + Result.year := min(9999, max(1, Result.year)); + Result.month := min(12, max(1, Result.month)); + Result.hour := min(23, max(0, Result.hour)); + Result.minute := min(59, max(0, Result.minute)); + Result.second := min(59, max(0, Result.second)); + Result.millisecond := min(999, max(0, Result.millisecond)); + + DayTable := @MonthDays[IsLeapYear(Result.year)]; + Result.day_of_month := min(DayTable^[Result.month], max(1, Result.day_of_month)); +end; function CefTimeToDateTime(const dt: TCefTime): TDateTime; var - TempTime : TSystemTime; + TempFixedCefTime : TCefTime; begin - TempTime := CefTimeToSystemTime(dt); - SystemTimeToTzSpecificLocalTime(nil, @TempTime, @TempTime); - Result := SystemTimeToDateTime(TempTime); + TempFixedCefTime := FixCefTime(dt); + Result := EncodeDate(TempFixedCefTime.year, TempFixedCefTime.month, TempFixedCefTime.day_of_month) + + EncodeTime(TempFixedCefTime.hour, TempFixedCefTime.minute, TempFixedCefTime.second, TempFixedCefTime.millisecond); end; function DateTimeToCefTime(dt: TDateTime): TCefTime; var - TempTime : TSystemTime; + TempYear, TempMonth, TempDay, TempHour, TempMin, TempSec, TempMSec : Word; begin - DateTimeToSystemTime(dt, TempTime); - TzSpecificLocalTimeToSystemTime(nil, @TempTime, @TempTime); - Result := SystemTimeToCefTime(TempTime); + DecodeDate(dt, TempYear, TempMonth, TempDay); + DecodeTime(dt, TempHour, TempMin, TempSec, TempMSec); + + Result.year := TempYear; + Result.month := TempMonth; + Result.day_of_week := DayOfWeek(dt); + Result.day_of_month := TempMonth; + Result.hour := TempHour; + Result.minute := TempMin; + Result.second := TempSec; + Result.millisecond := TempMSec; end; function cef_string_wide_copy(const src: PWideChar; src_len: NativeUInt; output: PCefStringWide): Integer; @@ -459,9 +613,9 @@ begin end; {$IFDEF MSWINDOWS} -procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : THandle; aRect : TRect; const aWindowName : ustring); +procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; const aWindowName : ustring; aExStyle : DWORD); begin - aWindowInfo.ex_style := 0; + aWindowInfo.ex_style := aExStyle; aWindowInfo.window_name := CefString(aWindowName); aWindowInfo.style := WS_CHILD or WS_VISIBLE or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or WS_TABSTOP; aWindowInfo.x := aRect.left; @@ -471,12 +625,14 @@ begin aWindowInfo.parent_window := aParent; aWindowInfo.menu := 0; aWindowInfo.windowless_rendering_enabled := ord(False); + aWindowInfo.shared_texture_enabled := ord(False); + aWindowInfo.external_begin_frame_enabled := ord(False); aWindowInfo.window := 0; end; -procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : THandle; const aWindowName : ustring); +procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring; aExStyle : DWORD); begin - aWindowInfo.ex_style := 0; + aWindowInfo.ex_style := aExStyle; aWindowInfo.window_name := CefString(aWindowName); aWindowInfo.style := WS_OVERLAPPEDWINDOW or WS_CLIPCHILDREN or WS_CLIPSIBLINGS or WS_VISIBLE; aWindowInfo.x := integer(CW_USEDEFAULT); @@ -486,12 +642,14 @@ begin aWindowInfo.parent_window := aParent; aWindowInfo.menu := 0; aWindowInfo.windowless_rendering_enabled := ord(False); + aWindowInfo.shared_texture_enabled := ord(False); + aWindowInfo.external_begin_frame_enabled := ord(False); aWindowInfo.window := 0; end; -procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : THandle; const aWindowName : ustring); +procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring; aExStyle : DWORD); begin - aWindowInfo.ex_style := 0; + aWindowInfo.ex_style := aExStyle; aWindowInfo.window_name := CefString(aWindowName); aWindowInfo.style := 0; aWindowInfo.x := 0; @@ -501,12 +659,14 @@ begin aWindowInfo.parent_window := aParent; aWindowInfo.menu := 0; aWindowInfo.windowless_rendering_enabled := ord(True); + aWindowInfo.shared_texture_enabled := ord(False); + aWindowInfo.external_begin_frame_enabled := ord(False); aWindowInfo.window := 0; end; {$ENDIF} -{$IFDEF MACOS} -procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; aHidden : boolean; const aWindowName : ustring); +{$IFDEF MACOSX} +procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; const aWindowName : ustring; aHidden : boolean); begin aWindowInfo.window_name := CefString(aWindowName); aWindowInfo.x := aRect.left; @@ -516,25 +676,36 @@ begin aWindowInfo.hidden := Ord(aHidden); aWindowInfo.parent_view := aParent; aWindowInfo.windowless_rendering_enabled := ord(False); + aWindowInfo.shared_texture_enabled := ord(False); + aWindowInfo.external_begin_frame_enabled := ord(False); + {$IFDEF FPC} aWindowInfo.view := 0; + {$ELSE} + aWindowInfo.view := nil; + {$ENDIF} end; -procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : THandle; aHidden : boolean; const aWindowName : ustring); +procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring; aHidden : boolean); begin aWindowInfo.window_name := CefString(aWindowName); - aWindowInfo.x := integer(CW_USEDEFAULT); - aWindowInfo.y := integer(CW_USEDEFAULT); - aWindowInfo.width := integer(CW_USEDEFAULT); - aWindowInfo.height := integer(CW_USEDEFAULT); + aWindowInfo.x := 0; + aWindowInfo.y := 0; + aWindowInfo.width := 0; + aWindowInfo.height := 0; aWindowInfo.hidden := Ord(aHidden); aWindowInfo.parent_view := aParent; aWindowInfo.windowless_rendering_enabled := ord(False); + aWindowInfo.shared_texture_enabled := ord(False); + aWindowInfo.external_begin_frame_enabled := ord(False); + {$IFDEF FPC} aWindowInfo.view := 0; + {$ELSE} + aWindowInfo.view := nil; + {$ENDIF} end; -procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : THandle; aHidden : boolean; const aWindowName : ustring); +procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring; aHidden : boolean); begin - aWindowInfo.window_name := CefString(aWindowName); aWindowInfo.x := 0; aWindowInfo.y := 0; @@ -543,41 +714,67 @@ begin aWindowInfo.hidden := Ord(aHidden); aWindowInfo.parent_view := aParent; aWindowInfo.windowless_rendering_enabled := ord(True); + aWindowInfo.shared_texture_enabled := ord(False); + aWindowInfo.external_begin_frame_enabled := ord(False); + {$IFDEF FPC} aWindowInfo.view := 0; + {$ELSE} + aWindowInfo.view := nil; + {$ENDIF} end; {$ENDIF} {$IFDEF LINUX} -procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect); +procedure WindowInfoAsChild(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; aRect : TRect; const aWindowName : ustring = ''); +var + TempParent : TCefWindowHandle; begin + // TODO: Find a way to get the right "parent_window" in FMX + TempParent := aParent; + {$IFDEF FPC} + if ValidCefWindowHandle(aParent) and (PGtkWidget(aParent)^.window <> nil) then + TempParent := gdk_window_xwindow(PGtkWidget(aParent)^.window); + {$ENDIF} + + aWindowInfo.window_name := CefString(aWindowName); aWindowInfo.x := aRect.left; aWindowInfo.y := aRect.top; aWindowInfo.width := aRect.right - aRect.left; aWindowInfo.height := aRect.bottom - aRect.top; - aWindowInfo.parent_window := aParent; + aWindowInfo.parent_window := TempParent; aWindowInfo.windowless_rendering_enabled := ord(False); + aWindowInfo.shared_texture_enabled := ord(False); + aWindowInfo.external_begin_frame_enabled := ord(False); aWindowInfo.window := 0; end; -procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : THandle); +// WindowInfoAsPopUp only exists for Windows. The Linux version of cefclient +// calls WindowInfoAsChild with aParent set to NULL to create a popup window. +procedure WindowInfoAsPopUp(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring = ''); begin - aWindowInfo.x := integer(CW_USEDEFAULT); - aWindowInfo.y := integer(CW_USEDEFAULT); - aWindowInfo.width := integer(CW_USEDEFAULT); - aWindowInfo.height := integer(CW_USEDEFAULT); + aWindowInfo.window_name := CefString(aWindowName); + aWindowInfo.x := 0; + aWindowInfo.y := 0; + aWindowInfo.width := 0; + aWindowInfo.height := 0; aWindowInfo.parent_window := aParent; aWindowInfo.windowless_rendering_enabled := ord(False); + aWindowInfo.shared_texture_enabled := ord(False); + aWindowInfo.external_begin_frame_enabled := ord(False); aWindowInfo.window := 0; end; -procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : THandle); +procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCefWindowHandle; const aWindowName : ustring = ''); begin + aWindowInfo.window_name := CefString(aWindowName); aWindowInfo.x := 0; aWindowInfo.y := 0; aWindowInfo.width := 0; aWindowInfo.height := 0; aWindowInfo.parent_window := aParent; - aWindowInfo.windowless_rendering_enabled := ord(False); + aWindowInfo.windowless_rendering_enabled := ord(True); + aWindowInfo.shared_texture_enabled := ord(False); + aWindowInfo.external_begin_frame_enabled := ord(False); aWindowInfo.window := 0; end; {$ENDIF} @@ -589,13 +786,6 @@ begin (cef_is_cert_status_error(Status) <> 0); end; -function CefIsCertStatusMinorError(Status : TCefCertStatus) : boolean; -begin - Result := (GlobalCEFApp <> nil) and - GlobalCEFApp.LibLoaded and - (cef_is_cert_status_minor_error(Status) <> 0); -end; - function CefCrashReportingEnabled : boolean; begin Result := (GlobalCEFApp <> nil) and @@ -628,7 +818,7 @@ begin end; end; -procedure CefDebugLog(const aMessage : string); +procedure CefDebugLog(const aMessage : string; aSeverity : integer); const DEFAULT_LINE = 1; var @@ -636,17 +826,80 @@ var begin if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then begin - TempString := 'PID: ' + IntToStr(GetCurrentProcessID) + ', TID: ' + IntToStr(GetCurrentThreadID); + {$IFDEF MSWINDOWS} + TempString := 'PID: ' + IntToStr(GetCurrentProcessID) + ', TID: ' + IntToStr(GetCurrentThreadID); + {$ENDIF} + + {$IFDEF LINUX} + {$IFDEF FPC} + TempString := 'PID: ' + IntToStr(GetProcessID()) + ', TID: ' + IntToStr(GetCurrentThreadID()); + {$ELSE} + // TO-DO: Find the equivalent function to get the process ID in Delphi FMX for Linux + {$ENDIF} + {$ENDIF} + + {$IFDEF MACOSX} + {$IFDEF FPC} + // TO-DO: Find the equivalent function to get the process ID in Lazarus/FPC for MacOS + {$ELSE} + TempString := 'PID: ' + IntToStr(TNSProcessInfo.Wrap(TNSProcessInfo.OCClass.processInfo).processIdentifier) + + ', TID: ' + IntToStr(TThread.Current.ThreadID); + {$ENDIF} + {$ENDIF} case GlobalCEFApp.ProcessType of ptBrowser : TempString := TempString + ', PT: Browser'; ptRenderer : TempString := TempString + ', PT: Renderer'; ptZygote : TempString := TempString + ', PT: Zygote'; ptGPU : TempString := TempString + ', PT: GPU'; - else TempString := TempString + ', PT: Other'; + ptUtility : TempString := TempString + ', PT: Utility'; + ptOther : TempString := TempString + ', PT: Other'; + end; + + CefLog('CEF4Delphi', DEFAULT_LINE, aSeverity, TempString + ' - ' + aMessage); + end; +end; + +procedure CefKeyEventLog(const aEvent : TCefKeyEvent); +const + DEFAULT_LINE = 1; +var + TempString : string; +begin + if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then + begin + case aEvent.kind of + KEYEVENT_RAWKEYDOWN : TempString := 'kind: KEYEVENT_RAWKEYDOWN'; + KEYEVENT_KEYDOWN : TempString := 'kind: KEYEVENT_KEYDOWN'; + KEYEVENT_KEYUP : TempString := 'kind: KEYEVENT_KEYUP'; + KEYEVENT_CHAR : TempString := 'kind: KEYEVENT_CHAR'; end; - CefLog('CEF4Delphi', DEFAULT_LINE, CEF_LOG_SEVERITY_ERROR, TempString + ' - ' + aMessage); + TempString := TempString + ', modifiers: $' + inttohex(aEvent.modifiers, SizeOf(aEvent.modifiers) * 2); + TempString := TempString + ', windows_key_code: $' + inttohex(aEvent.windows_key_code, SizeOf(aEvent.windows_key_code) * 2); + TempString := TempString + ', native_key_code: $' + inttohex(aEvent.native_key_code, SizeOf(aEvent.native_key_code) * 2); + TempString := TempString + ', is_system_key: ' + BoolToStr((aEvent.is_system_key <> 0), true); + TempString := TempString + ', character: $' + inttohex(ord(aEvent.character), SizeOf(aEvent.character) * 2); + TempString := TempString + ', unmodified_character: $' + inttohex(ord(aEvent.unmodified_character), SizeOf(aEvent.unmodified_character) * 2); + TempString := TempString + ', focus_on_editable_field: ' + BoolToStr((aEvent.focus_on_editable_field <> 0), true);; + + CefLog('CEF4Delphi', DEFAULT_LINE, CEF_LOG_SEVERITY_INFO, TempString); + end; +end; + +procedure CefMouseEventLog(const aEvent : TCefMouseEvent); +const + DEFAULT_LINE = 1; +var + TempString : string; +begin + if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then + begin + TempString := TempString + ', x: $' + inttohex(aEvent.x, SizeOf(aEvent.x) * 2); + TempString := TempString + ', y: $' + inttohex(aEvent.y, SizeOf(aEvent.y) * 2); + TempString := TempString + ', modifiers: $' + inttohex(aEvent.modifiers, SizeOf(aEvent.modifiers) * 2); + + CefLog('CEF4Delphi', DEFAULT_LINE, CEF_LOG_SEVERITY_INFO, TempString); end; end; @@ -655,7 +908,13 @@ const DEFAULT_LINE = 1; begin {$IFDEF DEBUG} - OutputDebugString({$IFDEF DELPHI12_UP}PWideChar{$ELSE}PAnsiChar{$ENDIF}(aMessage + chr(0))); + {$IFDEF MSWINDOWS} + {$IFDEF FMX} + FMX.Types.Log.d(aMessage); + {$ELSE} + OutputDebugString({$IFDEF DELPHI12_UP}PWideChar{$ELSE}PAnsiChar{$ENDIF}(aMessage + chr(0))); + {$ENDIF} + {$ENDIF} if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then CefLog('CEF4Delphi', DEFAULT_LINE, CEF_LOG_SEVERITY_ERROR, aMessage); @@ -759,9 +1018,10 @@ function SplitLongString(aSrcString : string) : string; const MAXLINELENGTH = 50; begin + Result := ''; while (length(aSrcString) > 0) do begin - if (length(Result) > 0) then + if (Result <> '') then Result := Result + CRLF + copy(aSrcString, 1, MAXLINELENGTH) else Result := Result + copy(aSrcString, 1, MAXLINELENGTH); @@ -776,14 +1036,8 @@ begin if (length(aSrcPath) > 0) then begin - aRsltPath := IncludeTrailingPathDelimiter(aSrcPath); - - if DirectoryExists(aSrcPath) then - begin - if CustomPathIsRelative(aRsltPath) then aRsltPath := GetModulePath + aRsltPath; - end - else - Result := False; + aRsltPath := IncludeTrailingPathDelimiter(CustomAbsolutePath(aSrcPath)); + Result := DirectoryExists(aRsltPath); end else aRsltPath := ''; @@ -858,7 +1112,7 @@ begin if (length(aLocalesDirPath) > 0) then TempDir := IncludeTrailingPathDelimiter(aLocalesDirPath) else - TempDir := 'locales\'; + TempDir := 'locales' + PathDelim; TempList := TStringList.Create; @@ -887,7 +1141,7 @@ begin end; end; -function CheckResources(const aResourcesDirPath : string; var aMissingFiles : string; aCheckDevResources: boolean) : boolean; +function CheckResources(const aResourcesDirPath : string; var aMissingFiles : string; aCheckDevResources, aCheckExtensions: boolean) : boolean; var TempDir : string; TempList : TStringList; @@ -900,14 +1154,13 @@ begin TempExists := GetAbsoluteDirPath(aResourcesDirPath, TempDir); TempList := TStringList.Create; - TempList.Add(TempDir + 'natives_blob.bin'); TempList.Add(TempDir + 'snapshot_blob.bin'); TempList.Add(TempDir + 'v8_context_snapshot.bin'); TempList.Add(TempDir + 'cef.pak'); TempList.Add(TempDir + 'cef_100_percent.pak'); TempList.Add(TempDir + 'cef_200_percent.pak'); - TempList.Add(TempDir + 'cef_extensions.pak'); + if aCheckExtensions then TempList.Add(TempDir + 'cef_extensions.pak'); if aCheckDevResources then TempList.Add(TempDir + 'devtools_resources.pak'); if TempExists then @@ -923,6 +1176,21 @@ begin end; end; +function CheckSubprocessPath(const aSubprocessPath : string; var aMissingFiles : string) : boolean; +begin + Result := False; + + try + if (length(aSubprocessPath) = 0) or FileExists(aSubprocessPath) then + Result := True + else + aMissingFiles := trim(aMissingFiles) + CRLF + ExtractFileName(aSubprocessPath); + except + on e : exception do + if CustomExceptionHandler('CheckSubprocessPath', e) then raise; + end; +end; + function CheckDLLs(const aFrameworkDirPath : string; var aMissingFiles : string) : boolean; var TempDir : string; @@ -940,14 +1208,21 @@ begin // http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=14503#p32263 TempList := TStringList.Create; - TempList.Add(TempDir + CHROMEELF_DLL); TempList.Add(TempDir + LIBCEF_DLL); - TempList.Add(TempDir + 'd3dcompiler_43.dll'); + {$IFDEF MSWINDOWS} + TempList.Add(TempDir + CHROMEELF_DLL); TempList.Add(TempDir + 'd3dcompiler_47.dll'); TempList.Add(TempDir + 'libEGL.dll'); TempList.Add(TempDir + 'libGLESv2.dll'); TempList.Add(TempDir + 'swiftshader\libEGL.dll'); TempList.Add(TempDir + 'swiftshader\libGLESv2.dll'); + {$ENDIF} + {$IFDEF LINUX} + TempList.Add(TempDir + 'libEGL.so'); + TempList.Add(TempDir + 'libGLESv2.so'); + TempList.Add(TempDir + 'swiftshader/libEGL.so'); + TempList.Add(TempDir + 'swiftshader/libGLESv2.so'); + {$ENDIF} TempList.Add(TempDir + 'icudtl.dat'); if TempExists then @@ -999,7 +1274,8 @@ begin aVersionInfo.Build := uint16(aVersion and $FFFF); end; -function GetExtendedFileVersion(const aFileName : string) : uint64; +{$IFDEF MSWINDOWS} +function GetExtendedFileVersion(const aFileName : ustring) : uint64; var TempSize : DWORD; TempBuffer : pointer; @@ -1012,20 +1288,22 @@ begin try try - TempSize := GetFileVersioninfoSize(PChar(aFileName), TempHandle); + TempSize := GetFileVersionInfoSizeW(PWideChar(aFileName), TempHandle); if (TempSize > 0) then begin GetMem(TempBuffer, TempSize); - if GetFileVersionInfo(PChar(aFileName), TempHandle, TempSize, TempBuffer) and + if GetFileVersionInfoW(PWideChar(aFileName), TempHandle, TempSize, TempBuffer) and VerQueryValue(TempBuffer, '\', Pointer(TempInfo), TempLen) then begin Result := TempInfo^.dwFileVersionMS; Result := Result shl 32; Result := Result or TempInfo^.dwFileVersionLS; end; - end; + end + else + OutputLastErrorMessage; except on e : exception do if CustomExceptionHandler('GetExtendedFileVersion', e) then raise; @@ -1035,114 +1313,88 @@ begin end; end; -function GetStringFileInfo(const aFileName, aField : string; var aValue : string) : boolean; -type - PLangAndCodepage = ^TLangAndCodepage; - TLangAndCodepage = record - wLanguage : word; - wCodePage : word; +procedure OutputLastErrorMessage; +begin + {$IFDEF DEBUG} + OutputDebugString({$IFDEF DELPHI12_UP}PWideChar{$ELSE}PAnsiChar{$ENDIF}(SysErrorMessage(GetLastError()) + chr(0))); + {$ENDIF} +end; + +function GetDLLVersion(const aDLLFile : ustring; var aVersionInfo : TFileVersionInfo) : boolean; +var + TempVersion : uint64; +begin + Result := False; + + try + if FileExists(aDLLFile) then + begin + TempVersion := GetExtendedFileVersion(aDLLFile); + if (TempVersion <> 0) then + begin + UInt64ToFileVersionInfo(TempVersion, aVersionInfo); + Result := True; + end; + end; + except + on e : exception do + if CustomExceptionHandler('GetDLLVersion', e) then raise; end; +end; + +function CheckDLLVersion(const aDLLFile : ustring; aMajor, aMinor, aRelease, aBuild : uint16) : boolean; +var + TempVersionInfo : TFileVersionInfo; +begin + Result := GetDLLVersion(aDLLFile, TempVersionInfo) and + (TempVersionInfo.MajorVer = aMajor) and + (TempVersionInfo.MinorVer = aMinor) and + (TempVersionInfo.Release = aRelease) and + (TempVersionInfo.Build = aBuild); +end; + +// This function is based on the answer given by 'Alex' in StackOverflow +// https://stackoverflow.com/questions/2748474/how-to-determine-if-dll-file-was-compiled-as-x64-or-x86-bit-using-either-delphi +function GetDLLHeaderMachine(const aDLLFile : ustring; var aMachine : integer) : boolean; var - TempSize : DWORD; - TempBuffer : pointer; - TempHandle : cardinal; - TempPointer : pointer; - TempSubBlock : string; - TempLang : PLangAndCodepage; - TempArray : array of TLangAndCodepage; - i, j : DWORD; + TempHeader : TImageDosHeader; + TempImageNtHeaders : TImageNtHeaders; + TempStream : TFileStream; begin Result := False; - TempBuffer := nil; - TempArray := nil; - aValue := ''; + aMachine := IMAGE_FILE_MACHINE_UNKNOWN; + TempStream := nil; try try - TempSize := GetFileVersionInfoSize(PChar(aFileName), TempHandle); - - if (TempSize > 0) then + if FileExists(aDLLFile) then begin - GetMem(TempBuffer, TempSize); + TempStream := TFileStream.Create(aDLLFile, fmOpenRead or fmShareDenyWrite); + TempStream.seek(0, soFromBeginning); + TempStream.ReadBuffer(TempHeader, SizeOf(TempHeader)); - if GetFileVersionInfo(PChar(aFileName), 0, TempSize, TempBuffer) then + if (TempHeader.e_magic = IMAGE_DOS_SIGNATURE) and + (TempHeader._lfanew <> 0) then begin - if VerQueryValue(TempBuffer, '\VarFileInfo\Translation\', Pointer(TempLang), TempSize) then - begin - i := 0; - j := TempSize div SizeOf(TLangAndCodepage); - - SetLength(TempArray, j); - - while (i < j) do - begin - TempArray[i].wLanguage := TempLang^.wLanguage; - TempArray[i].wCodePage := TempLang^.wCodePage; - inc(TempLang); - inc(i); - end; - end; + TempStream.Position := TempHeader._lfanew; + TempStream.ReadBuffer(TempImageNtHeaders, SizeOf(TempImageNtHeaders)); - i := 0; - j := Length(TempArray); - - while (i < j) and not(Result) do + if (TempImageNtHeaders.Signature = IMAGE_NT_SIGNATURE) then begin - TempSubBlock := '\StringFileInfo\' + - IntToHex(TempArray[i].wLanguage, 4) + IntToHex(TempArray[i].wCodePage, 4) + - '\' + aField; - - if VerQueryValue(TempBuffer, PChar(TempSubBlock), TempPointer, TempSize) then - begin - aValue := trim(PChar(TempPointer)); - Result := (length(aValue) > 0); - end; - - inc(i); - end; - - // Adobe's flash player DLL uses a different codepage to store the StringFileInfo fields - if not(Result) and (j > 0) and (TempArray[0].wCodePage <> 1252) then - begin - TempSubBlock := '\StringFileInfo\' + - IntToHex(TempArray[0].wLanguage, 4) + IntToHex(1252, 4) + - '\' + aField; - - if VerQueryValue(TempBuffer, PChar(TempSubBlock), TempPointer, TempSize) then - begin - aValue := trim(PChar(TempPointer)); - Result := (length(aValue) > 0); - end; + aMachine := TempImageNtHeaders.FileHeader.Machine; + Result := True; end; end; end; except on e : exception do - if CustomExceptionHandler('GetStringFileInfo', e) then raise; + if CustomExceptionHandler('GetDLLHeaderMachine', e) then raise; end; finally - if (TempBuffer <> nil) then FreeMem(TempBuffer); + if (TempStream <> nil) then FreeAndNil(TempStream); end; -end; - -function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersionInfo) : boolean; -var - TempVersion : uint64; -begin - Result := False; - - try - if FileExists(aDLLFile) then - begin - TempVersion := GetExtendedFileVersion(aDLLFile); - UInt64ToFileVersionInfo(TempVersion, aVersionInfo); - Result := True; - end; - except - on e : exception do - if CustomExceptionHandler('GetDLLVersion', e) then raise; - end; -end; +end; +{$ENDIF} function FileVersionInfoToString(const aVersionInfo : TFileVersionInfo) : string; begin @@ -1152,29 +1404,153 @@ begin IntToStr(aVersionInfo.Build); end; -function CheckDLLVersion(const aDLLFile : string; aMajor, aMinor, aRelease, aBuild : uint16) : boolean; +{$IFDEF MSWINDOWS} +function Is32BitProcessRunningIn64BitOS : boolean; var - TempVersionInfo : TFileVersionInfo; + TempResult : BOOL; begin - Result := GetDLLVersion(aDLLFile, TempVersionInfo) and - (TempVersionInfo.MajorVer = aMajor) and - (TempVersionInfo.MinorVer = aMinor) and - (TempVersionInfo.Release = aRelease) and - (TempVersionInfo.Build = aBuild); + Result := ProcessUnderWow64(GetCurrentProcess, TempResult) and TempResult; +end; +{$ENDIF} + +function Is32BitProcess : boolean; +begin + {$IFDEF TARGET_32BITS} + Result := True; + {$ELSE} + {$IFDEF MSWINDOWS} + Result := Is32BitProcessRunningIn64BitOS; + {$ELSE} + {$IFDEF DELPHI17_UP} + Result := TOSVersion.Architecture in [arIntelX86, arARM32]; + {$ELSE} + Result := False; + {$ENDIF} + {$ENDIF} + {$ENDIF} end; function CustomPathIsRelative(const aPath : string) : boolean; begin - {$IFDEF DELPHI12_UP} - Result := PathIsRelativeUnicode(PChar(aPath)); + {$IFDEF MSWINDOWS} + {$IFDEF DELPHI12_UP} + Result := PathIsRelativeUnicode(PChar(aPath)); + {$ELSE} + Result := PathIsRelativeAnsi(PChar(aPath)); + {$ENDIF} {$ELSE} - Result := PathIsRelativeAnsi(PChar(aPath)); + Result := (length(aPath) > 0) and (aPath[1] <> '/'); {$ENDIF} end; +function CustomPathIsURL(const aPath : string) : boolean; +begin + {$IFDEF MSWINDOWS} + {$IFDEF DELPHI12_UP} + Result := PathIsURLUnicode(PChar(aPath + #0)); + {$ELSE} + Result := PathIsURLAnsi(PChar(aPath + #0)); + {$ENDIF} + {$ELSE} + Result := False; + {$ENDIF} +end; + +function CustomPathIsUNC(const aPath : string) : boolean; +begin + {$IFDEF MSWINDOWS} + {$IFDEF DELPHI12_UP} + Result := PathIsUNCUnicode(PChar(aPath + #0)); + {$ELSE} + Result := PathIsUNCAnsi(PChar(aPath + #0)); + {$ENDIF} + {$ELSE} + Result := False; + {$ENDIF} +end; + +function CustomPathCanonicalize(const aOriginalPath : string; var aCanonicalPath : string) : boolean; +var + TempBuffer: array [0..pred(MAX_PATH)] of Char; +begin + Result := False; + aCanonicalPath := ''; + + if (length(aOriginalPath) > MAX_PATH) or + (Copy(aOriginalPath, 1, 4) = '\\?\') or + CustomPathIsUNC(aOriginalPath) then + exit; + + FillChar(TempBuffer, MAX_PATH * SizeOf(Char), 0); + + {$IFDEF MSWINDOWS} + {$IFDEF DELPHI12_UP} + if PathCanonicalizeUnicode(@TempBuffer[0], PChar(aOriginalPath + #0)) then + begin + aCanonicalPath := TempBuffer; + Result := True; + end; + {$ELSE} + if PathCanonicalizeAnsi(@TempBuffer[0], PChar(aOriginalPath + #0)) then + begin + aCanonicalPath := TempBuffer; + Result := True; + end; + {$ENDIF} + {$ENDIF} +end; + +function CustomAbsolutePath(const aPath : string; aMustExist : boolean) : string; +var + TempNewPath, TempOldPath : string; +begin + if (length(aPath) > 0) then + begin + if CustomPathIsRelative(aPath) then + TempOldPath := GetModulePath + aPath + else + TempOldPath := aPath; + + if not(CustomPathCanonicalize(TempOldPath, TempNewPath)) then + TempNewPath := TempOldPath; + + if aMustExist and not(DirectoryExists(TempNewPath)) then + Result := '' + else + Result := TempNewPath; + end + else + Result := ''; +end; + function GetModulePath : string; +{$IFDEF MACOSX} +const + MAC_APP_POSTFIX = '.app/'; + MAC_APP_SUBPATH = 'Contents/MacOS/'; +{$ENDIF} begin + {$IFDEF MSWINDOWS} Result := IncludeTrailingPathDelimiter(ExtractFileDir(GetModuleName(HINSTANCE{$IFDEF FPC}(){$ENDIF}))); + {$ENDIF} + + {$IFDEF LINUX} + Result := IncludeTrailingPathDelimiter(ExtractFileDir(ParamStr(0))); + {$ENDIF} + + {$IFDEF MACOSX} + Result := IncludeTrailingPathDelimiter(ExtractFileDir(ParamStr(0))); + + {$IFDEF FPC} + if copy(Result, Length(Result) + 1 - Length(MAC_APP_POSTFIX) - Length(MAC_APP_SUBPATH)) = MAC_APP_POSTFIX + MAC_APP_SUBPATH then + SetLength(Result, Length(Result) - Length(MAC_APP_SUBPATH)); + + Result := CreateAbsolutePath(Result, GetCurrentDirUTF8); + {$ELSE} + if Result.Contains(MAC_APP_POSTFIX + MAC_APP_SUBPATH) then + Result := Result.Remove(Result.IndexOf(MAC_APP_SUBPATH)); + {$ENDIF} + {$ENDIF} end; function CefParseUrl(const url: ustring; var parts: TUrlParts): Boolean; @@ -1190,7 +1566,7 @@ begin if Result then begin - //parts.spec := CefString(@TempParts.spec); + parts.spec := CefString(@TempParts.spec); parts.scheme := CefString(@TempParts.scheme); parts.username := CefString(@TempParts.username); parts.password := CefString(@TempParts.password); @@ -1199,6 +1575,7 @@ begin parts.origin := CefString(@TempParts.origin); parts.path := CefString(@TempParts.path); parts.query := CefString(@TempParts.query); + parts.fragment := CefString(@TempParts.fragment); end; end else @@ -1214,7 +1591,6 @@ begin if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then begin - FillChar(TempParts, sizeof(TempParts), 0); TempParts.spec := CefString(parts.spec); TempParts.scheme := CefString(parts.scheme); TempParts.username := CefString(parts.username); @@ -1224,9 +1600,12 @@ begin TempParts.origin := CefString(parts.origin); TempParts.path := CefString(parts.path); TempParts.query := CefString(parts.query); + TempParts.fragment := CefString(parts.fragment); + + CefStringInitialize(@TempURL); - FillChar(TempURL, SizeOf(TempURL), 0); - if cef_create_url(@TempParts, @TempURL) <> 0 then Result := CefString(@TempURL); + if (cef_create_url(@TempParts, @TempURL) <> 0) then + Result := CefStringClearAndGet(@TempURL); end; end; @@ -1312,45 +1691,17 @@ begin Result := ''; end; -function CefParseJson(const jsonString: ustring; options: TCefJsonParserOptions): ICefValue; +function CefGetPath(const aPathKey : TCefPathKey) : ustring; var - TempJSON : TCefString; + TempPath : TCefString; begin if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then begin - TempJSON := CefString(jsonString); - Result := TCefValueRef.UnWrap(cef_parse_json(@TempJSON, options)); - end - else - Result := nil; -end; + CefStringInitialize(@TempPath); -function CefParseJsonAndReturnError(const jsonString : ustring; - options : TCefJsonParserOptions; - out errorCodeOut : TCefJsonParserError; - out errorMsgOut : ustring): ICefValue; -var - TempJSON, TempError : TCefString; -begin - if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then - begin - FillChar(TempError, SizeOf(TempError), 0); - TempJSON := CefString(jsonString); - Result := TCefValueRef.UnWrap(cef_parse_jsonand_return_error(@TempJSON, options, @errorCodeOut, @TempError)); - errorMsgOut := CefString(@TempError); + if (cef_get_path(aPathKey, @TempPath) <> 0) then + Result := CefStringClearAndGet(@TempPath); end - else - begin - errorCodeOut := JSON_NO_ERROR; - Result := nil; - errorMsgOut := ''; - end; -end; - -function CefWriteJson(const node: ICefValue; options: TCefJsonWriterOptions): ustring; -begin - if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then - Result := CefStringFreeAndGet(cef_write_json(CefGetData(node), options)) else Result := ''; end; @@ -1374,9 +1725,9 @@ var begin if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then begin - FillChar(TempPath, SizeOf(TempPath), 0); + CefStringInitialize(@TempPath); Result := cef_get_temp_directory(@TempPath) <> 0; - tempDir := CefString(@TempPath); + tempDir := CefStringClearAndGet(@TempPath); end else begin @@ -1391,10 +1742,10 @@ var begin if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then begin - FillChar(TempPath, SizeOf(TempPath), 0); + CefStringInitialize(@TempPath); TempPref := CefString(prefix); Result := cef_create_new_temp_directory(@TempPref, @TempPath) <> 0; - newTempPath := CefString(@TempPath); + newTempPath := CefStringClearAndGet(@TempPath); end else begin @@ -1409,11 +1760,11 @@ var begin if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then begin - FillChar(TempPath, SizeOf(TempPath), 0); + CefStringInitialize(@TempPath); TempPref := CefString(prefix); TempBase := CefString(baseDir); Result := cef_create_temp_directory_in_directory(@TempBase, @TempPref, @TempPath) <> 0; - newDir := CefString(@TempPath); + newDir := CefStringClearAndGet(@TempPath); end else begin @@ -1473,6 +1824,7 @@ begin end; end; +{$IFDEF MSWINDOWS} function CefIsKeyDown(aWparam : WPARAM) : boolean; begin Result := (GetKeyState(aWparam) < 0); @@ -1586,39 +1938,32 @@ begin end; end; -function GefCursorToWindowsCursor(aCefCursor : TCefCursorType) : TCursor; -begin - case aCefCursor of - CT_POINTER : Result := crArrow; - CT_CROSS : Result := crCross; - CT_HAND : Result := crHandPoint; - CT_IBEAM : Result := crIBeam; - CT_WAIT : Result := crHourGlass; - CT_HELP : Result := crHelp; - CT_EASTRESIZE : Result := crSizeWE; - CT_NORTHRESIZE : Result := crSizeNS; - CT_NORTHEASTRESIZE : Result := crSizeNESW; - CT_NORTHWESTRESIZE : Result := crSizeNWSE; - CT_SOUTHRESIZE : Result := crSizeNS; - CT_SOUTHEASTRESIZE : Result := crSizeNWSE; - CT_SOUTHWESTRESIZE : Result := crSizeNESW; - CT_WESTRESIZE : Result := crSizeWE; - CT_NORTHSOUTHRESIZE : Result := crSizeNS; - CT_EASTWESTRESIZE : Result := crSizeWE; - CT_NORTHEASTSOUTHWESTRESIZE : Result := crSizeNESW; - CT_NORTHWESTSOUTHEASTRESIZE : Result := crSizeNWSE; - CT_COLUMNRESIZE : Result := crHSplit; - CT_ROWRESIZE : Result := crVSplit; - CT_MOVE : Result := crSizeAll; - CT_PROGRESS : Result := crAppStart; - CT_NONE : Result := crNone; - CT_NODROP, - CT_NOTALLOWED : Result := crNo; - CT_GRAB, - CT_GRABBING : Result := crDrag; - - else Result := crDefault; - end; +procedure CefCheckAltGrPressed(aWparam : WPARAM; var aEvent : TCefKeyEvent); +const + EITHER_SHIFT_KEY_PRESSED = $01; + EITHER_CONTROL_KEY_PRESSED = $02; + EITHER_ALT_KEY_PRESSED = $04; + EITHER_HANKAKU_KEY_PRESSED = $08; + EITHER_RESERVED1_KEY_PRESSED = $10; + EITHER_RESERVED2_KEY_PRESSED = $20; +var + TempKBLayout : HKL; + TempTranslatedChar : SHORT; + TempShiftState : byte; +begin + if (aEvent.kind = KEYEVENT_CHAR) and CefIsKeyDown(VK_RMENU) then + begin + TempKBLayout := GetKeyboardLayout(0); + TempTranslatedChar := VkKeyScanEx(char(aWparam), TempKBLayout); + TempShiftState := byte(TempTranslatedChar shr 8); + + if ((TempShiftState and EITHER_CONTROL_KEY_PRESSED) <> 0) and + ((TempShiftState and EITHER_ALT_KEY_PRESSED) <> 0) then + begin + aEvent.modifiers := aEvent.modifiers and not(EVENTFLAG_CONTROL_DOWN or EVENTFLAG_ALT_DOWN); + aEvent.modifiers := aEvent.modifiers or EVENTFLAG_ALTGR_DOWN; + end; + end; end; procedure DropEffectToDragOperation(aEffect: Longint; var aAllowedOps : TCefDragOperations); @@ -1639,17 +1984,175 @@ begin if ((aDragOperations and DRAG_OPERATION_MOVE) <> 0) then aEffect := aEffect or DROPEFFECT_MOVE; end; +function GetWindowsMajorMinorVersion(var wMajorVersion, wMinorVersion : DWORD) : boolean; +type + TRtlGetVersionFunc = function(var lpVersionInformation : TOSVersionInfoEx): LongInt; stdcall; +var + TempHandle : THandle; + TempInfo : TOSVersionInfoEx; + TempRtlGetVersionFunc : TRtlGetVersionFunc; +begin + Result := False; + wMajorVersion := 0; + wMinorVersion := 0; + + try + TempHandle := LoadLibrary(NTDLL); + + if (TempHandle <> 0) then + try + {$IFDEF FPC}Pointer({$ENDIF}TempRtlGetVersionFunc{$IFDEF FPC}){$ENDIF} := GetProcAddress(TempHandle, 'RtlGetVersion'); + + if assigned(TempRtlGetVersionFunc) then + begin + ZeroMemory(@TempInfo, SizeOf(TOSVersionInfoEx)); + + if (TempRtlGetVersionFunc(TempInfo) = 0) then + begin + Result := True; + wMajorVersion := TempInfo.dwMajorVersion; + wMinorVersion := TempInfo.dwMinorVersion; + end; + end; + finally + FreeLibrary(TempHandle); + end; + except + on e : exception do + if CustomExceptionHandler('GetWindowsMajorMinorVersion', e) then raise; + end; +end; + +// GetDpiForWindow is only available in Windows 10 (version 1607) or newer +function GetDPIForHandle(aHandle : HWND; var aDPI : UINT) : boolean; +type + TGetDpiForWindow = function(hwnd: HWND): UINT; stdcall; +var + TempHandle : THandle; + TempGetDpiForWindowFunc : TGetDpiForWindow; +begin + Result := False; + aDPI := 0; + + if (aHandle = 0) then exit; + + try + TempHandle := LoadLibrary(User32DLL); + + if (TempHandle <> 0) then + try + {$IFDEF FPC}Pointer({$ENDIF}TempGetDpiForWindowFunc{$IFDEF FPC}){$ENDIF} := GetProcAddress(TempHandle, 'GetDpiForWindow'); + + if assigned(TempGetDpiForWindowFunc) then + begin + aDPI := TempGetDpiForWindowFunc(aHandle); + Result := (aDPI <> 0); + end; + finally + FreeLibrary(TempHandle); + end; + except + on e : exception do + if CustomExceptionHandler('GetDPIForHandle', e) then raise; + end; +end; + +function RunningWindows10OrNewer : boolean; +var + TempMajorVer, TempMinorVer : DWORD; +begin + Result := GetWindowsMajorMinorVersion(TempMajorVer, TempMinorVer) and (TempMajorVer >= 10); +end; + +function GetDefaultCEFUserAgent : string; +var + TempOS, TempChromiumVersion : string; + TempMajorVer, TempMinorVer : DWORD; + Temp64bit : BOOL; +begin + if GetWindowsMajorMinorVersion(TempMajorVer, TempMinorVer) and + (TempMajorVer >= 4) then + TempOS := 'Windows NT' + else + TempOS := 'Windows'; + + TempOS := TempOS + ' ' + inttostr(TempMajorVer) + '.' + inttostr(TempMinorVer); + + if ProcessUnderWow64(GetCurrentProcess(), Temp64bit) and Temp64bit then + TempOS := TempOS + '; WOW64'; + + if (GlobalCEFApp <> nil) then + TempChromiumVersion := GlobalCEFApp.ChromeVersion + else + TempChromiumVersion := inttostr(CEF_CHROMEELF_VERSION_MAJOR) + '.' + + inttostr(CEF_CHROMEELF_VERSION_MINOR) + '.' + + inttostr(CEF_CHROMEELF_VERSION_RELEASE) + '.' + + inttostr(CEF_CHROMEELF_VERSION_BUILD); + + Result := 'Mozilla/5.0' + ' (' + TempOS + ') ' + + 'AppleWebKit/537.36 (KHTML, like Gecko) ' + + 'Chrome/' + TempChromiumVersion + ' Safari/537.36'; +end; + +{$IFDEF DELPHI14_UP} +function TouchPointToPoint(aHandle : HWND; const TouchPoint: TTouchInput): TPoint; +begin + Result := Point(TouchPoint.X div 100, TouchPoint.Y div 100); + PhysicalToLogicalPoint(aHandle, Result); +end; + +function GetDigitizerStatus(var aDigitizerStatus : TDigitizerStatus; aDPI : cardinal) : boolean; +var + TempStatus : integer; +begin + {$IFDEF DELPHI26_UP} + if (aDPI > 0) then + TempStatus := GetSystemMetricsForDpi(SM_DIGITIZER, aDPI) + else + {$ENDIF} + TempStatus := GetSystemMetrics(SM_DIGITIZER); + + aDigitizerStatus.IntegratedTouch := ((TempStatus and NID_INTEGRATED_TOUCH) <> 0); + aDigitizerStatus.ExternalTouch := ((TempStatus and NID_EXTERNAL_TOUCH) <> 0); + aDigitizerStatus.IntegratedPen := ((TempStatus and NID_INTEGRATED_PEN) <> 0); + aDigitizerStatus.ExternalPen := ((TempStatus and NID_EXTERNAL_PEN) <> 0); + aDigitizerStatus.MultiInput := ((TempStatus and NID_MULTI_INPUT) <> 0); + aDigitizerStatus.Ready := ((TempStatus and NID_READY) <> 0); + + Result := (TempStatus <> 0); +end; + +function HasTouchOrPen(aDPI : cardinal) : boolean; +var + TempStatus : TDigitizerStatus; +begin + Result := GetDigitizerStatus(TempStatus, aDPI); +end; +{$ENDIF} +{$ENDIF} + function DeviceToLogical(aValue : integer; const aDeviceScaleFactor : double) : integer; begin Result := floor(aValue / aDeviceScaleFactor); end; +function DeviceToLogical(aValue : single; const aDeviceScaleFactor : double) : single; +begin + Result := aValue / aDeviceScaleFactor; +end; + procedure DeviceToLogical(var aEvent : TCEFMouseEvent; const aDeviceScaleFactor : double); begin aEvent.x := DeviceToLogical(aEvent.x, aDeviceScaleFactor); aEvent.y := DeviceToLogical(aEvent.y, aDeviceScaleFactor); end; +procedure DeviceToLogical(var aEvent : TCefTouchEvent; const aDeviceScaleFactor : double); +begin + aEvent.x := DeviceToLogical(aEvent.x, aDeviceScaleFactor); + aEvent.y := DeviceToLogical(aEvent.y, aDeviceScaleFactor); +end; + procedure DeviceToLogical(var aPoint : TPoint; const aDeviceScaleFactor : double); begin aPoint.x := DeviceToLogical(aPoint.x, aDeviceScaleFactor); @@ -1670,17 +2173,201 @@ begin end; function GetScreenDPI : integer; +{$IFDEF MSWINDOWS} var TempDC : HDC; +{$ENDIF} begin + {$IFDEF MSWINDOWS} TempDC := GetDC(0); Result := GetDeviceCaps(TempDC, LOGPIXELSX); ReleaseDC(0, TempDC); + {$ENDIF} + + {$IFDEF LINUX} + {$IFDEF FPC} + if (Application <> nil) and + (Application.MainForm <> nil) and + (Application.MainForm.Monitor <> nil) then + Result := Application.MainForm.Monitor.PixelsPerInch + else + if (screen <> nil) then + begin + if (WidgetSet <> nil) and (screen.PrimaryMonitor <> nil) then + Result := screen.PrimaryMonitor.PixelsPerInch + else + Result := screen.PixelsPerInch; + end + else + Result := USER_DEFAULT_SCREEN_DPI; + {$ELSE} + // TODO: Find a way to get the screen scale in Delphi FMX for Linux + Result := USER_DEFAULT_SCREEN_DPI; + {$ENDIF} + {$ENDIF} + + {$IFDEF MACOSX} + {$IFDEF FPC} + // TODO: Find a way to get the screen scale in Lazarus/FPC for MacOS + Result := USER_DEFAULT_SCREEN_DPI; + {$ENDIF} + {$ENDIF} end; function GetDeviceScaleFactor : single; begin - Result := GetScreenDPI / 96; + {$IFDEF MACOS} + Result := MainScreen.backingScaleFactor; + {$ELSE} + Result := GetScreenDPI / USER_DEFAULT_SCREEN_DPI; + {$ENDIF} +end; + +function DeleteDirContents(const aDirectory : string; const aExcludeFiles : TStringList) : boolean; +var + TempRec : TSearchRec; + TempPath : string; + TempIdx : integer; +begin + Result := True; + + try + if (length(aDirectory) > 0) and + DirectoryExists(aDirectory) and + (FindFirst(aDirectory + '\*', faAnyFile, TempRec) = 0) then + try + repeat + TempPath := aDirectory + PathDelim + TempRec.Name; + + if ((TempRec.Attr and faDirectory) <> 0) then + begin + if (TempRec.Name <> '.') and (TempRec.Name <> '..') then + begin + if DeleteDirContents(TempPath, aExcludeFiles) then + Result := RemoveDir(TempPath) and Result + else + Result := False; + end; + end + else + if (aExcludeFiles <> nil) then + begin + TempIdx := aExcludeFiles.IndexOf(TempRec.Name); + Result := ((TempIdx >= 0) or + ((TempIdx < 0) and DeleteFile(TempPath))) and + Result; + end + else + Result := DeleteFile(TempPath) and Result; + + until (FindNext(TempRec) <> 0) or not(Result); + finally + FindClose(TempRec); + end; + except + on e : exception do + if CustomExceptionHandler('DeleteDirContents', e) then raise; + end; +end; + +function DeleteFileList(const aFileList : TStringList) : boolean; +var + i, TempCount : integer; +begin + Result := False; + + try + if (aFileList <> nil) then + begin + i := 0; + TempCount := 0; + + while (i < aFileList.Count) do + begin + if FileExists(aFileList[i]) and DeleteFile(aFileList[i]) then inc(TempCount); + inc(i); + end; + + Result := (aFileList.Count = TempCount); + end; + except + on e : exception do + if CustomExceptionHandler('DeleteFileList', e) then raise; + end; +end; + +function MoveFileList(const aFileList : TStringList; const aSrcDirectory, aDstDirectory : string) : boolean; +var + i, TempCount : integer; + TempSrcPath, TempDstPath : string; +begin + Result := False; + + try + if (aFileList <> nil) and + (length(aSrcDirectory) > 0) and + (length(aDstDirectory) > 0) and + DirectoryExists(aSrcDirectory) and + (DirectoryExists(aDstDirectory) or CreateDir(aDstDirectory)) then + begin + i := 0; + TempCount := 0; + + while (i < aFileList.Count) do + begin + TempSrcPath := IncludeTrailingPathDelimiter(aSrcDirectory) + aFileList[i]; + TempDstPath := IncludeTrailingPathDelimiter(aDstDirectory) + aFileList[i]; + + if FileExists(TempSrcPath) and RenameFile(TempSrcPath, TempDstPath) then inc(TempCount); + + inc(i); + end; + + Result := (aFileList.Count = TempCount); + end; + except + on e : exception do + if CustomExceptionHandler('MoveFileList', e) then raise; + end; +end; + +function CefGetDataURI(const aString, aMimeType : ustring) : ustring; +var + TempUTF : AnsiString; +begin + TempUTF := UTF8Encode(aString); + + if (length(TempUTF) > 0) then + Result := CefGetDataURI(@TempUTF[1], length(TempUTF), aMimeType, 'utf-8') + else + Result := ''; +end; + +function CefGetDataURI(aData : pointer; aSize : integer; const aMimeType, aCharset : ustring) : ustring; +begin + Result := 'data:' + aMimeType; + + if (length(aCharset) > 0) then Result := Result + ';charset=' + aCharset; + + Result := Result + ';base64,' + CefURIEncode(CefBase64Encode(aData, aSize), false); +end; + +function ValidCefWindowHandle(aHandle : TCefWindowHandle) : boolean; +begin + {$IFDEF MACOS} + Result := (aHandle <> nil); + {$ELSE} + Result := (aHandle <> 0); + {$ENDIF} +end; + +procedure InitializeWindowHandle(var aHandle : TCefWindowHandle); +begin + {$IFDEF MACOS} + aHandle := nil; + {$ELSE} + aHandle := 0; + {$ENDIF} end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFNavigationEntry.pas b/windows/src/ext/cef4delphi/source/uCEFNavigationEntry.pas index 1efe39acc5babb01b14b5cf0f2d5a5fa4515c964..940d8fc89084f2159fe372efc945dc6d963d2725 100644 --- a/windows/src/ext/cef4delphi/source/uCEFNavigationEntry.pas +++ b/windows/src/ext/cef4delphi/source/uCEFNavigationEntry.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFNavigationEntry; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -74,7 +72,7 @@ type implementation uses - uCEFMiscFunctions, uCefSSLStatus; + uCEFMiscFunctions, uCEFSSLStatus; function TCefNavigationEntryRef.IsValid: Boolean; begin diff --git a/windows/src/ext/cef4delphi/source/uCEFNavigationEntryVisitor.pas b/windows/src/ext/cef4delphi/source/uCEFNavigationEntryVisitor.pas index 9317b459a662686309d508928b8c84d8dcc5a9ad..f5a877bb397b3c4a57c710056511e471423b9314 100644 --- a/windows/src/ext/cef4delphi/source/uCEFNavigationEntryVisitor.pas +++ b/windows/src/ext/cef4delphi/source/uCEFNavigationEntryVisitor.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFNavigationEntryVisitor; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -72,9 +70,25 @@ type constructor Create(const proc: TCefNavigationEntryVisitorProc); reintroduce; end; + TCustomCefNavigationEntryVisitor = class(TCefNavigationEntryVisitorOwn) + protected + FEvents : Pointer; + + function Visit(const entry: ICefNavigationEntry; current: Boolean; index, total: Integer): Boolean; override; + + public + constructor Create(const aEvents : IChromiumEvents); reintroduce; + destructor Destroy; override; + end; + implementation uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} uCEFTypes, uCEFMiscFunctions, uCEFNavigationEntry; function cef_navigation_entry_visitor_visit(self : PCefNavigationEntryVisitor; @@ -129,4 +143,36 @@ begin Result := FVisitor(entry, current, index, total); end; +// TCustomCefNavigationEntryVisitor + +constructor TCustomCefNavigationEntryVisitor.Create(const aEvents : IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(aEvents); +end; + +destructor TCustomCefNavigationEntryVisitor.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + +function TCustomCefNavigationEntryVisitor.Visit(const entry : ICefNavigationEntry; + current : Boolean; + index : Integer; + total : Integer): Boolean; +begin + Result := False; + + try + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doNavigationVisitorResultAvailable(entry, current, index, total); + except + on e : exception do + if CustomExceptionHandler('TCustomCefNavigationEntryVisitor.Visit', e) then raise; + end; +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFOAuth2Helper.pas b/windows/src/ext/cef4delphi/source/uCEFOAuth2Helper.pas new file mode 100644 index 0000000000000000000000000000000000000000..fae2b4faa0a19e06bd4aad06e297207dcfce3082 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFOAuth2Helper.pas @@ -0,0 +1,515 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFOAuth2Helper; + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF}System.Classes, System.UITypes, System.SysUtils, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, {$IFDEF FPC}dynlibs,{$ENDIF}SysUtils, + {$ENDIF} + uCEFInterfaces, uCEFTypes; + +// REFERENCES : +// ============ +// https://tools.ietf.org/html/rfc6749 +// https://tools.ietf.org/html/rfc6750 +// https://tools.ietf.org/html/rfc8252 +// https://tools.ietf.org/html/rfc6819 +// https://tools.ietf.org/html/rfc7636 +// https://tools.ietf.org/html/draft-ietf-oauth-native-apps-12 +// https://tools.ietf.org/html/draft-ietf-oauth-security-topics-13 +// https://developers.google.com/identity/protocols/OAuth2 +// https://developers.google.com/identity/protocols/OAuth2InstalledApp +// https://developers.google.com/identity/protocols/googlescopes +// https://developers.google.com/identity/protocols/OpenIDConnect +// https://aaronparecki.com/oauth-2-simplified/ +// https://example-app.com/pkce + +const + DEFAULT_REDIRECT_IPV4_HOST = '127.0.0.1'; + DEFAULT_REDIRECT_IPV6_HOST = '[::1]'; + DEFAULT_REDIRECT_PORT = 50000; + + GOOGLE_DISCOVERY_DOCUMENT = 'https://accounts.google.com/.well-known/openid-configuration'; + +type + TOAuthChallengeMethod = (cmPlain, cmSHA256); + + TCEFOAuth2Helper = class + protected + FRedirectHost : ustring; + FRedirectPort : integer; + FAuthEndpoint : ustring; + FTokenEndpoint : ustring; + FClientID : ustring; + FClientSecret : ustring; + FAuthCode : ustring; + FError : ustring; + FErrorDescription : ustring; + FCodeVerifier : ustring; + FCodeChallenge : ustring; + FScope : ustring; + FAccessToken : ustring; + FIDToken : ustring; + FState : ustring; + FIncState : ustring; + FRefreshToken : ustring; + FTokenExpiry : integer; + FTokenType : ustring; + FLoginHint : ustring; + FChallengeMethod : TOAuthChallengeMethod; + + function GetRedirectURI : ustring; virtual; + function GetAuthCodeURI : ustring; virtual; + function GetRefreshParams : ustring; virtual; + function GetTokeExchangeParams : ustring; virtual; + function GetValidState : boolean; virtual; + + procedure GenerateRandomCodeChallenge; virtual; + procedure GenerateRandomState; virtual; + function GenerateRandomString(aLength : cardinal) : ustring; + procedure ParseQueryPair(const aPair : ustring); + function ReadJSONString(const aDictionary : ICefDictionaryValue; const aKey : ustring) : ustring; + function ReadJSONInteger(const aDictionary : ICefDictionaryValue; const aKey : ustring) : integer; + function CalculateSHA256Hash(const aString : ustring) : TCefCustomByteArray; + + public + constructor Create; + procedure Initialize; virtual; + function ParseTokenExchangeResponse(const aResponse : ustring) : boolean; virtual; + function ParseRefreshTokenResponse(const aResponse : ustring) : boolean; virtual; + function ParseCodeRequestResponse(const aURL : ustring) : boolean; virtual; + + property AuthEndpoint : ustring read FAuthEndpoint write FAuthEndpoint; + property TokenEndpoint : ustring read FTokenEndpoint write FTokenEndpoint; + + property ClientID : ustring read FClientID write FClientID; + property ClientSecret : ustring read FClientSecret write FClientSecret; + + property RedirectHost : ustring read FRedirectHost write FRedirectHost; + property RedirectPort : integer read FRedirectPort write FRedirectPort; + + property ChallengeMethod : TOAuthChallengeMethod read FChallengeMethod write FChallengeMethod; + property Scope : ustring read FScope write FScope; + + property Error : ustring read FError; + property ErrorDescription : ustring read FErrorDescription; + + property AccessToken : ustring read FAccessToken; + property IDToken : ustring read FIDToken; + property RefreshToken : ustring read FRefreshToken; + property TokenExpiry : integer read FTokenExpiry; + property TokenType : ustring read FTokenType; + + property CodeVerifier : ustring read FCodeVerifier; + property CodeChallenge : ustring read FCodeChallenge; + + property RedirectURI : ustring read GetRedirectURI; + property AuthCodeURI : ustring read GetAuthCodeURI; + property TokeExchangeParams : ustring read GetTokeExchangeParams; + property RefreshParams : ustring read GetRefreshParams; + property ValidState : boolean read GetValidState; + end; + +implementation + +uses + {$IFDEF DELPHI22_UP}System.Hash,{$ENDIF} + {$IFDEF FPC}DCPSha256,{$ENDIF} + uCEFMiscFunctions, uCEFJson; + +constructor TCEFOAuth2Helper.Create; +begin + inherited Create; + + Initialize; +end; + +procedure TCEFOAuth2Helper.Initialize; +begin + FRedirectHost := DEFAULT_REDIRECT_IPV4_HOST; + FRedirectPort := DEFAULT_REDIRECT_PORT; // This should be a random unused port + FAuthEndpoint := 'https://accounts.google.com/o/oauth2/v2/auth'; // obtained from GOOGLE_DISCOVERY_DOCUMENT + FTokenEndpoint := 'https://oauth2.googleapis.com/token'; // obtained from GOOGLE_DISCOVERY_DOCUMENT + FClientID := ''; + FClientSecret := ''; + FAuthCode := ''; + FError := ''; + FErrorDescription := ''; + FCodeVerifier := ''; + FCodeChallenge := ''; + FScope := 'openid'; + FAccessToken := ''; + FIDToken := ''; + FState := ''; + FIncState := ''; + FRefreshToken := ''; + FTokenExpiry := 0; + FTokenType := ''; + FLoginHint := ''; + FChallengeMethod := cmPlain; +end; + +function TCEFOAuth2Helper.GetRedirectURI : ustring; +begin + Result := 'http://' + FRedirectHost + ':' + inttostr(FRedirectPort); +end; + +function TCEFOAuth2Helper.GetAuthCodeURI : ustring; +begin + GenerateRandomCodeChallenge; + GenerateRandomState; + + Result := FAuthEndpoint + + '?response_type=code' + + '&client_id=' + CefUriEncode(FClientID, True) + + '&redirect_uri=' + CefUriEncode(RedirectURI, True) + + '&scope=' + CefUriEncode(FScope, True) + + '&state=' + FState + + '&code_challenge=' + CefUriEncode(FCodeChallenge, True); + + if (ChallengeMethod = cmPlain) then + Result := Result + '&code_challenge_method=plain' + else + Result := Result + '&code_challenge_method=S256'; + + if (length(FLoginHint) > 0) then + Result := Result + '&login_hint=' + CefUriEncode(FLoginHint, True); +end; + +function TCEFOAuth2Helper.GetTokeExchangeParams : ustring; +begin + Result := 'grant_type=authorization_code' + + '&code=' + FAuthCode + + '&client_id=' + CefUriEncode(FClientID, True) + + '&client_secret=' + CefUriEncode(FClientSecret, True) + + '&redirect_uri=' + CefUriEncode(RedirectURI, True) + + '&code_verifier=' + CefUriEncode(FCodeVerifier, True); +end; + +function TCEFOAuth2Helper.GetRefreshParams : ustring; +begin + Result := 'grant_type=refresh_token' + + '&client_id=' + CefUriEncode(FClientID, True) + + '&client_secret=' + CefUriEncode(FClientSecret, True) + + '&refresh_token=' + CefUriEncode(FRefreshToken, True); +end; + +function TCEFOAuth2Helper.GetValidState : boolean; +begin + Result := (CompareStr(FState, FIncState) = 0); +end; + +function TCEFOAuth2Helper.GenerateRandomString(aLength : cardinal) : ustring; +const + UnreservedCharValuesLen = 66; + UnreservedCharValues : array [0..pred(UnreservedCharValuesLen)] of + char = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '-', '.', '_', '~'); +var + i : cardinal; +begin + Result := ''; + i := 0; + + Randomize; + + while (i < aLength) do + begin + Result := Result + UnreservedCharValues[Random(UnreservedCharValuesLen)]; + inc(i); + end; +end; + +procedure TCEFOAuth2Helper.GenerateRandomCodeChallenge; +var + TempHash : TCefCustomByteArray; +begin + // The "code_verifier" can have a minimum length of 43 characters + // and a maximum length of 128 characters. + FCodeVerifier := GenerateRandomString(64); + + case ChallengeMethod of + cmPlain : FCodeChallenge := FCodeVerifier; + + cmSHA256 : + try + TempHash := CalculateSHA256Hash(FCodeVerifier); + + if (length(TempHash) > 0) then + begin + FCodeChallenge := CefBase64Encode(@TempHash[0], length(TempHash)); + + // Converts base64 to base64url. + FCodeChallenge := StringReplace(FCodeChallenge, '+', '-', [rfReplaceAll]); + FCodeChallenge := StringReplace(FCodeChallenge, '/', '_', [rfReplaceAll]); + + // Strips padding. + while (length(FCodeChallenge) > 0) and (FCodeChallenge[length(FCodeChallenge)] = '=') do + FCodeChallenge := copy(FCodeChallenge, 1, pred(length(FCodeChallenge))); + end + else + FCodeChallenge := ''; + finally + if (TempHash <> nil) then + begin + Finalize(TempHash); + TempHash := nil; + end; + end; + end; +end; + +{$IFDEF FPC} +function TCEFOAuth2Helper.CalculateSHA256Hash(const aString : ustring) : TCefCustomByteArray; +var + TempSHA256 : TDCP_sha256; + TempString : AnsiString; +begin + Result := nil; + try + TempSHA256 := TDCP_sha256.Create(nil); + TempSHA256.Burn; + TempSHA256.Init; + TempString := AnsiString(aString); + TempSHA256.Update(TempString[1], length(TempString)); + SetLength(Result, 32); + TempSHA256.Final(Result[0]); + finally + FreeAndNil(TempSHA256); + end; +end; +{$ELSE} +{$IFDEF DELPHI22_UP} +function TCEFOAuth2Helper.CalculateSHA256Hash(const aString : ustring) : TCefCustomByteArray; +var + TempBytes : TBytes; +begin + TempBytes := THashSHA2.GetHashBytes(FCodeVerifier); + SetLength(Result, length(TempBytes)); + Move(TempBytes[0], Result[0], length(TempBytes)); +end; +{$ELSE} +// TO-DO: Calculate SHA256 hash in older Delphi versions +function TCEFOAuth2Helper.CalculateSHA256Hash(const aString : ustring) : TCefCustomByteArray; +begin + Result := nil; +end; +{$ENDIF} +{$ENDIF} + +procedure TCEFOAuth2Helper.GenerateRandomState; +begin + // The "state" should be a string of 30 or so characters constructed + // using a high-quality random-number generator. + + Randomize; + + FState := IntToHex(Random(high(integer)), 8) + + IntToHex(Random(high(integer)), 8) + + IntToHex(Random(high(integer)), 8) + + IntToHex(Random(high(integer)), 8); +end; + +function TCEFOAuth2Helper.ReadJSONString(const aDictionary : ICefDictionaryValue; const aKey : ustring) : ustring; +var + TempValue : ICefValue; +begin + Result := ''; + + if (aDictionary <> nil) then + begin + TempValue := aDictionary.GetValue(aKey); + if (TempValue <> nil) and (TempValue.GetType = VTYPE_STRING) then Result := TempValue.GetString; + end; +end; + +function TCEFOAuth2Helper.ReadJSONInteger(const aDictionary : ICefDictionaryValue; const aKey : ustring) : integer; +var + TempValue : ICefValue; +begin + Result := 0; + + if (aDictionary <> nil) then + begin + TempValue := aDictionary.GetValue(aKey); + if (TempValue <> nil) and (TempValue.GetType = VTYPE_INT) then Result := TempValue.GetInt; + end; +end; + +function TCEFOAuth2Helper.ParseTokenExchangeResponse(const aResponse : ustring) : boolean; +var + TempRoot : ICefValue; + TempDictionary : ICefDictionaryValue; +begin + Result := False; + + try + if (length(aResponse) > 0) then + begin + TempRoot := TCEFJson.Parse(aResponse); + + if (TempRoot <> nil) and (TempRoot.GetType = VTYPE_DICTIONARY) then + begin + TempDictionary := TempRoot.GetDictionary; + FError := ReadJSONString(TempDictionary, 'error'); + + if (length(FError) > 0) then + FErrorDescription := ReadJSONString(TempDictionary, 'error_description') + else + begin + FAccessToken := ReadJSONString(TempDictionary, 'access_token'); + + if (length(FAccessToken) > 0) then + begin + FIDToken := ReadJSONString(TempDictionary, 'id_token'); + FScope := ReadJSONString(TempDictionary, 'scope'); + FTokenType := ReadJSONString(TempDictionary, 'token_type'); + FRefreshToken := ReadJSONString(TempDictionary, 'refresh_token'); + FTokenExpiry := ReadJSONInteger(TempDictionary, 'expires_in'); + Result := True; + end; + end; + end; + end; + except + on e : exception do + if CustomExceptionHandler('TCEFOAuth2Helper.ParseTokenExchangeResponse', e) then raise; + end; +end; + +function TCEFOAuth2Helper.ParseRefreshTokenResponse(const aResponse : ustring) : boolean; +var + TempRoot : ICefValue; + TempDictionary : ICefDictionaryValue; +begin + Result := False; + + try + if (length(aResponse) > 0) then + begin + TempRoot := TCEFJson.Parse(aResponse); + + if (TempRoot <> nil) and (TempRoot.GetType = VTYPE_DICTIONARY) then + begin + TempDictionary := TempRoot.GetDictionary; + FError := ReadJSONString(TempDictionary, 'error'); + + if (length(FError) > 0) then + FErrorDescription := ReadJSONString(TempDictionary, 'error_description') + else + begin + FAccessToken := ReadJSONString(TempDictionary, 'access_token'); + + if (length(FAccessToken) > 0) then + begin + FTokenType := ReadJSONString(TempDictionary, 'token_type'); + FTokenExpiry := ReadJSONInteger(TempDictionary, 'expires_in'); + Result := True; + end; + end; + end; + end; + except + on e : exception do + if CustomExceptionHandler('TCEFOAuth2Helper.ParseRefreshTokenResponse', e) then raise; + end; +end; + +procedure TCEFOAuth2Helper.ParseQueryPair(const aPair : ustring); +var + TempKey : ustring; + TempValue : ustring; + i : integer; +begin + i := pos('=', aPair); + + if (i > 0) then + begin + TempKey := copy(aPair, 1, pred(i)); + TempValue := copy(aPair, succ(i), length(aPair)); + + if (CompareStr(TempKey, 'code') = 0) then FAuthCode := TempValue + else if (CompareStr(TempKey, 'state') = 0) then FIncState := TempValue + else if (CompareStr(TempKey, 'error') = 0) then FError := TempValue + else if (CompareStr(TempKey, 'error_description') = 0) then FErrorDescription := TempValue; + end; +end; + +function TCEFOAuth2Helper.ParseCodeRequestResponse(const aURL : ustring) : boolean; +var + TempParts : TUrlParts; + TempQuery : ustring; + i : integer; +begin + Result := False; + + if (length(aURL) > 0) then + begin + CefParseUrl(aURL, TempParts); + + TempQuery := TempParts.query; + + if (length(TempQuery) > 0) then + begin + i := pos('&', TempQuery); + + while (i > 0) do + begin + ParseQueryPair(copy(TempQuery, 1, pred(i))); + TempQuery := copy(TempQuery, succ(i), length(TempQuery)); + i := pos('&', TempQuery); + end; + + ParseQueryPair(TempQuery); + + Result := ValidState and (length(FAuthCode) > 0); + end; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uOLEDragAndDrop.pas b/windows/src/ext/cef4delphi/source/uCEFOLEDragAndDrop.pas similarity index 76% rename from windows/src/ext/cef4delphi/source/uOLEDragAndDrop.pas rename to windows/src/ext/cef4delphi/source/uCEFOLEDragAndDrop.pas index 81e3a4d4e079d1bddf44a1ae14bc8a452cc9d6f9..6d0a0c5e8ac9bbfb6539dffe1d080bf7c1376922 100644 --- a/windows/src/ext/cef4delphi/source/uOLEDragAndDrop.pas +++ b/windows/src/ext/cef4delphi/source/uCEFOLEDragAndDrop.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -35,7 +35,7 @@ * *) -unit uOLEDragAndDrop; +unit uCEFOLEDragAndDrop; {$IFDEF FPC} {$MODE OBJFPC}{$H+} @@ -43,6 +43,11 @@ unit uOLEDragAndDrop; {$I cef.inc} +{$IFNDEF FPC}{$IFNDEF DELPHI12_UP} + // Workaround for "Internal error" in old Delphi versions caused by uint64 handling + {$R-} +{$ENDIF}{$ENDIF} + interface uses @@ -88,8 +93,13 @@ type destructor Destroy; override; // IEnumFormatEtc - function Next(Celt: LongInt; out Elt; pCeltFetched: pLongInt): HRESULT; stdcall; + {$IFNDEF FPC} + function Next(Celt: LongInt; out Rgelt; pCeltFetched: pLongInt): HRESULT; stdcall; function Skip(Celt: Longint): HRESULT; stdcall; + {$ELSE} + function Next(Celt: ULONG; out Rgelt: FormatEtc; pceltFetched: PULONG = nil): HRESULT; stdcall; + function Skip(Celt: ULONG): HRESULT; stdcall; + {$ENDIF} function Reset: HRESULT; stdcall; function Clone(out Enum: IEnumFormatEtc): HRESULT; stdcall; end; @@ -97,8 +107,13 @@ type TOLEDropSource = class(TInterfacedObject, IDropSource) public // IDropSource + {$IFNDEF FPC} function QueryContinueDrag(fEscapePressed: bool; grfKeyState: LongInt): HRESULT; stdcall; function GiveFeedback(dwEffect: LongInt): HRESULT; stdcall; + {$ELSE} + function QueryContinueDrag(fEscapePressed: BOOL; grfKeyState: DWORD): HRESULT; stdcall; + function GiveFeedback(dwEffect: DWORD): HRESULT; stdcall; + {$ENDIF} end; TOLEDataObject = class(TInterfacedObject, IDataObject) @@ -120,11 +135,19 @@ type function GetDataHere(const FormatEtc: TFormatEtc; out Medium: TStgMedium):HRESULT; stdcall; function QueryGetData(const FormatEtc: TFormatEtc): HRESULT; stdcall; function GetCanonicalFormatEtc(const FormatEtc: TFormatEtc; out FormatEtcout: TFormatEtc): HRESULT; stdcall; + {$IFNDEF FPC} function SetData(const FormatEtc: TFormatEtc; var Medium: TStgMedium; fRelease: Bool): HRESULT; stdcall; function EnumFormatEtc(dwDirection: LongInt; out aEnumFormatEtc: IEnumFormatEtc): HRESULT; stdcall; function dAdvise(const FormatEtc: TFormatEtc; advf: LongInt; const advsink: IAdviseSink; out dwConnection: LongInt): HRESULT; stdcall; function dUnadvise(dwConnection: LongInt): HRESULT; stdcall; + {$ELSE} + function SetData(const pformatetc: FORMATETC; {$IFDEF FPC_VER_320}var{$ELSE}const{$ENDIF} medium: STGMEDIUM; FRelease: BOOL): HRESULT; stdcall; + function EnumFormatEtc(dwDirection: DWORD; out aEnumFormatEtc: IENUMFORMATETC): HRESULT; stdcall; + function DAdvise(const formatetc: FORMATETC; advf: DWORD; const AdvSink: IAdviseSink; out dwConnection: DWORD): HRESULT; stdcall; + function DUnadvise(dwconnection: DWORD): HRESULT; stdcall; + {$ENDIF} function EnumdAdvise(out EnumAdvise: IEnumStatData): HRESULT; stdcall; + end; TOLEDropTarget = class(TInterfacedObject, IDropTarget) @@ -135,10 +158,17 @@ type constructor Create(const aManager : TOLEDragAndDropMgr); reintroduce; // IDropTarget + {$IFNDEF FPC} function DragEnter(const DataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HRESULT; stdcall; function DragOver(grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HRESULT; stdcall; - function DragLeave: HRESULT; stdcall; function Drop(const dataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HRESULT; stdcall; + {$ELSE} + function DragEnter(const dataObj: IDataObject; grfKeyState: DWORD; pt: TPoint; var dwEffect: DWORD): HRESULT; stdcall; + function DragOver(grfKeyState: DWORD; pt: TPoint; var dwEffect: DWORD): HRESULT; stdcall; + function Drop(const dataObj: IDataObject; grfKeyState: DWORD; pt: TPoint; var dwEffect: DWORD): HRESULT; stdcall; + {$ENDIF} + function DragLeave: HRESULT; stdcall; + end; implementation @@ -168,7 +198,11 @@ begin aMedium.hGlobal := TempHandle; aMedium.tymed := TYMED_HGLOBAL; + {$IFNDEF FPC} aMedium.unkForRelease := nil; + {$ELSE} + aMedium.PUnkForRelease := nil; + {$ENDIF} GlobalUnlock(TempHandle); @@ -207,6 +241,10 @@ begin end; function TOLEDragAndDropMgr.GetStorageForFileDescriptor(var aMedium : TStgMedium; const aFileName : string) : boolean; +{$IFDEF FPC} +const + FD_LINKUI = $8000; +{$ENDIF} var TempHandle : HGLOBAL; TempDescriptor : TFileGroupDescriptor; @@ -243,7 +281,11 @@ begin aMedium.tymed := TYMED_HGLOBAL; aMedium.hGlobal := TempHandle; + {$IFNDEF FPC} aMedium.unkForRelease := nil; + {$ELSE} + aMedium.PUnkForRelease := nil; + {$ENDIF} GlobalUnlock(TempHandle); @@ -330,6 +372,8 @@ begin end; procedure TOLEEnumFormatEtc.CopyFormatEtc(var aDstFormatEtc : TFormatEtc; const aSrcFormatEtc : TFormatEtc); +var + Size: Integer; begin aDstFormatEtc.cfFormat := aSrcFormatEtc.cfFormat; aDstFormatEtc.dwAspect := aSrcFormatEtc.dwAspect; @@ -340,27 +384,28 @@ begin aDstFormatEtc.ptd := nil else begin - aDstFormatEtc.ptd := CoTaskMemAlloc(SizeOf(TDVTargetDevice)); - - aDstFormatEtc.ptd.tdSize := aSrcFormatEtc.ptd.tdSize; - aDstFormatEtc.ptd.tdDriverNameOffset := aSrcFormatEtc.ptd.tdDriverNameOffset; - aDstFormatEtc.ptd.tdDeviceNameOffset := aSrcFormatEtc.ptd.tdDeviceNameOffset; - aDstFormatEtc.ptd.tdPortNameOffset := aSrcFormatEtc.ptd.tdPortNameOffset; - aDstFormatEtc.ptd.tdExtDevmodeOffset := aSrcFormatEtc.ptd.tdExtDevmodeOffset; - aDstFormatEtc.ptd.tdData := aSrcFormatEtc.ptd.tdData; + Size := Max(aSrcFormatEtc.ptd^.tdSize, SizeOf(DVTARGETDEVICE)); + aDstFormatEtc.ptd := CoTaskMemAlloc(Size); + Move(aSrcFormatEtc.ptd^, aDstFormatEtc.ptd^, Size); end; end; -function TOLEEnumFormatEtc.Next(Celt: LongInt; out Elt; pCeltFetched: pLongInt): HRESULT; +function TOLEEnumFormatEtc.Next +{$IFNDEF FPC} + (Celt: LongInt; out Rgelt; pCeltFetched: pLongInt): HRESULT; stdcall; +{$ELSE} + (Celt: ULONG; out Rgelt: FormatEtc; pceltFetched: PULONG): HRESULT; stdcall; +{$ENDIF} var i : integer; - TempArray : TOLEFormatArray absolute Elt; + TempArray : ^TOLEFormatArray; begin i := 0; + TempArray := @Rgelt; while (i < Celt) and (FIndex < FNumFormats) do begin - CopyFormatEtc(TempArray[i], FFormatArray[FIndex]); + CopyFormatEtc(TempArray^[i], FFormatArray[FIndex]); inc(i); inc(FIndex); end; @@ -373,7 +418,12 @@ begin Result := S_FALSE; end; -function TOLEEnumFormatEtc.Skip(Celt: Longint): HRESULT; +function TOLEEnumFormatEtc.Skip +{$IFNDEF FPC} + (Celt: Longint): HRESULT; stdcall; +{$ELSE} + (Celt: ULONG): HRESULT; stdcall; +{$ENDIF} begin FIndex := FIndex + Celt; @@ -383,13 +433,13 @@ begin Result := S_FALSE; end; -function TOLEEnumFormatEtc.Reset: HRESULT; +function TOLEEnumFormatEtc.Reset: HRESULT; stdcall; begin FIndex := 0; Result := S_OK; end; -function TOLEEnumFormatEtc.Clone(out Enum: IEnumFormatEtc): HRESULT; +function TOLEEnumFormatEtc.Clone(out Enum: IEnumFormatEtc): HRESULT; stdcall; begin Enum := TOLEEnumFormatEtc.Create(FFormatArray, FNumFormats, FIndex); Result := S_OK; @@ -407,14 +457,24 @@ begin FManager := aManager; end; -function TOLEDropTarget.DragEnter(const DataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HRESULT; stdcall; +function TOLEDropTarget.DragEnter +{$IFNDEF FPC} + (const DataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HRESULT; stdcall; +{$ELSE} + (const dataObj: IDataObject; grfKeyState: DWORD; pt: TPoint; var dwEffect: DWORD): HRESULT; stdcall; +{$ENDIF} begin - Result := FManager.DragEnter(DataObj, grfKeyState, pt, dwEffect); + Result := FManager.DragEnter(DataObj, grfKeyState, pt, Longint(dwEffect)); end; -function TOLEDropTarget.DragOver(grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HRESULT; stdcall; +function TOLEDropTarget.DragOver +{$IFNDEF FPC} + (grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HRESULT; stdcall; +{$ELSE} + (grfKeyState: DWORD; pt: TPoint; var dwEffect: DWORD): HRESULT; stdcall; +{$ENDIF} begin - Result := FManager.DragOver(grfKeyState, pt, dwEffect); + Result := FManager.DragOver(grfKeyState, pt, Longint(dwEffect)); end; function TOLEDropTarget.DragLeave: HRESULT; stdcall; @@ -422,9 +482,14 @@ begin Result := FManager.DragLeave; end; -function TOLEDropTarget.Drop(const dataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HRESULT; stdcall; +function TOLEDropTarget.Drop +{$IFNDEF FPC} + (const dataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HRESULT; stdcall; +{$ELSE} + (const dataObj: IDataObject; grfKeyState: DWORD; pt: TPoint; var dwEffect: DWORD): HRESULT; stdcall; +{$ENDIF} begin - Result := FManager.Drop(dataObj, grfKeyState, pt, dwEffect); + Result := FManager.Drop(dataObj, grfKeyState, pt, Longint(dwEffect)); end; @@ -432,7 +497,12 @@ end; // ****************** TOLEDropSource ******************* // ***************************************************** -function TOLEDropSource.QueryContinueDrag(fEscapePressed: bool; grfKeyState: LongInt): HRESULT; stdcall; +function TOLEDropSource.QueryContinueDrag +{$IFNDEF FPC} + (fEscapePressed: bool; grfKeyState: LongInt): HRESULT; stdcall; +{$ELSE} + (fEscapePressed: BOOL; grfKeyState: DWORD): HRESULT; stdcall; +{$ENDIF} begin if fEscapePressed then Result := DRAGDROP_S_CANCEL @@ -443,7 +513,12 @@ begin Result := S_OK; end; -function TOLEDropSource.GiveFeedback(dwEffect: LongInt): HRESULT; stdcall; +function TOLEDropSource.GiveFeedback +{$IFNDEF FPC} + (dwEffect: LongInt): HRESULT; stdcall; +{$ELSE} + (dwEffect: DWORD): HRESULT; stdcall; +{$ENDIF} begin Result := DRAGDROP_S_USEDEFAULTCURSORS; end; @@ -542,14 +617,22 @@ begin if (i < 0) or ((FFormatArray[i].tymed and TYMED_HGLOBAL) = 0) then begin Medium.tymed := TYMED_NULL; + {$IFNDEF FPC} Medium.unkForRelease := nil; + {$ELSE} + Medium.PUnkForRelease := nil; + {$ENDIF} Medium.hGlobal := 0; Result := DV_E_FORMATETC; end else begin Medium.tymed := FFormatArray[i].tymed; + {$IFNDEF FPC} Medium.unkForRelease := nil; + {$ELSE} + Medium.PUnkForRelease := nil; + {$ENDIF} Medium.hGlobal := DupGlobalMem(FMediumArray[i].hGlobal); Result := S_OK; end; @@ -579,12 +662,22 @@ begin Result := E_NOTIMPL; end; -function TOLEDataObject.SetData(const FormatEtc: TFormatEtc; var Medium: TStgMedium; fRelease: Bool): HRESULT; stdcall; +function TOLEDataObject.SetData +{$IFNDEF FPC} + (const FormatEtc: TFormatEtc; var Medium: TStgMedium; fRelease: Bool): HRESULT; stdcall; +{$ELSE} + (const pformatetc: FORMATETC; {$IFDEF FPC_VER_320}var{$ELSE}const{$ENDIF} medium: STGMEDIUM; FRelease: BOOL): HRESULT; stdcall; +{$ENDIF} begin Result := E_NOTIMPL; end; -function TOLEDataObject.EnumFormatEtc(dwDirection: LongInt; out aEnumFormatEtc: IEnumFormatEtc): HRESULT; stdcall; +function TOLEDataObject.EnumFormatEtc +{$IFNDEF FPC} + (dwDirection: LongInt; out aEnumFormatEtc: IEnumFormatEtc): HRESULT; stdcall; +{$ELSE} + (dwDirection: DWORD; out aEnumFormatEtc: IENUMFORMATETC): HRESULT; stdcall; +{$ENDIF} begin if (dwDirection = DATADIR_GET) then begin @@ -602,15 +695,22 @@ begin end; end; -function TOLEDataObject.dAdvise(const FormatEtc: TFormatEtc; - advf: LongInt; - const advsink: IAdviseSink; - out dwConnection: LongInt): HRESULT; stdcall; +function TOLEDataObject.dAdvise +{$IFNDEF FPC} + (const FormatEtc: TFormatEtc; advf: LongInt; const advsink: IAdviseSink; out dwConnection: LongInt): HRESULT; stdcall; +{$ELSE} + (const formatetc: FORMATETC; advf: DWORD; const AdvSink: IAdviseSink; out dwConnection: DWORD): HRESULT; stdcall; +{$ENDIF} begin Result := OLE_E_ADVISENOTSUPPORTED; end; -function TOLEDataObject.dUnadvise(dwConnection: LongInt): HRESULT; stdcall; +function TOLEDataObject.dUnadvise +{$IFNDEF FPC} + (dwConnection: LongInt): HRESULT; stdcall; +{$ELSE} + (dwconnection: DWORD): HRESULT; stdcall; +{$ENDIF} begin Result := OLE_E_ADVISENOTSUPPORTED; end; diff --git a/windows/src/ext/cef4delphi/source/uCEFOSRIMEHandler.pas b/windows/src/ext/cef4delphi/source/uCEFOSRIMEHandler.pas new file mode 100644 index 0000000000000000000000000000000000000000..5c6232562edfbf5fac2b5b78a32082aad5f86b00 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFOSRIMEHandler.pas @@ -0,0 +1,759 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFOSRIMEHandler; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, System.Math, WinApi.imm, + {$ELSE} + {$IFDEF MSWINDOWS}Windows, imm, {$IFDEF FPC}imm_dyn,{$ENDIF}{$ENDIF} Classes, Math, + {$ENDIF} + uCEFTypes; + +const + DEFAULT_BLINK_UNDERLINE_COLOR = $FF000000; // Black SkColor + DEFAULT_BLINK_BACKGROUND_COLOR = $00000000; // White SkColor + DEFAULT_BLINK_UNDERLINE_STYLE = CEF_CUS_SOLID; + + KEYBOARD_LAYOUT_EN_US = $0409; + +type + {$IFNDEF MSWINDOWS} + {$IFDEF FPC} + // Define some types to compile in Linux with Lazarus + HWND = NativeUInt; + LANGID = Word; + HIMC = Integer; + LPARAM = NativeInt; + WParam = NativeUInt; + PWChar = ^WideChar; + {$ENDIF} + {$ENDIF} + + TCEFOSRIMEHandler = class + protected + FHWND : HWND; + FCompositionRange : TCefRange; + FCursorIndex : integer; + FIMERect : TCefRect; + FSystemCaret : boolean; + FInputLanguageID : LANGID; + FCompositionBounds : TCefRectDynArray; + FIsComposing : boolean; + FIMM32DLL : THandle; + + function GetPrimaryLangID : word; + function GetSubLangID : word; + function GetInitialized : boolean; + + procedure GetCompositionInfo(imc : HIMC; aParam : LPARAM; var composition_text : ustring; var underlines : TCefCompositionUnderlineDynArray; var composition_start : integer); + function GetString(imc : HIMC; aParam : WParam; aType : integer; var aResult : ustring) : boolean; + {$IFDEF MSWINDOWS} + function IsSelectionAttribute(aAttribute : byte) : boolean; + {$ENDIF} + procedure GetCompositionSelectionRange(imc : HIMC; var target_start, target_end : integer); + procedure GetCompositionUnderlines(imc : HIMC; target_start, target_end : integer; var underlines : TCefCompositionUnderlineDynArray); + + public + constructor Create(aHWND : HWND); + destructor Destroy; override; + + {$IFDEF MSWINDOWS} + procedure SetInputLanguage; + {$ENDIF} + procedure CreateImeWindow; + procedure DestroyImeWindow; + procedure CleanupComposition; + procedure ResetComposition; + function GetResult(aParam : LPARAM; var aResult : ustring) : boolean; + function GetComposition(aParam : LPARAM; var composition_text : ustring; var underlines : TCefCompositionUnderlineDynArray; var composition_start : integer) : boolean; + procedure EnableIME; + procedure DisableIME; + procedure CancelIME; + procedure UpdateCaretPosition(index : integer); + procedure ChangeCompositionRange(const selection_range : TCefRange; const character_bounds : TCefRectDynArray); + procedure MoveImeWindow; + + property IsComposing : boolean read FIsComposing; + property InputLanguageID : LANGID read FInputLanguageID; + property PrimaryLangID : word read GetPrimaryLangID; + property SubLangID : word read GetSubLangID; + property Initialized : boolean read GetInitialized; + + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions; + +constructor TCEFOSRIMEHandler.Create(aHWND : HWND); +begin + inherited Create; + + FHWND := aHWND; + FCompositionRange.from := 0; + FCompositionRange.to_ := 0; + FCursorIndex := -1; + FIMERect.x := -1; + FIMERect.y := -1; + FIMERect.width := 0; + FIMERect.height := 0; + FSystemCaret := False; + FCompositionBounds := nil; + FIsComposing := False; + FIMM32DLL := 0; + {$IFDEF MSWINDOWS} + FInputLanguageID := LANG_USER_DEFAULT; + {$IFNDEF FPC} + FIMM32DLL := SafeLoadLibrary('imm32.dll'); + {$ENDIF} + {$ENDIF} +end; + +destructor TCEFOSRIMEHandler.Destroy; +begin + DestroyImeWindow; + + {$IFDEF MSWINDOWS} + if (FIMM32DLL <> 0) then + begin + FreeLibrary(FIMM32DLL); + FIMM32DLL := 0; + end; + {$ENDIF} + + if (FCompositionBounds <> nil) then + begin + Finalize(FCompositionBounds); + FCompositionBounds := nil; + end; + + inherited Destroy; +end; + +function TCEFOSRIMEHandler.GetPrimaryLangID : word; +begin + Result := FInputLanguageID and $03FF; +end; + +function TCEFOSRIMEHandler.GetSubLangID : word; +begin + Result := (FInputLanguageID and $FC00) shr 10; +end; + +function TCEFOSRIMEHandler.GetInitialized : boolean; +begin + {$IFDEF MSWINDOWS} + {$IFNDEF FPC} + Result := (FIMM32DLL <> 0); + {$ELSE} + Result := True; + {$ENDIF} + {$ELSE} + Result := False; + {$ENDIF} +end; + +procedure TCEFOSRIMEHandler.GetCompositionInfo( imc : HIMC; + aParam : LPARAM; + var composition_text : ustring; + var underlines : TCefCompositionUnderlineDynArray; + var composition_start : integer); +var + TempStart : integer; + TempEnd : integer; + TempLen : integer; + i : integer; +begin + if (underlines <> nil) then + begin + Finalize(underlines, 0); + underlines := nil; + end; + + TempLen := length(composition_text); + TempStart := TempLen; + TempEnd := TempLen; + + {$IFDEF MSWINDOWS} + if ((aParam and GCS_COMPATTR) <> 0) then + GetCompositionSelectionRange(imc, TempStart, TempEnd); + + if ((aParam and CS_NOMOVECARET) = 0) and ((aParam and GCS_CURSORPOS) <> 0) then + composition_start := ImmGetCompositionString(imc, GCS_CURSORPOS, nil, 0) + else + composition_start := 0; + + if ((aParam and GCS_COMPCLAUSE) <> 0) then + GetCompositionUnderlines(imc, TempStart, TempEnd, underlines); + {$ENDIF} + + if (underlines = nil) or (length(underlines) = 0) then + begin + i := 0; + + if (TempStart > 0) then inc(i); + if (TempEnd > TempStart) then inc(i); + if (TempEnd < TempLen) then inc(i); + + if (i > 0) then + begin + SetLength(underlines, i); + i := 0; + + if (TempStart > 0) then + begin + underlines[i].color := DEFAULT_BLINK_UNDERLINE_COLOR; + underlines[i].background_color := DEFAULT_BLINK_BACKGROUND_COLOR; + underlines[i].range.from := 0; + underlines[i].range.to_ := TempStart; + underlines[i].thick := 0; + underlines[i].style := DEFAULT_BLINK_UNDERLINE_STYLE; + + inc(i); + end; + + if (TempEnd > TempStart) then + begin + underlines[i].color := DEFAULT_BLINK_UNDERLINE_COLOR; + underlines[i].background_color := DEFAULT_BLINK_BACKGROUND_COLOR; + underlines[i].range.from := TempStart; + underlines[i].range.to_ := TempEnd; + underlines[i].thick := 1; + underlines[i].style := DEFAULT_BLINK_UNDERLINE_STYLE; + + inc(i); + end; + + if (TempEnd < TempLen) then + begin + underlines[i].color := DEFAULT_BLINK_UNDERLINE_COLOR; + underlines[i].background_color := DEFAULT_BLINK_BACKGROUND_COLOR; + underlines[i].range.from := TempEnd; + underlines[i].range.to_ := TempLen; + underlines[i].thick := 0; + underlines[i].style := DEFAULT_BLINK_UNDERLINE_STYLE; + end; + end; + end; +end; + +function TCEFOSRIMEHandler.GetString(imc : HIMC; aParam : WParam; aType : integer; var aResult : ustring) : boolean; +var + TempBufferLen : integer; + TempBuffer : PWChar; +begin + Result := False; + + if ((aParam and aType) = 0) then exit; + + {$IFDEF MSWINDOWS} + {$IFDEF FPC} + TempBufferLen := ImmGetCompositionStringW(imc, aType, nil, 0); + {$ELSE} + TempBufferLen := ImmGetCompositionString(imc, aType, nil, 0); + {$ENDIF} + + if (GetLastError <> 0) or (TempBufferLen <= 0) then exit; + {$ENDIF} + + TempBuffer := nil; + TempBufferLen := TempBufferLen + SizeOf(wchar); + + try + try + GetMem(TempBuffer, TempBufferLen); + FillChar(TempBuffer^, TempBufferLen, 0); + + {$IFDEF MSWINDOWS} + {$IFDEF FPC} + TempBufferLen := ImmGetCompositionStringW(imc, aType, TempBuffer, TempBufferLen); + {$ELSE} + TempBufferLen := ImmGetCompositionString(imc, aType, TempBuffer, TempBufferLen); + {$ENDIF} + {$ENDIF} + + if (TempBufferLen > 0) then + begin + aResult := TempBuffer; + Result := True; + end; + except + on e : exception do + if CustomExceptionHandler('TCEFOSRIMEHandler.GetString', e) then raise; + end; + finally + if (TempBuffer <> nil) then FreeMem(TempBuffer); + end; +end; + +{$IFDEF MSWINDOWS} +function TCEFOSRIMEHandler.IsSelectionAttribute(aAttribute : byte) : boolean; +begin + Result := (aAttribute = ATTR_TARGET_CONVERTED) or + (aAttribute = ATTR_TARGET_NOTCONVERTED); +end; +{$ENDIF} + +procedure TCEFOSRIMEHandler.GetCompositionSelectionRange(imc : HIMC; var target_start, target_end : integer); +var + i : integer; + TempBufferLen : integer; + TempBuffer : array of byte; +begin + TempBuffer := nil; + {$IFDEF MSWINDOWS} + try + try + TempBufferLen := ImmGetCompositionString(imc, GCS_COMPATTR, nil, 0); + + if (GetLastError = 0) and (TempBufferLen > 0) then + begin + SetLength(TempBuffer, TempBufferLen); + for i := 0 to pred(TempBufferLen) do TempBuffer[i] := 0; + + TempBufferLen := ImmGetCompositionString(imc, GCS_COMPATTR, @TempBuffer[0], TempBufferLen); + + if (TempBufferLen > 0) then + begin + i := 0; + while (i < TempBufferLen) do + if IsSelectionAttribute(TempBuffer[i]) then + begin + target_start := i; + break; + end + else + inc(i); + + while (i < TempBufferLen) do + if not(IsSelectionAttribute(TempBuffer[i])) then + begin + target_end := i; + break; + end + else + inc(i); + end; + end; + except + on e : exception do + if CustomExceptionHandler('TCEFOSRIMEHandler.GetCompositionSelectionRange', e) then raise; + end; + finally + if (TempBuffer <> nil) then + begin + Finalize(TempBuffer); + TempBuffer := nil; + end; + end; + {$ENDIF} +end; + +procedure TCEFOSRIMEHandler.GetCompositionUnderlines( imc : HIMC; + target_start : integer; + target_end : integer; + var underlines : TCefCompositionUnderlineDynArray); +var + i, j, TempSize : integer; + TempUndLen : integer; + TempBufferLen : integer; + TempBuffer : array of cardinal; +begin + TempBuffer := nil; + + {$IFDEF MSWINDOWS} + try + try + TempBufferLen := ImmGetCompositionString(imc, GCS_COMPCLAUSE, nil, 0); + + if (GetLastError = 0) and (TempBufferLen > 0) then + begin + TempSize := TempBufferLen div SizeOf(cardinal); + SetLength(TempBuffer, TempSize); + for i := 0 to pred(TempSize) do TempBuffer[i] := 0; + + TempBufferLen := ImmGetCompositionString(imc, GCS_COMPCLAUSE, @TempBuffer[0], TempBufferLen); + + if (TempBufferLen > 0) then + begin + TempSize := TempBufferLen div SizeOf(cardinal); + + if (underlines <> nil) then + TempUndLen := length(underlines) + else + TempUndLen := 0; + + SetLength(underlines, TempUndLen + pred(TempSize)); + i := 0; + + while (i < pred(TempSize)) do + begin + j := i + TempUndLen; + + underlines[j].range.from := TempBuffer[i]; + underlines[j].range.to_ := TempBuffer[succ(i)]; + underlines[j].color := DEFAULT_BLINK_UNDERLINE_COLOR; + underlines[j].background_color := DEFAULT_BLINK_BACKGROUND_COLOR; + underlines[j].style := DEFAULT_BLINK_UNDERLINE_STYLE; + + if (underlines[j].range.from >= target_start) and + (underlines[j].range.to_ <= target_end) then + underlines[j].thick := 1 + else + underlines[j].thick := 0; + + inc(i); + end; + end; + end; + except + on e : exception do + if CustomExceptionHandler('TCEFOSRIMEHandler.GetCompositionUnderlines', e) then raise; + end; + finally + if (TempBuffer <> nil) then + begin + Finalize(TempBuffer); + TempBuffer := nil; + end; + end; + {$ENDIF} +end; + +{$IFDEF MSWINDOWS} +procedure TCEFOSRIMEHandler.SetInputLanguage; +var + TempName : array[0..KL_NAMELENGTH] of char; + TempLayout : string; + i : integer; + TempID : LANGID; +begin + TempID := KEYBOARD_LAYOUT_EN_US; + + try + try + for i := 0 to KL_NAMELENGTH do TempName[i] := #0; + + if GetKeyboardLayoutName(TempName) then + begin + TempLayout := trim(copy(TempName, KL_NAMELENGTH div 2, KL_NAMELENGTH)); + if (length(TempLayout) > 0) then TempID := StrToInt('$' + TempLayout); + end; + except + on e : exception do + if CustomExceptionHandler('TCEFOSRIMEHandler.SetInputLanguage', e) then raise; + end; + finally + FInputLanguageID := TempID; + end; +end; +{$ENDIF} + +procedure TCEFOSRIMEHandler.CreateImeWindow; +begin + {$IFDEF MSWINDOWS} + if ((PrimaryLangID = LANG_CHINESE) or (PrimaryLangID = LANG_JAPANESE)) and + not(FSystemCaret) and + CreateCaret(FHWND, 0, 1, 1) then + FSystemCaret := True; + {$ENDIF} +end; + +procedure TCEFOSRIMEHandler.DestroyImeWindow; +begin + if FSystemCaret then + begin + {$IFDEF MSWINDOWS} + DestroyCaret(); + {$ENDIF} + FSystemCaret := False; + end; +end; + +procedure TCEFOSRIMEHandler.CleanupComposition; +var + TempIMC : HIMC; +begin + if Initialized and FIsComposing then + begin + {$IFDEF MSWINDOWS} + TempIMC := ImmGetContext(FHWND); + + if (TempIMC <> 0) then + try + ImmNotifyIME(TempIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); + finally + ImmReleaseContext(FHWND, TempIMC); + end; + + ResetComposition; + {$ENDIF} + end; +end; + +procedure TCEFOSRIMEHandler.ResetComposition; +begin + FIsComposing := False; + FCursorIndex := -1; +end; + +function TCEFOSRIMEHandler.GetResult(aParam : LPARAM; var aResult : ustring) : boolean; +var + TempIMC : HIMC; +begin + Result := False; + if not(Initialized) then exit; + + {$IFDEF MSWINDOWS} + TempIMC := ImmGetContext(FHWND); + + if (TempIMC <> 0) then + try + Result := GetString(TempIMC, aParam, GCS_RESULTSTR, aResult); + finally + ImmReleaseContext(FHWND, TempIMC); + end; + {$ENDIF} +end; + +function TCEFOSRIMEHandler.GetComposition( aParam : LPARAM; + var composition_text : ustring; + var underlines : TCefCompositionUnderlineDynArray; + var composition_start : integer) : boolean; +var + TempIMC : HIMC; +begin + Result := False; + if not(Initialized) then exit; + + {$IFDEF MSWINDOWS} + TempIMC := ImmGetContext(FHWND); + + if (TempIMC <> 0) then + try + if GetString(TempIMC, aParam, GCS_COMPSTR, composition_text) then + begin + GetCompositionInfo(TempIMC, aParam, composition_text, underlines, composition_start); + FIsComposing := True; + Result := True; + end; + finally + ImmReleaseContext(FHWND, TempIMC); + end; + {$ENDIF} +end; + +procedure TCEFOSRIMEHandler.EnableIME; +begin + {$IFDEF MSWINDOWS} + if Initialized then + begin + {$IFDEF DELPHI22_UP} + ImmAssociateContextEx(FHWND, 0, IACE_DEFAULT); + {$ELSE} + ImmAssociateContext(FHWND, 0); + {$ENDIF} + end; + {$ENDIF} +end; + +procedure TCEFOSRIMEHandler.DisableIME; +begin + {$IFDEF MSWINDOWS} + if Initialized then + begin + CleanupComposition(); + {$IFDEF DELPHI22_UP} + ImmAssociateContextEx(FHWND, 0, 0); + {$ELSE} + ImmAssociateContext(FHWND, 0); + {$ENDIF} + end; + {$ENDIF} +end; + +procedure TCEFOSRIMEHandler.CancelIME; +var + TempIMC : HIMC; +begin + if Initialized and FIsComposing then + begin + {$IFDEF MSWINDOWS} + TempIMC := ImmGetContext(FHWND); + + if (TempIMC <> 0) then + try + ImmNotifyIME(TempIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0); + finally + ImmReleaseContext(FHWND, TempIMC); + end; + + ResetComposition; + {$ENDIF} + end; +end; + +procedure TCEFOSRIMEHandler.UpdateCaretPosition(index : integer); +begin + FCursorIndex := index; + MoveImeWindow(); +end; + +procedure TCEFOSRIMEHandler.ChangeCompositionRange(const selection_range : TCefRange; + const character_bounds : TCefRectDynArray); +var + i : integer; +begin + FCompositionRange := selection_range; + + if (character_bounds <> nil) then + begin + SetLength(FCompositionBounds, length(character_bounds)); + i := pred(length(character_bounds)); + + while (i >= 0) do + begin + FCompositionBounds[i] := character_bounds[i]; + dec(i); + end; + end + else + begin + Finalize(FCompositionBounds); + FCompositionBounds := nil; + end; + + MoveImeWindow(); +end; + +procedure TCEFOSRIMEHandler.MoveImeWindow; +{$IFDEF MSWINDOWS} +var + TempRect : TCefRect; + TempLocation : integer; + TempIMC : HIMC; + TempCandidate : TCandidateForm; +const + CARET_MARGIN = 1; +{$ENDIF} +begin + {$IFDEF MSWINDOWS} + if not(Initialized) and (GetFocus <> FHWND) then exit; + + TempRect := FIMERect; + TempLocation := FCursorIndex; + + if (TempLocation = -1) then + TempLocation := FCompositionRange.from; + + if (TempLocation >= FCompositionRange.from) then + TempLocation := TempLocation - FCompositionRange.from; + + if (FCompositionBounds = nil) then + exit + else + if (TempLocation >= 0) and + (TempLocation < length(FCompositionBounds)) then + TempRect := FCompositionBounds[TempLocation] + else + if (length(FCompositionBounds) > 0) then + TempRect := FCompositionBounds[pred(length(FCompositionBounds))] + else + exit; + + TempIMC := ImmGetContext(FHWND); + + if (TempIMC <> 0) then + try + if (PrimaryLangID = LANG_CHINESE) then + begin + TempCandidate.dwIndex := 0; + TempCandidate.dwStyle := CFS_CANDIDATEPOS; + TempCandidate.ptCurrentPos.X := TempRect.x; + TempCandidate.ptCurrentPos.Y := TempRect.y; + TempCandidate.rcArea.Left := 0; + TempCandidate.rcArea.Top := 0; + TempCandidate.rcArea.Right := 0; + TempCandidate.rcArea.Bottom := 0; + + ImmSetCandidateWindow(TempIMC, @TempCandidate); + end; + + if FSystemCaret then + case PrimaryLangID of + LANG_JAPANESE : SetCaretPos(TempRect.x, TempRect.y + TempRect.height); + else SetCaretPos(TempRect.x, TempRect.y); + end; + + + if (PrimaryLangID = LANG_KOREAN) then + TempRect.y := TempRect.y + CARET_MARGIN; + + TempCandidate.dwIndex := 0; + TempCandidate.dwStyle := CFS_EXCLUDE; + TempCandidate.ptCurrentPos.X := TempRect.x; + TempCandidate.ptCurrentPos.Y := TempRect.y; + TempCandidate.rcArea.Left := TempRect.x; + TempCandidate.rcArea.Top := TempRect.y; + TempCandidate.rcArea.Right := TempRect.x + TempRect.width; + TempCandidate.rcArea.Bottom := TempRect.y + TempRect.height; + + ImmSetCandidateWindow(TempIMC, @TempCandidate); + finally + ImmReleaseContext(FHWND, TempIMC); + end; + {$ENDIF} +end; + + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFOsrBrowserWindow.pas b/windows/src/ext/cef4delphi/source/uCEFOsrBrowserWindow.pas new file mode 100644 index 0000000000000000000000000000000000000000..08d33fa0631f25d4b6a99d83b3b74719042d97e1 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFOsrBrowserWindow.pas @@ -0,0 +1,1029 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +(* + + === State of Implementation === + + On MacOS the keyboard support is currently incomplete + + +*) + +unit uCEFOsrBrowserWindow; + +{$mode objfpc}{$H+} +{$i cef.inc} + +interface + +uses + {$IFDEF DARWIN} // $IFDEF MACOSX + uCEFLazarusCocoa, + {$ENDIF} + {$IFDEF FPC} + LResources, PropEdits, + {$ENDIF} + uCEFApplication, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces, uCEFChromium, + uCEFLinkedWinControlBase, uCEFBufferPanel, + uCEFBrowserWindow, uCEFBitmapBitBuffer, uCEFMiscFunctions, + uCEFConstants, uCEFChromiumEvents, Forms, ExtCtrls, LCLType, Graphics, + Controls, syncobjs, Classes, sysutils, math; + +type + + TBrowserMouseEvent = procedure(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer; + var AHandled: Boolean) of Object; + TBrowserMouseMoveEvent = procedure(Sender: TObject; Shift: TShiftState; + X, Y: Integer; + var AHandled: Boolean) of Object; + TBrowserMouseWheelEvent = procedure(Sender: TObject; Shift: TShiftState; + WheelDelta: Integer; MousePos: TPoint; + var AHandled: Boolean) of Object; + TBrowserKeyEvent = procedure(Sender: TObject; var Key: Word; Shift: TShiftState; var AHandled: Boolean) of Object; + //TBrowserKeyPressEvent = procedure(Sender: TObject; var Key: char; var AHandled: Boolean) of Object; + TBrowserUTF8KeyPressEvent = procedure(Sender: TObject; var UTF8Key: TUTF8Char; var AHandled: Boolean) of Object; + + (* TEmbeddedOsrChromium + + Hides (THiddenPropertyEditor) any published event that is used by TOsrBrowserWindow + * Hidden events must also not be used by user code * + *) + + TEmbeddedOsrChromium = class(TEmbeddedChromium) + end; + + { TOsrBrowserWindow - Off-Screen-Rendering + + A simple "drop on the Form" component for an full embedded browser. + + See notes an TBrowserWindow for requirements in user code. + Further: + - Some keystrokes may not be sent to KeyDown/KeyPress by the LCL. + They may be available as WM_SYSKEYDOWN/UP message on the containing Form. + + + This component is still experimental. + - On MacOS Keyboard support is not complete + + } + + TOsrBrowserWindow = class(TBufferPanel) + private + FPopUpBitmap : TBitmap; + FPopUpRect : TRect; + FShowPopUp : boolean; + FResizing : boolean; + FPendingResize : boolean; + FResizeCS : syncobjs.TCriticalSection; + + //FIMECS : TCriticalSection; + FDeviceBounds : TCefRectDynArray; + FSelectedRange : TCefRange; + + FLastKeyDown: Word; + + procedure AsyncInvalidate(Data: PtrInt); + procedure AsyncResize(Data: PtrInt); + procedure SyncIMERangeChanged; + + procedure DoGetChromiumBeforePopup(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, + targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; + userGesture: Boolean; const popupFeatures: TCefPopupFeatures; + var windowInfo: TCefWindowInfo; var client: ICefClient; + var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; + var noJavascriptAccess: Boolean; var Result: Boolean); + procedure DoGetChromiumPopupShow(Sender: TObject; + const browser: ICefBrowser; AShow: Boolean); + procedure DoGetChromiumPopupSize(Sender: TObject; + const browser: ICefBrowser; const rect: PCefRect); + procedure DoGetChromiumTooltip(Sender: TObject; + const browser: ICefBrowser; var AText: ustring; out Result: Boolean); + procedure DoGetChromiumIMECompositionRangeChanged(Sender: TObject; + const browser: ICefBrowser; const selected_range: PCefRange; + character_boundsCount: NativeUInt; const character_bounds: PCefRect); + procedure DoGetChromiumCursorChange(Sender: TObject; + const browser: ICefBrowser; cursor_: TCefCursorHandle; + cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; + var aResult: boolean); + procedure DoGetChromiumGetScreenInfo(Sender: TObject; + const browser: ICefBrowser; var screenInfo: TCefScreenInfo; out + Result: Boolean); + procedure DoGetChromiumGetScreenPoint(Sender: TObject; + const browser: ICefBrowser; viewX, viewY: Integer; var screenX, + screenY: Integer; out Result: Boolean); + procedure DoGetChromiumViewRect(Sender: TObject; + const browser: ICefBrowser; var rect: TCefRect); + procedure DoChromiumPaint(Sender: TObject; const browser: ICefBrowser; + kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; + const dirtyRects: PCefRectArray; const ABuffer: Pointer; AWidth, + AHeight: Integer); + + private + FChromium : TEmbeddedOsrChromium; + + FOnBrowserClosed : TNotifyEvent; + FOnBrowserCreated : TNotifyEvent; + FOnKeyDown: TBrowserKeyEvent; + FOnKeyUp: TBrowserKeyEvent; + FOnMouseDown: TBrowserMouseEvent; + FOnMouseMove: TBrowserMouseMoveEvent; + FOnMouseUp: TBrowserMouseEvent; + FOnMouseWheel: TBrowserMouseWheelEvent; + FOnUtf8KeyPress: TBrowserUTF8KeyPressEvent; + + procedure DoCreateBrowserAfterContext(Sender: TObject); + + protected + function GetChromium: TEmbeddedOsrChromium; + function getModifiers(Shift: TShiftState): TCefEventFlags; + function getKeyModifiers(Shift: TShiftState): TCefEventFlags; + function GetButton(Button: TMouseButton): TCefMouseButtonType; + procedure DestroyHandle; override; + procedure RealizeBounds; override; + + procedure DoEnter; override; + procedure DoExit; override; + procedure Click; override; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + procedure MouseEnter; override; + procedure MouseLeave; override; + function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override; + + (* Key input works only for windows. + *) + procedure KeyDown(var Key: Word; Shift: TShiftState); override; + procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override; + procedure KeyUp(var Key: Word; Shift: TShiftState); override; + {$IFDEF MSWINDOWS} + procedure DoOnIMECancelComposition; override; + procedure DoOnIMECommitText(const aText : ustring; const replacement_range : PCefRange; relative_cursor_pos : integer); override; + procedure DoOnIMESetComposition(const aText : ustring; const underlines : TCefCompositionUnderlineDynArray; const replacement_range, selection_range : TCefRange); override; + {$ENDIF} + procedure CaptureChanged; override; + + procedure DoOnCreated(Sender: TObject); + procedure DoOnClosed(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure CreateHandle; override; + + procedure CloseBrowser(aForceClose: boolean); + procedure WaitForBrowserClosed; + function IsClosed: boolean; + procedure LoadURL(aURL: ustring); + // + published + property Chromium : TEmbeddedOsrChromium read GetChromium; + + property OnBrowserCreated : TNotifyEvent read FOnBrowserCreated write FOnBrowserCreated; + property OnBrowserClosed : TNotifyEvent read FOnBrowserClosed write FOnBrowserClosed; + + (* Mouse/Key events + The below events can be used to see mouse/key input before it is sent to CEF. + All events have a "AHandled" parameter, which can be used to prevent the event + from being sent to CEF. + *) + property OnMouseDown: TBrowserMouseEvent read FOnMouseDown write FOnMouseDown; + property OnMouseUp: TBrowserMouseEvent read FOnMouseUp write FOnMouseUp; + property OnMouseMove: TBrowserMouseMoveEvent read FOnMouseMove write FOnMouseMove; + property OnMouseWheel: TBrowserMouseWheelEvent read FOnMouseWheel write FOnMouseWheel; + property OnKeyDown: TBrowserKeyEvent read FOnKeyDown write FOnKeyDown; + property OnKeyUp: TBrowserKeyEvent read FOnKeyUp write FOnKeyUp; + property OnUtf8KeyPress: TBrowserUTF8KeyPressEvent read FOnUtf8KeyPress write FOnUtf8KeyPress; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + + +implementation + +{ TOsrBrowserWindow } + +procedure TOsrBrowserWindow.AsyncInvalidate(Data: PtrInt); +begin + Invalidate; +end; + +procedure TOsrBrowserWindow.AsyncResize(Data: PtrInt); +begin + try + FResizeCS.Acquire; + + if FResizing then + FPendingResize := True + else + if BufferIsResized then + Chromium.Invalidate(PET_VIEW) + else + begin + FResizing := True; + Chromium.WasResized; + end; + finally + FResizeCS.Release; + end; +end; + +procedure TOsrBrowserWindow.SyncIMERangeChanged; +begin + ChangeCompositionRange(FSelectedRange, FDeviceBounds); +end; + +procedure TOsrBrowserWindow.DoGetChromiumBeforePopup(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, + targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; + userGesture: Boolean; const popupFeatures: TCefPopupFeatures; + var windowInfo: TCefWindowInfo; var client: ICefClient; + var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; + var noJavascriptAccess: Boolean; var Result: Boolean); +begin + // For simplicity, this demo blocks all popup windows and new tabs + Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]); +end; + +procedure TOsrBrowserWindow.DoGetChromiumPopupShow(Sender: TObject; + const browser: ICefBrowser; AShow: Boolean); +begin + if aShow then + FShowPopUp := True + else + begin + FShowPopUp := False; + FPopUpRect := rect(0, 0, 0, 0); + + if (Chromium <> nil) then Chromium.Invalidate(PET_VIEW); + end; +end; + +procedure TOsrBrowserWindow.DoGetChromiumPopupSize(Sender: TObject; + const browser: ICefBrowser; const rect: PCefRect); +begin + LogicalToDevice(rect^, ScreenScale); + + FPopUpRect.Left := rect^.x; + FPopUpRect.Top := rect^.y; + FPopUpRect.Right := rect^.x + rect^.width - 1; + FPopUpRect.Bottom := rect^.y + rect^.height - 1; +end; + +procedure TOsrBrowserWindow.DoGetChromiumTooltip(Sender: TObject; + const browser: ICefBrowser; var AText: ustring; out Result: Boolean); +begin + hint := aText; + ShowHint := (length(aText) > 0); + Result := True; +end; + +procedure TOsrBrowserWindow.DoGetChromiumIMECompositionRangeChanged( + Sender: TObject; const browser: ICefBrowser; const selected_range: PCefRange; + character_boundsCount: NativeUInt; const character_bounds: PCefRect); +var + TempPRect : PCefRect; + i : NativeUInt; + TempScale : single; +begin + // TChromium.OnIMECompositionRangeChanged is triggered in a different thread + // and all functions using a IMM context need to be executed in the same + // thread, in this case the main thread. We need to save the parameters and + // send a message to the form to execute Panel1.ChangeCompositionRange in + // the main thread. + + if (FDeviceBounds <> nil) then + begin + Finalize(FDeviceBounds); + FDeviceBounds := nil; + end; + + FSelectedRange := selected_range^; + + if (character_boundsCount > 0) then + begin + SetLength(FDeviceBounds, character_boundsCount); + + i := 0; + TempPRect := character_bounds; + TempScale := ScreenScale; + + while (i < character_boundsCount) do + begin + FDeviceBounds[i] := TempPRect^; + LogicalToDevice(FDeviceBounds[i], TempScale); + + inc(TempPRect); + inc(i); + end; + end; + + TThread.Synchronize(nil, @SyncIMERangeChanged); +end; + +procedure TOsrBrowserWindow.DoGetChromiumCursorChange(Sender: TObject; + const browser: ICefBrowser; cursor_: TCefCursorHandle; + cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo; + var aResult: boolean); +begin + Cursor := CefCursorToWindowsCursor(cursorType); + aResult := True; +end; + +procedure TOsrBrowserWindow.DoGetChromiumGetScreenInfo(Sender: TObject; + const browser: ICefBrowser; var screenInfo: TCefScreenInfo; out + Result: Boolean); +var + TempRect : TCEFRect; + TempScale : single; +begin + TempScale := ScreenScale; + TempRect.x := 0; + TempRect.y := 0; + TempRect.width := DeviceToLogical(Width, TempScale); + TempRect.height := DeviceToLogical(Height, TempScale); + + screenInfo.device_scale_factor := TempScale; + screenInfo.depth := 0; + screenInfo.depth_per_component := 0; + screenInfo.is_monochrome := Ord(False); + screenInfo.rect := TempRect; + screenInfo.available_rect := TempRect; + + Result := True; +end; + +procedure TOsrBrowserWindow.DoGetChromiumGetScreenPoint(Sender: TObject; + const browser: ICefBrowser; viewX, viewY: Integer; var screenX, + screenY: Integer; out Result: Boolean); +var + TempScreenPt, TempViewPt : TPoint; + TempScale : single; +begin + TempScale := ScreenScale; + TempViewPt.x := LogicalToDevice(viewX, TempScale); + TempViewPt.y := LogicalToDevice(viewY, TempScale); + TempScreenPt := ClientToScreen(TempViewPt); + screenX := TempScreenPt.x; + screenY := TempScreenPt.y; + Result := True; +end; + +procedure TOsrBrowserWindow.DoGetChromiumViewRect(Sender: TObject; + const browser: ICefBrowser; var rect: TCefRect); +var + TempScale : single; +begin + TempScale := ScreenScale; + rect.x := 0; + rect.y := 0; + rect.width := DeviceToLogical(Width, TempScale); + rect.height := DeviceToLogical(Height, TempScale); +end; + +procedure TOsrBrowserWindow.DoChromiumPaint(Sender: TObject; + const browser: ICefBrowser; kind: TCefPaintElementType; + dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; + const ABuffer: Pointer; AWidth, AHeight: Integer); +var + src, dst: PByte; + i, j, TempLineSize, TempSrcOffset, TempDstOffset, SrcStride : Integer; + n : NativeUInt; + TempWidth, TempHeight: integer; + TempBufferBits : Pointer; + TempForcedResize : boolean; + TempBitmap : TBitmap; + TempSrcRect : TRect; + {$IFDEF DARWIN} + s: PByte; + ls: integer; + {$ENDIF} +begin + try + FResizeCS.Acquire; + TempForcedResize := False; + + if BeginBufferDraw then + begin + if (kind = PET_POPUP) then + begin + if (FPopUpBitmap = nil) or + (aWidth <> FPopUpBitmap.Width) or + (aHeight <> FPopUpBitmap.Height) then + begin + if (FPopUpBitmap <> nil) then FPopUpBitmap.Free; + + FPopUpBitmap := TBitmap.Create; + FPopUpBitmap.PixelFormat := pf32bit; + FPopUpBitmap.HandleType := bmDIB; + FPopUpBitmap.Width := aWidth; + FPopUpBitmap.Height := aHeight; + end; + + TempBitmap := FPopUpBitmap; + TempBitmap.BeginUpdate; + + TempWidth := FPopUpBitmap.Width; + TempHeight := FPopUpBitmap.Height; + end + else + begin + TempForcedResize := UpdateBufferDimensions(aWidth, aHeight) or not(BufferIsResized(False)); + + TempBitmap := Buffer; + TempBitmap.BeginUpdate; + + TempWidth := BufferWidth; + TempHeight := BufferHeight; + end; + + SrcStride := aWidth * SizeOf(TRGBQuad); + n := 0; + + while (n < dirtyRectsCount) do + begin + if (dirtyRects^[n].x >= 0) and (dirtyRects^[n].y >= 0) then + begin + TempLineSize := min(dirtyRects^[n].width, TempWidth - dirtyRects^[n].x) {$IFnDEF DARWIN}* SizeOf(TRGBQuad){$ENDIF}; + + if (TempLineSize > 0) then + begin + TempSrcOffset := ((dirtyRects^[n].y * aWidth) + dirtyRects^[n].x) * SizeOf(TRGBQuad); + TempDstOffset := (dirtyRects^[n].x * SizeOf(TRGBQuad)); + + src := @PByte(ABuffer)[TempSrcOffset]; + + i := 0; + j := min(dirtyRects^[n].height, TempHeight - dirtyRects^[n].y); + + while (i < j) do + begin + TempBufferBits := TempBitmap.Scanline[dirtyRects^[n].y + i]; + dst := @PByte(TempBufferBits)[TempDstOffset]; + + {$IFDEF DARWIN} + ls := TempLineSize; + s := src; + while ls > 0 do begin + PCardinal(dst)^ := (s[0] shl 24) or (s[1] shl 16) or (s[2] shl 8) or s[3]; + inc(dst, 4); + inc(s, 4); + dec(ls); + end; + {$ELSE} + Move(src^, dst^, TempLineSize); + {$ENDIF} + + + Inc(src, SrcStride); + inc(i); + end; + end; + end; + + inc(n); + end; + + TempBitmap.EndUpdate; + + if FShowPopup and (FPopUpBitmap <> nil) then + begin + TempSrcRect := Rect(0, 0, + min(FPopUpRect.Right - FPopUpRect.Left, FPopUpBitmap.Width), + min(FPopUpRect.Bottom - FPopUpRect.Top, FPopUpBitmap.Height)); + + BufferDraw(FPopUpBitmap, TempSrcRect, FPopUpRect); + end; + + EndBufferDraw; + + if HandleAllocated then + //PostMessage(Handle, CEF_PENDINGINVALIDATE, 0, 0); + Application.QueueAsyncCall(@AsyncInvalidate, 0); + + if (kind = PET_VIEW) then + begin + if (TempForcedResize or FPendingResize) and + HandleAllocated then + Application.QueueAsyncCall(@AsyncResize, 0); + //PostMessage(Handle, CEF_PENDINGRESIZE, 0, 0); + + FResizing := False; + FPendingResize := False; + end; + end; + finally + FResizeCS.Release; + end; +end; + +function TOsrBrowserWindow.GetChromium: TEmbeddedOsrChromium; +begin + Result := FChromium; +end; + +function TOsrBrowserWindow.getModifiers(Shift: TShiftState + ): TCefEventFlags; +begin + Result := EVENTFLAG_NONE; + + if (ssShift in Shift) then Result := Result or EVENTFLAG_SHIFT_DOWN; + if (ssAlt in Shift) then Result := Result or EVENTFLAG_ALT_DOWN; + if (ssCtrl in Shift) then Result := Result or EVENTFLAG_CONTROL_DOWN; + if (ssMeta in Shift) then Result := Result or EVENTFLAG_COMMAND_DOWN; + if (ssLeft in Shift) then Result := Result or EVENTFLAG_LEFT_MOUSE_BUTTON; + if (ssRight in Shift) then Result := Result or EVENTFLAG_RIGHT_MOUSE_BUTTON; + if (ssMiddle in Shift) then Result := Result or EVENTFLAG_MIDDLE_MOUSE_BUTTON; +end; + +function TOsrBrowserWindow.getKeyModifiers(Shift: TShiftState): TCefEventFlags; +begin + Result := EVENTFLAG_NONE; + + if (ssShift in Shift) then Result := Result or EVENTFLAG_SHIFT_DOWN; + if (ssAlt in Shift) then Result := Result or EVENTFLAG_ALT_DOWN; + if (ssCtrl in Shift) then Result := Result or EVENTFLAG_CONTROL_DOWN; + if (ssMeta in Shift) then Result := Result or EVENTFLAG_COMMAND_DOWN; + if (ssNum in Shift) then Result := Result or EVENTFLAG_NUM_LOCK_ON; + if (ssCaps in Shift) then Result := Result or EVENTFLAG_CAPS_LOCK_ON; +end; + +function TOsrBrowserWindow.GetButton(Button: TMouseButton + ): TCefMouseButtonType; +begin + case Button of + TMouseButton.mbRight : Result := MBT_RIGHT; + TMouseButton.mbMiddle : Result := MBT_MIDDLE; + else Result := MBT_LEFT; + end; +end; + +procedure TOsrBrowserWindow.DoCreateBrowserAfterContext(Sender: TObject); +begin + FChromium.CreateBrowser(nil); +end; + +procedure TOsrBrowserWindow.CreateHandle; +begin + inherited CreateHandle; + if not (csDesigning in ComponentState) then begin + GlobalCEFApp.AddContextInitializedHandler(@DoCreateBrowserAfterContext); + end; +end; + +procedure TOsrBrowserWindow.DestroyHandle; +begin + if (GlobalCEFApp = nil) or + (not FChromium.HasBrowser) or + (csDesigning in ComponentState) + then begin + inherited DestroyHandle; + exit; + end; + + FChromium.CloseBrowser(True); + inherited DestroyHandle; +end; + +procedure TOsrBrowserWindow.RealizeBounds; +begin + inherited RealizeBounds; + Chromium.NotifyMoveOrResizeStarted; + AsyncResize(0); +end; + +procedure TOsrBrowserWindow.DoEnter; +begin + inherited DoEnter; + Chromium.SendFocusEvent(True); +end; + +procedure TOsrBrowserWindow.DoExit; +begin + inherited DoExit; + Chromium.SendFocusEvent(False); +end; + +procedure TOsrBrowserWindow.Click; +begin + inherited Click; + SetFocus; +end; + +procedure TOsrBrowserWindow.MouseDown(Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +var + TempEvent : TCefMouseEvent; + LastClickCount: integer; + IsHandled: Boolean; +begin + inherited MouseDown(Button, Shift, X, Y); + IsHandled := False; + if FOnMouseDown <> nil then + FOnMouseDown(Self, Button, Shift, X, Y, IsHandled); + if IsHandled then + exit; + + SetFocus; + + LastClickCount := 1; + if ssDouble in Shift then LastClickCount := 2 + else if ssTriple in Shift then LastClickCount := 3 + else if ssQuad in Shift then LastClickCount := 4; + + TempEvent.x := X; + TempEvent.y := Y; + TempEvent.modifiers := getModifiers(Shift); + DeviceToLogical(TempEvent, ScreenScale); + Chromium.SendMouseClickEvent(@TempEvent, GetButton(Button), False, LastClickCount); +end; + +procedure TOsrBrowserWindow.MouseUp(Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +var + TempEvent : TCefMouseEvent; + LastClickCount: integer; + IsHandled: Boolean; +begin + inherited MouseUp(Button, Shift, X, Y); + IsHandled := False; + if FOnMouseDown <> nil then + FOnMouseDown(Self, Button, Shift, X, Y, IsHandled); + if IsHandled then + exit; + + LastClickCount := 1; + if ssDouble in Shift then LastClickCount := 2 + else if ssTriple in Shift then LastClickCount := 3 + else if ssQuad in Shift then LastClickCount := 4; + + TempEvent.x := X; + TempEvent.y := Y; + TempEvent.modifiers := getModifiers(Shift); + DeviceToLogical(TempEvent, ScreenScale); + Chromium.SendMouseClickEvent(@TempEvent, GetButton(Button), True, LastClickCount); +end; + +procedure TOsrBrowserWindow.MouseMove(Shift: TShiftState; X, Y: Integer); +var + TempEvent : TCefMouseEvent; + IsHandled: Boolean; +begin + inherited MouseMove(Shift, X, Y); + IsHandled := False; + if FOnMouseMove <> nil then + FOnMouseMove(Self, Shift, X, Y, IsHandled); + if IsHandled then + exit; + + TempEvent.x := x; + TempEvent.y := y; + TempEvent.modifiers := getModifiers(Shift); + DeviceToLogical(TempEvent, ScreenScale); + Chromium.SendMouseMoveEvent(@TempEvent, False); +end; + +procedure TOsrBrowserWindow.MouseEnter; +var + TempEvent : TCefMouseEvent; + TempPoint : TPoint; +begin + inherited MouseEnter; + + TempPoint := ScreenToClient(mouse.CursorPos); + TempEvent.x := TempPoint.x; + TempEvent.y := TempPoint.y; + TempEvent.modifiers := EVENTFLAG_NONE; + DeviceToLogical(TempEvent, ScreenScale); + Chromium.SendMouseMoveEvent(@TempEvent, False); +end; + +procedure TOsrBrowserWindow.MouseLeave; +var + TempEvent : TCefMouseEvent; + TempPoint : TPoint; + TempTime : integer; +begin + inherited MouseLeave; + + TempPoint := ScreenToClient(mouse.CursorPos); + TempPoint := ScreenToclient(TempPoint); + TempEvent.x := TempPoint.x; + TempEvent.y := TempPoint.y; + {$IFDEF MSWINDOWS} + TempEvent.modifiers := GetCefMouseModifiers; + {$ELSE} + TempEvent.modifiers := EVENTFLAG_NONE; + {$ENDIF} + DeviceToLogical(TempEvent, ScreenScale); + Chromium.SendMouseMoveEvent(@TempEvent, True); +end; + +function TOsrBrowserWindow.DoMouseWheel(Shift: TShiftState; + WheelDelta: Integer; MousePos: TPoint): Boolean; +var + TempEvent : TCefMouseEvent; + IsHandled: Boolean; +begin + Result := inherited DoMouseWheel(Shift, WheelDelta, MousePos); + IsHandled := False; + if FOnMouseWheel <> nil then + FOnMouseWheel(Self, Shift, WheelDelta, MousePos, IsHandled); + if IsHandled then + exit; + + TempEvent.x := MousePos.x; + TempEvent.y := MousePos.y; + TempEvent.modifiers := getModifiers(Shift); + DeviceToLogical(TempEvent, ScreenScale); + {$IFDEF MSWINDOWS} + if CefIsKeyDown(VK_SHIFT) then + Chromium.SendMouseWheelEvent(@TempEvent, WheelDelta, 0) + else + {$ENDIF} + Chromium.SendMouseWheelEvent(@TempEvent, 0, WheelDelta); +end; + +procedure TOsrBrowserWindow.KeyDown(var Key: Word; Shift: TShiftState); +var + TempKeyEvent : TCefKeyEvent; + IsHandled: Boolean; +begin + IsHandled := False; + if FOnKeyDown <> nil then + FOnKeyDown(Self, Key, Shift, IsHandled); + if IsHandled then begin + inherited KeyDown(Key, Shift); + exit; + end; + + FLastKeyDown := Key; + if (Key <> 0) and (Chromium <> nil) then + begin + TempKeyEvent.kind := KEYEVENT_RAWKEYDOWN; + TempKeyEvent.modifiers := getModifiers(Shift); + TempKeyEvent.windows_key_code := Key; + {$IFDEF DARWIN} // $IFDEF MACOSX + TempKeyEvent.native_key_code := LastMacOsKeyDownCode; + {$ELSE} + TempKeyEvent.native_key_code := 0; + {$ENDIF} + TempKeyEvent.is_system_key := ord(False); + TempKeyEvent.character := #0; + TempKeyEvent.unmodified_character := #0; + TempKeyEvent.focus_on_editable_field := ord(False); + + Chromium.SendKeyEvent(@TempKeyEvent); + + if (Key in [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_TAB]) then Key := 0; + end; + + inherited KeyDown(Key, Shift); +end; + +procedure TOsrBrowserWindow.UTF8KeyPress(var UTF8Key: TUTF8Char); +var + TempKeyEvent : TCefKeyEvent; + TempString : UnicodeString; + IsHandled: Boolean; +begin + IsHandled := False; + if FOnUtf8KeyPress <> nil then + FOnUtf8KeyPress(Self, UTF8Key, IsHandled); + if IsHandled then begin + inherited UTF8KeyPress(UTF8Key); + exit; + end; + + if Focused then + begin + TempString := UTF8Decode(UTF8Key); + + if (length(TempString) > 0) then + begin + TempKeyEvent.kind := KEYEVENT_CHAR; + {$IFDEF MSWINDOWS} + TempKeyEvent.modifiers := GetCefKeyboardModifiers(WParam(TempString[1]), 0); + TempKeyEvent.windows_key_code := ord(TempString[1]); + {$ELSE} + TempKeyEvent.modifiers := getKeyModifiers(GetKeyShiftState); + TempKeyEvent.windows_key_code := FLastKeyDown; + {$ENDIF} + TempKeyEvent.native_key_code := 0; + TempKeyEvent.is_system_key := ord(False); + TempKeyEvent.character := TempString[1]; + TempKeyEvent.unmodified_character := TempString[1]; + TempKeyEvent.focus_on_editable_field := ord(False); + + Chromium.SendKeyEvent(@TempKeyEvent); + end; + end; + + inherited UTF8KeyPress(UTF8Key); +end; + +procedure TOsrBrowserWindow.KeyUp(var Key: Word; Shift: TShiftState); +var + TempKeyEvent : TCefKeyEvent; + IsHandled: Boolean; +begin + IsHandled := False; + if FOnKeyUp <> nil then + FOnKeyUp(Self, Key, Shift, IsHandled); + if IsHandled then begin + inherited KeyUp(Key, Shift); + exit; + end; + + if (Key <> 0) and (Chromium <> nil) then + begin + TempKeyEvent.kind := KEYEVENT_KEYUP; + TempKeyEvent.modifiers := getModifiers(Shift); + TempKeyEvent.windows_key_code := Key; + TempKeyEvent.native_key_code := 0; + TempKeyEvent.is_system_key := ord(False); + TempKeyEvent.character := #0; + TempKeyEvent.unmodified_character := #0; + TempKeyEvent.focus_on_editable_field := ord(False); + + Chromium.SendKeyEvent(@TempKeyEvent); + end; + + inherited KeyUp(Key, Shift); +end; + +{$IFDEF MSWINDOWS} +procedure TOsrBrowserWindow.DoOnIMECancelComposition; +begin + inherited DoOnIMECancelComposition; + Chromium.IMECancelComposition; +end; + +procedure TOsrBrowserWindow.DoOnIMECommitText(const aText: ustring; + const replacement_range: PCefRange; relative_cursor_pos: integer); +begin + inherited DoOnIMECommitText(aText, replacement_range, relative_cursor_pos); + Chromium.IMECommitText(aText, replacement_range, relative_cursor_pos);; +end; + +procedure TOsrBrowserWindow.DoOnIMESetComposition(const aText: ustring; + const underlines: TCefCompositionUnderlineDynArray; const replacement_range, + selection_range: TCefRange); +begin + inherited DoOnIMESetComposition(aText, underlines, replacement_range, selection_range); + Chromium.IMESetComposition(aText, underlines, @replacement_range, @selection_range); +end; +{$ENDIF} + +procedure TOsrBrowserWindow.CaptureChanged; +begin + inherited CaptureChanged; + + if (Chromium <> nil) then Chromium.SendCaptureLostEvent; +end; + +procedure TOsrBrowserWindow.DoOnCreated(Sender: TObject); +begin + if Assigned(FOnBrowserCreated) then + FOnBrowserCreated(Self); +end; + +procedure TOsrBrowserWindow.DoOnClosed(Sender: TObject); +begin + if (not(csDestroying in ComponentState)) and + Assigned(FOnBrowserClosed) + then + FOnBrowserClosed(Self); +end; + +constructor TOsrBrowserWindow.Create(AOwner: TComponent); +begin + FResizeCS := TCriticalSection.Create; + + FDeviceBounds := nil; + FSelectedRange.from := 0; + FSelectedRange.to_ := 0; + + FChromium := TEmbeddedOsrChromium.Create(Self); + FChromium.InternalOnBrowserClosed := {$IFDEF FPC}@{$ENDIF}DoOnClosed; + FChromium.InternalOnBrowserCreated := {$IFDEF FPC}@{$ENDIF}DoOnCreated; + + FChromium.OnPaint := {$IFDEF FPC}@{$ENDIF}DoChromiumPaint; + FChromium.OnGetViewRect := {$IFDEF FPC}@{$ENDIF}DoGetChromiumViewRect; + FChromium.OnCursorChange := {$IFDEF FPC}@{$ENDIF}DoGetChromiumCursorChange; + FChromium.OnGetScreenPoint := {$IFDEF FPC}@{$ENDIF}DoGetChromiumGetScreenPoint; + FChromium.OnGetScreenInfo := {$IFDEF FPC}@{$ENDIF}DoGetChromiumGetScreenInfo; + FChromium.OnPopupShow := {$IFDEF FPC}@{$ENDIF}DoGetChromiumPopupShow; + FChromium.OnPopupSize := {$IFDEF FPC}@{$ENDIF}DoGetChromiumPopupSize; + FChromium.OnTooltip := {$IFDEF FPC}@{$ENDIF}DoGetChromiumTooltip; + FChromium.OnBeforePopup := {$IFDEF FPC}@{$ENDIF}DoGetChromiumBeforePopup; + FChromium.OnIMECompositionRangeChanged := @DoGetChromiumIMECompositionRangeChanged; + + inherited Create(AOwner); + ControlStyle := ControlStyle + [csOwnedChildrenNotSelectable]; + CopyOriginalBuffer := true; +end; + +destructor TOsrBrowserWindow.Destroy; +begin + inherited Destroy; + FreeAndNil(FResizeCS); + if (FDeviceBounds <> nil) then + begin + Finalize(FDeviceBounds); + FDeviceBounds := nil; + end; +end; + +procedure TOsrBrowserWindow.CloseBrowser(aForceClose: boolean); +begin + FChromium.CloseBrowser(aForceClose); +end; + +procedure TOsrBrowserWindow.WaitForBrowserClosed; +begin + if not FChromium.HasBrowser then + exit; + FChromium.CloseBrowser(True); + + while FChromium.HasBrowser do begin + Application.ProcessMessages; + if GlobalCEFApp.ExternalMessagePump then + GlobalCEFApp.DoMessageLoopWork; + sleep(5); + end; + + // TODO : sent closed? +end; + +function TOsrBrowserWindow.IsClosed: boolean; +begin + Result := not FChromium.HasBrowser; +end; + +procedure TOsrBrowserWindow.LoadURL(aURL: ustring); +begin + FChromium.LoadURL(aURL); +end; + + +{$IFDEF FPC} +procedure Register; +begin + {$I res/TOsrBrowserWindow.lrs} + RegisterComponents('Chromium', [TOsrBrowserWindow]); + RegisterClass(TEmbeddedOsrChromium); + RegisterPropertyEditor(TypeInfo(TOnClose), TEmbeddedOsrChromium,'OnClose',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnPaint), TEmbeddedOsrChromium,'OnPaint',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnGetViewRect), TEmbeddedOsrChromium,'OnGetViewRect',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnCursorChange), TEmbeddedOsrChromium,'OnCursorChange',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnGetScreenPoint), TEmbeddedOsrChromium,'OnGetScreenPoint',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnGetScreenInfo), TEmbeddedOsrChromium,'OnGetScreenInfo',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnPopupShow), TEmbeddedOsrChromium,'OnPopupShow',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnPopupSize), TEmbeddedOsrChromium,'OnPopupSize',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnTooltip), TEmbeddedOsrChromium,'OnTooltip',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnBeforePopup), TEmbeddedOsrChromium,'OnBeforePopup',THiddenPropertyEditor); + RegisterPropertyEditor(TypeInfo(TOnIMECompositionRangeChanged), TEmbeddedOsrChromium,'OnIMECompositionRangeChanged',THiddenPropertyEditor); +end; +{$ENDIF} + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFPDFPrintCallback.pas b/windows/src/ext/cef4delphi/source/uCEFPDFPrintCallback.pas index f48a784297e464f3c335ed065986fa9cf5a598be..08705dad6138a0bfe5e7373555ae90c1c5d5e760 100644 --- a/windows/src/ext/cef4delphi/source/uCEFPDFPrintCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFPDFPrintCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFPDFPrintCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFPDFPrintOptions.pas b/windows/src/ext/cef4delphi/source/uCEFPDFPrintOptions.pas index 3e2652e91af09138979e85594c4787161f164e9d..1cce5f7a44af1028e490efe03f32aadf0b21ac0f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFPDFPrintOptions.pas +++ b/windows/src/ext/cef4delphi/source/uCEFPDFPrintOptions.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFPDFPrintOptions; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -64,15 +62,15 @@ type Fpage_width : integer; Fpage_height : Integer; Fscale_factor : integer; - Fmargin_top : double; - Fmargin_right : double; - Fmargin_bottom : double; - Fmargin_left : double; + Fmargin_top : integer; + Fmargin_right : integer; + Fmargin_bottom : integer; + Fmargin_left : integer; Fmargin_type : TCefPdfPrintMarginType; - Fheader_footer_enabled : integer; - Fselection_only : integer; - Flandscape : integer; - Fbackgrounds_enabled : integer; + Fheader_footer_enabled : boolean; + Fselection_only : boolean; + Flandscape : boolean; + Fbackgrounds_enabled : boolean; public constructor Create; virtual; @@ -81,15 +79,15 @@ type property page_width : integer read Fpage_width write Fpage_width default 0; property page_height : integer read Fpage_height write Fpage_height default 0; property scale_factor : integer read Fscale_factor write Fscale_factor default 0; - property margin_top : double read Fmargin_top write Fmargin_top; - property margin_right : double read Fmargin_right write Fmargin_right; - property margin_bottom : double read Fmargin_bottom write Fmargin_bottom; - property margin_left : double read Fmargin_left write Fmargin_left; + property margin_top : integer read Fmargin_top write Fmargin_top; + property margin_right : integer read Fmargin_right write Fmargin_right; + property margin_bottom : integer read Fmargin_bottom write Fmargin_bottom; + property margin_left : integer read Fmargin_left write Fmargin_left; property margin_type : TCefPdfPrintMarginType read Fmargin_type write Fmargin_type default PDF_PRINT_MARGIN_DEFAULT; - property header_footer_enabled : integer read Fheader_footer_enabled write Fheader_footer_enabled default 0; - property selection_only : integer read Fselection_only write Fselection_only default 0; - property landscape : integer read Flandscape write Flandscape default 0; - property backgrounds_enabled : integer read Fbackgrounds_enabled write Fbackgrounds_enabled default 0; + property header_footer_enabled : boolean read Fheader_footer_enabled write Fheader_footer_enabled default False; + property selection_only : boolean read Fselection_only write Fselection_only default False; + property landscape : boolean read Flandscape write Flandscape default False; + property backgrounds_enabled : boolean read Fbackgrounds_enabled write Fbackgrounds_enabled default False; end; implementation @@ -104,10 +102,10 @@ begin Fmargin_bottom := 0; Fmargin_left := 0; Fmargin_type := PDF_PRINT_MARGIN_DEFAULT; - Fheader_footer_enabled := 0; - Fselection_only := 0; - Flandscape := 0; - Fbackgrounds_enabled := 0; + Fheader_footer_enabled := False; + Fselection_only := False; + Flandscape := False; + Fbackgrounds_enabled := False; end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFPanel.pas b/windows/src/ext/cef4delphi/source/uCEFPanel.pas new file mode 100644 index 0000000000000000000000000000000000000000..2666682d6f66f949c7cb18ab0bdefc686fe3ba5a --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFPanel.pas @@ -0,0 +1,170 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPanel; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFView; + +type + TCefPanelRef = class(TCefViewRef, ICefPanel) + protected + function GetAsWindow : ICefWindow; + function SetToFillLayout : ICefFillLayout; + function SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout; + function GetLayout : ICefLayout; + procedure Layout; + procedure AddChildView(const view: ICefView); + procedure AddChildViewAt(const view: ICefView; index: Integer); + procedure ReorderChildView(const view: ICefView; index: Integer); + procedure RemoveChildView(const view: ICefView); + procedure RemoveAllChildViews; + function GetChildViewCount : NativeUInt; + function GetChildViewAt(index: Integer): ICefView; + + public + class function UnWrap(data: Pointer): ICefPanel; + class function CreatePanel(const delegate: ICefPanelDelegate): ICefPanel; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFWindow, uCEFLayout, uCEFFillLayout, + uCEFBoxLayout; + +function TCefPanelRef.GetAsWindow : ICefWindow; +begin + Result := TCefWindowRef.UnWrap(PCefPanel(FData)^.as_window(PCefPanel(FData))); +end; + +function TCefPanelRef.SetToFillLayout : ICefFillLayout; +begin + Result := TCefFillLayoutRef.UnWrap(PCefPanel(FData)^.set_to_fill_layout(PCefPanel(FData))); +end; + +function TCefPanelRef.SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout; +begin + Result := TCefBoxLayoutRef.UnWrap(PCefPanel(FData)^.set_to_box_layout(PCefPanel(FData), @settings)); +end; + +function TCefPanelRef.GetLayout : ICefLayout; +begin + Result := TCefLayoutRef.UnWrap(PCefPanel(FData)^.get_layout(PCefPanel(FData))); +end; + +procedure TCefPanelRef.Layout; +begin + PCefPanel(FData)^.layout(PCefPanel(FData)); +end; + +procedure TCefPanelRef.AddChildView(const view: ICefView); +begin + PCefPanel(FData)^.add_child_view(PCefPanel(FData), CefGetData(view)); +end; + +procedure TCefPanelRef.AddChildViewAt(const view: ICefView; index: Integer); +begin + PCefPanel(FData)^.add_child_view_at(PCefPanel(FData), CefGetData(view), index); +end; + +procedure TCefPanelRef.ReorderChildView(const view: ICefView; index: Integer); +begin + PCefPanel(FData)^.reorder_child_view(PCefPanel(FData), CefGetData(view), index); +end; + +procedure TCefPanelRef.RemoveChildView(const view: ICefView); +begin + PCefPanel(FData)^.remove_child_view(PCefPanel(FData), CefGetData(view)); +end; + +procedure TCefPanelRef.RemoveAllChildViews; +begin + PCefPanel(FData)^.remove_all_child_views(PCefPanel(FData)); +end; + +function TCefPanelRef.GetChildViewCount : NativeUInt; +begin + Result := PCefPanel(FData)^.get_child_view_count(PCefPanel(FData)); +end; + +function TCefPanelRef.GetChildViewAt(index: Integer): ICefView; +begin + Result := TCefViewRef.UnWrap(PCefPanel(FData)^.get_child_view_at(PCefPanel(FData), index)); +end; + +class function TCefPanelRef.UnWrap(data: Pointer): ICefPanel; +begin + if (data <> nil) then + Result := Create(data) as ICefPanel + else + Result := nil; +end; + +class function TCefPanelRef.CreatePanel(const delegate: ICefPanelDelegate): ICefPanel; +var + TempPanel : PCefPanel; +begin + Result := nil; + + if (delegate <> nil) then + begin + TempPanel := cef_panel_create(CefGetData(delegate)); + + if (TempPanel <> nil) then + Result := Create(TempPanel) as ICefPanel; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFPanelComponent.pas b/windows/src/ext/cef4delphi/source/uCEFPanelComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..1c1088c3e22fb4c576d61fc8d9ad04a885adec21 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFPanelComponent.pas @@ -0,0 +1,264 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPanelComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents, uCEFViewComponent; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFPanelComponent = class(TCEFViewComponent, ICefPanelDelegateEvents) + protected + FPanel : ICefPanel; + + procedure DestroyView; override; + procedure Initialize; override; + + function GetInitialized : boolean; override; + function GetAsView : ICefView; override; + function GetAsPanel : ICefPanel; override; + function GetAsWindow : ICefWindow; virtual; + + // ICefViewDelegateEvents + procedure doCreateCustomView; override; + + public + procedure CreatePanel; + function SetToFillLayout : ICefFillLayout; + function SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout; + function GetLayout : ICefLayout; + procedure Layout; + procedure AddChildView(const view: ICefView); + procedure AddChildViewAt(const view: ICefView; index: Integer); + procedure ReorderChildView(const view: ICefView; index: Integer); + procedure RemoveChildView(const view: ICefView); + procedure RemoveAllChildViews; + function GetChildViewCount : NativeUInt; + function GetChildViewAt(index: Integer): ICefView; + + property AsWindow : ICefWindow read GetAsWindow; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + uCEFPanelDelegate, uCEFPanel, uCEFMiscFunctions, uCEFTask; + +procedure TCEFPanelComponent.CreatePanel; +begin + CreateView; +end; + +procedure TCEFPanelComponent.doCreateCustomView; +var + TempDelegate : ICefPanelDelegate; +begin + if (FPanel = nil) then + try + TempDelegate := TCustomPanelDelegate.Create(self); + FPanel := TCefPanelRef.CreatePanel(TempDelegate); + finally + TempDelegate := nil; + end; +end; + +procedure TCEFPanelComponent.DestroyView; +begin + FPanel := nil; +end; + +procedure TCEFPanelComponent.Initialize; +begin + inherited Initialize; + + FPanel := nil; +end; + +function TCEFPanelComponent.GetInitialized : boolean; +begin + Result := (FPanel <> nil); +end; + +function TCEFPanelComponent.GetAsView : ICefView; +begin + Result := FPanel as ICefView; +end; + +function TCEFPanelComponent.GetAsPanel : ICefPanel; +begin + Result := FPanel; +end; + +function TCEFPanelComponent.GetAsWindow : ICefWindow; +begin + if Initialized then + Result := AsPanel.AsWindow + else + Result := nil; +end; + +function TCEFPanelComponent.SetToFillLayout : ICefFillLayout; +begin + if Initialized then + Result := AsPanel.SetToFillLayout + else + Result := nil; +end; + +function TCEFPanelComponent.SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout; +begin + if Initialized then + Result := AsPanel.SetToBoxLayout(settings) + else + Result := nil; +end; + +function TCEFPanelComponent.GetLayout : ICefLayout; +begin + if Initialized then + Result := AsPanel.GetLayout + else + Result := nil; +end; + +procedure TCEFPanelComponent.Layout; +begin + if Initialized then AsPanel.Layout; +end; + +procedure TCEFPanelComponent.AddChildView(const view: ICefView); +begin + if Initialized then AsPanel.AddChildView(view); +end; + +procedure TCEFPanelComponent.AddChildViewAt(const view: ICefView; index: Integer); +begin + if Initialized then AsPanel.AddChildViewAt(view, index); +end; + +procedure TCEFPanelComponent.ReorderChildView(const view: ICefView; index: Integer); +begin + if Initialized then AsPanel.ReorderChildView(view, index); +end; + +procedure TCEFPanelComponent.RemoveChildView(const view: ICefView); +begin + if Initialized then AsPanel.RemoveChildView(view); +end; + +procedure TCEFPanelComponent.RemoveAllChildViews; +begin + if Initialized then AsPanel.RemoveAllChildViews; +end; + +function TCEFPanelComponent.GetChildViewCount : NativeUInt; +begin + if Initialized then + Result := AsPanel.GetChildViewCount + else + Result := 0; +end; + +function TCEFPanelComponent.GetChildViewAt(index: Integer): ICefView; +begin + if Initialized then + Result := AsPanel.GetChildViewAt(index) + else + Result := nil; +end; + + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tcefpanelcomponent.lrs} + RegisterComponents('Chromium Views Framework', [TCEFPanelComponent]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFPanelDelegate.pas b/windows/src/ext/cef4delphi/source/uCEFPanelDelegate.pas new file mode 100644 index 0000000000000000000000000000000000000000..c5a5099b810258364c781ce5659f2a01f4e5bc8d --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFPanelDelegate.pas @@ -0,0 +1,216 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPanelDelegate; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFViewDelegate; + +type + TCefPanelDelegateRef = class(TCefViewDelegateRef, ICefPanelDelegate) + public + class function UnWrap(data: Pointer): ICefPanelDelegate; + end; + + TCefPanelDelegateOwn = class(TCefViewDelegateOwn, ICefPanelDelegate) + public + constructor Create; override; + end; + + TCustomPanelDelegate = class(TCefPanelDelegateOwn) + protected + FEvents : Pointer; + + // ICefViewDelegate + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); override; + procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); override; + procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); override; + procedure OnFocus(const view: ICefView); override; + procedure OnBlur(const view: ICefView); override; + + public + constructor Create(const events: ICefPanelDelegateEvents); reintroduce; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions; + +// ************************************************************** +// ******************** TCefPanelDelegateRef ******************** +// ************************************************************** + +class function TCefPanelDelegateRef.UnWrap(data: Pointer): ICefPanelDelegate; +begin + if (data <> nil) then + Result := Create(data) as ICefPanelDelegate + else + Result := nil; +end; + +// ************************************************************** +// ******************** TCefPanelDelegateOwn ******************** +// ************************************************************** + +constructor TCefPanelDelegateOwn.Create; +begin + inherited CreateData(SizeOf(TCefPanelDelegate)); + + InitializeCEFMethods; +end; + +// ************************************************************** +// ******************** TCustomPanelDelegate ******************** +// ************************************************************** + +constructor TCustomPanelDelegate.Create(const events: ICefPanelDelegateEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +procedure TCustomPanelDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefPanelDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomPanelDelegate.OnGetPreferredSize', e) then raise; + end; +end; + +procedure TCustomPanelDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefPanelDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomPanelDelegate.OnGetMinimumSize', e) then raise; + end; +end; + +procedure TCustomPanelDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefPanelDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomPanelDelegate.OnGetMaximumSize', e) then raise; + end; +end; + +procedure TCustomPanelDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); +begin + try + if (FEvents <> nil) then + ICefPanelDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomPanelDelegate.OnGetHeightForWidth', e) then raise; + end; +end; + +procedure TCustomPanelDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); +begin + try + if (FEvents <> nil) then + ICefPanelDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent); + except + on e : exception do + if CustomExceptionHandler('TCustomPanelDelegate.OnParentViewChanged', e) then raise; + end; +end; + +procedure TCustomPanelDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); +begin + try + if (FEvents <> nil) then + ICefPanelDelegateEvents(FEvents).doOnChildViewChanged(view, added, child); + except + on e : exception do + if CustomExceptionHandler('TCustomPanelDelegate.OnChildViewChanged', e) then raise; + end; +end; + +procedure TCustomPanelDelegate.OnFocus(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefPanelDelegateEvents(FEvents).doOnFocus(view); + except + on e : exception do + if CustomExceptionHandler('TCustomPanelDelegate.OnFocus', e) then raise; + end; +end; + +procedure TCustomPanelDelegate.OnBlur(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefPanelDelegateEvents(FEvents).doOnBlur(view); + except + on e : exception do + if CustomExceptionHandler('TCustomPanelDelegate.OnBlur', e) then raise; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFPostData.pas b/windows/src/ext/cef4delphi/source/uCEFPostData.pas index bdca8127adc534c9e7072e922faf2a54a77f88ee..b675b677cad9a0912306900dbe462ef9b71da881 100644 --- a/windows/src/ext/cef4delphi/source/uCEFPostData.pas +++ b/windows/src/ext/cef4delphi/source/uCEFPostData.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFPostData; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -63,10 +61,10 @@ type protected function IsReadOnly: Boolean; function HasExcludedElements: Boolean; - function GetCount: NativeUInt; - function GetElements(Count: NativeUInt): IInterfaceList; // ICefPostDataElement - function RemoveElement(const element: ICefPostDataElement): Integer; - function AddElement(const element: ICefPostDataElement): Integer; + function GetElementCount: NativeUInt; + procedure GetElements(elementsCount: NativeUInt; var elements: TCefPostDataElementArray); + function RemoveElement(const element: ICefPostDataElement): Boolean; + function AddElement(const element: ICefPostDataElement): Boolean; procedure RemoveElements; public @@ -90,45 +88,60 @@ begin Result := PCefPostData(FData)^.has_excluded_elements(PCefPostData(FData)) <> 0; end; -function TCefPostDataRef.AddElement(const element: ICefPostDataElement): Integer; +function TCefPostDataRef.AddElement(const element: ICefPostDataElement): Boolean; begin - Result := PCefPostData(FData)^.add_element(PCefPostData(FData), CefGetData(element)); + Result := PCefPostData(FData)^.add_element(PCefPostData(FData), CefGetData(element)) <> 0; end; -function TCefPostDataRef.GetCount: NativeUInt; +function TCefPostDataRef.GetElementCount: NativeUInt; begin Result := PCefPostData(FData)^.get_element_count(PCefPostData(FData)) end; -function TCefPostDataRef.GetElements(Count: NativeUInt): IInterfaceList; +procedure TCefPostDataRef.GetElements(elementsCount: NativeUInt; var elements: TCefPostDataElementArray); var - items : PCefPostDataElementArray; - i : NativeUInt; + TempArray : array of PCefPostDataElement; + i : NativeUInt; begin - Result := nil; - items := nil; + TempArray := nil; try try - GetMem(items, SizeOf(PCefPostDataElement) * Count); - FillChar(items^, SizeOf(PCefPostDataElement) * Count, 0); - - PCefPostData(FData)^.get_elements(PCefPostData(FData), @Count, items); - - Result := TInterfaceList.Create; - i := 0; - - while (i < Count) do + if (elementsCount > 0) then begin - Result.Add(TCefPostDataElementRef.UnWrap(items^[i])); - inc(i); + SetLength(TempArray, elementsCount); + + i := 0; + while (i < elementsCount) do + begin + TempArray[i] := nil; + inc(i); + end; + + PCefPostData(FData)^.get_elements(PCefPostData(FData), elementsCount, TempArray[0]); + + if (elementsCount > 0) then + begin + SetLength(elements, elementsCount); + + i := 0; + while (i < elementsCount) do + begin + elements[i] := TCefPostDataElementRef.UnWrap(TempArray[i]); + inc(i); + end; + end; end; except on e : exception do if CustomExceptionHandler('TCefPostDataRef.GetElements', e) then raise; end; finally - if (items <> nil) then FreeMem(items); + if (TempArray <> nil) then + begin + Finalize(TempArray); + TempArray := nil; + end; end; end; @@ -137,9 +150,9 @@ begin Result := UnWrap(cef_post_data_create()); end; -function TCefPostDataRef.RemoveElement(const element: ICefPostDataElement): Integer; +function TCefPostDataRef.RemoveElement(const element: ICefPostDataElement): Boolean; begin - Result := PCefPostData(FData)^.remove_element(PCefPostData(FData), CefGetData(element)); + Result := PCefPostData(FData)^.remove_element(PCefPostData(FData), CefGetData(element)) <> 0; end; procedure TCefPostDataRef.RemoveElements; diff --git a/windows/src/ext/cef4delphi/source/uCEFPostDataElement.pas b/windows/src/ext/cef4delphi/source/uCEFPostDataElement.pas index c4bf18c766bbdae25f21ac51e685d279c2036fb7..c9d07ecc4822c304407eb854fe5b46940037d2b8 100644 --- a/windows/src/ext/cef4delphi/source/uCEFPostDataElement.pas +++ b/windows/src/ext/cef4delphi/source/uCEFPostDataElement.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFPostDataElement; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -277,9 +275,10 @@ begin FReadOnly := readonly; FDataType := PDE_TYPE_EMPTY; FValueByte := nil; - FillChar(FValueStr, SizeOf(FValueStr), 0); FSize := 0; + CefStringInitialize(@FValueStr); + with PCefPostDataElement(FData)^ do begin is_read_only := {$IFDEF FPC}@{$ENDIF}cef_post_data_element_is_read_only; diff --git a/windows/src/ext/cef4delphi/source/uCEFPrintDialogCallback.pas b/windows/src/ext/cef4delphi/source/uCEFPrintDialogCallback.pas new file mode 100644 index 0000000000000000000000000000000000000000..5587337834659c5ef69d142a6be250ddbc46af98 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFPrintDialogCallback.pas @@ -0,0 +1,87 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPrintDialogCallback; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefPrintDialogCallbackRef = class(TCefBaseRefCountedRef, ICefPrintDialogCallback) + protected + procedure cont(const settings: ICefPrintSettings); + procedure cancel; + + public + class function UnWrap(data: Pointer): ICefPrintDialogCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefPrintDialogCallbackRef.cancel; +begin + PCefPrintDialogCallback(FData)^.cancel(PCefPrintDialogCallback(FData)); +end; + +procedure TCefPrintDialogCallbackRef.cont(const settings: ICefPrintSettings); +begin + PCefPrintDialogCallback(FData)^.cont(PCefPrintDialogCallback(FData), CefGetData(settings)); +end; + +class function TCefPrintDialogCallbackRef.UnWrap(data: Pointer): ICefPrintDialogCallback; +begin + if (data <> nil) then + Result := Create(data) as ICefPrintDialogCallback + else + Result := nil; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFPrintHandler.pas b/windows/src/ext/cef4delphi/source/uCEFPrintHandler.pas new file mode 100644 index 0000000000000000000000000000000000000000..b0ca71b1effa3b288725edb7c7f6689d8509e315 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFPrintHandler.pas @@ -0,0 +1,319 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPrintHandler; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplicationCore; + +type + TCefPrintHandlerOwn = class(TCefBaseRefCountedOwn, ICefPrintHandler) + protected + procedure OnPrintStart(const browser: ICefBrowser); virtual; abstract; + procedure OnPrintSettings(const browser: ICefBrowser; const settings: ICefPrintSettings; getDefaults: boolean); virtual; abstract; + procedure OnPrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult: boolean); virtual; + procedure OnPrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult: boolean); virtual; + procedure OnPrintReset(const browser: ICefBrowser); virtual; abstract; + procedure GetPDFPaperSize(deviceUnitsPerInch: Integer; var aResult: TCefSize); virtual; + + procedure RemoveReferences; virtual; abstract; + + public + constructor Create; virtual; + end; + + TCustomPrintHandler = class(TCefPrintHandlerOwn) + protected + FCefApp : TCefApplicationCore; + + procedure OnPrintStart(const browser: ICefBrowser); override; + procedure OnPrintSettings(const browser: ICefBrowser; const settings: ICefPrintSettings; getDefaults: boolean); override; + procedure OnPrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult: boolean); override; + procedure OnPrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult: boolean); override; + procedure OnPrintReset(const browser: ICefBrowser); override; + procedure GetPDFPaperSize(deviceUnitsPerInch: Integer; var aResult: TCefSize); override; + + procedure RemoveReferences; override; + + public + constructor Create(const aCefApp : TCefApplicationCore); reintroduce; virtual; + destructor Destroy; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFPrintSettings, + uCEFPrintDialogCallback, uCEFPrintJobCallback; + + +// TCefPrintHandlerOwn + +procedure cef_print_handler_on_print_start(self: PCefPrintHandler; browser: PCefBrowser); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefPrintHandlerOwn) then + TCefPrintHandlerOwn(TempObject).OnPrintStart(TCefBrowserRef.UnWrap(browser)); +end; + +procedure cef_print_handler_on_print_settings(self : PCefPrintHandler; + browser : PCefBrowser; + settings : PCefPrintSettings; + get_defaults : Integer); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefPrintHandlerOwn) then + TCefPrintHandlerOwn(TempObject).OnPrintSettings(TCefBrowserRef.UnWrap(browser), + TCefPrintSettingsRef.UnWrap(settings), + get_defaults <> 0); +end; + +function cef_print_handler_on_print_dialog(self : PCefPrintHandler; + browser : PCefBrowser; + has_selection : Integer; + callback : PCefPrintDialogCallback): Integer; stdcall; +var + TempObject : TObject; + TempResult : boolean; +begin + TempResult := False; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefPrintHandlerOwn) then + TCefPrintHandlerOwn(TempObject).OnPrintDialog(TCefBrowserRef.UnWrap(browser), + has_selection <> 0, + TCefPrintDialogCallbackRef.UnWrap(callback), + TempResult); + + Result := ord(TempResult); +end; + +function cef_print_handler_on_print_job( self : PCefPrintHandler; + browser : PCefBrowser; + const document_name : PCefString; + const pdf_file_path : PCefString; + callback : PCefPrintJobCallback): Integer; stdcall; +var + TempObject : TObject; + TempResult : boolean; +begin + TempResult := False; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefPrintHandlerOwn) then + TCefPrintHandlerOwn(TempObject).OnPrintJob(TCefBrowserRef.UnWrap(browser), + CefString(document_name), + CefString(pdf_file_path), + TCefPrintJobCallbackRef.UnWrap(callback), + TempResult); + + Result := ord(TempResult); +end; + +procedure cef_print_handler_on_print_reset(self : PCefPrintHandler; + browser : PCefBrowser); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefPrintHandlerOwn) then + TCefPrintHandlerOwn(TempObject).OnPrintReset(TCefBrowserRef.UnWrap(browser)); +end; + +function cef_print_handler_get_pdf_paper_size(self : PCefPrintHandler; + device_units_per_inch : Integer): TCefSize; stdcall; +var + TempObject : TObject; + TempSize : TCefSize; +begin + TempObject := CefGetObject(self); + TempSize.Width := 0; + TempSize.Height := 0; + + if (TempObject <> nil) and (TempObject is TCefPrintHandlerOwn) then + TCefPrintHandlerOwn(TempObject).GetPDFPaperSize(device_units_per_inch, TempSize); + + Result := TempSize; +end; + +constructor TCefPrintHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefPrintHandler)); + + with PCefPrintHandler(FData)^ do + begin + on_print_start := {$IFDEF FPC}@{$ENDIF}cef_print_handler_on_print_start; + on_print_settings := {$IFDEF FPC}@{$ENDIF}cef_print_handler_on_print_settings; + on_print_dialog := {$IFDEF FPC}@{$ENDIF}cef_print_handler_on_print_dialog; + on_print_job := {$IFDEF FPC}@{$ENDIF}cef_print_handler_on_print_job; + on_print_reset := {$IFDEF FPC}@{$ENDIF}cef_print_handler_on_print_reset; + get_pdf_paper_size := {$IFDEF FPC}@{$ENDIF}cef_print_handler_get_pdf_paper_size; + end; +end; + +procedure TCefPrintHandlerOwn.OnPrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult: boolean); +begin + aResult := False; +end; + +procedure TCefPrintHandlerOwn.OnPrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult: boolean); +begin + aResult := False; +end; + +procedure TCefPrintHandlerOwn.GetPDFPaperSize(deviceUnitsPerInch: Integer; var aResult: TCefSize); +begin + aResult.Width := 0; + aResult.Height := 0; +end; + + +// TCustomPrintHandler + +constructor TCustomPrintHandler.Create(const aCefApp : TCefApplicationCore); +begin + inherited Create; + + FCefApp := aCefApp; +end; + +destructor TCustomPrintHandler.Destroy; +begin + RemoveReferences; + + inherited Destroy; +end; + +procedure TCustomPrintHandler.RemoveReferences; +begin + FCefApp := nil; +end; + +procedure TCustomPrintHandler.OnPrintStart(const browser : ICefBrowser); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnPrintStart(browser); + except + on e : exception do + if CustomExceptionHandler('TCustomPrintHandler.OnPrintStart', e) then raise; + end; +end; + +procedure TCustomPrintHandler.OnPrintSettings(const browser : ICefBrowser; + const settings : ICefPrintSettings; + getDefaults : boolean); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnPrintSettings(browser, settings, getDefaults); + except + on e : exception do + if CustomExceptionHandler('TCustomPrintHandler.OnPrintSettings', e) then raise; + end; +end; + +procedure TCustomPrintHandler.OnPrintDialog(const browser : ICefBrowser; + hasSelection : boolean; + const callback : ICefPrintDialogCallback; + var aResult : boolean); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnPrintDialog(browser, hasSelection, callback, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomPrintHandler.OnPrintDialog', e) then raise; + end; +end; + +procedure TCustomPrintHandler.OnPrintJob(const browser : ICefBrowser; + const documentName : ustring; + const PDFFilePath : ustring; + const callback : ICefPrintJobCallback; + var aResult : boolean); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnPrintJob(browser, documentName, PDFFilePath, callback, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomPrintHandler.OnPrintJob', e) then raise; + end; +end; + +procedure TCustomPrintHandler.OnPrintReset(const browser : ICefBrowser); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnPrintReset(browser); + except + on e : exception do + if CustomExceptionHandler('TCustomPrintHandler.OnPrintReset', e) then raise; + end; +end; + +procedure TCustomPrintHandler.GetPDFPaperSize( deviceUnitsPerInch : Integer; + var aResult : TCefSize); +begin + try + if (FCefApp <> nil) then FCefApp.Internal_OnGetPDFPaperSize(deviceUnitsPerInch, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomPrintHandler.GetPDFPaperSize', e) then raise; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFPrintJobCallback.pas b/windows/src/ext/cef4delphi/source/uCEFPrintJobCallback.pas new file mode 100644 index 0000000000000000000000000000000000000000..1dec190fcad305b62065104a9130de1e53c413fb --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFPrintJobCallback.pas @@ -0,0 +1,81 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFPrintJobCallback; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefPrintJobCallbackRef = class(TCefBaseRefCountedRef, ICefPrintJobCallback) + protected + procedure cont; + + public + class function UnWrap(data: Pointer): ICefPrintJobCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefPrintJobCallbackRef.cont; +begin + PCefPrintJobCallback(FData)^.cont(PCefPrintJobCallback(FData)); +end; + +class function TCefPrintJobCallbackRef.UnWrap(data: Pointer): ICefPrintJobCallback; +begin + if (data <> nil) then + Result := Create(data) as ICefPrintJobCallback + else + Result := nil; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFPrintSettings.pas b/windows/src/ext/cef4delphi/source/uCEFPrintSettings.pas index 8df5de0c75762b3b6ab46ff4decdeaef88ef3840..cacedf59008fb930da04ae0f2b8ff3557f38267f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFPrintSettings.pas +++ b/windows/src/ext/cef4delphi/source/uCEFPrintSettings.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFPrintSettings; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -58,7 +56,6 @@ type protected function IsValid: Boolean; function IsReadOnly: Boolean; - function Copy: ICefPrintSettings; procedure SetOrientation(landscape: Boolean); function IsLandscape: Boolean; procedure SetPrinterPrintableArea(const physicalSizeDeviceUnits: PCefSize; const printableAreaDeviceUnits: PCefRect; landscapeNeedsFlip: Boolean); @@ -90,11 +87,6 @@ uses uCEFMiscFunctions, uCEFLibFunctions; -function TCefPrintSettingsRef.Copy: ICefPrintSettings; -begin - Result := UnWrap(PCefPrintSettings(FData)^.copy(FData)) -end; - function TCefPrintSettingsRef.GetColorModel: TCefColorModel; begin Result := PCefPrintSettings(FData)^.get_color_model(FData); diff --git a/windows/src/ext/cef4delphi/source/uCEFProcessMessage.pas b/windows/src/ext/cef4delphi/source/uCEFProcessMessage.pas index 5b6bb0d29a527a657d5c64620747008489be93c9..3099d522d6f4ea56f5614571abd622f66db9d4e7 100644 --- a/windows/src/ext/cef4delphi/source/uCEFProcessMessage.pas +++ b/windows/src/ext/cef4delphi/source/uCEFProcessMessage.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFProcessMessage; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFRegisterCDMCallback.pas b/windows/src/ext/cef4delphi/source/uCEFRegisterCDMCallback.pas index 0f1011d13f1e11e519e55d7abaa37236daaf17d1..10b742040728fde5805a3bb1c512b69e8a408e53 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRegisterCDMCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRegisterCDMCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,17 +41,15 @@ unit uCEFRegisterCDMCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} interface uses - uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplication; + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplicationCore; type TCefRegisterCDMCallbackOwn = class(TCefBaseRefCountedOwn, ICefRegisterCDMCallback) @@ -74,12 +72,12 @@ type TCefCustomRegisterCDMCallback = class(TCefRegisterCDMCallbackOwn) protected - FCefApp : TCefApplication; + FCefApp : TCefApplicationCore; procedure OnCDMRegistrationComplete(result: TCefCDMRegistrationError; const error_message: ustring); override; public - constructor Create(const aCefApp : TCefApplication); reintroduce; + constructor Create(const aCefApp : TCefApplicationCore); reintroduce; destructor Destroy; override; end; @@ -149,7 +147,7 @@ end; // ************************************************ -constructor TCefCustomRegisterCDMCallback.Create(const aCefApp : TCefApplication); +constructor TCefCustomRegisterCDMCallback.Create(const aCefApp : TCefApplicationCore); begin inherited Create; diff --git a/windows/src/ext/cef4delphi/source/uCEFRegistration.pas b/windows/src/ext/cef4delphi/source/uCEFRegistration.pas new file mode 100644 index 0000000000000000000000000000000000000000..bac6f9f30e691facbad4e00455cb999987a6c603 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFRegistration.pas @@ -0,0 +1,70 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFRegistration; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefRegistrationRef = class(TCefBaseRefCountedRef, ICefRegistration) + public + class function UnWrap(data: Pointer): ICefRegistration; + end; + +implementation + +class function TCefRegistrationRef.UnWrap(data: Pointer): ICefRegistration; +begin + if (data <> nil) then + Result := Create(data) as ICefRegistration + else + Result := nil; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFRenderHandler.pas b/windows/src/ext/cef4delphi/source/uCEFRenderHandler.pas index 46e4052111e2ae341169fa82dfed168e026247d4..7f45df4cf444f21dd76a15cdcd6b057594095012 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRenderHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRenderHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFRenderHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -58,18 +56,19 @@ type protected procedure GetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); virtual; function GetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; - function GetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; + procedure GetViewRect(const browser: ICefBrowser; var rect: TCefRect); virtual; function GetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; virtual; function GetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): 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: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); virtual; - procedure OnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); virtual; + procedure OnAcceleratedPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; shared_handle: Pointer); virtual; function OnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; virtual; procedure OnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); virtual; procedure OnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); virtual; procedure OnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); virtual; procedure OnTextSelectionChanged(const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange); virtual; + procedure OnVirtualKeyboardRequested(const browser: ICefBrowser; input_mode: TCefTextInpuMode); virtual; procedure RemoveReferences; virtual; @@ -83,23 +82,24 @@ type procedure GetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); override; function GetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; override; - function GetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; override; + procedure GetViewRect(const browser: ICefBrowser; var rect: TCefRect); override; function GetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): 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: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); override; - procedure OnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); override; + procedure OnAcceleratedPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; shared_handle: Pointer); override; function GetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; override; function OnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; override; procedure OnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); override; procedure OnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); override; procedure OnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); override; procedure OnTextSelectionChanged(const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange); override; + procedure OnVirtualKeyboardRequested(const browser: ICefBrowser; input_mode: TCefTextInpuMode); override; procedure RemoveReferences; override; public - constructor Create(const events: Pointer); reintroduce; virtual; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; destructor Destroy; override; end; @@ -145,18 +145,21 @@ begin rect^)); end; -function cef_render_handler_get_view_rect(self : PCefRenderHandler; - browser : PCefBrowser; - rect : PCefRect): Integer; stdcall; +procedure cef_render_handler_get_view_rect(self : PCefRenderHandler; + browser : PCefBrowser; + rect : PCefRect); stdcall; var TempObject : TObject; begin - Result := Ord(False); TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefRenderHandlerOwn) then - Result := Ord(TCefRenderHandlerOwn(TempObject).GetViewRect(TCefBrowserRef.UnWrap(browser), - rect^)); + TCefRenderHandlerOwn(TempObject).GetViewRect(TCefBrowserRef.UnWrap(browser), + rect^); + + // CEF needs a rect with valid height and width + if (rect^.width <= 0) then rect^.width := 800; + if (rect^.height <= 0) then rect^.height := 600; end; function cef_render_handler_get_screen_point(self : PCefRenderHandler; @@ -240,21 +243,23 @@ begin height); end; -procedure cef_render_handler_on_cursor_change( self : PCefRenderHandler; - browser : PCefBrowser; - cursor : TCefCursorHandle; - type_ : TCefCursorType; - const custom_cursor_info : PCefCursorInfo); stdcall; +procedure cef_render_handler_on_accelerated_paint( self : PCefRenderHandler; + browser : PCefBrowser; + kind : TCefPaintElementType; + dirtyRectsCount : NativeUInt; + const dirtyRects : PCefRectArray; + shared_handle : Pointer); stdcall; var TempObject : TObject; begin TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefRenderHandlerOwn) then - TCefRenderHandlerOwn(TempObject).OnCursorChange(TCefBrowserRef.UnWrap(browser), - cursor, - type_, - custom_cursor_info); + TCefRenderHandlerOwn(TempObject).OnAcceleratedPaint(TCefBrowserRef.UnWrap(browser), + kind, + dirtyRectsCount, + dirtyRects, + shared_handle); end; function cef_render_handler_start_dragging(self : PCefRenderHandler; @@ -336,6 +341,19 @@ begin selected_range); end; +procedure cef_render_handler_on_virtual_keyboard_requested(self : PCefRenderHandler; + browser : PCefBrowser; + input_mode : TCefTextInpuMode); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefRenderHandlerOwn) then + TCefRenderHandlerOwn(TempObject).OnVirtualKeyboardRequested(TCefBrowserRef.UnWrap(browser), + input_mode); +end; + constructor TCefRenderHandlerOwn.Create; begin inherited CreateData(SizeOf(TCefRenderHandler)); @@ -350,12 +368,13 @@ begin on_popup_show := {$IFDEF FPC}@{$ENDIF}cef_render_handler_on_popup_show; on_popup_size := {$IFDEF FPC}@{$ENDIF}cef_render_handler_on_popup_size; on_paint := {$IFDEF FPC}@{$ENDIF}cef_render_handler_on_paint; - on_cursor_change := {$IFDEF FPC}@{$ENDIF}cef_render_handler_on_cursor_change; + on_accelerated_paint := {$IFDEF FPC}@{$ENDIF}cef_render_handler_on_accelerated_paint; start_dragging := {$IFDEF FPC}@{$ENDIF}cef_render_handler_start_dragging; update_drag_cursor := {$IFDEF FPC}@{$ENDIF}cef_render_handler_update_drag_cursor; on_scroll_offset_changed := {$IFDEF FPC}@{$ENDIF}cef_render_handler_on_scroll_offset_changed; on_ime_composition_range_changed := {$IFDEF FPC}@{$ENDIF}cef_render_handler_on_ime_composition_range_changed; on_text_selection_changed := {$IFDEF FPC}@{$ENDIF}cef_render_handler_on_text_selection_changed; + on_virtual_keyboard_requested := {$IFDEF FPC}@{$ENDIF}cef_render_handler_on_virtual_keyboard_requested; end; end; @@ -379,17 +398,17 @@ begin Result := False; end; -function TCefRenderHandlerOwn.GetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; +procedure TCefRenderHandlerOwn.GetViewRect(const browser: ICefBrowser; var rect: TCefRect); begin - Result := False; + // end; -procedure TCefRenderHandlerOwn.OnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; CursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); +procedure TCefRenderHandlerOwn.OnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); begin // end; -procedure TCefRenderHandlerOwn.OnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); +procedure TCefRenderHandlerOwn.OnAcceleratedPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; shared_handle: Pointer); begin // end; @@ -424,6 +443,12 @@ begin // end; +procedure TCefRenderHandlerOwn.OnVirtualKeyboardRequested(const browser : ICefBrowser; + input_mode : TCefTextInpuMode); +begin + // +end; + function TCefRenderHandlerOwn.OnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; begin Result := False; @@ -441,11 +466,11 @@ end; // TCustomRenderHandler -constructor TCustomRenderHandler.Create(const events: Pointer); +constructor TCustomRenderHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomRenderHandler.Destroy; @@ -489,20 +514,12 @@ begin Result := inherited GetScreenPoint(browser, viewX, viewY, screenX, screenY); end; -function TCustomRenderHandler.GetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; +procedure TCustomRenderHandler.GetViewRect(const browser: ICefBrowser; var rect: TCefRect); begin if (FEvents <> nil) then - Result := IChromiumEvents(FEvents).doOnGetViewRect(browser, rect) + IChromiumEvents(FEvents).doOnGetViewRect(browser, rect) else - Result := inherited GetViewRect(browser, rect); -end; - -procedure TCustomRenderHandler.OnCursorChange(const browser : ICefBrowser; - cursor : TCefCursorHandle; - cursorType : TCefCursorType; - const customCursorInfo : PCefCursorInfo); -begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnCursorChange(browser, cursor, cursorType, customCursorInfo); + inherited GetViewRect(browser, rect); end; procedure TCustomRenderHandler.OnPaint(const browser : ICefBrowser; @@ -516,6 +533,15 @@ begin if (FEvents <> nil) then IChromiumEvents(FEvents).doOnPaint(browser, kind, dirtyRectsCount, dirtyRects, buffer, width, height); end; +procedure TCustomRenderHandler.OnAcceleratedPaint(const browser : ICefBrowser; + kind : TCefPaintElementType; + dirtyRectsCount : NativeUInt; + const dirtyRects : PCefRectArray; + shared_handle : Pointer); +begin + if (FEvents <> nil) then IChromiumEvents(FEvents).doOnAcceleratedPaint(browser, kind, dirtyRectsCount, dirtyRects, shared_handle); +end; + procedure TCustomRenderHandler.OnPopupShow(const browser: ICefBrowser; show: Boolean); begin if (FEvents <> nil) then IChromiumEvents(FEvents).doOnPopupShow(browser, show); @@ -546,6 +572,12 @@ begin if (FEvents <> nil) then IChromiumEvents(FEvents).doOnTextSelectionChanged(browser, selected_text, selected_range); end; +procedure TCustomRenderHandler.OnVirtualKeyboardRequested(const browser : ICefBrowser; + input_mode : TCefTextInpuMode); +begin + if (FEvents <> nil) then IChromiumEvents(FEvents).doOnVirtualKeyboardRequested(browser, input_mode); +end; + function TCustomRenderHandler.OnStartDragging(const browser : ICefBrowser; const dragData : ICefDragData; allowedOps : TCefDragOperations; diff --git a/windows/src/ext/cef4delphi/source/uCEFRenderProcessHandler.pas b/windows/src/ext/cef4delphi/source/uCEFRenderProcessHandler.pas index b7a573259cd390ffff8c4370856afec44eb1f571..ce45afe8e7a135cba7466359ce5467130299553f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRenderProcessHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRenderProcessHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFRenderProcessHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -57,21 +55,22 @@ uses Classes, {$ENDIF} uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFListValue, uCEFBrowser, uCEFFrame, uCEFRequest, - uCEFv8Context, uCEFv8Exception, uCEFv8StackTrace, uCEFDomNode, uCEFProcessMessage, uCEFApplication; + uCEFv8Context, uCEFv8Exception, uCEFv8StackTrace, uCEFDomNode, uCEFProcessMessage, uCEFApplicationCore; type TCefRenderProcessHandlerOwn = class(TCefBaseRefCountedOwn, ICefRenderProcessHandler) protected - procedure OnRenderThreadCreated(const extraInfo: ICefListValue); virtual; abstract; procedure OnWebKitInitialized; virtual; abstract; - procedure OnBrowserCreated(const browser: ICefBrowser); virtual; abstract; + procedure OnBrowserCreated(const browser: ICefBrowser; const extra_info: ICefDictionaryValue); virtual; abstract; procedure OnBrowserDestroyed(const browser: ICefBrowser); virtual; abstract; function GetLoadHandler: ICefLoadHandler; virtual; procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; abstract; procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); virtual; abstract; procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const V8Exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); virtual; abstract; procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); virtual; abstract; - function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual; + function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual; + + procedure RemoveReferences; virtual; abstract; public constructor Create; virtual; @@ -79,20 +78,23 @@ type TCefCustomRenderProcessHandler = class(TCefRenderProcessHandlerOwn) protected - FCefApp : TCefApplication; + FCefApp : TCefApplicationCore; + FLoadHandler : ICefLoadHandler; - procedure OnRenderThreadCreated(const extraInfo: ICefListValue); override; procedure OnWebKitInitialized; override; - procedure OnBrowserCreated(const browser: ICefBrowser); override; + procedure OnBrowserCreated(const browser: ICefBrowser; const extra_info: ICefDictionaryValue); override; procedure OnBrowserDestroyed(const browser: ICefBrowser); override; + function GetLoadHandler: ICefLoadHandler; override; procedure OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override; procedure OnContextReleased(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context); override; procedure OnUncaughtException(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context; const V8Exception: ICefV8Exception; const stackTrace: ICefV8StackTrace); override; procedure OnFocusedNodeChanged(const browser: ICefBrowser; const frame: ICefFrame; const node: ICefDomNode); override; - function OnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage : ICefProcessMessage): Boolean; override; + function OnProcessMessageReceived(const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId; const aMessage : ICefProcessMessage): Boolean; override; + + procedure RemoveReferences; override; public - constructor Create(const aCefApp : TCefApplication); reintroduce; + constructor Create(const aCefApp : TCefApplicationCore); reintroduce; destructor Destroy; override; end; @@ -104,18 +106,7 @@ uses {$ELSE} SysUtils, {$ENDIF} - uCEFMiscFunctions, uCEFLibFunctions, uCEFConstants; - -procedure cef_render_process_handler_on_render_thread_created(self : PCefRenderProcessHandler; - extra_info : PCefListValue); stdcall; -var - TempObject : TObject; -begin - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then - TCefRenderProcessHandlerOwn(TempObject).OnRenderThreadCreated(TCefListValueRef.UnWrap(extra_info)); -end; + uCEFMiscFunctions, uCEFLibFunctions, uCEFConstants, uCEFLoadHandler, uCEFDictionaryValue; procedure cef_render_process_handler_on_web_kit_initialized(self: PCefRenderProcessHandler); stdcall; var @@ -123,19 +114,23 @@ var begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefRenderProcessHandlerOwn) then TCefRenderProcessHandlerOwn(TempObject).OnWebKitInitialized; end; -procedure cef_render_process_handler_on_browser_created(self : PCefRenderProcessHandler; - browser : PCefBrowser); stdcall; +procedure cef_render_process_handler_on_browser_created(self : PCefRenderProcessHandler; + browser : PCefBrowser; + extra_info : PCefDictionaryValue); stdcall; var TempObject : TObject; begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then - TCefRenderProcessHandlerOwn(TempObject).OnBrowserCreated(TCefBrowserRef.UnWrap(browser)); + if (TempObject <> nil) and + (TempObject is TCefRenderProcessHandlerOwn) then + TCefRenderProcessHandlerOwn(TempObject).OnBrowserCreated(TCefBrowserRef.UnWrap(browser), + TCefDictionaryValueRef.UnWrap(extra_info)); end; procedure cef_render_process_handler_on_browser_destroyed(self : PCefRenderProcessHandler; @@ -145,7 +140,8 @@ var begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefRenderProcessHandlerOwn) then TCefRenderProcessHandlerOwn(TempObject).OnBrowserDestroyed(TCefBrowserRef.UnWrap(browser)); end; @@ -156,7 +152,8 @@ begin Result := nil; TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefRenderProcessHandlerOwn) then Result := CefGetData(TCefRenderProcessHandlerOwn(TempObject).GetLoadHandler); end; @@ -169,7 +166,8 @@ var begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefRenderProcessHandlerOwn) then TCefRenderProcessHandlerOwn(TempObject).OnContextCreated(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), TCefv8ContextRef.UnWrap(context)); @@ -184,7 +182,8 @@ var begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefRenderProcessHandlerOwn) then TCefRenderProcessHandlerOwn(TempObject).OnContextReleased(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), TCefv8ContextRef.UnWrap(context)); @@ -201,7 +200,8 @@ var begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefRenderProcessHandlerOwn) then TCefRenderProcessHandlerOwn(TempObject).OnUncaughtException(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), TCefv8ContextRef.UnWrap(context), @@ -218,7 +218,8 @@ var begin TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefRenderProcessHandlerOwn) then TCefRenderProcessHandlerOwn(TempObject).OnFocusedNodeChanged(TCefBrowserRef.UnWrap(browser), TCefFrameRef.UnWrap(frame), TCefDomNodeRef.UnWrap(node)); @@ -226,6 +227,7 @@ end; function cef_render_process_handler_on_process_message_received(self : PCefRenderProcessHandler; browser : PCefBrowser; + frame : PCefFrame; source_process : TCefProcessId; message_ : PCefProcessMessage): Integer; stdcall; var @@ -234,8 +236,10 @@ begin Result := Ord(False); TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefRenderProcessHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefRenderProcessHandlerOwn) then Result := Ord(TCefRenderProcessHandlerOwn(TempObject).OnProcessMessageReceived(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), source_process, TCefProcessMessageRef.UnWrap(message_))); end; @@ -250,7 +254,6 @@ begin with PCefRenderProcessHandler(FData)^ do begin - on_render_thread_created := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_render_thread_created; on_web_kit_initialized := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_web_kit_initialized; on_browser_created := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_browser_created; on_browser_destroyed := {$IFDEF FPC}@{$ENDIF}cef_render_process_handler_on_browser_destroyed; @@ -269,6 +272,7 @@ begin end; function TCefRenderProcessHandlerOwn.OnProcessMessageReceived(const browser : ICefBrowser; + const frame : ICefFrame; sourceProcess : TCefProcessId; const aMessage : ICefProcessMessage): Boolean; begin @@ -279,28 +283,32 @@ end; // TCefCustomRenderProcessHandler -constructor TCefCustomRenderProcessHandler.Create(const aCefApp : TCefApplication); +constructor TCefCustomRenderProcessHandler.Create(const aCefApp : TCefApplicationCore); begin inherited Create; FCefApp := aCefApp; + + if (FCefApp <> nil) and FCefApp.MustCreateLoadHandler then + FLoadHandler := TCustomRenderLoadHandler.Create(FCefApp) + else + FLoadHandler := nil; end; destructor TCefCustomRenderProcessHandler.Destroy; begin - FCefApp := nil; + RemoveReferences; inherited Destroy; end; -procedure TCefCustomRenderProcessHandler.OnRenderThreadCreated(const extraInfo: ICefListValue); +procedure TCefCustomRenderProcessHandler.RemoveReferences; begin - try - if (FCefApp <> nil) then FCefApp.Internal_OnRenderThreadCreated(extraInfo); - except - on e : exception do - if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnRenderThreadCreated', e) then raise; - end; + if (FLoadHandler <> nil) then + FLoadHandler.RemoveReferences; + + FCefApp := nil; + FLoadHandler := nil; end; procedure TCefCustomRenderProcessHandler.OnWebKitInitialized; @@ -313,10 +321,10 @@ begin end; end; -procedure TCefCustomRenderProcessHandler.OnBrowserCreated(const browser: ICefBrowser); +procedure TCefCustomRenderProcessHandler.OnBrowserCreated(const browser: ICefBrowser; const extra_info: ICefDictionaryValue); begin try - if (FCefApp <> nil) then FCefApp.Internal_OnBrowserCreated(browser); + if (FCefApp <> nil) then FCefApp.Internal_OnBrowserCreated(browser, extra_info); except on e : exception do if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnBrowserCreated', e) then raise; @@ -333,6 +341,14 @@ begin end; end; +function TCefCustomRenderProcessHandler.GetLoadHandler: ICefLoadHandler; +begin + if (FLoadHandler <> nil) then + Result := FLoadHandler + else + Result := inherited GetLoadHandler; +end; + procedure TCefCustomRenderProcessHandler.OnContextCreated(const browser : ICefBrowser; const frame : ICefFrame; const context : ICefv8Context); @@ -383,14 +399,15 @@ begin end; end; -function TCefCustomRenderProcessHandler.OnProcessMessageReceived(const browser : ICefBrowser; - sourceProcess : TCefProcessId; - const aMessage : ICefProcessMessage): Boolean; +function TCefCustomRenderProcessHandler.OnProcessMessageReceived(const browser : ICefBrowser; + const frame : ICefFrame; + sourceProcess : TCefProcessId; + const aMessage : ICefProcessMessage): Boolean; begin - Result := inherited OnProcessMessageReceived(browser, sourceProcess, aMessage); + Result := inherited OnProcessMessageReceived(browser, frame, sourceProcess, aMessage); try - if (FCefApp <> nil) then FCefApp.Internal_OnProcessMessageReceived(browser, sourceProcess, aMessage, Result); + if (FCefApp <> nil) then FCefApp.Internal_OnProcessMessageReceived(browser, frame, sourceProcess, aMessage, Result); except on e : exception do if CustomExceptionHandler('TCefCustomRenderProcessHandler.OnProcessMessageReceived', e) then raise; diff --git a/windows/src/ext/cef4delphi/source/uCEFRequest.pas b/windows/src/ext/cef4delphi/source/uCEFRequest.pas index ae05318a5a18014064e2a7f9db4a619cae3e3a86..8e5907e1eade7bdc49afb256e4c9c916cebc35d0 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRequest.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRequest.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFRequest; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -68,6 +66,8 @@ type function GetReferrerPolicy: TCefReferrerPolicy; procedure SetPostData(const value: ICefPostData); procedure SetHeaderMap(const HeaderMap: ICefStringMultimap); + function GetHeaderByName(const name: ustring): ustring; + procedure SetHeaderByName(const name, value: ustring; overwrite: boolean); function GetFlags: TCefUrlRequestFlags; procedure SetFlags(flags: TCefUrlRequestFlags); function GetFirstPartyForCookies: ustring; @@ -168,6 +168,23 @@ begin PCefRequest(FData)^.set_header_map(PCefRequest(FData), HeaderMap.Handle); end; +function TCefRequestRef.GetHeaderByName(const name: ustring): ustring; +var + TempName : TCefString; +begin + TempName := CefString(name); + Result := CefStringFreeAndGet(PCefRequest(FData)^.get_header_by_name(PCefRequest(FData), @TempName)); +end; + +procedure TCefRequestRef.SetHeaderByName(const name, value: ustring; overwrite: boolean); +var + TempName, TempValue : TCefString; +begin + TempName := CefString(name); + TempValue := CefString(value); + PCefRequest(FData)^.set_header_by_name(PCefRequest(FData), @TempName, @TempValue, ord(overwrite)); +end; + procedure TCefRequestRef.SetMethod(const value: ustring); var TempValue : TCefString; diff --git a/windows/src/ext/cef4delphi/source/uCEFRequestCallback.pas b/windows/src/ext/cef4delphi/source/uCEFRequestCallback.pas index e9c843a35fccdab3b18d42bf72ae6fdaf8980d14..b0058ce2ec57781103b3b9c3cc4128b185ad860b 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRequestCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRequestCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFRequestCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFRequestContext.pas b/windows/src/ext/cef4delphi/source/uCEFRequestContext.pas index f3e21fdf0b83a4d65573d67e9f3da48c09cc1592..ec5b28d96a0619e2628be26c2ec2ccccaf4cbaf3 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRequestContext.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRequestContext.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFRequestContext; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,7 +54,7 @@ uses {$ELSE} Classes, SysUtils, {$ENDIF} - uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFCompletionCallback; type TCefRequestContextRef = class(TCefBaseRefCountedRef, ICefRequestContext) @@ -66,8 +64,8 @@ type function IsGlobal: Boolean; function GetHandler: ICefRequestContextHandler; function GetCachePath: ustring; - function GetDefaultCookieManager(const callback: ICefCompletionCallback): ICefCookieManager; - function GetDefaultCookieManagerProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; + function GetCookieManager(const callback: ICefCompletionCallback): ICefCookieManager; + function GetCookieManagerProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; function RegisterSchemeHandlerFactory(const schemeName, domainName: ustring; const factory: ICefSchemeHandlerFactory): Boolean; function ClearSchemeHandlerFactories: Boolean; procedure PurgePluginListCache(reloadPages: Boolean); @@ -77,28 +75,45 @@ type function CanSetPreference(const name: ustring): Boolean; function SetPreference(const name: ustring; const value: ICefValue; out error: ustring): Boolean; procedure ClearCertificateExceptions(const callback: ICefCompletionCallback); + procedure ClearHttpAuthCredentials(const callback: ICefCompletionCallback); procedure CloseAllConnections(const callback: ICefCompletionCallback); procedure ResolveHost(const origin: ustring; const callback: ICefResolveCallback); - function ResolveHostCached(const origin: ustring; const resolvedIps: TStrings): TCefErrorCode; procedure LoadExtension(const root_directory: ustring; const manifest: ICefDictionaryValue; const handler: ICefExtensionHandler); function DidLoadExtension(const extension_id: ustring): boolean; function HasExtension(const extension_id: ustring): boolean; function GetExtensions(const extension_ids: TStringList): boolean; function GetExtension(const extension_id: ustring): ICefExtension; + function GetMediaRouter: ICefMediaRouter; public class function UnWrap(data: Pointer): ICefRequestContext; class function Global: ICefRequestContext; class function New(const settings: PCefRequestContextSettings; const handler: ICefRequestContextHandler = nil): ICefRequestContext; overload; - class function New(const aCache, aAcceptLanguageList : ustring; aPersistSessionCookies, aPersistUserPreferences, aIgnoreCertificateErrors, aEnableNetSecurityExpiration : boolean; const handler: ICefRequestContextHandler = nil): ICefRequestContext; overload; + class function New(const aCache, aAcceptLanguageList : ustring; aPersistSessionCookies, aPersistUserPreferences, aIgnoreCertificateErrors : boolean; const handler: ICefRequestContextHandler = nil): ICefRequestContext; overload; class function Shared(const other: ICefRequestContext; const handler: ICefRequestContextHandler): ICefRequestContext; end; + TCefClearCertificateExceptionsCompletionCallback = class(TCefCustomCompletionCallback) + protected + procedure OnComplete; override; + end; + + TCefClearHttpAuthCredentialsCompletionCallback = class(TCefCustomCompletionCallback) + protected + procedure OnComplete; override; + end; + + TCefCloseAllConnectionsCompletionCallback = class(TCefCustomCompletionCallback) + protected + procedure OnComplete; override; + end; + implementation uses - uCEFMiscFunctions, uCEFLibFunctions, uCEFValue, uCEFDictionaryValue, uCEFCookieManager, - uCEFCompletionCallback, uCEFRequestContextHandler, uCEFExtension, uCEFStringList; + uCEFMiscFunctions, uCEFLibFunctions, uCEFValue, uCEFDictionaryValue, + uCEFCookieManager, uCEFRequestContextHandler, uCEFExtension, uCEFStringList, + uCEFMediaRouter; function TCefRequestContextRef.ClearSchemeHandlerFactories: Boolean; begin @@ -110,19 +125,26 @@ begin Result := CefStringFreeAndGet(PCefRequestContext(FData)^.get_cache_path(PCefRequestContext(FData))); end; -function TCefRequestContextRef.GetDefaultCookieManager(const callback: ICefCompletionCallback): ICefCookieManager; +function TCefRequestContextRef.GetCookieManager(const callback: ICefCompletionCallback): ICefCookieManager; begin - Result := TCefCookieManagerRef.UnWrap(PCefRequestContext(FData)^.get_default_cookie_manager(PCefRequestContext(FData), CefGetData(callback))); + Result := TCefCookieManagerRef.UnWrap(PCefRequestContext(FData)^.get_cookie_manager(PCefRequestContext(FData), CefGetData(callback))); end; -function TCefRequestContextRef.GetDefaultCookieManagerProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; +function TCefRequestContextRef.GetCookieManagerProc(const callback: TCefCompletionCallbackProc): ICefCookieManager; begin - Result := GetDefaultCookieManager(TCefFastCompletionCallback.Create(callback)); + Result := GetCookieManager(TCefFastCompletionCallback.Create(callback)); end; function TCefRequestContextRef.GetHandler: ICefRequestContextHandler; +var + TempHandler : PCefRequestContextHandler; begin - Result := TCefRequestContextHandlerRef.UnWrap(PCefRequestContext(FData)^.get_handler(PCefRequestContext(FData))); + TempHandler := PCefRequestContext(FData)^.get_handler(PCefRequestContext(FData)); + + if (TempHandler <> nil) then + Result := TCefRequestContextHandlerRef.UnWrap(TempHandler) + else + Result := nil; end; class function TCefRequestContextRef.Global: ICefRequestContext; @@ -145,8 +167,8 @@ begin Result := PCefRequestContext(FData)^.is_sharing_with(PCefRequestContext(FData), CefGetData(other)) <> 0; end; -class function TCefRequestContextRef.New(const settings: PCefRequestContextSettings; - const handler: ICefRequestContextHandler): ICefRequestContext; +class function TCefRequestContextRef.New(const settings : PCefRequestContextSettings; + const handler : ICefRequestContextHandler): ICefRequestContext; begin Result := UnWrap(cef_request_context_create_context(settings, CefGetData(handler))); end; @@ -156,7 +178,6 @@ class function TCefRequestContextRef.New(const aCache : us aPersistSessionCookies : boolean; aPersistUserPreferences : boolean; aIgnoreCertificateErrors : boolean; - aEnableNetSecurityExpiration : boolean; const handler : ICefRequestContextHandler): ICefRequestContext; var TempSettings : TCefRequestContextSettings; @@ -166,7 +187,6 @@ begin TempSettings.persist_session_cookies := Ord(aPersistSessionCookies); TempSettings.persist_user_preferences := Ord(aPersistUserPreferences); TempSettings.ignore_certificate_errors := Ord(aIgnoreCertificateErrors); - TempSettings.enable_net_security_expiration := Ord(aEnableNetSecurityExpiration); TempSettings.accept_language_list := CefString(aAcceptLanguageList); Result := UnWrap(cef_request_context_create_context(@TempSettings, CefGetData(handler))); @@ -212,10 +232,11 @@ function TCefRequestContextRef.SetPreference(const name : ustring; var TempName, TempError : TCefString; begin + CefStringInitialize(@TempError); + TempName := CefString(name); - FillChar(TempError, SizeOf(TempError), 0); Result := PCefRequestContext(FData)^.set_preference(PCefRequestContext(FData), @TempName, CefGetData(value), @TempError) <> 0; - error := CefString(@TempError); + error := CefStringClearAndGet(@TempError); end; procedure TCefRequestContextRef.ClearCertificateExceptions(const callback: ICefCompletionCallback); @@ -223,6 +244,11 @@ begin PCefRequestContext(FData)^.clear_certificate_exceptions(PCefRequestContext(FData), CefGetData(callback)); end; +procedure TCefRequestContextRef.ClearHttpAuthCredentials(const callback: ICefCompletionCallback); +begin + PCefRequestContext(FData)^.clear_http_auth_credentials(PCefRequestContext(FData), CefGetData(callback)); +end; + procedure TCefRequestContextRef.CloseAllConnections(const callback: ICefCompletionCallback); begin PCefRequestContext(FData)^.close_all_connections(PCefRequestContext(FData), CefGetData(callback)); @@ -237,18 +263,6 @@ begin PCefRequestContext(FData)^.resolve_host(PCefRequestContext(FData), @TempOrigin, CefGetData(callback)); end; -function TCefRequestContextRef.ResolveHostCached(const origin : ustring; - const resolvedIps : TStrings): TCefErrorCode; -var - TempSL : ICefStringList; - TempOrigin : TCefString; -begin - TempSL := TCefStringListOwn.Create; - TempOrigin := CefString(origin); - Result := PCefRequestContext(FData)^.resolve_host_cached(PCefRequestContext(FData), @TempOrigin, TempSL.Handle); - TempSL.CopyToStrings(resolvedIps); -end; - procedure TCefRequestContextRef.LoadExtension(const root_directory: ustring; const manifest: ICefDictionaryValue; const handler: ICefExtensionHandler); var TempDir : TCefString; @@ -295,6 +309,11 @@ begin Result := TCefExtensionRef.UnWrap(PCefRequestContext(FData)^.get_extension(PCefRequestContext(FData), @TempID)); end; +function TCefRequestContextRef.GetMediaRouter: ICefMediaRouter; +begin + Result := TCefMediaRouterRef.UnWrap(PCefRequestContext(FData)^.get_media_router(PCefRequestContext(FData))); +end; + function TCefRequestContextRef.RegisterSchemeHandlerFactory(const schemeName : ustring; const domainName : ustring; const factory : ICefSchemeHandlerFactory): Boolean; @@ -323,4 +342,55 @@ begin Result := nil; end; + +// TCefClearCertificateExceptionsCompletionCallback + +procedure TCefClearCertificateExceptionsCompletionCallback.OnComplete; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doCertificateExceptionsCleared; + except + on e : exception do + if CustomExceptionHandler('TCefClearCertificateExceptionsCompletionCallback.OnComplete', e) then raise; + end; + finally + FEvents := nil; + end; +end; + + +// TCefClearHttpAuthCredentialsCompletionCallback + +procedure TCefClearHttpAuthCredentialsCompletionCallback.OnComplete; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doHttpAuthCredentialsCleared; + except + on e : exception do + if CustomExceptionHandler('TCefClearHttpAuthCredentialsCompletionCallback.OnComplete', e) then raise; + end; + finally + FEvents := nil; + end; +end; + + +// TCefCloseAllConnectionsCompletionCallback + +procedure TCefCloseAllConnectionsCompletionCallback.OnComplete; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doAllConnectionsClosed; + except + on e : exception do + if CustomExceptionHandler('TCefCloseAllConnectionsCompletionCallback.OnComplete', e) then raise; + end; + finally + FEvents := nil; + end; +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFRequestContextHandler.pas b/windows/src/ext/cef4delphi/source/uCEFRequestContextHandler.pas index 49c596ff1bb5a27d63c6e2ddae9b6d50837cb88a..6ec28d12f09bf64a9bbd5fd2a09651188652648a 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRequestContextHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRequestContextHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFRequestContextHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -57,8 +55,10 @@ type TCefRequestContextHandlerRef = class(TCefBaseRefCountedRef, ICefRequestContextHandler) protected procedure OnRequestContextInitialized(const request_context: ICefRequestContext); - function GetCookieManager: ICefCookieManager; - function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean; + function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; + procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); + + procedure RemoveReferences; virtual; public class function UnWrap(data: Pointer): ICefRequestContextHandler; @@ -66,28 +66,35 @@ type TCefRequestContextHandlerOwn = class(TCefBaseRefCountedOwn, ICefRequestContextHandler) protected - procedure OnRequestContextInitialized(const request_context: ICefRequestContext); - function GetCookieManager: ICefCookieManager; virtual; - function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; pluginPolicy: PCefPluginPolicy): Boolean; virtual; + procedure OnRequestContextInitialized(const request_context: ICefRequestContext); virtual; + function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; virtual; + procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); virtual; + + procedure RemoveReferences; virtual; public constructor Create; virtual; end; - TCefFastRequestContextHandler = class(TCefRequestContextHandlerOwn) + TCustomRequestContextHandler = class(TCefRequestContextHandlerOwn) protected - FProc: TCefRequestContextHandlerProc; + FEvents : Pointer; - function GetCookieManager: ICefCookieManager; override; + procedure OnRequestContextInitialized(const request_context: ICefRequestContext); override; + function OnBeforePluginLoad(const mimeType, pluginUrl: ustring; isMainFrame : boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy): Boolean; override; + procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); override; public - constructor Create(const proc: TCefRequestContextHandlerProc); reintroduce; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; + procedure BeforeDestruction; override; + procedure RemoveReferences; override; end; implementation uses - uCEFMiscFunctions, uCEFLibFunctions, uCEFCookieManager, uCEFWebPluginInfo, uCEFRequestContext; + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame, uCEFRequest, + uCEFWebPluginInfo, uCEFRequestContext, uCEFResourceRequestHandler; // TCefRequestContextHandlerOwn @@ -102,17 +109,6 @@ begin TCefRequestContextHandlerOwn(TempObject).OnRequestContextInitialized(TCefRequestContextRef.UnWrap(request_context)); end; -function cef_request_context_handler_get_cookie_manager(self: PCefRequestContextHandler): PCefCookieManager; stdcall; -var - TempObject : TObject; -begin - Result := nil; - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRequestContextHandlerOwn) then - Result := CefGetData(TCefRequestContextHandlerOwn(TempObject).GetCookieManager()); -end; - function cef_request_context_handler_on_before_plugin_load( self : PCefRequestContextHandler; const mime_type : PCefString; const plugin_url : PCefString; @@ -122,9 +118,11 @@ function cef_request_context_handler_on_before_plugin_load( self plugin_policy : PCefPluginPolicy): Integer; stdcall; var TempObject : TObject; + TempPolicy : TCefPluginPolicy; begin Result := Ord(False); TempObject := CefGetObject(self); + TempPolicy := plugin_policy^; if (TempObject <> nil) and (TempObject is TCefRequestContextHandlerOwn) then Result := Ord(TCefRequestContextHandlerOwn(TempObject).OnBeforePluginLoad(CefString(mime_type), @@ -132,7 +130,44 @@ begin (is_main_frame <> 0), CefString(top_origin_url), TCefWebPluginInfoRef.UnWrap(plugin_info), - plugin_policy)); + TempPolicy)); + plugin_policy^ := TempPolicy; +end; + +function cef_request_context_handler_get_resource_request_handler( self : PCefRequestContextHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + is_navigation : Integer; + is_download : Integer; + const request_initiator : PCefString; + disable_default_handling : PInteger): PCefResourceRequestHandler; stdcall; +var + TempObject : TObject; + TempDisableDefHandling : Boolean; + TempResourceRequestHandler : ICefResourceRequestHandler; +begin + Result := nil; + TempResourceRequestHandler := nil; + TempObject := CefGetObject(self); + TempDisableDefHandling := disable_default_handling^ <> 0; + + if (TempObject <> nil) and (TempObject is TCefRequestContextHandlerOwn) then + try + TCefRequestContextHandlerOwn(TempObject).GetResourceRequestHandler(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + is_navigation <> 0, + is_download <> 0, + CefString(request_initiator), + TempDisableDefHandling, + TempResourceRequestHandler); + + Result := CefGetData(TempResourceRequestHandler); + disable_default_handling^ := Ord(TempDisableDefHandling); + finally + TempResourceRequestHandler := nil; + end; end; constructor TCefRequestContextHandlerOwn.Create; @@ -142,8 +177,8 @@ begin with PCefRequestContextHandler(FData)^ do begin on_request_context_initialized := {$IFDEF FPC}@{$ENDIF}cef_request_context_handler_on_request_context_initialized; - get_cookie_manager := {$IFDEF FPC}@{$ENDIF}cef_request_context_handler_get_cookie_manager; on_before_plugin_load := {$IFDEF FPC}@{$ENDIF}cef_request_context_handler_on_before_plugin_load; + get_resource_request_handler := {$IFDEF FPC}@{$ENDIF}cef_request_context_handler_get_resource_request_handler; end; end; @@ -152,31 +187,39 @@ begin // end; -function TCefRequestContextHandlerOwn.GetCookieManager: ICefCookieManager; -begin - Result:= nil; -end; - function TCefRequestContextHandlerOwn.OnBeforePluginLoad(const mimeType : ustring; const pluginUrl : ustring; isMainFrame : boolean; const topOriginUrl : ustring; const pluginInfo : ICefWebPluginInfo; - pluginPolicy : PCefPluginPolicy): Boolean; + var pluginPolicy : TCefPluginPolicy): Boolean; begin Result := False; end; -// TCefRequestContextHandlerRef +procedure TCefRequestContextHandlerOwn.GetResourceRequestHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + is_navigation : boolean; + is_download : boolean; + const request_initiator : ustring; + var disable_default_handling : boolean; + var aResourceRequestHandler : ICefResourceRequestHandler); +begin + aResourceRequestHandler := nil; +end; -procedure TCefRequestContextHandlerRef.OnRequestContextInitialized(const request_context: ICefRequestContext); +procedure TCefRequestContextHandlerOwn.RemoveReferences; begin - PCefRequestContextHandler(FData)^.on_request_context_initialized(PCefRequestContextHandler(FData), CefGetData(request_context)); + // end; -function TCefRequestContextHandlerRef.GetCookieManager: ICefCookieManager; + +// TCefRequestContextHandlerRef + +procedure TCefRequestContextHandlerRef.OnRequestContextInitialized(const request_context: ICefRequestContext); begin - Result := TCefCookieManagerRef.UnWrap(PCefRequestContextHandler(FData)^.get_cookie_manager(PCefRequestContextHandler(FData))); + PCefRequestContextHandler(FData)^.on_request_context_initialized(PCefRequestContextHandler(FData), CefGetData(request_context)); end; function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType : ustring; @@ -184,7 +227,7 @@ function TCefRequestContextHandlerRef.OnBeforePluginLoad(const mimeType : us isMainFrame : boolean; const topOriginUrl : ustring; const pluginInfo : ICefWebPluginInfo; - pluginPolicy : PCefPluginPolicy): Boolean; + var pluginPolicy : TCefPluginPolicy): Boolean; var TempType, TempPluginURL, TempOriginURL : TCefString; begin @@ -198,7 +241,45 @@ begin ord(isMainFrame), @TempOriginURL, CefGetData(pluginInfo), - pluginPolicy) <> 0; + @pluginPolicy) <> 0; +end; + + +procedure TCefRequestContextHandlerRef.GetResourceRequestHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + is_navigation : boolean; + is_download : boolean; + const request_initiator : ustring; + var disable_default_handling : boolean; + var aResourceRequestHandler : ICefResourceRequestHandler); +var + TempRequestInitiator : TCefString; + TempDisableDefaultHandling : integer; + TempResourceRequestHandler : PCefResourceRequestHandler; +begin + TempRequestInitiator := CefString(request_initiator); + TempDisableDefaultHandling := ord(disable_default_handling); + TempResourceRequestHandler := PCefRequestContextHandler(FData)^.get_resource_request_handler(PCefRequestContextHandler(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request), + ord(is_navigation), + ord(is_download), + @TempRequestInitiator, + @TempDisableDefaultHandling); + + disable_default_handling := TempDisableDefaultHandling <> 0; + + if (TempResourceRequestHandler <> nil) then + aResourceRequestHandler := TCefResourceRequestHandlerRef.UnWrap(TempResourceRequestHandler) + else + aResourceRequestHandler := nil; +end; + +procedure TCefRequestContextHandlerRef.RemoveReferences; +begin + // end; class function TCefRequestContextHandlerRef.UnWrap(data: Pointer): ICefRequestContextHandler; @@ -209,18 +290,87 @@ begin Result := nil; end; -// TCefFastRequestContextHandler -constructor TCefFastRequestContextHandler.Create(const proc: TCefRequestContextHandlerProc); -begin - FProc := proc; +// TCustomRequestContextHandler +constructor TCustomRequestContextHandler.Create(const events : IChromiumEvents); +begin inherited Create; + + FEvents := Pointer(events); +end; + +procedure TCustomRequestContextHandler.BeforeDestruction; +begin + FEvents := nil; + + inherited BeforeDestruction; end; -function TCefFastRequestContextHandler.GetCookieManager: ICefCookieManager; +procedure TCustomRequestContextHandler.RemoveReferences; begin - Result := FProc(); + FEvents := nil; end; +procedure TCustomRequestContextHandler.OnRequestContextInitialized(const request_context: ICefRequestContext); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnRequestContextInitialized(request_context) + else + inherited OnRequestContextInitialized(request_context); +end; + +function TCustomRequestContextHandler.OnBeforePluginLoad(const mimeType : ustring; + const pluginUrl : ustring; + isMainFrame : boolean; + const topOriginUrl : ustring; + const pluginInfo : ICefWebPluginInfo; + var pluginPolicy : TCefPluginPolicy): Boolean; +begin + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doOnBeforePluginLoad(mimeType, + pluginUrl, + isMainFrame, + topOriginUrl, + pluginInfo, + pluginPolicy) + else + Result := inherited OnBeforePluginLoad(mimeType, + pluginUrl, + isMainFrame, + topOriginUrl, + pluginInfo, + pluginPolicy); +end; + +procedure TCustomRequestContextHandler.GetResourceRequestHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + is_navigation : boolean; + is_download : boolean; + const request_initiator : ustring; + var disable_default_handling : boolean; + var aResourceRequestHandler : ICefResourceRequestHandler); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doGetResourceRequestHandler_ReqCtxHdlr(browser, + frame, + request, + is_navigation, + is_download, + request_initiator, + disable_default_handling, + aResourceRequestHandler) + else + inherited GetResourceRequestHandler(browser, + frame, + request, + is_navigation, + is_download, + request_initiator, + disable_default_handling, + aResourceRequestHandler); +end; + + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFRequestHandler.pas b/windows/src/ext/cef4delphi/source/uCEFRequestHandler.pas index 3d416402944a74b01b48ee5c417cf2d62b67bcc3..06cca360f74662a1d1d8e32fa834b576bca1e855 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRequestHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRequestHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFRequestHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -58,23 +56,15 @@ type protected function OnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; virtual; function OnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; virtual; - function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; virtual; - function GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; virtual; - procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); virtual; - function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; virtual; - function GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; virtual; - procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); virtual; - function GetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual; - function CanGetCookies(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): boolean; virtual; - function CanSetCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie : PCefCookie): boolean; virtual; + procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); virtual; + function GetAuthCredentials(const browser: ICefBrowser; const originUrl: ustring; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual; function OnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; virtual; - function GetCookieManager(const browser: ICefBrowser; const mainUrl: ustring): ICefCookieManager; virtual; - procedure OnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); virtual; function OnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; virtual; function OnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; virtual; procedure OnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); virtual; procedure OnRenderViewReady(const browser: ICefBrowser); virtual; procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); virtual; + procedure OnDocumentAvailableInMainFrame(const browser: ICefBrowser); virtual; procedure RemoveReferences; virtual; @@ -88,28 +78,20 @@ type function OnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; override; function OnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; override; - function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; override; - function GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; override; - procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); override; - function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; override; - function GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; override; - procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); override; - function GetAuthCredentials(const browser: ICefBrowser; const frame: ICefFrame; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; override; - function CanGetCookies(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): boolean; override; - function CanSetCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie : PCefCookie): boolean; override; + procedure GetResourceRequestHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; is_navigation, is_download: boolean; const request_initiator: ustring; var disable_default_handling: boolean; var aResourceRequestHandler : ICefResourceRequestHandler); override; + function GetAuthCredentials(const browser: ICefBrowser; const originUrl: ustring; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; override; function OnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; override; - procedure OnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); override; function OnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; override; function OnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; override; procedure OnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); override; procedure OnRenderViewReady(const browser: ICefBrowser); override; procedure OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); override; - - procedure RemoveReferences; override; + procedure OnDocumentAvailableInMainFrame(const browser: ICefBrowser); override; public - constructor Create(const events: Pointer); reintroduce; virtual; - destructor Destroy; override; + constructor Create(const events : IChromiumEvents); reintroduce; virtual; + procedure BeforeDestruction; override; + procedure RemoveReferences; override; end; implementation @@ -122,7 +104,7 @@ uses {$ENDIF} uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame, uCEFRequest, uCEFRequestCallback, uCEFResponse, uCEFAuthCallback, uCEFSslInfo, uCEFSelectClientCertificateCallback, uCEFX509Certificate, - uCEFApplication; + uCEFApplicationCore; function cef_request_handler_on_before_browse(self : PCefRequestHandler; browser : PCefBrowser; @@ -164,129 +146,51 @@ begin user_gesture <> 0)); end; -function cef_request_handler_on_before_resource_load(self : PCefRequestHandler; - browser : PCefBrowser; - frame : PCefFrame; - request : PCefRequest; - callback : PCefRequestCallback): TCefReturnValue; stdcall; -var - TempObject : TObject; -begin - Result := RV_CONTINUE; - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then - Result := TCefRequestHandlerOwn(TempObject).OnBeforeResourceLoad(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), - TCefRequestRef.UnWrap(request), - TcefRequestCallbackRef.UnWrap(callback)); -end; - -function cef_request_handler_get_resource_handler(self : PCefRequestHandler; - browser : PCefBrowser; - frame : PCefFrame; - request : PCefRequest): PCefResourceHandler; stdcall; -var - TempObject : TObject; -begin - Result := nil; - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then - Result := CefGetData(TCefRequestHandlerOwn(TempObject).GetResourceHandler(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), - TCefRequestRef.UnWrap(request))); -end; - -procedure cef_request_handler_on_resource_redirect(self : PCefRequestHandler; - browser : PCefBrowser; - frame : PCefFrame; - request : PCefRequest; - response : PCefResponse; - new_url : PCefString); stdcall; +function cef_request_handler_get_resource_request_handler( self : PCefRequestHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + is_navigation : Integer; + is_download : Integer; + const request_initiator : PCefString; + disable_default_handling : PInteger): PCefResourceRequestHandler; stdcall; var - TempURL : ustring; TempObject : TObject; + TempDisableDefHandling : boolean; + TempResourceRequestHandler : ICefResourceRequestHandler; begin - TempURL := CefString(new_url); - TempObject := CefGetObject(self); + Result := nil; + TempResourceRequestHandler := nil; + TempObject := CefGetObject(self); + TempDisableDefHandling := disable_default_handling^ <> 0; if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then - TCefRequestHandlerOwn(TempObject).OnResourceRedirect(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), - TCefRequestRef.UnWrap(request), - TCefResponseRef.UnWrap(response), - TempURL); - - if (TempURL <> '') then CefStringSet(new_url, TempURL); + try + TCefRequestHandlerOwn(TempObject).GetResourceRequestHandler(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + is_navigation <> 0, + is_download <> 0, + CefString(request_initiator), + TempDisableDefHandling, + TempResourceRequestHandler); + + Result := CefGetData(TempResourceRequestHandler); + disable_default_handling^ := Ord(TempDisableDefHandling); + finally + TempResourceRequestHandler := nil; + end; end; -function cef_request_handler_on_resource_response(self : PCefRequestHandler; - browser : PCefBrowser; - frame : PCefFrame; - request : PCefRequest; - response : PCefResponse): Integer; stdcall; -var - TempObject : TObject; -begin - Result := Ord(False); - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then - Result := Ord(TCefRequestHandlerOwn(TempObject).OnResourceResponse(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), - TCefRequestRef.UnWrap(request), - TCefResponseRef.UnWrap(response))); -end; - -function cef_request_handler_get_resource_response_filter(self : PCefRequestHandler; - browser : PCefBrowser; - frame : PCefFrame; - request : PCefRequest; - response : PCefResponse): PCefResponseFilter; stdcall; -var - TempObject : TObject; -begin - Result := nil; - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then - Result := CefGetData(TCefRequestHandlerOwn(TempObject).GetResourceResponseFilter(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), - TCefRequestRef.UnWrap(request), - TCefResponseRef.UnWrap(response))); -end; - -procedure cef_request_handler_on_resource_load_complete(self : PCefRequestHandler; - browser : PCefBrowser; - frame : PCefFrame; - request : PCefRequest; - response : PCefResponse; - status : TCefUrlRequestStatus; - received_content_length : Int64); stdcall; -var - TempObject : TObject; -begin - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then - TCefRequestHandlerOwn(TempObject).OnResourceLoadComplete(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), - TCefRequestRef.UnWrap(request), - TCefResponseRef.UnWrap(response), - status, - received_content_length); -end; - -function cef_request_handler_get_auth_credentials( self : PCefRequestHandler; - browser : PCefBrowser; - frame : PCefFrame; - isProxy : Integer; - const host : PCefString; - port : Integer; - const realm : PCefString; - const scheme : PCefString; - callback : PCefAuthCallback): Integer; stdcall; +function cef_request_handler_get_auth_credentials( self : PCefRequestHandler; + browser : PCefBrowser; + const origin_url : PCefString; + isProxy : Integer; + const host : PCefString; + port : Integer; + const realm : PCefString; + const scheme : PCefString; + callback : PCefAuthCallback): Integer; stdcall; var TempObject : TObject; begin @@ -295,7 +199,7 @@ begin if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then Result := Ord(TCefRequestHandlerOwn(TempObject).GetAuthCredentials(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), + CefString(origin_url), isProxy <> 0, CefString(host), port, @@ -304,40 +208,6 @@ begin TCefAuthCallbackRef.UnWrap(callback))); end; -function cef_request_handler_can_get_cookies(self : PCefRequestHandler; - browser : PCefBrowser; - frame : PCefFrame; - request : PCefRequest): Integer; stdcall; -var - TempObject : TObject; -begin - Result := Ord(True); - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then - Result := Ord(TCefRequestHandlerOwn(TempObject).CanGetCookies(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), - TCefRequestRef.UnWrap(request))); -end; - -function cef_request_handler_can_set_cookie( self : PCefRequestHandler; - browser : PCefBrowser; - frame : PCefFrame; - request : PCefRequest; - const cookie : PCefCookie): Integer; stdcall; -var - TempObject : TObject; -begin - Result := Ord(True); - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then - Result := Ord(TCefRequestHandlerOwn(TempObject).CanSetCookie(TCefBrowserRef.UnWrap(browser), - TCefFrameRef.UnWrap(frame), - TCefRequestRef.UnWrap(request), - cookie)); -end; - function cef_request_handler_on_quota_request( self : PCefRequestHandler; browser : PCefBrowser; const origin_url : PCefString; @@ -356,25 +226,6 @@ begin TCefRequestCallbackRef.UnWrap(callback))); end; -procedure cef_request_handler_on_protocol_execution( self : PCefRequestHandler; - browser : PCefBrowser; - const url : PCefString; - allow_os_execution : PInteger); stdcall; -var - allow : Boolean; - TempObject : TObject; -begin - allow := allow_os_execution^ <> 0; - TempObject := CefGetObject(self); - - if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then - TCefRequestHandlerOwn(TempObject).OnProtocolExecution(TCefBrowserRef.UnWrap(browser), - CefString(url), - allow); - - allow_os_execution^ := Ord(allow); -end; - function cef_request_handler_on_certificate_error( self : PCefRequestHandler; browser : PCefBrowser; cert_error : TCefErrorcode; @@ -432,6 +283,17 @@ begin status); end; +procedure cef_request_handler_on_document_available_in_main_frame(self : PCefRequestHandler; + browser : PCefBrowser); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefRequestHandlerOwn) then + TCefRequestHandlerOwn(TempObject).OnDocumentAvailableInMainFrame(TCefBrowserRef.UnWrap(browser)); +end; + function cef_request_handler_on_select_client_certificate( self : PCefRequestHandler; browser : PCefBrowser; isProxy : integer; @@ -498,60 +360,32 @@ begin with PCefRequestHandler(FData)^ do begin - on_before_browse := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_before_browse; - on_open_urlfrom_tab := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_open_urlfrom_tab; - on_before_resource_load := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_before_resource_load; - get_resource_handler := {$IFDEF FPC}@{$ENDIF}cef_request_handler_get_resource_handler; - on_resource_redirect := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_resource_redirect; - on_resource_response := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_resource_response; - get_resource_response_filter := {$IFDEF FPC}@{$ENDIF}cef_request_handler_get_resource_response_filter; - on_resource_load_complete := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_resource_load_complete; - get_auth_credentials := {$IFDEF FPC}@{$ENDIF}cef_request_handler_get_auth_credentials; - can_get_cookies := {$IFDEF FPC}@{$ENDIF}cef_request_handler_can_get_cookies; - can_set_cookie := {$IFDEF FPC}@{$ENDIF}cef_request_handler_can_set_cookie; - on_quota_request := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_quota_request; - on_protocol_execution := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_protocol_execution; - on_certificate_error := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_certificate_error; - on_select_client_certificate := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_select_client_certificate; - on_plugin_crashed := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_plugin_crashed; - on_render_view_ready := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_render_view_ready; - on_render_process_terminated := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_render_process_terminated; + on_before_browse := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_before_browse; + on_open_urlfrom_tab := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_open_urlfrom_tab; + get_resource_request_handler := {$IFDEF FPC}@{$ENDIF}cef_request_handler_get_resource_request_handler; + get_auth_credentials := {$IFDEF FPC}@{$ENDIF}cef_request_handler_get_auth_credentials; + on_quota_request := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_quota_request; + on_certificate_error := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_certificate_error; + on_select_client_certificate := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_select_client_certificate; + on_plugin_crashed := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_plugin_crashed; + on_render_view_ready := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_render_view_ready; + on_render_process_terminated := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_render_process_terminated; + on_document_available_in_main_frame := {$IFDEF FPC}@{$ENDIF}cef_request_handler_on_document_available_in_main_frame; end; end; -function TCefRequestHandlerOwn.GetAuthCredentials(const browser : ICefBrowser; - const frame : ICefFrame; - isProxy : Boolean; - const host : ustring; - port : Integer; - const realm : ustring; - const scheme : ustring; - const callback : ICefAuthCallback): Boolean; +function TCefRequestHandlerOwn.GetAuthCredentials(const browser : ICefBrowser; + const originUrl : ustring; + isProxy : Boolean; + const host : ustring; + port : Integer; + const realm : ustring; + const scheme : ustring; + const callback : ICefAuthCallback): Boolean; begin Result := False; end; -function TCefRequestHandlerOwn.CanGetCookies(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest): boolean; -begin - Result := True; -end; - -function TCefRequestHandlerOwn.CanSetCookie(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const cookie : PCefCookie): boolean; -begin - Result := True; -end; - -function TCefRequestHandlerOwn.GetCookieManager(const browser : ICefBrowser; - const mainUrl : ustring): ICefCookieManager; -begin - Result := nil; -end; - function TCefRequestHandlerOwn.OnBeforeBrowse(const browser : ICefBrowser; const frame : ICefFrame; const request : ICefRequest; @@ -561,14 +395,6 @@ begin Result := False; end; -function TCefRequestHandlerOwn.OnBeforeResourceLoad(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const callback : ICefRequestCallback): TCefReturnValue; -begin - Result := RV_CONTINUE; -end; - function TCefRequestHandlerOwn.OnCertificateError(const browser : ICefBrowser; certError : TCefErrorcode; const requestUrl : ustring; @@ -598,11 +424,16 @@ begin Result := False; end; -function TCefRequestHandlerOwn.GetResourceHandler(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest): ICefResourceHandler; +procedure TCefRequestHandlerOwn.GetResourceRequestHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + is_navigation : boolean; + is_download : boolean; + const request_initiator : ustring; + var disable_default_handling : boolean; + var aResourceRequestHandler : ICefResourceRequestHandler); begin - Result := nil; + aResourceRequestHandler := nil; end; procedure TCefRequestHandlerOwn.OnPluginCrashed(const browser : ICefBrowser; @@ -611,13 +442,6 @@ begin // end; -procedure TCefRequestHandlerOwn.OnProtocolExecution(const browser : ICefBrowser; - const url : ustring; - out allowOsExecution : Boolean); -begin - // -end; - function TCefRequestHandlerOwn.OnQuotaRequest(const browser : ICefBrowser; const originUrl : ustring; newSize : Int64; @@ -632,42 +456,12 @@ begin // end; -procedure TCefRequestHandlerOwn.OnRenderViewReady(const browser: ICefBrowser); -begin - // -end; - -procedure TCefRequestHandlerOwn.OnResourceRedirect(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - var newUrl : ustring); +procedure TCefRequestHandlerOwn.OnDocumentAvailableInMainFrame(const browser: ICefBrowser); begin // end; -function TCefRequestHandlerOwn.OnResourceResponse(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse): Boolean; -begin - Result := False; -end; - -function TCefRequestHandlerOwn.GetResourceResponseFilter(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse): ICefResponseFilter; -begin - Result := nil; -end; - -procedure TCefRequestHandlerOwn.OnResourceLoadComplete(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - status : TCefUrlRequestStatus; - receivedContentLength : Int64); +procedure TCefRequestHandlerOwn.OnRenderViewReady(const browser: ICefBrowser); begin // end; @@ -679,18 +473,18 @@ end; // TCustomRequestHandler -constructor TCustomRequestHandler.Create(const events: Pointer); +constructor TCustomRequestHandler.Create(const events : IChromiumEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; -destructor TCustomRequestHandler.Destroy; +procedure TCustomRequestHandler.BeforeDestruction; begin - RemoveReferences; + FEvents := nil; - inherited Destroy; + inherited BeforeDestruction; end; procedure TCustomRequestHandler.RemoveReferences; @@ -698,50 +492,19 @@ begin FEvents := nil; end; -function TCustomRequestHandler.GetAuthCredentials(const browser : ICefBrowser; - const frame : ICefFrame; - isProxy : Boolean; - const host : ustring; - port : Integer; - const realm : ustring; - const scheme : ustring; - const callback : ICefAuthCallback): Boolean; +function TCustomRequestHandler.GetAuthCredentials(const browser : ICefBrowser; + const originUrl : ustring; + isProxy : Boolean; + const host : ustring; + port : Integer; + const realm : ustring; + const scheme : ustring; + const callback : ICefAuthCallback): Boolean; begin if (FEvents <> nil) then - Result := IChromiumEvents(FEvents).doOnGetAuthCredentials(browser, frame, isProxy, host, port, realm, scheme, callback) + Result := IChromiumEvents(FEvents).doOnGetAuthCredentials(browser, originUrl, isProxy, host, port, realm, scheme, callback) else - Result := inherited GetAuthCredentials(browser, frame, isProxy, host, port, realm, scheme, callback); -end; - -function TCustomRequestHandler.CanGetCookies(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest): boolean; -begin - if (FEvents <> nil) then - Result := IChromiumEvents(FEvents).doCanGetCookies(browser, frame, request) - else - Result := inherited CanGetCookies(browser, frame, request); -end; - -function TCustomRequestHandler.CanSetCookie(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const cookie : PCefCookie): boolean; -begin - if (FEvents <> nil) then - Result := IChromiumEvents(FEvents).doCanSetCookie(browser, frame, request, cookie) - else - Result := inherited CanSetCookie(browser, frame, request, cookie); -end; - -function TCustomRequestHandler.GetResourceHandler(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest): ICefResourceHandler; -begin - if (FEvents <> nil) then - Result := IChromiumEvents(FEvents).doOnGetResourceHandler(browser, frame, request) - else - Result := inherited GetResourceHandler(browser, frame, request); + Result := inherited GetAuthCredentials(browser, originUrl, isProxy, host, port, realm, scheme, callback); end; function TCustomRequestHandler.OnBeforeBrowse(const browser : ICefBrowser; @@ -756,17 +519,6 @@ begin Result := inherited OnBeforeBrowse(browser, frame, request, user_gesture, isRedirect); end; -function TCustomRequestHandler.OnBeforeResourceLoad(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const callback : ICefRequestCallback): TCefReturnValue; -begin - if (FEvents <> nil) then - Result := IChromiumEvents(FEvents).doOnBeforeResourceLoad(browser, frame, request, callback) - else - Result := inherited OnBeforeResourceLoad(browser, frame, request, callback); -end; - function TCustomRequestHandler.OnCertificateError(const browser : ICefBrowser; certError : TCefErrorcode; const requestUrl : ustring; @@ -791,6 +543,35 @@ begin Result := inherited OnOpenUrlFromTab(browser, frame, targetUrl, targetDisposition, userGesture); end; +procedure TCustomRequestHandler.GetResourceRequestHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + is_navigation : boolean; + is_download : boolean; + const request_initiator : ustring; + var disable_default_handling : boolean; + var aResourceRequestHandler : ICefResourceRequestHandler); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doGetResourceRequestHandler_ReqHdlr(browser, + frame, + request, + is_navigation, + is_download, + request_initiator, + disable_default_handling, + aResourceRequestHandler) + else + inherited GetResourceRequestHandler(browser, + frame, + request, + is_navigation, + is_download, + request_initiator, + disable_default_handling, + aResourceRequestHandler); +end; + function TCustomRequestHandler.OnSelectClientCertificate(const browser : ICefBrowser; isProxy : boolean; const host : ustring; @@ -810,13 +591,6 @@ begin if (FEvents <> nil) then IChromiumEvents(FEvents).doOnPluginCrashed(browser, pluginPath); end; -procedure TCustomRequestHandler.OnProtocolExecution(const browser : ICefBrowser; - const url : ustring; - out allowOsExecution : Boolean); -begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnProtocolExecution(browser, url, allowOsExecution); -end; - function TCustomRequestHandler.OnQuotaRequest(const browser : ICefBrowser; const originUrl : ustring; newSize : Int64; @@ -829,55 +603,21 @@ begin end; procedure TCustomRequestHandler.OnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); -begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnRenderProcessTerminated(browser, status); -end; - -procedure TCustomRequestHandler.OnRenderViewReady(const browser: ICefBrowser); -begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnRenderViewReady(browser); -end; - -procedure TCustomRequestHandler.OnResourceRedirect(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - var newUrl : ustring); -begin - if (FEvents <> nil) then IChromiumEvents(FEvents).doOnResourceRedirect(browser, frame, request, response, newUrl); -end; - -function TCustomRequestHandler.OnResourceResponse(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse): Boolean; begin if (FEvents <> nil) then - Result := IChromiumEvents(FEvents).doOnResourceResponse(browser, frame, request, response) - else - Result := inherited OnResourceResponse(browser, frame, request, response); + IChromiumEvents(FEvents).doOnRenderProcessTerminated(browser, status); end; -function TCustomRequestHandler.GetResourceResponseFilter(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse): ICefResponseFilter; +procedure TCustomRequestHandler.OnDocumentAvailableInMainFrame(const browser: ICefBrowser); begin if (FEvents <> nil) then - Result := IChromiumEvents(FEvents).doOnGetResourceResponseFilter(browser, frame, request, response) - else - Result := inherited GetResourceResponseFilter(browser, frame, request, response); + IChromiumEvents(FEvents).doOnDocumentAvailableInMainFrame(browser); end; -procedure TCustomRequestHandler.OnResourceLoadComplete(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - status : TCefUrlRequestStatus; - receivedContentLength : Int64); +procedure TCustomRequestHandler.OnRenderViewReady(const browser: ICefBrowser); begin if (FEvents <> nil) then - IChromiumEvents(FEvents).doOnResourceLoadComplete(browser, frame, request, response, status, receivedContentLength); + IChromiumEvents(FEvents).doOnRenderViewReady(browser); end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFResolveCallback.pas b/windows/src/ext/cef4delphi/source/uCEFResolveCallback.pas index d0c76e576c580877f3fbc378bfd689cc67809354..d3ef1751b7beead12f1ad5d0470d6d9c8698b3ba 100644 --- a/windows/src/ext/cef4delphi/source/uCEFResolveCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFResolveCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFResolveCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFResourceBundle.pas b/windows/src/ext/cef4delphi/source/uCEFResourceBundle.pas index d9662223b5dea381d07ef1fc4f214197bf058b7a..38feb95dd351f5877a58bda6651e43e4c753e9fc 100644 --- a/windows/src/ext/cef4delphi/source/uCEFResourceBundle.pas +++ b/windows/src/ext/cef4delphi/source/uCEFResourceBundle.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFResourceBundle; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -57,8 +55,8 @@ type TCefResourceBundleRef = class(TCefBaseRefCountedRef, ICefResourceBundle) protected function GetLocalizedString(stringId: Integer): ustring; - function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean; - function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean; + function GetDataResource(resourceId: Integer): ICefBinaryValue; + function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor): ICefBinaryValue; public class function UnWrap(data: Pointer): ICefResourceBundle; class function Global: ICefResourceBundle; @@ -67,29 +65,21 @@ type implementation uses - uCEFMiscFunctions, uCEFLibFunctions; + uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue; -function TCefResourceBundleRef.GetDataResource( resourceId : Integer; - var data : Pointer; - var dataSize : NativeUInt): Boolean; +function TCefResourceBundleRef.GetDataResource(resourceId: Integer): ICefBinaryValue; begin - Result := PCefResourceBundle(FData)^.get_data_resource(PCefResourceBundle(FData), - resourceId, - data, - dataSize) <> 0; + Result := TCefBinaryValueRef.UnWrap(PCefResourceBundle(FData)^.get_data_resource(PCefResourceBundle(FData), + resourceId)); end; -function TCefResourceBundleRef.GetDataResourceForScale( resourceId : Integer; - scaleFactor : TCefScaleFactor; - var data : Pointer; - var dataSize : NativeUInt): Boolean; +function TCefResourceBundleRef.GetDataResourceForScale(resourceId : Integer; + scaleFactor : TCefScaleFactor): ICefBinaryValue; begin - Result := PCefResourceBundle(FData)^.get_data_resource_for_scale(PCefResourceBundle(FData), - resourceId, - scaleFactor, - data, - dataSize) <> 0; + Result := TCefBinaryValueRef.UnWrap(PCefResourceBundle(FData)^.get_data_resource_for_scale(PCefResourceBundle(FData), + resourceId, + scaleFactor)); end; function TCefResourceBundleRef.GetLocalizedString(stringId: Integer): ustring; diff --git a/windows/src/ext/cef4delphi/source/uCEFResourceBundleHandler.pas b/windows/src/ext/cef4delphi/source/uCEFResourceBundleHandler.pas index c1a5401bbb6bc1af4a9c6d6cfb828e8fa7759c94..23a850e4c3fe3dc2f2db9fdad5531302f1ceed23 100644 --- a/windows/src/ext/cef4delphi/source/uCEFResourceBundleHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFResourceBundleHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,17 +41,15 @@ unit uCEFResourceBundleHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} interface uses - uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplication; + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFApplicationCore; type TCefResourceBundleHandlerOwn = class(TCefBaseRefCountedOwn, ICefResourceBundleHandler) @@ -60,20 +58,24 @@ type function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean; virtual; abstract; function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean; virtual; abstract; + procedure RemoveReferences; virtual; abstract; + public constructor Create; virtual; end; TCefCustomResourceBundleHandler = class(TCefResourceBundleHandlerOwn) protected - FCefApp : TCefApplication; + FCefApp : TCefApplicationCore; function GetLocalizedString(stringid: Integer; var stringVal: ustring): Boolean; override; function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean; override; function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean; override; + procedure RemoveReferences; override; + public - constructor Create(const aCefApp : TCefApplication); reintroduce; + constructor Create(const aCefApp : TCefApplicationCore); reintroduce; destructor Destroy; override; end; @@ -97,12 +99,17 @@ begin Result := Ord(False); TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefResourceBundleHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefResourceBundleHandlerOwn) then begin TempString := ''; Result := Ord(TCefResourceBundleHandlerOwn(TempObject).GetLocalizedString(string_id, TempString)); - if (Result <> 0) then string_val^ := CefString(TempString); + if (string_val <> nil) then + begin + CefStringFree(string_val); + string_val^ := CefStringAlloc(TempString); + end; end; end; @@ -116,7 +123,8 @@ begin Result := Ord(False); TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefResourceBundleHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefResourceBundleHandlerOwn) then Result := Ord(TCefResourceBundleHandlerOwn(TempObject).GetDataResource(resource_id, data, data_size)); end; @@ -131,7 +139,8 @@ begin Result := Ord(False); TempObject := CefGetObject(self); - if (TempObject <> nil) and (TempObject is TCefResourceBundleHandlerOwn) then + if (TempObject <> nil) and + (TempObject is TCefResourceBundleHandlerOwn) then Result := Ord(TCefResourceBundleHandlerOwn(TempObject).GetDataResourceForScale(resource_id, scale_factor, data, data_size)); end; @@ -151,7 +160,7 @@ end; // TCefCustomResourceBundleHandler -constructor TCefCustomResourceBundleHandler.Create(const aCefApp : TCefApplication); +constructor TCefCustomResourceBundleHandler.Create(const aCefApp : TCefApplicationCore); begin inherited Create; @@ -160,11 +169,16 @@ end; destructor TCefCustomResourceBundleHandler.Destroy; begin - FCefApp := nil; + RemoveReferences; inherited Destroy; end; +procedure TCefCustomResourceBundleHandler.RemoveReferences; +begin + FCefApp := nil; +end; + function TCefCustomResourceBundleHandler.GetLocalizedString( stringid : Integer; var stringVal : ustring): Boolean; begin diff --git a/windows/src/ext/cef4delphi/source/uCEFResourceHandler.pas b/windows/src/ext/cef4delphi/source/uCEFResourceHandler.pas index 8a36ade9db4a1b0fac475a642384092b1128cb92..50aea679a64bb15605b9307809b07f6a3efcbee4 100644 --- a/windows/src/ext/cef4delphi/source/uCEFResourceHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFResourceHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFResourceHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -54,13 +52,28 @@ uses uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; type + TCefResourceHandlerRef = class(TCefBaseRefCountedRef, ICefResourceHandler) + protected + function open(const request: ICefRequest; var handle_request: boolean; const callback: ICefCallback): boolean; + function ProcessRequest(const request: ICefRequest; const callback: ICefCallback): Boolean; // deprecated + procedure GetResponseHeaders(const response: ICefResponse; out responseLength: Int64; out redirectUrl: ustring); + function skip(bytes_to_skip: int64; var bytes_skipped: Int64; const callback: ICefResourceSkipCallback): boolean; + function read(const data_out: Pointer; bytes_to_read: Integer; var bytes_read: Integer; const callback: ICefResourceReadCallback): boolean; + function ReadResponse(const dataOut: Pointer; bytesToRead: Integer; var bytesRead: Integer; const callback: ICefCallback): Boolean; // deprecated + procedure Cancel; + + public + class function UnWrap(data: Pointer): ICefResourceHandler; + end; + TCefResourceHandlerOwn = class(TCefBaseRefCountedOwn, ICefResourceHandler) protected - function ProcessRequest(const request: ICefRequest; const callback: ICefCallback): Boolean; virtual; + function open(const request: ICefRequest; var handle_request: boolean; const callback: ICefCallback): boolean; virtual; + function ProcessRequest(const request: ICefRequest; const callback: ICefCallback): Boolean; virtual; // deprecated procedure GetResponseHeaders(const response: ICefResponse; out responseLength: Int64; out redirectUrl: ustring); virtual; - function ReadResponse(const dataOut: Pointer; bytesToRead: Integer; var bytesRead: Integer; const callback: ICefCallback): Boolean; virtual; - function CanGetCookie(const cookie: PCefCookie): Boolean; virtual; - function CanSetCookie(const cookie: PCefCookie): Boolean; virtual; + function skip(bytes_to_skip: int64; var bytes_skipped: Int64; const callback: ICefResourceSkipCallback): boolean; virtual; + function read(const data_out: Pointer; bytes_to_read: Integer; var bytes_read: Integer; const callback: ICefResourceReadCallback): boolean; virtual; + function ReadResponse(const dataOut: Pointer; bytesToRead: Integer; var bytesRead: Integer; const callback: ICefCallback): Boolean; virtual; // deprecated procedure Cancel; virtual; public @@ -72,7 +85,31 @@ type implementation uses - uCEFMiscFunctions, uCEFLibFunctions, uCEFCallback, uCEFRequest, uCEFResponse; + uCEFMiscFunctions, uCEFLibFunctions, uCEFCallback, uCEFRequest, uCEFResponse, + uCEFResourceSkipCallback, uCEFResourceReadCallback; + + +// TCefResourceHandlerOwn + +function cef_resource_handler_open(self : PCefResourceHandler; + request : PCefRequest; + handle_request : PInteger; + callback : PCefCallback): Integer; stdcall; +var + TempObject : TObject; + TempHandleRequest : Boolean; +begin + Result := Ord(False); + TempObject := CefGetObject(self); + TempHandleRequest := False; + + if (TempObject <> nil) and (TempObject is TCefResourceHandlerOwn) then + Result := Ord(TCefResourceHandlerOwn(TempObject).Open(TCefRequestRef.UnWrap(request), + TempHandleRequest, + TCefCallbackRef.UnWrap(callback))); + + handle_request^ := Ord(TempHandleRequest); +end; function cef_resource_handler_process_request(self : PCefResourceHandler; request : PCefRequest; @@ -100,53 +137,79 @@ begin TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefResourceHandlerOwn) then - TCefResourceHandlerOwn(TempObject).GetResponseHeaders(TCefResponseRef.UnWrap(response), - response_length^, - TempRedirect); - - if (TempRedirect <> '') then CefStringSet(redirectUrl, TempRedirect); + begin + TCefResourceHandlerOwn(TempObject).GetResponseHeaders(TCefResponseRef.UnWrap(response), + response_length^, + TempRedirect); + CefStringFree(redirectUrl); + if (redirectUrl <> nil) then redirectUrl^ := CefStringAlloc(TempRedirect); + end; end; -function cef_resource_handler_read_response(self : PCefResourceHandler; - data_out : Pointer; - bytes_to_read : Integer; - bytes_read : PInteger; - callback : PCefCallback): Integer; stdcall; +function cef_resource_handler_skip(self : PCefResourceHandler; + bytes_to_skip : int64; + bytes_skipped : PInt64; + callback : PCefResourceSkipCallback): Integer; stdcall; var - TempObject : TObject; + TempObject : TObject; + TempBytesSkipped : int64; begin - Result := Ord(False); - TempObject := CefGetObject(self); + Result := Ord(False); + TempObject := CefGetObject(self); + TempBytesSkipped := bytes_skipped^; if (TempObject <> nil) and (TempObject is TCefResourceHandlerOwn) then - Result := Ord(TCefResourceHandlerOwn(TempObject).ReadResponse(data_out, - bytes_to_read, - bytes_read^, - TCefCallbackRef.UnWrap(callback))); + Result := Ord(TCefResourceHandlerOwn(TempObject).Skip(bytes_to_skip, + TempBytesSkipped, + TCefResourceSkipCallbackRef.UnWrap(callback))); + bytes_skipped^ := TempBytesSkipped; end; -function cef_resource_handler_can_get_cookie( self : PCefResourceHandler; - const cookie : PCefCookie): Integer; stdcall; +function cef_resource_handler_read(self : PCefResourceHandler; + data_out : Pointer; + bytes_to_read : Integer; + bytes_read : PInteger; + callback : PCefResourceReadCallback): Integer; stdcall; var - TempObject : TObject; + + TempObject : TObject; + TempBytesRead : integer; begin - Result := Ord(True); - TempObject := CefGetObject(self); + Result := Ord(False); + TempObject := CefGetObject(self); + TempBytesRead := bytes_read^; if (TempObject <> nil) and (TempObject is TCefResourceHandlerOwn) then - Result := Ord(TCefResourceHandlerOwn(TempObject).CanGetCookie(cookie)); + Result := Ord(TCefResourceHandlerOwn(TempObject).Read(data_out, + bytes_to_read, + TempBytesRead, + TCefResourceReadCallbackRef.UnWrap(callback))); + + + bytes_read^ := TempBytesRead; + end; -function cef_resource_handler_can_set_cookie( self : PCefResourceHandler; - const cookie : PCefCookie): Integer; stdcall; +function cef_resource_handler_read_response(self : PCefResourceHandler; + data_out : Pointer; + bytes_to_read : Integer; + bytes_read : PInteger; + callback : PCefCallback): Integer; stdcall; var - TempObject : TObject; + TempObject : TObject; + TempBytesRead : integer; begin - Result := Ord(True); - TempObject := CefGetObject(self); + Result := Ord(False); + TempObject := CefGetObject(self); + TempBytesRead := bytes_read^; if (TempObject <> nil) and (TempObject is TCefResourceHandlerOwn) then - Result := Ord(TCefResourceHandlerOwn(TempObject).CanSetCookie(cookie)); + Result := Ord(TCefResourceHandlerOwn(TempObject).ReadResponse(data_out, + bytes_to_read, + TempBytesRead, + TCefCallbackRef.UnWrap(callback))); + + bytes_read^ := TempBytesRead; end; procedure cef_resource_handler_cancel(self: PCefResourceHandler); stdcall; @@ -164,16 +227,6 @@ begin // end; -function TCefResourceHandlerOwn.CanGetCookie(const cookie: PCefCookie): Boolean; -begin - Result := True; -end; - -function TCefResourceHandlerOwn.CanSetCookie(const cookie: PCefCookie): Boolean; -begin - Result := True; -end; - constructor TCefResourceHandlerOwn.Create(const browser : ICefBrowser; const frame : ICefFrame; const schemeName : ustring; @@ -183,11 +236,12 @@ begin with PCefResourceHandler(FData)^ do begin + open := {$IFDEF FPC}@{$ENDIF}cef_resource_handler_open; process_request := {$IFDEF FPC}@{$ENDIF}cef_resource_handler_process_request; get_response_headers := {$IFDEF FPC}@{$ENDIF}cef_resource_handler_get_response_headers; + skip := {$IFDEF FPC}@{$ENDIF}cef_resource_handler_skip; + read := {$IFDEF FPC}@{$ENDIF}cef_resource_handler_read; read_response := {$IFDEF FPC}@{$ENDIF}cef_resource_handler_read_response; - can_get_cookie := {$IFDEF FPC}@{$ENDIF}cef_resource_handler_can_get_cookie; - can_set_cookie := {$IFDEF FPC}@{$ENDIF}cef_resource_handler_can_set_cookie; cancel := {$IFDEF FPC}@{$ENDIF}cef_resource_handler_cancel; end; end; @@ -199,6 +253,30 @@ begin // end; +function TCefResourceHandlerOwn.open(const request : ICefRequest; + var handle_request : boolean; + const callback : ICefCallback): boolean; +begin + Result := False; + handle_request := False; +end; + +function TCefResourceHandlerOwn.skip( bytes_to_skip : int64; + var bytes_skipped : Int64; + const callback : ICefResourceSkipCallback): boolean; +begin + Result := False; +end; + +function TCefResourceHandlerOwn.read(const data_out : Pointer; + bytes_to_read : Integer; + var bytes_read : Integer; + const callback : ICefResourceReadCallback): boolean; +begin + bytes_read := -1; + Result := False; +end; + function TCefResourceHandlerOwn.ProcessRequest(const request : ICefRequest; const callback : ICefCallback): Boolean; begin @@ -213,4 +291,91 @@ begin Result := False; end; + +// TCefResourceHandlerRef + +class function TCefResourceHandlerRef.UnWrap(data: Pointer): ICefResourceHandler; +begin + if (data <> nil) then + Result := Create(data) as ICefResourceHandler + else + Result := nil; +end; + +function TCefResourceHandlerRef.open(const request : ICefRequest; + var handle_request : boolean; + const callback : ICefCallback): boolean; +var + TempHandleRequest : integer; +begin + TempHandleRequest := Ord(False); + Result := PCefResourceHandler(FData)^.open(PCefResourceHandler(FData), + CefGetData(request), + @TempHandleRequest, + CefGetData(callback)) <> 0; + handle_request := TempHandleRequest <> 0; +end; + +function TCefResourceHandlerRef.ProcessRequest(const request : ICefRequest; + const callback : ICefCallback): boolean; +begin + Result := PCefResourceHandler(FData)^.process_request(PCefResourceHandler(FData), + CefGetData(request), + CefGetData(callback)) <> 0; +end; + +procedure TCefResourceHandlerRef.GetResponseHeaders(const response : ICefResponse; + out responseLength : Int64; + out redirectUrl : ustring); +var + TempRedirectURL : TCefString; +begin + TempRedirectURL := CefString(redirectUrl); + PCefResourceHandler(FData)^.get_response_headers(PCefResourceHandler(FData), + CefGetData(response), + @responseLength, + @TempRedirectURL); + redirectUrl := CefString(@TempRedirectURL); +end; + +function TCefResourceHandlerRef.skip( bytes_to_skip : int64; + var bytes_skipped : Int64; + const callback : ICefResourceSkipCallback): boolean; +begin + Result := PCefResourceHandler(FData)^.skip(PCefResourceHandler(FData), + bytes_to_skip, + @bytes_skipped, + CefGetData(callback)) <> 0; +end; + +function TCefResourceHandlerRef.read(const data_out : Pointer; + bytes_to_read : Integer; + var bytes_read : Integer; + const callback : ICefResourceReadCallback): boolean; +begin + Result := PCefResourceHandler(FData)^.read(PCefResourceHandler(FData), + data_out, + bytes_to_read, + @bytes_read, + CefGetData(callback)) <> 0; +end; + +function TCefResourceHandlerRef.ReadResponse(const dataOut : Pointer; + bytesToRead : Integer; + var bytesRead : Integer; + const callback : ICefCallback): boolean; +begin + Result := PCefResourceHandler(FData)^.read_response(PCefResourceHandler(FData), + dataOut, + bytesToRead, + @bytesRead, + CefGetData(callback)) <> 0; +end; + +procedure TCefResourceHandlerRef.Cancel; +begin + PCefResourceHandler(FData)^.Cancel(PCefResourceHandler(FData)); +end; + + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFResourceReadCallback.pas b/windows/src/ext/cef4delphi/source/uCEFResourceReadCallback.pas new file mode 100644 index 0000000000000000000000000000000000000000..bde649ea4bab1d6c5d10dc5a1ffa3bd41f23f7fc --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFResourceReadCallback.pas @@ -0,0 +1,81 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFResourceReadCallback; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefResourceReadCallbackRef = class(TCefBaseRefCountedRef, ICefResourceReadCallback) + protected + procedure Cont(bytes_read: int64); + + public + class function UnWrap(data: Pointer): ICefResourceReadCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefResourceReadCallbackRef.Cont(bytes_read: int64); +begin + PCefResourceReadCallback(FData)^.cont(PCefResourceReadCallback(FData), bytes_read); +end; + +class function TCefResourceReadCallbackRef.UnWrap(data: Pointer): ICefResourceReadCallback; +begin + if (data <> nil) then + Result := Create(data) as ICefResourceReadCallback + else + Result := nil; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFResourceRequestHandler.pas b/windows/src/ext/cef4delphi/source/uCEFResourceRequestHandler.pas new file mode 100644 index 0000000000000000000000000000000000000000..fae5b925950bcfbe67ab71068eedf738b5a4a553 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFResourceRequestHandler.pas @@ -0,0 +1,658 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFResourceRequestHandler; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefResourceRequestHandlerRef = class(TCefBaseRefCountedRef, ICefResourceRequestHandler) + protected + procedure GetCookieAccessFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aFilter: ICefCookieAccessFilter); + function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; + procedure GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aResourceHandler : ICefResourceHandler); + procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); + function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; + procedure GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var aResponseFilter: ICefResponseFilter); + procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); + procedure OnProtocolExecution(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var allowOsExecution: Boolean); + + procedure RemoveReferences; + public + class function UnWrap(data: Pointer): ICefResourceRequestHandler; + end; + + TCefResourceRequestHandlerOwn = class(TCefBaseRefCountedOwn, ICefResourceRequestHandler) + protected + procedure GetCookieAccessFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aFilter: ICefCookieAccessFilter); virtual; + function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; virtual; + procedure GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aResourceHandler : ICefResourceHandler); virtual; + procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); virtual; + function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; virtual; + procedure GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var aResponseFilter: ICefResponseFilter); virtual; + procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); virtual; + procedure OnProtocolExecution(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var allowOsExecution: Boolean); virtual; + + procedure RemoveReferences; virtual; + + public + constructor Create; virtual; + end; + + TCustomResourceRequestHandler = class(TCefResourceRequestHandlerOwn) + protected + FEvents : Pointer; + FCookieAccessFilter : ICefCookieAccessFilter; + + procedure GetCookieAccessFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aFilter: ICefCookieAccessFilter); override; + function OnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; override; + procedure GetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var aResourceHandler : ICefResourceHandler); override; + procedure OnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); override; + function OnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; override; + procedure GetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var aResponseFilter: ICefResponseFilter); override; + procedure OnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); override; + procedure OnProtocolExecution(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; var allowOsExecution: Boolean); override; + + procedure InitializeVars; + + public + constructor Create(const events : IChromiumEvents); reintroduce; + procedure BeforeDestruction; override; + procedure RemoveReferences; override; + end; + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser, uCEFFrame, uCEFRequest, uCEFRequestCallback, + uCEFResponse, uCEFResponseFilter, uCEFCookieAccessFilter, uCEFResourceHandler; + + +// TCefResourceRequestHandlerOwn + +function cef_resource_request_handler_get_cookie_access_filter(self : PCefResourceRequestHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest): PCefCookieAccessFilter; stdcall; +var + TempObject : TObject; + TempCookieAccessFilter : ICefCookieAccessFilter; +begin + Result := nil; + TempCookieAccessFilter := nil; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefResourceRequestHandlerOwn) then + try + TCefResourceRequestHandlerOwn(TempObject).GetCookieAccessFilter(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TempCookieAccessFilter); + Result := CefGetData(TempCookieAccessFilter); + finally + TempCookieAccessFilter := nil; + end; +end; + +function cef_resource_request_handler_on_before_resource_load(self : PCefResourceRequestHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + callback : PCefRequestCallback): TCefReturnValue; stdcall; +var + TempObject : TObject; +begin + Result := RV_CONTINUE; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefResourceRequestHandlerOwn) then + Result := TCefResourceRequestHandlerOwn(TempObject).OnBeforeResourceLoad(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TcefRequestCallbackRef.UnWrap(callback)); +end; + +function cef_resource_request_handler_get_resource_handler(self : PCefResourceRequestHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest): PCefResourceHandler; stdcall; +var + TempObject : TObject; + TempResourceHandler : ICefResourceHandler; +begin + Result := nil; + TempResourceHandler := nil; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefResourceRequestHandlerOwn) then + try + TCefResourceRequestHandlerOwn(TempObject).GetResourceHandler(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TempResourceHandler); + Result := CefGetData(TempResourceHandler); + finally + TempResourceHandler := nil; + end; +end; + +procedure cef_resource_request_handler_on_resource_redirect(self : PCefResourceRequestHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + response : PCefResponse; + new_url : PCefString); stdcall; +var + TempURL : ustring; + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefResourceRequestHandlerOwn) then + begin + TempURL := CefStringClearAndGet(new_url); + TCefResourceRequestHandlerOwn(TempObject).OnResourceRedirect(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TCefResponseRef.UnWrap(response), + TempURL); + if (new_url <> nil) then new_url^ := CefStringAlloc(TempURL); + end; +end; + +function cef_resource_request_handler_on_resource_response(self : PCefResourceRequestHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + response : PCefResponse): Integer; stdcall; +var + TempObject : TObject; +begin + Result := Ord(False); + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefResourceRequestHandlerOwn) then + Result := Ord(TCefResourceRequestHandlerOwn(TempObject).OnResourceResponse(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TCefResponseRef.UnWrap(response))); +end; + +function cef_resource_request_handler_get_resource_response_filter(self : PCefResourceRequestHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + response : PCefResponse): PCefResponseFilter; stdcall; +var + TempObject : TObject; + TempResponseFilter : ICefResponseFilter; +begin + Result := nil; + TempResponseFilter := nil; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefResourceRequestHandlerOwn) then + try + TCefResourceRequestHandlerOwn(TempObject).GetResourceResponseFilter(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TCefResponseRef.UnWrap(response), + TempResponseFilter); + Result := CefGetData(TempResponseFilter); + finally + TempResponseFilter := nil; + end; +end; + +procedure cef_resource_request_handler_on_resource_load_complete(self : PCefResourceRequestHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + response : PCefResponse; + status : TCefUrlRequestStatus; + received_content_length : Int64); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefResourceRequestHandlerOwn) then + TCefResourceRequestHandlerOwn(TempObject).OnResourceLoadComplete(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TCefResponseRef.UnWrap(response), + status, + received_content_length); +end; + +procedure cef_resource_request_handler_on_protocol_execution(self : PCefResourceRequestHandler; + browser : PCefBrowser; + frame : PCefFrame; + request : PCefRequest; + allow_os_execution : PInteger); stdcall; +var + TempAllow : Boolean; + TempObject : TObject; +begin + TempAllow := allow_os_execution^ <> 0; + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefResourceRequestHandlerOwn) then + TCefResourceRequestHandlerOwn(TempObject).OnProtocolExecution(TCefBrowserRef.UnWrap(browser), + TCefFrameRef.UnWrap(frame), + TCefRequestRef.UnWrap(request), + TempAllow); + + allow_os_execution^ := Ord(TempAllow); +end; + +constructor TCefResourceRequestHandlerOwn.Create; +begin + inherited CreateData(SizeOf(TCefResourceRequestHandler)); + + with PCefResourceRequestHandler(FData)^ do + begin + get_cookie_access_filter := {$IFDEF FPC}@{$ENDIF}cef_resource_request_handler_get_cookie_access_filter; + on_before_resource_load := {$IFDEF FPC}@{$ENDIF}cef_resource_request_handler_on_before_resource_load; + get_resource_handler := {$IFDEF FPC}@{$ENDIF}cef_resource_request_handler_get_resource_handler; + on_resource_redirect := {$IFDEF FPC}@{$ENDIF}cef_resource_request_handler_on_resource_redirect; + on_resource_response := {$IFDEF FPC}@{$ENDIF}cef_resource_request_handler_on_resource_response; + get_resource_response_filter := {$IFDEF FPC}@{$ENDIF}cef_resource_request_handler_get_resource_response_filter; + on_resource_load_complete := {$IFDEF FPC}@{$ENDIF}cef_resource_request_handler_on_resource_load_complete; + on_protocol_execution := {$IFDEF FPC}@{$ENDIF}cef_resource_request_handler_on_protocol_execution; + end; +end; + +procedure TCefResourceRequestHandlerOwn.GetCookieAccessFilter(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var aFilter : ICefCookieAccessFilter); +begin + aFilter := nil; +end; + +function TCefResourceRequestHandlerOwn.OnBeforeResourceLoad(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const callback : ICefRequestCallback): TCefReturnValue; +begin + Result := RV_CONTINUE; +end; + +procedure TCefResourceRequestHandlerOwn.GetResourceHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var aResourceHandler : ICefResourceHandler); +begin + aResourceHandler := nil; +end; + +procedure TCefResourceRequestHandlerOwn.OnResourceRedirect(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + var newUrl : ustring); +begin + // +end; + +function TCefResourceRequestHandlerOwn.OnResourceResponse(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse): Boolean; +begin + Result := False; +end; + +procedure TCefResourceRequestHandlerOwn.GetResourceResponseFilter(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + var aResponseFilter : ICefResponseFilter); +begin + aResponseFilter := nil; +end; + +procedure TCefResourceRequestHandlerOwn.OnResourceLoadComplete(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + status : TCefUrlRequestStatus; + receivedContentLength : Int64); +begin + // +end; + +procedure TCefResourceRequestHandlerOwn.OnProtocolExecution(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var allowOsExecution : Boolean); +begin + // +end; + +procedure TCefResourceRequestHandlerOwn.RemoveReferences; +begin + // +end; + + +// TCefResourceRequestHandlerRef + +class function TCefResourceRequestHandlerRef.UnWrap(data: Pointer): ICefResourceRequestHandler; +begin + if (data <> nil) then + Result := Create(data) as ICefResourceRequestHandler + else + Result := nil; +end; + +procedure TCefResourceRequestHandlerRef.GetCookieAccessFilter(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var aFilter : ICefCookieAccessFilter); +var + TempCookieAccessFilter : PCefCookieAccessFilter; +begin + TempCookieAccessFilter := PCefResourceRequestHandler(FData)^.get_cookie_access_filter(PCefResourceRequestHandler(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request)); + + if (TempCookieAccessFilter <> nil) then + aFilter := TCefCookieAccessFilterRef.UnWrap(TempCookieAccessFilter) + else + aFilter := nil; +end; + +function TCefResourceRequestHandlerRef.OnBeforeResourceLoad(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const callback : ICefRequestCallback): TCefReturnValue; +begin + Result := PCefResourceRequestHandler(FData)^.on_before_resource_load(PCefResourceRequestHandler(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request), + CefGetData(callback)); +end; + +procedure TCefResourceRequestHandlerRef.GetResourceHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var aResourceHandler : ICefResourceHandler); +var + TempResourceHandler : PCefResourceHandler; +begin + TempResourceHandler := PCefResourceRequestHandler(FData)^.get_resource_handler(PCefResourceRequestHandler(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request)); + + if (TempResourceHandler <> nil) then + aResourceHandler := TCefResourceHandlerRef.UnWrap(TempResourceHandler) + else + aResourceHandler := nil; +end; + +procedure TCefResourceRequestHandlerRef.OnResourceRedirect(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + var newUrl : ustring); +var + TempNewURL : TCefString; +begin + TempNewURL := CefString(newUrl); + PCefResourceRequestHandler(FData)^.on_resource_redirect(PCefResourceRequestHandler(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request), + CefGetData(response), + @TempNewURL); + newUrl := CefString(@TempNewURL); +end; + +function TCefResourceRequestHandlerRef.OnResourceResponse(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse): Boolean; +begin + Result := (PCefResourceRequestHandler(FData)^.on_resource_response(PCefResourceRequestHandler(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request), + CefGetData(response)) <> 0); +end; + +procedure TCefResourceRequestHandlerRef.GetResourceResponseFilter(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + var aResponseFilter : ICefResponseFilter); +var + TempResponseFilter : PCefResponseFilter; +begin + TempResponseFilter := PCefResourceRequestHandler(FData)^.get_resource_response_filter(PCefResourceRequestHandler(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request), + CefGetData(response)); + if (TempResponseFilter <> nil) then + aResponseFilter := TCefResponseFilterRef.UnWrap(TempResponseFilter) + else + aResponseFilter := nil; +end; + +procedure TCefResourceRequestHandlerRef.OnResourceLoadComplete(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + status : TCefUrlRequestStatus; + receivedContentLength : Int64); +begin + PCefResourceRequestHandler(FData)^.on_resource_load_complete(PCefResourceRequestHandler(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request), + CefGetData(response), + status, + receivedContentLength); +end; + +procedure TCefResourceRequestHandlerRef.OnProtocolExecution(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var allowOsExecution : Boolean); +var + TempAllow : integer; +begin + TempAllow := ord(allowOsExecution); + PCefResourceRequestHandler(FData)^.on_protocol_execution(PCefResourceRequestHandler(FData), + CefGetData(browser), + CefGetData(frame), + CefGetData(request), + @TempAllow); + allowOsExecution := TempAllow <> 0; +end; + +procedure TCefResourceRequestHandlerRef.RemoveReferences; +begin + // +end; + + +// TCustomResourceRequestHandler + +constructor TCustomResourceRequestHandler.Create(const events : IChromiumEvents); +begin + inherited Create; + + InitializeVars; + + FEvents := Pointer(events); + + if (events <> nil) and events.MustCreateCookieAccessFilter then + FCookieAccessFilter := TCustomCookieAccessFilter.Create(events); +end; + +procedure TCustomResourceRequestHandler.BeforeDestruction; +begin + InitializeVars; + + inherited BeforeDestruction; +end; + +procedure TCustomResourceRequestHandler.RemoveReferences; +begin + FEvents := nil; + + if (FCookieAccessFilter <> nil) then FCookieAccessFilter.RemoveReferences; +end; + +procedure TCustomResourceRequestHandler.InitializeVars; +begin + FCookieAccessFilter := nil; + FEvents := nil; +end; + +procedure TCustomResourceRequestHandler.GetCookieAccessFilter(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var aFilter : ICefCookieAccessFilter); +begin + if (FCookieAccessFilter <> nil) then + aFilter := FCookieAccessFilter + else + aFilter := nil; +end; + +function TCustomResourceRequestHandler.OnBeforeResourceLoad(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const callback : ICefRequestCallback): TCefReturnValue; +begin + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doOnBeforeResourceLoad(browser, frame, request, callback) + else + Result := inherited OnBeforeResourceLoad(browser, frame, request, callback); +end; + +procedure TCustomResourceRequestHandler.GetResourceHandler(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var aResourceHandler : ICefResourceHandler); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnGetResourceHandler(browser, frame, request, aResourceHandler) + else + inherited GetResourceHandler(browser, frame, request, aResourceHandler); +end; + +procedure TCustomResourceRequestHandler.OnResourceRedirect(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + var newUrl : ustring); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnResourceRedirect(browser, frame, request, response, newUrl); +end; + +function TCustomResourceRequestHandler.OnResourceResponse(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse): Boolean; +begin + if (FEvents <> nil) then + Result := IChromiumEvents(FEvents).doOnResourceResponse(browser, frame, request, response) + else + Result := inherited OnResourceResponse(browser, frame, request, response); +end; + +procedure TCustomResourceRequestHandler.GetResourceResponseFilter(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + var aResponseFilter : ICefResponseFilter); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnGetResourceResponseFilter(browser, frame, request, response, aResponseFilter) + else + inherited GetResourceResponseFilter(browser, frame, request, response, aResponseFilter); +end; + +procedure TCustomResourceRequestHandler.OnResourceLoadComplete(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + const response : ICefResponse; + status : TCefUrlRequestStatus; + receivedContentLength : Int64); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnResourceLoadComplete(browser, frame, request, response, status, receivedContentLength); +end; + +procedure TCustomResourceRequestHandler.OnProtocolExecution(const browser : ICefBrowser; + const frame : ICefFrame; + const request : ICefRequest; + var allowOsExecution : Boolean); +begin + if (FEvents <> nil) then + IChromiumEvents(FEvents).doOnProtocolExecution(browser, frame, request, allowOsExecution); +end; + + + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFResourceSkipCallback.pas b/windows/src/ext/cef4delphi/source/uCEFResourceSkipCallback.pas new file mode 100644 index 0000000000000000000000000000000000000000..7b4dc7f548eebb3413c5556ec772259dc2557431 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFResourceSkipCallback.pas @@ -0,0 +1,81 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFResourceSkipCallback; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefResourceSkipCallbackRef = class(TCefBaseRefCountedRef, ICefResourceSkipCallback) + protected + procedure Cont(bytes_skipped: int64); + + public + class function UnWrap(data: Pointer): ICefResourceSkipCallback; + end; + +implementation + +uses + uCEFMiscFunctions, uCEFLibFunctions; + +procedure TCefResourceSkipCallbackRef.Cont(bytes_skipped: int64); +begin + PCefResourceSkipCallback(FData)^.cont(PCefResourceSkipCallback(FData), bytes_skipped); +end; + +class function TCefResourceSkipCallbackRef.UnWrap(data: Pointer): ICefResourceSkipCallback; +begin + if (data <> nil) then + Result := Create(data) as ICefResourceSkipCallback + else + Result := nil; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFResponse.pas b/windows/src/ext/cef4delphi/source/uCEFResponse.pas index 6476426880add4e0b58b16ace4b98a77488efe1e..e0786c39bfe0c54d92b1b68c20f5e1be0cfffff7 100644 --- a/windows/src/ext/cef4delphi/source/uCEFResponse.pas +++ b/windows/src/ext/cef4delphi/source/uCEFResponse.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFResponse; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -65,7 +63,10 @@ type procedure SetStatusText(const StatusText: ustring); function GetMimeType: ustring; procedure SetMimeType(const mimetype: ustring); - function GetHeader(const name: ustring): ustring; + function GetCharset: ustring; + procedure SetCharset(const charset: ustring); + function GetHeaderByName(const name: ustring): ustring; + procedure SetHeaderByName(const name, value: ustring; overwrite: boolean); procedure GetHeaderMap(const headerMap: ICefStringMultimap); procedure SetHeaderMap(const headerMap: ICefStringMultimap); function GetURL: ustring; @@ -92,12 +93,21 @@ begin Result := PCefResponse(FData)^.get_error(FData); end; -function TCefResponseRef.GetHeader(const name: ustring): ustring; +function TCefResponseRef.GetHeaderByName(const name: ustring): ustring; var TempName : TCefString; begin TempName := CefString(name); - Result := CefStringFreeAndGet(PCefResponse(FData)^.get_header(PCefResponse(FData), @TempName)); + Result := CefStringFreeAndGet(PCefResponse(FData)^.get_header_by_name(PCefResponse(FData), @TempName)); +end; + +procedure TCefResponseRef.SetHeaderByName(const name, value: ustring; overwrite: boolean); +var + TempName, TempValue : TCefString; +begin + TempName := CefString(name); + TempValue := CefString(value); + PCefResponse(FData)^.set_header_by_name(PCefResponse(FData), @TempName, @TempValue, ord(overwrite)); end; procedure TCefResponseRef.GetHeaderMap(const headerMap: ICefStringMultimap); @@ -143,6 +153,19 @@ begin PCefResponse(FData)^.set_mime_type(PCefResponse(FData), @TempType); end; +function TCefResponseRef.GetCharset: ustring; +begin + Result := CefStringFreeAndGet(PCefResponse(FData)^.get_charset(PCefResponse(FData))); +end; + +procedure TCefResponseRef.SetCharset(const charset: ustring); +var + TempCharset : TCefString; +begin + TempCharset := CefString(charset); + PCefResponse(FData)^.set_charset(PCefResponse(FData), @TempCharset); +end; + procedure TCefResponseRef.SetStatus(status: Integer); begin PCefResponse(FData)^.set_status(PCefResponse(FData), status); diff --git a/windows/src/ext/cef4delphi/source/uCEFResponseFilter.pas b/windows/src/ext/cef4delphi/source/uCEFResponseFilter.pas index acff12178deeac5b335dcd340df4fe15e59371f7..0bf21e29cddc8a6976d6154f0ba966aada9680de 100644 --- a/windows/src/ext/cef4delphi/source/uCEFResponseFilter.pas +++ b/windows/src/ext/cef4delphi/source/uCEFResponseFilter.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFResponseFilter; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -57,6 +55,14 @@ type TOnFilterEvent = procedure(Sender: TObject; data_in: Pointer; data_in_size: NativeUInt; var data_in_read: NativeUInt; data_out: Pointer; data_out_size : NativeUInt; var data_out_written: NativeUInt; var aResult : TCefResponseFilterStatus) of object; TOnInitFilterEvent = procedure(Sender: TObject; var aResult : boolean) of object; + TCefResponseFilterRef = class(TCefBaseRefCountedRef, ICefResponseFilter) + protected + function InitFilter: Boolean; virtual; + function Filter(data_in: Pointer; data_in_size: NativeUInt; var data_in_read: NativeUInt; data_out: Pointer; data_out_size : NativeUInt; var data_out_written: NativeUInt): TCefResponseFilterStatus; virtual; + + public + class function UnWrap(data: Pointer): ICefResponseFilter; + end; TCefResponseFilterOwn = class(TCefBaseRefCountedOwn, ICefResponseFilter) protected @@ -164,4 +170,35 @@ begin end; +// TCefResponseFilterRef + +class function TCefResponseFilterRef.UnWrap(data: Pointer): ICefResponseFilter; +begin + if (data <> nil) then + Result := Create(data) as ICefResponseFilter + else + Result := nil; +end; + +function TCefResponseFilterRef.InitFilter: Boolean; +begin + Result := PCefResponseFilter(FData)^.init_filter(PCefResponseFilter(FData)) <> 0; +end; + +function TCefResponseFilterRef.Filter( data_in : Pointer; + data_in_size : NativeUInt; + var data_in_read : NativeUInt; + data_out : Pointer; + data_out_size : NativeUInt; + var data_out_written : NativeUInt) : TCefResponseFilterStatus; +begin + Result := PCefResponseFilter(FData)^.filter(PCefResponseFilter(FData), + data_in, + data_in_size, + data_in_read, + data_out, + data_out_size, + data_out_written); +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFRunContextMenuCallback.pas b/windows/src/ext/cef4delphi/source/uCEFRunContextMenuCallback.pas index c20341dc5e8ffda7abb024e418fb8caf0de87caa..2d861f26f3708357a68cf7f22a95b34ab9cb69ea 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRunContextMenuCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRunContextMenuCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFRunContextMenuCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFRunFileDialogCallback.pas b/windows/src/ext/cef4delphi/source/uCEFRunFileDialogCallback.pas index 241553c63595b8ca5fd8724bd45d401a3056dc4e..6a0d5565241a394155e991d4283111a1bd569937 100644 --- a/windows/src/ext/cef4delphi/source/uCEFRunFileDialogCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFRunFileDialogCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFRunFileDialogCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFSSLStatus.pas b/windows/src/ext/cef4delphi/source/uCEFSSLStatus.pas index 74f5a5517e30a6c8191252cce35e61983d502a7a..ea52d920167ee8c98cae4e942758ede5030ec364 100644 --- a/windows/src/ext/cef4delphi/source/uCEFSSLStatus.pas +++ b/windows/src/ext/cef4delphi/source/uCEFSSLStatus.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFSSLStatus; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFSchemeHandlerFactory.pas b/windows/src/ext/cef4delphi/source/uCEFSchemeHandlerFactory.pas index e5b108fcf28f1309741c89a6dfc3deabd7896d5a..fdd534a0cf05f5676278a394de3aad7887ac8285 100644 --- a/windows/src/ext/cef4delphi/source/uCEFSchemeHandlerFactory.pas +++ b/windows/src/ext/cef4delphi/source/uCEFSchemeHandlerFactory.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFSchemeHandlerFactory; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFSchemeRegistrar.pas b/windows/src/ext/cef4delphi/source/uCEFSchemeRegistrar.pas index 185c5771cf6b220f2b3818e4bd0e12208efeddf5..07655ac6397bc98d51f8dd701884040c70faa760 100644 --- a/windows/src/ext/cef4delphi/source/uCEFSchemeRegistrar.pas +++ b/windows/src/ext/cef4delphi/source/uCEFSchemeRegistrar.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFSchemeRegistrar; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,7 +54,7 @@ uses type TCefSchemeRegistrarRef = class(TCEFBaseScopedWrapperRef) public - function AddCustomScheme(const schemeName: ustring; IsStandard, IsLocal, IsDisplayIsolated, IsSecure, IsCorsEnabled, IsCSPBypassing: Boolean): Boolean; + function AddCustomScheme(const schemeName: ustring; options : TCefSchemeOptions): Boolean; end; implementation @@ -64,25 +62,15 @@ implementation uses uCEFMiscFunctions; -function TCefSchemeRegistrarRef.AddCustomScheme(const schemeName : ustring; - IsStandard : Boolean; - IsLocal : Boolean; - IsDisplayIsolated : Boolean; - IsSecure : Boolean; - IsCorsEnabled : Boolean; - IsCSPBypassing : Boolean): Boolean; +function TCefSchemeRegistrarRef.AddCustomScheme(const schemeName : ustring; + options : TCefSchemeOptions): Boolean; var TempName : TCefString; begin TempName := CefString(schemeName); Result := PCefSchemeRegistrar(FData)^.add_custom_scheme(PCefSchemeRegistrar(FData), @TempName, - Ord(IsStandard), - Ord(IsLocal), - Ord(IsDisplayIsolated), - Ord(isSecure), - Ord(IsCorsEnabled), - Ord(IsCSPBypassing)) <> 0; + options) <> 0; end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFScrollView.pas b/windows/src/ext/cef4delphi/source/uCEFScrollView.pas new file mode 100644 index 0000000000000000000000000000000000000000..af98a1e0606e68e4ed163b701fd03786a58dcaac --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFScrollView.pas @@ -0,0 +1,140 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFScrollView; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFView; + +type + TCefScrollViewRef = class(TCefViewRef, ICefScrollView) + protected + procedure SetContentView(const view: ICefView); + function GetContentView : ICefView; + function GetVisibleContentRect : TCefRect; + function HasHorizontalScrollbar : boolean; + function GetHorizontalScrollbarHeight : Integer; + function HasVerticalScrollbar : boolean; + function GetVerticalScrollbarWidth : Integer; + + public + class function UnWrap(data: Pointer): ICefScrollView; + class function CreateScrollView(const delegate: ICefViewDelegate): ICefScrollView; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions; + +procedure TCefScrollViewRef.SetContentView(const view: ICefView); +begin + PCefScrollView(FData)^.set_content_view(PCefScrollView(FData), + CefGetData(view)); +end; + +function TCefScrollViewRef.GetContentView : ICefView; +begin + Result := TCefViewRef.UnWrap(PCefScrollView(FData)^.get_content_view(PCefScrollView(FData))); +end; + +function TCefScrollViewRef.GetVisibleContentRect : TCefRect; +begin + Result := PCefScrollView(FData)^.get_visible_content_rect(PCefScrollView(FData)); +end; + +function TCefScrollViewRef.HasHorizontalScrollbar : boolean; +begin + Result := (PCefScrollView(FData)^.has_horizontal_scrollbar(PCefScrollView(FData)) <> 0); +end; + +function TCefScrollViewRef.GetHorizontalScrollbarHeight : Integer; +begin + Result := PCefScrollView(FData)^.get_horizontal_scrollbar_height(PCefScrollView(FData)); +end; + +function TCefScrollViewRef.HasVerticalScrollbar : boolean; +begin + Result := (PCefScrollView(FData)^.has_vertical_scrollbar(PCefScrollView(FData)) <> 0); +end; + +function TCefScrollViewRef.GetVerticalScrollbarWidth : Integer; +begin + Result := PCefScrollView(FData)^.get_vertical_scrollbar_width(PCefScrollView(FData)); +end; + +class function TCefScrollViewRef.UnWrap(data: Pointer): ICefScrollView; +begin + if (data <> nil) then + Result := Create(data) as ICefScrollView + else + Result := nil; +end; + +class function TCefScrollViewRef.CreateScrollView(const delegate: ICefViewDelegate): ICefScrollView; +var + TempScrollView : PCefScrollView; +begin + Result := nil; + + if (delegate <> nil) then + begin + TempScrollView := cef_scroll_view_create(CefGetData(delegate)); + + if (TempScrollView <> nil) then + Result := Create(TempScrollView) as ICefScrollView; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFScrollViewComponent.pas b/windows/src/ext/cef4delphi/source/uCEFScrollViewComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..4e0df3fb89df120bd984b703472f4f066de1c066 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFScrollViewComponent.pas @@ -0,0 +1,242 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFScrollViewComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents, uCEFViewComponent; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFScrollViewComponent = class(TCEFViewComponent) + protected + FScrollView : ICefScrollView; + + procedure DestroyView; override; + procedure Initialize; override; + + function GetInitialized : boolean; override; + function GetAsView : ICefView; override; + function GetAsScrollView : ICefScrollView; override; + function GetContentView : ICefView; + function GetVisibleContentRect : TCefRect; + function GetHasHorizontalScrollbar : boolean; + function GetHorizontalScrollbarHeight : Integer; + function GetHasVerticalScrollbar : boolean; + function GetVerticalScrollbarWidth : Integer; + + procedure SetContentView(const view: ICefView); + + // ICefViewDelegateEvents + procedure doCreateCustomView; override; + + public + procedure CreateScrollView; + + property ContentView : ICefView read GetContentView write SetContentView; + property VisibleContentRect : TCefRect read GetVisibleContentRect; + property HorizontalScrollbarHeight : Integer read GetHorizontalScrollbarHeight; + property VerticalScrollbarWidth : Integer read GetVerticalScrollbarWidth; + property HasHorizontalScrollbar : boolean read GetHasHorizontalScrollbar; + property HasVerticalScrollbar : boolean read GetHasVerticalScrollbar; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + uCEFScrollView, uCEFMiscFunctions, uCEFViewDelegate; + +procedure TCEFScrollViewComponent.CreateScrollView; +begin + CreateView; +end; + +procedure TCEFScrollViewComponent.doCreateCustomView; +var + TempDelegate : ICefViewDelegate; +begin + if (FScrollView = nil) then + try + TempDelegate := TCustomViewDelegate.Create(self); + FScrollView := TCefScrollViewRef.CreateScrollView(TempDelegate); + finally + TempDelegate := nil; + end; +end; + +procedure TCEFScrollViewComponent.Initialize; +begin + inherited Initialize; + + FScrollView := nil; +end; + +procedure TCEFScrollViewComponent.DestroyView; +begin + FScrollView := nil; +end; + +function TCEFScrollViewComponent.GetInitialized : boolean; +begin + Result := (FScrollView <> nil); +end; + +function TCEFScrollViewComponent.GetAsView : ICefView; +begin + Result := FScrollView as ICefView; +end; + +function TCEFScrollViewComponent.GetAsScrollView : ICefScrollView; +begin + Result := FScrollView; +end; + +procedure TCEFScrollViewComponent.SetContentView(const view: ICefView); +begin + if Initialized then FScrollView.SetContentView(view); +end; + +function TCEFScrollViewComponent.GetContentView : ICefView; +begin + if Initialized then + Result := FScrollView.GetContentView + else + Result := nil; +end; + +function TCEFScrollViewComponent.GetVisibleContentRect : TCefRect; +var + TempRect : TCefRect; +begin + if Initialized then + TempRect := FScrollView.GetVisibleContentRect + else + begin + TempRect.x := 0; + TempRect.y := 0; + TempRect.width := 0; + TempRect.height := 0; + end; + + Result := TempRect; +end; + +function TCEFScrollViewComponent.GetHasHorizontalScrollbar : boolean; +begin + Result := Initialized and FScrollView.HasHorizontalScrollbar; +end; + +function TCEFScrollViewComponent.GetHorizontalScrollbarHeight : Integer; +begin + if Initialized then + Result := FScrollView.GetHorizontalScrollbarHeight + else + Result := 0; +end; + +function TCEFScrollViewComponent.GetHasVerticalScrollbar : boolean; +begin + Result := Initialized and FScrollView.HasVerticalScrollbar; +end; + +function TCEFScrollViewComponent.GetVerticalScrollbarWidth : Integer; +begin + if Initialized then + Result := FScrollView.GetVerticalScrollbarWidth + else + Result := 0; +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tcefscrollviewcomponent.lrs} + RegisterComponents('Chromium Views Framework', [TCEFScrollViewComponent]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFSelectClientCertificateCallback.pas b/windows/src/ext/cef4delphi/source/uCEFSelectClientCertificateCallback.pas index 965f1badd19dcdb4c770d8138cecec2797d3901b..2ca6a9e51b829c0b30cf2bc87fc1054b9ddd18fa 100644 --- a/windows/src/ext/cef4delphi/source/uCEFSelectClientCertificateCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFSelectClientCertificateCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFSelectClientCertificateCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFSentinel.pas b/windows/src/ext/cef4delphi/source/uCEFSentinel.pas new file mode 100644 index 0000000000000000000000000000000000000000..8e49986fc9ef80f50416f538c4123060cef12b09 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFSentinel.pas @@ -0,0 +1,320 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + + // Attribution : + // TCEFSentinel icon made by Everaldo Coelho + // https://www.iconfinder.com/icons/17914/castle_fortress_tower_war_icon + // http://www.everaldo.com/ + +unit uCEFSentinel; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} + System.Classes, Vcl.Controls, Vcl.ExtCtrls, System.SysUtils, System.SyncObjs, System.Math, + {$ELSE} + {$IFDEF MSWINDOWS}Windows, {$ENDIF} Classes, Controls, ExtCtrls, SysUtils, SyncObjs, Math, + {$IFDEF FPC} + LCLIntf, LResources, Forms, + {$ELSE} + Messages, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces; + +const + CEFSENTINEL_DEFAULT_DELAYPERPROCMS = 200; + CEFSENTINEL_DEFAULT_MININITDELAYMS = 1500; + CEFSENTINEL_DEFAULT_FINALDELAYMS = 100; + CEFSENTINEL_DEFAULT_MINCHILDPROCS = 2; + CEFSENTINEL_DEFAULT_MAXCHECKCOUNTS = 10; + +type + TSentinelStatus = (ssIdle, ssInitialDelay, ssCheckingChildren, ssClosing); + + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFSentinel = class(TComponent) + protected + {$IFDEF MSWINDOWS} + FCompHandle : HWND; + {$ENDIF} + FStatus : TSentinelStatus; + FStatusCS : TCriticalSection; + FDelayPerProcMs : cardinal; + FMinInitDelayMs : cardinal; + FFinalDelayMs : cardinal; + FMinChildProcs : integer; + FMaxCheckCount : integer; + FCheckCount : integer; + FOnClose : TNotifyEvent; + FTimer : TTimer; + + function GetStatus : TSentinelStatus; + function GetChildProcCount : integer; + + {$IFDEF MSWINDOWS} + procedure WndProc(var aMessage: TMessage); + {$ENDIF} + procedure doStartMsg({$IFDEF MSWINDOWS}var aMessage : TMessage{$ELSE IFDEF FPC}Data: PtrInt{$ENDIF}); virtual; + procedure doCloseMsg({$IFDEF MSWINDOWS}var aMessage : TMessage{$ELSE IFDEF FPC}Data: PtrInt{$ENDIF}); virtual; + function SendCompMessage(aMsg : cardinal) : boolean; + function CanClose : boolean; virtual; + + procedure Timer_OnTimer(Sender: TObject); virtual; + + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure AfterConstruction; override; + procedure Start; virtual; + + property Status : TSentinelStatus read GetStatus; + property ChildProcCount : integer read GetChildProcCount; + + published + property DelayPerProcMs : cardinal read FDelayPerProcMs write FDelayPerProcMs default CEFSENTINEL_DEFAULT_DELAYPERPROCMS; + property MinInitDelayMs : cardinal read FMinInitDelayMs write FMinInitDelayMs default CEFSENTINEL_DEFAULT_MININITDELAYMS; + property FinalDelayMs : cardinal read FFinalDelayMs write FFinalDelayMs default CEFSENTINEL_DEFAULT_FINALDELAYMS; + property MinChildProcs : integer read FMinChildProcs write FMinChildProcs default CEFSENTINEL_DEFAULT_MINCHILDPROCS; + property MaxCheckCount : integer read FMaxCheckCount write FMaxCheckCount default CEFSENTINEL_DEFAULT_MAXCHECKCOUNTS; + + property OnClose : TNotifyEvent read FOnClose write FOnClose; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +implementation + +uses + uCEFLibFunctions, uCEFApplicationCore, uCEFMiscFunctions, uCEFConstants; + +constructor TCEFSentinel.Create(AOwner: TComponent); +begin + inherited Create(aOwner); + + {$IFDEF MSWINDOWS} + FCompHandle := 0; + {$ENDIF} + FDelayPerProcMs := CEFSENTINEL_DEFAULT_DELAYPERPROCMS; + FMinInitDelayMs := CEFSENTINEL_DEFAULT_MININITDELAYMS; + FFinalDelayMs := CEFSENTINEL_DEFAULT_FINALDELAYMS; + FMinChildProcs := CEFSENTINEL_DEFAULT_MINCHILDPROCS; + FMaxCheckCount := CEFSENTINEL_DEFAULT_MAXCHECKCOUNTS; + FOnClose := nil; + FTimer := nil; + FStatusCS := nil; + FStatus := ssIdle; + FCheckCount := 0; +end; + +procedure TCEFSentinel.AfterConstruction; +begin + inherited AfterConstruction; + + if not(csDesigning in ComponentState) then + begin + {$IFDEF MSWINDOWS} + FCompHandle := AllocateHWnd({$IFDEF FPC}@{$ENDIF}WndProc); + {$ENDIF} + + FStatusCS := TCriticalSection.Create; + FTimer := TTimer.Create(nil); + FTimer.Enabled := False; + FTimer.OnTimer := {$IFDEF FPC}@{$ENDIF}Timer_OnTimer; + end; +end; + +destructor TCEFSentinel.Destroy; +begin + try + {$IFDEF MSWINDOWS} + if (FCompHandle <> 0) then + begin + DeallocateHWnd(FCompHandle); + FCompHandle := 0; + end; + {$ENDIF} + + if (FTimer <> nil) then FreeAndNil(FTimer); + if (FStatusCS <> nil) then FreeAndNil(FStatusCS); + finally + inherited Destroy; + end; +end; + +{$IFDEF MSWINDOWS} +procedure TCEFSentinel.WndProc(var aMessage: TMessage); +begin + case aMessage.Msg of + CEF_SENTINEL_START : doStartMsg(aMessage); + CEF_SENTINEL_DOCLOSE : doCloseMsg(aMessage); + + else aMessage.Result := DefWindowProc(FCompHandle, aMessage.Msg, aMessage.WParam, aMessage.LParam); + end; +end; +{$ENDIF} + +procedure TCEFSentinel.doStartMsg({$IFDEF MSWINDOWS}var aMessage : TMessage{$ELSE IFDEF FPC}Data: PtrInt{$ENDIF}); +begin + if (FTimer <> nil) then + begin + FTimer.Interval := max(ChildProcCount * CEFSENTINEL_DEFAULT_DELAYPERPROCMS, FMinInitDelayMs); + FTimer.Enabled := True; + end; +end; + +procedure TCEFSentinel.doCloseMsg({$IFDEF MSWINDOWS}var aMessage : TMessage{$ELSE IFDEF FPC}Data: PtrInt{$ENDIF}); +begin + if assigned(FOnClose) then FOnClose(self); +end; + +function TCEFSentinel.SendCompMessage(aMsg : cardinal) : boolean; +begin + {$IFDEF MSWINDOWS} + Result := (FCompHandle <> 0) and PostMessage(FCompHandle, aMsg, 0, 0); + {$ELSE IFDEF FPC} + case aMsg of + CEF_SENTINEL_START : Application.QueueAsyncCall(@doStartMsg, 0); + CEF_SENTINEL_DOCLOSE : Application.QueueAsyncCall(@doCloseMsg, 0); + end; + {$ENDIF} +end; + +procedure TCEFSentinel.Start; +begin + try + if (FStatusCS <> nil) then FStatusCS.Acquire; + + if (FStatus = ssIdle) then + begin + FStatus := ssInitialDelay; + SendCompMessage(CEF_SENTINEL_START); + end; + finally + if (FStatusCS <> nil) then FStatusCS.Release; + end; +end; + +function TCEFSentinel.GetStatus : TSentinelStatus; +begin + Result := ssIdle; + + if (FStatusCS <> nil) then + try + FStatusCS.Acquire; + Result := FStatus; + finally + FStatusCS.Release; + end; +end; + +function TCEFSentinel.GetChildProcCount : integer; +begin + if (GlobalCEFApp <> nil) then + Result := GlobalCEFApp.ChildProcessesCount + else + Result := 0; +end; + +function TCEFSentinel.CanClose : boolean; +begin + Result := (FCheckCount >= FMaxCheckCount) or + (GlobalCEFApp = nil) or + (ChildProcCount <= FMinChildProcs); +end; + +procedure TCEFSentinel.Timer_OnTimer(Sender: TObject); +begin + FTimer.Enabled := False; + + try + if (FStatusCS <> nil) then FStatusCS.Acquire; + + case FStatus of + ssInitialDelay : + if CanClose then + begin + FStatus := ssClosing; + SendCompMessage(CEF_SENTINEL_DOCLOSE); + end + else + begin + FStatus := ssCheckingChildren; + FCheckCount := 0; + FTimer.Interval := FFinalDelayMs; + FTimer.Enabled := True; + end; + + ssCheckingChildren : + if CanClose then + begin + FStatus := ssClosing; + SendCompMessage(CEF_SENTINEL_DOCLOSE); + end + else + begin + inc(FCheckCount); + FTimer.Enabled := True; + end; + end; + finally + if (FStatusCS <> nil) then FStatusCS.Release; + end; +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tcefsentinel.lrs} + RegisterComponents('Chromium', [TCEFSentinel]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFServer.pas b/windows/src/ext/cef4delphi/source/uCEFServer.pas index 8e244630ec5a8720d8153d2ca3c08da076a918ec..7853e2c348e9fcba590d938fb1a598b810e10c05 100644 --- a/windows/src/ext/cef4delphi/source/uCEFServer.pas +++ b/windows/src/ext/cef4delphi/source/uCEFServer.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFServer; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFServerComponent.pas b/windows/src/ext/cef4delphi/source/uCEFServerComponent.pas index 013ea4b6243942b1d4cf28f6f5e8a0a96db3221e..b152c5c884414c0d47d08504d572cda56dddf986 100644 --- a/windows/src/ext/cef4delphi/source/uCEFServerComponent.pas +++ b/windows/src/ext/cef4delphi/source/uCEFServerComponent.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFServerComponent; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -53,9 +51,9 @@ interface uses {$IFDEF DELPHI16_UP} {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, WinApi.ActiveX,{$ENDIF} - System.Classes, Vcl.Controls, Vcl.Graphics, Vcl.Forms, System.Math, + System.Classes, System.Math, {$ELSE} - {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics, ActiveX, Math, + {$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} Classes, Math, {$IFDEF FPC} LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, {$ELSE} @@ -70,6 +68,7 @@ const DEFAULT_CEFSERVER_BACKLOG = 10; type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} TCEFServerComponent = class(TComponent, IServerEvents) protected FHandler : ICefServerHandler; @@ -138,13 +137,40 @@ type procedure Register; {$ENDIF} +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + implementation uses - uCEFLibFunctions, uCEFApplication, uCEFMiscFunctions; + uCEFLibFunctions, uCEFApplicationCore, uCEFMiscFunctions; // For more information about the TCEFServerComponent properties and functions -// read the code comments in the CEF3 source file /include/capi/cef_server_cap.h +// read the code comments in the CEF source file /include/capi/cef_server_cap.h constructor TCEFServerComponent.Create(AOwner: TComponent); begin @@ -294,10 +320,10 @@ begin Result := Initialized and FServer.IsValidConnection(connection_id); end; -procedure TCEFServerComponent.SendHttp200response(connection_id : Integer; - const content_type : ustring; - const data : Pointer; - data_size : NativeUInt); +procedure TCEFServerComponent.SendHttp200response( connection_id : Integer; + const content_type : ustring; + const data : Pointer; + data_size : NativeUInt); begin if Initialized then FServer.SendHttp200response(connection_id, content_type, data, data_size); end; @@ -312,8 +338,8 @@ begin if Initialized then FServer.SendHttp500response(connection_id, error_message); end; -procedure TCEFServerComponent.SendHttpResponse(connection_id : Integer; - response_code : Integer; +procedure TCEFServerComponent.SendHttpResponse( connection_id : Integer; + response_code : Integer; const content_type : ustring; content_length : int64; const extra_headers : ICefStringMultimap); diff --git a/windows/src/ext/cef4delphi/source/uCEFServerEvents.pas b/windows/src/ext/cef4delphi/source/uCEFServerEvents.pas index 8af17726ec6ff7de4067353281635e8626d92b05..a4e00d801c7ebb2e77dadc1e6608b09e32e6a2bc 100644 --- a/windows/src/ext/cef4delphi/source/uCEFServerEvents.pas +++ b/windows/src/ext/cef4delphi/source/uCEFServerEvents.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFServerEvents; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFServerHandler.pas b/windows/src/ext/cef4delphi/source/uCEFServerHandler.pas index e452866481c9d550afa1fc1a51601c3112908a3d..fc2e70461c10edf10e0fdb646b0fc9e6cb81b0f1 100644 --- a/windows/src/ext/cef4delphi/source/uCEFServerHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFServerHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFServerHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -71,7 +69,7 @@ type TCustomServerHandler = class(TCEFServerHandlerOwn) protected - FEvents : IServerEvents; + FEvents : Pointer; procedure OnServerCreated(const server: ICefServer); override; procedure OnServerDestroyed(const server: ICefServer); override; @@ -280,7 +278,7 @@ constructor TCustomServerHandler.Create(const events: IServerEvents); begin inherited Create; - FEvents := events; + FEvents := Pointer(events); end; destructor TCustomServerHandler.Destroy; @@ -293,7 +291,8 @@ end; procedure TCustomServerHandler.OnServerCreated(const server: ICefServer); begin try - if (FEvents <> nil) then FEvents.doOnServerCreated(server); + if (FEvents <> nil) then + IServerEvents(FEvents).doOnServerCreated(server); except on e : exception do if CustomExceptionHandler('TCustomServerHandler.OnServerCreated', e) then raise; @@ -303,7 +302,8 @@ end; procedure TCustomServerHandler.OnServerDestroyed(const server: ICefServer); begin try - if (FEvents <> nil) then FEvents.doOnServerDestroyed(server); + if (FEvents <> nil) then + IServerEvents(FEvents).doOnServerDestroyed(server); except on e : exception do if CustomExceptionHandler('TCustomServerHandler.OnServerDestroyed', e) then raise; @@ -313,7 +313,8 @@ end; procedure TCustomServerHandler.OnClientConnected(const server: ICefServer; connection_id: Integer); begin try - if (FEvents <> nil) then FEvents.doOnClientConnected(server, connection_id); + if (FEvents <> nil) then + IServerEvents(FEvents).doOnClientConnected(server, connection_id); except on e : exception do if CustomExceptionHandler('TCustomServerHandler.OnClientConnected', e) then raise; @@ -323,7 +324,8 @@ end; procedure TCustomServerHandler.OnClientDisconnected(const server: ICefServer; connection_id: Integer); begin try - if (FEvents <> nil) then FEvents.doOnClientDisconnected(server, connection_id); + if (FEvents <> nil) then + IServerEvents(FEvents).doOnClientDisconnected(server, connection_id); except on e : exception do if CustomExceptionHandler('TCustomServerHandler.OnClientDisconnected', e) then raise; @@ -333,7 +335,8 @@ end; procedure TCustomServerHandler.OnHttpRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest); begin try - if (FEvents <> nil) then FEvents.doOnHttpRequest(server, connection_id, client_address, request); + if (FEvents <> nil) then + IServerEvents(FEvents).doOnHttpRequest(server, connection_id, client_address, request); except on e : exception do if CustomExceptionHandler('TCustomServerHandler.OnHttpRequest', e) then raise; @@ -343,7 +346,8 @@ end; procedure TCustomServerHandler.OnWebSocketRequest(const server: ICefServer; connection_id: Integer; const client_address: ustring; const request: ICefRequest; const callback: ICefCallback); begin try - if (FEvents <> nil) then FEvents.doOnWebSocketRequest(server, connection_id, client_address, request, callback); + if (FEvents <> nil) then + IServerEvents(FEvents).doOnWebSocketRequest(server, connection_id, client_address, request, callback); except on e : exception do if CustomExceptionHandler('TCustomServerHandler.OnWebSocketRequest', e) then raise; @@ -353,7 +357,8 @@ end; procedure TCustomServerHandler.OnWebSocketConnected(const server: ICefServer; connection_id: Integer); begin try - if (FEvents <> nil) then FEvents.doOnWebSocketConnected(server, connection_id); + if (FEvents <> nil) then + IServerEvents(FEvents).doOnWebSocketConnected(server, connection_id); except on e : exception do if CustomExceptionHandler('TCustomServerHandler.OnWebSocketConnected', e) then raise; @@ -363,7 +368,8 @@ end; procedure TCustomServerHandler.OnWebSocketMessage(const server: ICefServer; connection_id: Integer; const data: Pointer; data_size: NativeUInt); begin try - if (FEvents <> nil) then FEvents.doOnWebSocketMessage(server, connection_id, data, data_size); + if (FEvents <> nil) then + IServerEvents(FEvents).doOnWebSocketMessage(server, connection_id, data, data_size); except on e : exception do if CustomExceptionHandler('TCustomServerHandler.OnWebSocketMessage', e) then raise; diff --git a/windows/src/ext/cef4delphi/source/uCEFSetCookieCallback.pas b/windows/src/ext/cef4delphi/source/uCEFSetCookieCallback.pas index d3c8a4a9f87169d0734a841a7a12bf83b68931db..7d84fc0c592533db0b1b2ddb782001d657d734c9 100644 --- a/windows/src/ext/cef4delphi/source/uCEFSetCookieCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFSetCookieCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFSetCookieCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -72,9 +70,26 @@ type constructor Create(const callback: TCefSetCookieCallbackProc); reintroduce; end; + TCefCustomSetCookieCallback = class(TCefSetCookieCallbackOwn) + protected + FEvents : Pointer; + FID : integer; + + procedure OnComplete(success: Boolean); override; + + public + constructor Create(const aEvents : IChromiumEvents; aID : integer); reintroduce; + destructor Destroy; override; + end; + implementation uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} uCEFMiscFunctions, uCEFLibFunctions; procedure cef_set_cookie_callback_on_complete(self : PCefSetCookieCallback; @@ -110,4 +125,37 @@ begin FCallback(success); end; + +// TCefCustomSetCookieCallback + +constructor TCefCustomSetCookieCallback.Create(const aEvents : IChromiumEvents; aID : integer); +begin + inherited Create; + + FEvents := Pointer(aEvents); + FID := aID; +end; + +destructor TCefCustomSetCookieCallback.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + +procedure TCefCustomSetCookieCallback.OnComplete(success: Boolean); +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doOnCookieSet(success, FID); + except + on e : exception do + if CustomExceptionHandler('TCefCustomSetCookieCallback.OnComplete', e) then raise; + end; + finally + FEvents := nil; + end; +end; + + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFSslInfo.pas b/windows/src/ext/cef4delphi/source/uCEFSslInfo.pas index b0cf0019cc65aa44586365c115f77fc9fd9329e6..b02769403e1d759d55c76586c567157cae17e01c 100644 --- a/windows/src/ext/cef4delphi/source/uCEFSslInfo.pas +++ b/windows/src/ext/cef4delphi/source/uCEFSslInfo.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFSslInfo; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFStreamReader.pas b/windows/src/ext/cef4delphi/source/uCEFStreamReader.pas index 52b887f17d4b29df61ba9e4af3e117080889892d..87ff864567b72c0f900c8dc23b9ea64150122a2f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFStreamReader.pas +++ b/windows/src/ext/cef4delphi/source/uCEFStreamReader.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFStreamReader; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFStreamWriter.pas b/windows/src/ext/cef4delphi/source/uCEFStreamWriter.pas index 54ca59b5b1b124a72e05b759c931ea97896230b8..bf39cf84e355c1e9d863d3813d2d94dbcc2931ba 100644 --- a/windows/src/ext/cef4delphi/source/uCEFStreamWriter.pas +++ b/windows/src/ext/cef4delphi/source/uCEFStreamWriter.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFStreamWriter; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFStringList.pas b/windows/src/ext/cef4delphi/source/uCEFStringList.pas index 80060003a9e0ba281cfbb5eeef6e4f9bc7731c22..ec1bf0bf2ce3d610af57e9171421e3e38073aca5 100644 --- a/windows/src/ext/cef4delphi/source/uCEFStringList.pas +++ b/windows/src/ext/cef4delphi/source/uCEFStringList.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFStringList; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -150,17 +148,17 @@ begin if (FHandle <> nil) then begin - FillChar(TempValue, SizeOf(TempValue), 0); + CefStringInitialize(@TempValue); if (cef_string_list_value(FHandle, index, @TempValue) <> 0) then - Result := CefString(@TempValue); + Result := CefStringClearAndGet(@TempValue); end; end; procedure TCefCustomStringList.CopyToStrings(const aStrings : TStrings); var i, j : NativeUInt; - TempString : TCefString; + TempValue : TCefString; begin if (aStrings <> nil) and (FHandle <> nil) then begin @@ -169,10 +167,10 @@ begin while (i < j) do begin - FillChar(TempString, SizeOf(TCefString), 0); + CefStringInitialize(@TempValue); - if (cef_string_list_value(FHandle, i, @TempString) <> 0) then - aStrings.Add(CefStringClearAndGet(TempString)); + if (cef_string_list_value(FHandle, i, @TempValue) <> 0) then + aStrings.Add(CefStringClearAndGet(@TempValue)); inc(i); end; diff --git a/windows/src/ext/cef4delphi/source/uCEFStringMap.pas b/windows/src/ext/cef4delphi/source/uCEFStringMap.pas index 0e2b01cd3d2c6495c8486e2e00f7242e4b4e5e27..050705e1ebff4a1343028adcb48ced687ec0705d 100644 --- a/windows/src/ext/cef4delphi/source/uCEFStringMap.pas +++ b/windows/src/ext/cef4delphi/source/uCEFStringMap.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFStringMap; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -126,11 +124,12 @@ begin if (FHandle <> nil) then begin - FillChar(TempValue, SizeOf(TempValue), 0); + CefStringInitialize(@TempValue); + TempKey := CefString(key); - if (cef_string_map_find(FHandle, @TempKey, TempValue) <> 0) then - Result := CefString(@TempValue); + if (cef_string_map_find(FHandle, @TempKey, @TempValue) <> 0) then + Result := CefStringClearAndGet(@TempValue); end; end; @@ -147,10 +146,10 @@ begin if (FHandle <> nil) then begin - FillChar(TempKey, SizeOf(TempKey), 0); + CefStringInitialize(@TempKey); - if (cef_string_map_key(FHandle, index, TempKey) <> 0) then - Result := CefString(@TempKey); + if (cef_string_map_key(FHandle, index, @TempKey) <> 0) then + Result := CefStringClearAndGet(@TempKey); end; end; @@ -170,10 +169,10 @@ begin if (FHandle <> nil) then begin - FillChar(TempValue, SizeOf(TempValue), 0); + CefStringInitialize(@TempValue); - if (cef_string_map_value(FHandle, index, TempValue) <> 0) then - Result := CefString(@TempValue); + if (cef_string_map_value(FHandle, index, @TempValue) <> 0) then + Result := CefStringClearAndGet(@TempValue); end; end; diff --git a/windows/src/ext/cef4delphi/source/uCEFStringMultimap.pas b/windows/src/ext/cef4delphi/source/uCEFStringMultimap.pas index 08f20711eb1c8c2690edaa3a54b26946d289ef53..7898ccd2a4d9616a31749d90b89fd318328e2e32 100644 --- a/windows/src/ext/cef4delphi/source/uCEFStringMultimap.pas +++ b/windows/src/ext/cef4delphi/source/uCEFStringMultimap.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFStringMultimap; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -140,11 +138,12 @@ begin if (FHandle <> nil) then begin + CefStringInitialize(@TempValue); + TempKey := CefString(Key); - FillChar(TempValue, SizeOf(TempValue), 0); - if (cef_string_multimap_enumerate(FHandle, @TempKey, ValueIndex, TempValue) <> 0) then - Result := CefString(@TempValue); + if (cef_string_multimap_enumerate(FHandle, @TempKey, ValueIndex, @TempValue) <> 0) then + Result := CefStringClearAndGet(@TempValue); end; end; @@ -161,10 +160,10 @@ begin if (FHandle <> nil) then begin - FillChar(TempKey, SizeOf(TempKey), 0); + CefStringInitialize(@TempKey); - if (cef_string_multimap_key(FHandle, index, TempKey) <> 0) then - Result := CefString(@TempKey); + if (cef_string_multimap_key(FHandle, index, @TempKey) <> 0) then + Result := CefStringClearAndGet(@TempKey); end; end; @@ -184,10 +183,10 @@ begin if (FHandle <> nil) then begin - FillChar(TempValue, SizeOf(TempValue), 0); + CefStringInitialize(@TempValue); - if (cef_string_multimap_value(FHandle, index, TempValue) <> 0) then - Result := CefString(@TempValue); + if (cef_string_multimap_value(FHandle, index, @TempValue) <> 0) then + Result := CefStringClearAndGet(@TempValue); end; end; diff --git a/windows/src/ext/cef4delphi/source/uCEFStringVisitor.pas b/windows/src/ext/cef4delphi/source/uCEFStringVisitor.pas index 0d04c935de54ef126fff149b767dd795bb6584f3..37c99a5ebd3dfa4cf8b8a15eb72b955225c9408d 100644 --- a/windows/src/ext/cef4delphi/source/uCEFStringVisitor.pas +++ b/windows/src/ext/cef4delphi/source/uCEFStringVisitor.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFStringVisitor; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFTask.pas b/windows/src/ext/cef4delphi/source/uCEFTask.pas index 9d36f9e48349932aa88cea70e71d15383155075f..26a98b1f31d7b0c4b30f9d5bf3ba2eb114905a53 100644 --- a/windows/src/ext/cef4delphi/source/uCEFTask.pas +++ b/windows/src/ext/cef4delphi/source/uCEFTask.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFTask; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -104,6 +102,123 @@ type destructor Destroy; override; end; + TCefURLRequestTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + + procedure Execute; override; + + public + constructor Create(const aEvents : ICEFUrlRequestClientEvents); reintroduce; + destructor Destroy; override; + end; + + TCefGenericTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + FTaskID : cardinal; + + procedure Execute; override; + + public + constructor Create(const aEvents : IChromiumEvents; aTaskID : cardinal); reintroduce; + destructor Destroy; override; + end; + + TCefUpdateZoomStepTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + FInc : boolean; + + procedure Execute; override; + + public + constructor Create(const aEvents : IChromiumEvents; aInc : boolean); reintroduce; + destructor Destroy; override; + end; + + TCefUpdateZoomPctTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + FInc : boolean; + + procedure Execute; override; + + public + constructor Create(const aEvents : IChromiumEvents; aInc : boolean); reintroduce; + destructor Destroy; override; + end; + + TCefReadZoomTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + + procedure Execute; override; + + public + constructor Create(const aEvents : IChromiumEvents); reintroduce; + destructor Destroy; override; + end; + + TCefSetZoomLevelTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + FValue : double; + + procedure Execute; override; + + public + constructor Create(const aEvents : IChromiumEvents; const aValue : double); reintroduce; + destructor Destroy; override; + end; + + TCefSetZoomPctTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + FValue : double; + + procedure Execute; override; + + public + constructor Create(const aEvents : IChromiumEvents; const aValue : double); reintroduce; + destructor Destroy; override; + end; + + TCefSetZoomStepTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + FValue : byte; + + procedure Execute; override; + + public + constructor Create(const aEvents : IChromiumEvents; aValue : byte); reintroduce; + destructor Destroy; override; + end; + + TCefCreateCustomViewTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + + procedure Execute; override; + + public + constructor Create(const aEvents : ICefViewDelegateEvents); reintroduce; + destructor Destroy; override; + end; + + TCefBrowserNavigationTask = class(TCefTaskOwn) + protected + FEvents : Pointer; + FTask : TCefBrowserNavigation; + + procedure Execute; override; + + public + constructor Create(const aEvents : IChromiumEvents; aTask : TCefBrowserNavigation); reintroduce; + destructor Destroy; override; + end; + implementation uses @@ -112,7 +227,7 @@ uses {$ELSE} SysUtils, {$ENDIF} - uCEFMiscFunctions, uCEFLibFunctions, uCEFCookieManager; + uCEFMiscFunctions, uCEFLibFunctions, uCEFCookieManager, uCEFUrlRequest; procedure cef_task_execute(self: PCefTask); stdcall; var @@ -243,4 +358,327 @@ begin end; end; + +// TCefURLRequestTask + +procedure TCefURLRequestTask.Execute; +begin + try + try + if (FEvents <> nil) then ICEFUrlRequestClientEvents(FEvents).doOnCreateURLRequest; + except + on e : exception do + if CustomExceptionHandler('TCefURLRequestTask.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefURLRequestTask.Create(const aEvents : ICEFUrlRequestClientEvents); +begin + inherited Create; + + FEvents := Pointer(aEvents); +end; + +destructor TCefURLRequestTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + + +// TCefGenericTask + +procedure TCefGenericTask.Execute; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doOnExecuteTaskOnCefThread(FTaskID); + except + on e : exception do + if CustomExceptionHandler('TCefGenericTask.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefGenericTask.Create(const aEvents : IChromiumEvents; aTaskID : cardinal); +begin + inherited Create; + + FEvents := Pointer(aEvents); + FTaskID := aTaskID; +end; + +destructor TCefGenericTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + + + +// TCefUpdateZoomStepTask + +procedure TCefUpdateZoomStepTask.Execute; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doUpdateZoomStep(FInc); + except + on e : exception do + if CustomExceptionHandler('TCefUpdateZoomStepTask.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefUpdateZoomStepTask.Create(const aEvents : IChromiumEvents; aInc : boolean); +begin + inherited Create; + + FEvents := Pointer(aEvents); + FInc := aInc; +end; + +destructor TCefUpdateZoomStepTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + + + +// TCefUpdateZoomPctTask + +procedure TCefUpdateZoomPctTask.Execute; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doUpdateZoomPct(FInc); + except + on e : exception do + if CustomExceptionHandler('TCefUpdateZoomPctTask.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefUpdateZoomPctTask.Create(const aEvents : IChromiumEvents; aInc : boolean); +begin + inherited Create; + + FEvents := Pointer(aEvents); + FInc := aInc; +end; + +destructor TCefUpdateZoomPctTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + + + +// TCefReadZoomTask + +procedure TCefReadZoomTask.Execute; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doReadZoom; + except + on e : exception do + if CustomExceptionHandler('TCefReadZoomTask.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefReadZoomTask.Create(const aEvents : IChromiumEvents); +begin + inherited Create; + + FEvents := Pointer(aEvents); +end; + +destructor TCefReadZoomTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + + + +// TCefSetZoomLevelTask + +procedure TCefSetZoomLevelTask.Execute; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doSetZoomLevel(FValue); + except + on e : exception do + if CustomExceptionHandler('TCefSetZoomLevelTask.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefSetZoomLevelTask.Create(const aEvents : IChromiumEvents; const aValue : double); +begin + inherited Create; + + FEvents := Pointer(aEvents); + FValue := aValue; +end; + +destructor TCefSetZoomLevelTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + + + +// TCefSetZoomPctTask + +procedure TCefSetZoomPctTask.Execute; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doSetZoomPct(FValue); + except + on e : exception do + if CustomExceptionHandler('TCefSetZoomPctTask.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefSetZoomPctTask.Create(const aEvents : IChromiumEvents; const aValue : double); +begin + inherited Create; + + FEvents := Pointer(aEvents); + FValue := aValue; +end; + +destructor TCefSetZoomPctTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + + + +// TCefSetZoomStepTask + +procedure TCefSetZoomStepTask.Execute; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doSetZoomStep(FValue); + except + on e : exception do + if CustomExceptionHandler('TCefSetZoomStepTask.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefSetZoomStepTask.Create(const aEvents : IChromiumEvents; aValue : byte); +begin + inherited Create; + + FEvents := Pointer(aEvents); + FValue := aValue; +end; + +destructor TCefSetZoomStepTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + + +// TCefCreateCustomViewTask + +procedure TCefCreateCustomViewTask.Execute; +begin + try + try + if (FEvents <> nil) then ICefViewDelegateEvents(FEvents).doCreateCustomView; + except + on e : exception do + if CustomExceptionHandler('ICefViewDelegateEvents.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefCreateCustomViewTask.Create(const aEvents : ICefViewDelegateEvents); +begin + inherited Create; + + FEvents := Pointer(aEvents); +end; + +destructor TCefCreateCustomViewTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + + +// TCefBrowserNavigationTask + +procedure TCefBrowserNavigationTask.Execute; +begin + try + try + if (FEvents <> nil) then IChromiumEvents(FEvents).doBrowserNavigation(FTask); + except + on e : exception do + if CustomExceptionHandler('TCefBrowserNavigationTask.Execute', e) then raise; + end; + finally + FEvents := nil; + end; +end; + +constructor TCefBrowserNavigationTask.Create(const aEvents : IChromiumEvents; aTask : TCefBrowserNavigation); +begin + inherited Create; + + FEvents := Pointer(aEvents); + FTask := aTask; +end; + +destructor TCefBrowserNavigationTask.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFTaskRunner.pas b/windows/src/ext/cef4delphi/source/uCEFTaskRunner.pas index 83aaecbb4b6d388d97fc92d69f924e8073282375..46df78d97471526bd65681d44e29337f527577c1 100644 --- a/windows/src/ext/cef4delphi/source/uCEFTaskRunner.pas +++ b/windows/src/ext/cef4delphi/source/uCEFTaskRunner.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFTaskRunner; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFTextfield.pas b/windows/src/ext/cef4delphi/source/uCEFTextfield.pas new file mode 100644 index 0000000000000000000000000000000000000000..26918b049e9b89814e76057ce4ecd38d0b15bb38 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFTextfield.pas @@ -0,0 +1,303 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFTextfield; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFView; + +type + TCefTextfieldRef = class(TCefViewRef, ICefTextfield) + protected + procedure SetPasswordInput(password_input: boolean); + function IsPasswordInput : boolean; + procedure SetReadOnly(read_only: boolean); + function IsReadOnly : boolean; + function GetText : ustring; + procedure SetText(const text_: ustring); + procedure AppendText(const text_: ustring); + procedure InsertOrReplaceText(const text_: ustring); + function HasSelection : boolean; + function GetSelectedText : ustring; + procedure SelectAll(reversed: boolean); + procedure ClearSelection; + function GetSelectedRange : TCefRange; + procedure SelectRange(const range: TCefRange); + function GetCursorPosition : NativeUInt; + procedure SetTextColor(color: TCefColor); + function GetTextColor : TCefColor; + procedure SetSelectionTextColor(color: TCefColor); + function GetSelectionTextColor : TCefColor; + procedure SetSelectionBackgroundColor(color: TCefColor); + function GetSelectionBackgroundColor : TCefColor; + procedure SetFontList(const font_list: ustring); + procedure ApplyTextColor(color: TCefColor; const range: TCefRange); + procedure ApplyTextStyle(style: TCefTextStyle; add: boolean; const range: TCefRange); + function IsCommandEnabled(command_id: TCefTextFieldCommands): boolean; + procedure ExecuteCommand(command_id: TCefTextFieldCommands); + procedure ClearEditHistory; + procedure SetPlaceholderText(const text_: ustring); + function GetPlaceholderText : ustring; + procedure SetPlaceholderTextColor(color: TCefColor); + procedure SetAccessibleName(const name: ustring); + + public + class function UnWrap(data: Pointer): ICefTextfield; + class function CreateTextField(const delegate: ICefTextfieldDelegate): ICefTextfield; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions; + +procedure TCefTextfieldRef.SetPasswordInput(password_input: boolean); +begin + PCefTextfield(FData)^.set_password_input(PCefTextfield(FData), + ord(password_input)); +end; + +function TCefTextfieldRef.IsPasswordInput : boolean; +begin + Result := (PCefTextfield(FData)^.is_password_input(PCefTextfield(FData)) <> 0); +end; + +procedure TCefTextfieldRef.SetReadOnly(read_only: boolean); +begin + PCefTextfield(FData)^.set_read_only(PCefTextfield(FData), + ord(read_only)); +end; + +function TCefTextfieldRef.IsReadOnly : boolean; +begin + Result := (PCefTextfield(FData)^.is_read_only(PCefTextfield(FData)) <> 0); +end; + +function TCefTextfieldRef.GetText : ustring; +begin + Result := CefStringFreeAndGet(PCefTextfield(FData)^.get_text(PCefTextfield(FData))); +end; + +procedure TCefTextfieldRef.SetText(const text_: ustring); +var + TempText : TCefString; +begin + TempText := CefString(text_); + PCefTextfield(FData)^.set_text(PCefTextfield(FData), @TempText); +end; + +procedure TCefTextfieldRef.AppendText(const text_: ustring); +var + TempText : TCefString; +begin + TempText := CefString(text_); + PCefTextfield(FData)^.append_text(PCefTextfield(FData), @TempText); +end; + +procedure TCefTextfieldRef.InsertOrReplaceText(const text_: ustring); +var + TempText : TCefString; +begin + TempText := CefString(text_); + PCefTextfield(FData)^.insert_or_replace_text(PCefTextfield(FData), @TempText); +end; + +function TCefTextfieldRef.HasSelection : boolean; +begin + Result := (PCefTextfield(FData)^.has_selection(PCefTextfield(FData)) <> 0); +end; + +function TCefTextfieldRef.GetSelectedText : ustring; +begin + Result := CefStringFreeAndGet(PCefTextfield(FData)^.get_selected_text(PCefTextfield(FData))); +end; + +procedure TCefTextfieldRef.SelectAll(reversed: boolean); +begin + PCefTextfield(FData)^.select_all(PCefTextfield(FData), ord(reversed)); +end; + +procedure TCefTextfieldRef.ClearSelection; +begin + PCefTextfield(FData)^.clear_selection(PCefTextfield(FData)); +end; + +function TCefTextfieldRef.GetSelectedRange : TCefRange; +begin + Result := PCefTextfield(FData)^.get_selected_range(PCefTextfield(FData)); +end; + +procedure TCefTextfieldRef.SelectRange(const range: TCefRange); +begin + PCefTextfield(FData)^.select_range(PCefTextfield(FData), @range); +end; + +function TCefTextfieldRef.GetCursorPosition : NativeUInt; +begin + Result := PCefTextfield(FData)^.get_cursor_position(PCefTextfield(FData)); +end; + +procedure TCefTextfieldRef.SetTextColor(color: TCefColor); +begin + PCefTextfield(FData)^.set_text_color(PCefTextfield(FData), color); +end; + +function TCefTextfieldRef.GetTextColor : TCefColor; +begin + Result := PCefTextfield(FData)^.get_text_color(PCefTextfield(FData)); +end; + +procedure TCefTextfieldRef.SetSelectionTextColor(color: TCefColor); +begin + PCefTextfield(FData)^.set_selection_text_color(PCefTextfield(FData), color); +end; + +function TCefTextfieldRef.GetSelectionTextColor : TCefColor; +begin + Result := PCefTextfield(FData)^.get_selection_text_color(PCefTextfield(FData)); +end; + +procedure TCefTextfieldRef.SetSelectionBackgroundColor(color: TCefColor); +begin + PCefTextfield(FData)^.set_selection_background_color(PCefTextfield(FData), color); +end; + +function TCefTextfieldRef.GetSelectionBackgroundColor : TCefColor; +begin + Result := PCefTextfield(FData)^.get_selection_background_color(PCefTextfield(FData)); +end; + +procedure TCefTextfieldRef.SetFontList(const font_list: ustring); +var + TempFontList : TCefString; +begin + TempFontList := CefString(font_list); + PCefTextfield(FData)^.set_font_list(PCefTextfield(FData), @TempFontList); +end; + +procedure TCefTextfieldRef.ApplyTextColor(color: TCefColor; const range: TCefRange); +begin + PCefTextfield(FData)^.apply_text_color(PCefTextfield(FData), color, @range); +end; + +procedure TCefTextfieldRef.ApplyTextStyle(style: TCefTextStyle; add: boolean; const range: TCefRange); +begin + PCefTextfield(FData)^.apply_text_style(PCefTextfield(FData), style, ord(add), @range); +end; + +function TCefTextfieldRef.IsCommandEnabled(command_id: TCefTextFieldCommands): boolean; +begin + Result := (PCefTextfield(FData)^.is_command_enabled(PCefTextfield(FData), command_id) <> 0); +end; + +procedure TCefTextfieldRef.ExecuteCommand(command_id: TCefTextFieldCommands); +begin + PCefTextfield(FData)^.execute_command(PCefTextfield(FData), command_id); +end; + +procedure TCefTextfieldRef.ClearEditHistory; +begin + PCefTextfield(FData)^.clear_edit_history(PCefTextfield(FData)); +end; + +procedure TCefTextfieldRef.SetPlaceholderText(const text_: ustring); +var + TempText : TCefString; +begin + TempText := CefString(text_); + PCefTextfield(FData)^.set_placeholder_text(PCefTextfield(FData), @TempText); +end; + +function TCefTextfieldRef.GetPlaceholderText : ustring; +begin + Result := CefStringFreeAndGet(PCefTextfield(FData)^.get_placeholder_text(PCefTextfield(FData))); +end; + +procedure TCefTextfieldRef.SetPlaceholderTextColor(color: TCefColor); +begin + PCefTextfield(FData)^.set_placeholder_text_color(PCefTextfield(FData), color); +end; + +procedure TCefTextfieldRef.SetAccessibleName(const name: ustring); +var + TempName : TCefString; +begin + TempName := CefString(name); + PCefTextfield(FData)^.set_accessible_name(PCefTextfield(FData), @TempName); +end; + +class function TCefTextfieldRef.UnWrap(data: Pointer): ICefTextfield; +begin + if (data <> nil) then + Result := Create(data) as ICefTextfield + else + Result := nil; +end; + +class function TCefTextfieldRef.CreateTextField(const delegate: ICefTextfieldDelegate): ICefTextfield; +var + TempTextfield : PCefTextfield; +begin + Result := nil; + + if (delegate <> nil) then + begin + TempTextfield := cef_textfield_create(CefGetData(delegate)); + + if (TempTextfield <> nil) then + Result := Create(TempTextfield) as ICefTextfield; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFTextfieldComponent.pas b/windows/src/ext/cef4delphi/source/uCEFTextfieldComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..4a02a67b40c8ce633ac415dc896a0e3291ab217d --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFTextfieldComponent.pas @@ -0,0 +1,447 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFTextfieldComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents, uCEFViewComponent; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFTextfieldComponent = class(TCEFViewComponent, ICefTextfieldDelegateEvents) + protected + FTextfield : ICefTextfield; + + // ICefTextfieldDelegateEvents + FOnTextfieldKeyEvent : TOnTextfieldKeyEventEvent; + FOnAfterUserAction : TOnAfterUserActionEvent; + + procedure DestroyView; override; + procedure Initialize; override; + + function GetInitialized : boolean; override; + function GetAsView : ICefView; override; + function GetAsTextfield : ICefTextfield; override; + function GetIsPasswordInput : boolean; + function GetIsReadOnly : boolean; + function GetText : ustring; + function GetHasSelection : boolean; + function GetSelectedText : ustring; + function GetSelectedRange : TCefRange; + function GetCursorPosition : NativeUInt; + function GetTextColor : TCefColor; + function GetSelectionTextColor : TCefColor; + function GetSelectionBackgroundColor : TCefColor; + function GetPlaceholderText : ustring; + + procedure SetPasswordInput(password_input: boolean); + procedure SetReadOnly(read_only: boolean); + procedure SetText(const text_: ustring); + procedure SetTextColor(color: TCefColor); + procedure SetSelectionTextColor(color: TCefColor); + procedure SetSelectionBackgroundColor(color: TCefColor); + procedure SetPlaceholderText(const text_: ustring); + + // ICefTextfieldDelegateEvents + procedure doOnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); + procedure doOnAfterUserAction(const textfield: ICefTextfield); + + // ICefViewDelegateEvents + procedure doCreateCustomView; override; + + public + procedure CreateTextField; + procedure AppendText(const text_: ustring); + procedure InsertOrReplaceText(const text_: ustring); + procedure SelectAll(reversed: boolean); + procedure ClearSelection; + procedure SelectRange(const range: TCefRange); + procedure SetFontList(const font_list: ustring); + procedure ApplyTextColor(color: TCefColor; const range: TCefRange); + procedure ApplyTextStyle(style: TCefTextStyle; add: boolean; const range: TCefRange); + function IsCommandEnabled(command_id: TCefTextFieldCommands): boolean; + procedure ExecuteCommand(command_id: TCefTextFieldCommands); + procedure ClearEditHistory; + procedure SetAccessibleName(const name_: ustring); + procedure SetPlaceholderTextColor(color: TCefColor); + + property PasswordInput : boolean read GetIsPasswordInput write SetPasswordInput; + property ReadOnly : boolean read GetIsReadOnly write SetReadOnly; + property Text : ustring read GetText write SetText; + property SelectedText : ustring read GetSelectedText; + property TextColor : TCefColor read GetTextColor write SetTextColor; + property SelectionTextColor : TCefColor read GetSelectionTextColor write SetSelectionTextColor; + property SelectionBackgroundColor : TCefColor read GetSelectionBackgroundColor write SetSelectionBackgroundColor; + property PlaceholderText : ustring read GetPlaceholderText write SetPlaceholderText; + property HasSelection : boolean read GetHasSelection; + + published + property OnTextfieldKeyEvent : TOnTextfieldKeyEventEvent read FOnTextfieldKeyEvent write FOnTextfieldKeyEvent; + property OnAfterUserAction : TOnAfterUserActionEvent read FOnAfterUserAction write FOnAfterUserAction; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + uCEFTextfieldDelegate, uCEFMiscFunctions, uCEFTask, uCEFTextfield; + +procedure TCEFTextfieldComponent.Initialize; +begin + inherited Initialize; + + FTextfield := nil; + FOnTextfieldKeyEvent := nil; + FOnAfterUserAction := nil; +end; + +procedure TCEFTextfieldComponent.DestroyView; +begin + FTextfield := nil; +end; + +procedure TCEFTextfieldComponent.CreateTextField; +begin + CreateView; +end; + +procedure TCEFTextfieldComponent.doOnKeyEvent(const textfield : ICefTextfield; + const event : TCefKeyEvent; + var aResult : boolean); +begin + if assigned(FOnTextfieldKeyEvent) then + FOnTextfieldKeyEvent(self, textfield, event, aResult); +end; + +procedure TCEFTextfieldComponent.doOnAfterUserAction(const textfield: ICefTextfield); +begin + if assigned(FOnAfterUserAction) then + FOnAfterUserAction(self, textfield); +end; + +procedure TCEFTextfieldComponent.doCreateCustomView; +var + TempDelegate : ICefTextfieldDelegate; +begin + if (FTextfield = nil) then + try + TempDelegate := TCustomTextfieldDelegate.Create(self); + FTextfield := TCefTextfieldRef.CreateTextField(TempDelegate); + finally + TempDelegate := nil; + end; +end; + +function TCEFTextfieldComponent.GetInitialized : boolean; +begin + Result := (FTextfield <> nil); +end; + +function TCEFTextfieldComponent.GetAsView : ICefView; +begin + Result := FTextfield as ICefView; +end; + +function TCEFTextfieldComponent.GetAsTextfield : ICefTextfield; +begin + Result := FTextfield; +end; + +function TCEFTextfieldComponent.GetIsPasswordInput : boolean; +begin + Result := Initialized and FTextfield.IsPasswordInput; +end; + +function TCEFTextfieldComponent.GetIsReadOnly : boolean; +begin + Result := Initialized and FTextfield.IsReadOnly; +end; + +function TCEFTextfieldComponent.GetText : ustring; +begin + if Initialized then + Result := FTextfield.GetText + else + Result := ''; +end; + +function TCEFTextfieldComponent.GetHasSelection : boolean; +begin + Result := Initialized and FTextfield.HasSelection; +end; + +function TCEFTextfieldComponent.GetSelectedText : ustring; +begin + if Initialized then + Result := FTextfield.SelectedText + else + Result := ''; +end; + +function TCEFTextfieldComponent.GetSelectedRange : TCefRange; +var + TempRange : TCefRange; +begin + if Initialized then + TempRange := FTextfield.GetSelectedRange + else + begin + TempRange.from := 0; + TempRange.to_ := 0; + end; + + Result := TempRange; +end; + +function TCEFTextfieldComponent.GetCursorPosition : NativeUInt; +begin + if Initialized then + Result := FTextfield.GetCursorPosition + else + Result := 0; +end; + +function TCEFTextfieldComponent.GetTextColor : TCefColor; +begin + if Initialized then + Result := FTextfield.GetTextColor + else + Result := 0; +end; + +function TCEFTextfieldComponent.GetSelectionTextColor : TCefColor; +begin + if Initialized then + Result := FTextfield.GetSelectionTextColor + else + Result := 0; +end; + +function TCEFTextfieldComponent.GetSelectionBackgroundColor : TCefColor; +begin + if Initialized then + Result := FTextfield.GetSelectionBackgroundColor + else + Result := 0; +end; + +function TCEFTextfieldComponent.GetPlaceholderText : ustring; +begin + if Initialized then + Result := FTextfield.GetPlaceholderText + else + Result := ''; +end; + +procedure TCEFTextfieldComponent.SetPasswordInput(password_input: boolean); +begin + if Initialized then + FTextfield.SetPasswordInput(password_input); +end; + +procedure TCEFTextfieldComponent.SetReadOnly(read_only: boolean); +begin + if Initialized then + FTextfield.SetReadOnly(read_only); +end; + +procedure TCEFTextfieldComponent.SetText(const text_: ustring); +begin + if Initialized then + FTextfield.SetText(text_); +end; + +procedure TCEFTextfieldComponent.SetTextColor(color: TCefColor); +begin + if Initialized then + FTextfield.SetTextColor(color); +end; + +procedure TCEFTextfieldComponent.SetSelectionTextColor(color: TCefColor); +begin + if Initialized then + FTextfield.SetSelectionTextColor(color); +end; + +procedure TCEFTextfieldComponent.SetSelectionBackgroundColor(color: TCefColor); +begin + if Initialized then + FTextfield.SetSelectionBackgroundColor(color); +end; + +procedure TCEFTextfieldComponent.SetPlaceholderText(const text_: ustring); +begin + if Initialized then + FTextfield.SetPlaceholderText(text_); +end; + +procedure TCEFTextfieldComponent.AppendText(const text_: ustring); +begin + if Initialized then + FTextfield.AppendText(text_); +end; + +procedure TCEFTextfieldComponent.InsertOrReplaceText(const text_: ustring); +begin + if Initialized then + FTextfield.InsertOrReplaceText(text_); +end; + +procedure TCEFTextfieldComponent.SelectAll(reversed: boolean); +begin + if Initialized then + FTextfield.SelectAll(reversed); +end; + +procedure TCEFTextfieldComponent.ClearSelection; +begin + if Initialized then + FTextfield.ClearSelection; +end; + +procedure TCEFTextfieldComponent.SelectRange(const range: TCefRange); +begin + if Initialized then + FTextfield.SelectRange(range); +end; + +procedure TCEFTextfieldComponent.SetFontList(const font_list: ustring); +begin + if Initialized then + FTextfield.SetFontList(font_list); +end; + +procedure TCEFTextfieldComponent.ApplyTextColor(color: TCefColor; const range: TCefRange); +begin + if Initialized then + FTextfield.ApplyTextColor(color, range); +end; + +procedure TCEFTextfieldComponent.ApplyTextStyle(style: TCefTextStyle; add: boolean; const range: TCefRange); +begin + if Initialized then + FTextfield.ApplyTextStyle(style, add, range); +end; + +function TCEFTextfieldComponent.IsCommandEnabled(command_id: TCefTextFieldCommands): boolean; +begin + Result := Initialized and FTextfield.IsCommandEnabled(command_id); +end; + +procedure TCEFTextfieldComponent.ExecuteCommand(command_id: TCefTextFieldCommands); +begin + if Initialized then + FTextfield.ExecuteCommand(command_id); +end; + +procedure TCEFTextfieldComponent.ClearEditHistory; +begin + if Initialized then + FTextfield.ClearEditHistory; +end; + +procedure TCEFTextfieldComponent.SetAccessibleName(const name_: ustring); +begin + if Initialized then + FTextfield.SetAccessibleName(name_); +end; + +procedure TCEFTextfieldComponent.SetPlaceholderTextColor(color: TCefColor); +begin + if Initialized then + FTextfield.SetPlaceholderTextColor(color); +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tceftextfieldcomponent.lrs} + RegisterComponents('Chromium Views Framework', [TCEFTextfieldComponent]); +end; +{$ENDIF} + + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFTextfieldDelegate.pas b/windows/src/ext/cef4delphi/source/uCEFTextfieldDelegate.pas new file mode 100644 index 0000000000000000000000000000000000000000..0f9a9fc1cae6e8e46869245275572b9ec8be910c --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFTextfieldDelegate.pas @@ -0,0 +1,314 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFTextfieldDelegate; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFViewDelegate; + +type + TCefTextfieldDelegateRef = class(TCefViewDelegateRef, ICefTextfieldDelegate) + protected + procedure OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); + procedure OnAfterUserAction(const textfield: ICefTextfield); + + public + class function UnWrap(data: Pointer): ICefTextfieldDelegate; + end; + + TCefTextfieldDelegateOwn = class(TCefViewDelegateOwn, ICefTextfieldDelegate) + protected + procedure OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); virtual; + procedure OnAfterUserAction(const textfield: ICefTextfield); virtual; + + procedure InitializeCEFMethods; override; + + public + constructor Create; override; + end; + + TCustomTextfieldDelegate = class(TCefTextfieldDelegateOwn) + protected + FEvents : Pointer; + + // ICefViewDelegate + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); override; + procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); override; + procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); override; + procedure OnFocus(const view: ICefView); override; + procedure OnBlur(const view: ICefView); override; + + // ICefTextfieldDelegate + procedure OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); override; + procedure OnAfterUserAction(const textfield: ICefTextfield); override; + + public + constructor Create(const events: ICefTextfieldDelegateEvents); reintroduce; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFTextfield; + + +// ************************************************************** +// ***************** TCefTextfieldDelegateRef ******************* +// ************************************************************** + +procedure TCefTextfieldDelegateRef.OnKeyEvent(const textfield : ICefTextfield; + const event : TCefKeyEvent; + var aResult : boolean); +begin + aResult := (PCefTextfieldDelegate(FData)^.on_key_event(PCefTextfieldDelegate(FData), + CefGetData(textfield), + @event) <> 0); +end; + +procedure TCefTextfieldDelegateRef.OnAfterUserAction(const textfield: ICefTextfield); +begin + PCefTextfieldDelegate(FData)^.on_after_user_action(PCefTextfieldDelegate(FData), + CefGetData(textfield)); +end; + +class function TCefTextfieldDelegateRef.UnWrap(data: Pointer): ICefTextfieldDelegate; +begin + if (data <> nil) then + Result := Create(data) as ICefTextfieldDelegate + else + Result := nil; +end; + + +// ************************************************************** +// ***************** TCefTextfieldDelegateOwn ******************* +// ************************************************************** + +function cef_textfield_delegate_on_key_event(self: PCefTextfieldDelegate; textfield: PCefTextfield; const event: PCefKeyEvent): Integer; stdcall; +var + TempObject : TObject; + TempResult : boolean; +begin + TempObject := CefGetObject(self); + TempResult := False; + + if (TempObject <> nil) and (TempObject is TCefTextfieldDelegateOwn) then + TCefTextfieldDelegateOwn(TempObject).OnKeyEvent(TCefTextfieldRef.UnWrap(textfield), event^, TempResult); + + Result := ord(TempResult); +end; + +procedure cef_textfield_delegate_on_accelerator(self: PCefTextfieldDelegate; textfield: PCefTextfield); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefTextfieldDelegateOwn) then + TCefTextfieldDelegateOwn(TempObject).OnAfterUserAction(TCefTextfieldRef.UnWrap(textfield)); +end; + +constructor TCefTextfieldDelegateOwn.Create; +begin + inherited CreateData(SizeOf(TCefTextfieldDelegate)); + + InitializeCEFMethods; +end; + +procedure TCefTextfieldDelegateOwn.InitializeCEFMethods; +begin + inherited InitializeCEFMethods; + + with PCefTextfieldDelegate(FData)^ do + begin + on_after_user_action := {$IFDEF FPC}@{$ENDIF}cef_textfield_delegate_on_accelerator; + on_key_event := {$IFDEF FPC}@{$ENDIF}cef_textfield_delegate_on_key_event; + end; +end; + +procedure TCefTextfieldDelegateOwn.OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); +begin + // +end; + +procedure TCefTextfieldDelegateOwn.OnAfterUserAction(const textfield: ICefTextfield); +begin + // +end; + + +// ************************************************************** +// ***************** TCustomTextfieldDelegate ******************* +// ************************************************************** + +constructor TCustomTextfieldDelegate.Create(const events: ICefTextfieldDelegateEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +procedure TCustomTextfieldDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnGetPreferredSize', e) then raise; + end; +end; + +procedure TCustomTextfieldDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnGetMinimumSize', e) then raise; + end; +end; + +procedure TCustomTextfieldDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnGetMaximumSize', e) then raise; + end; +end; + +procedure TCustomTextfieldDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnGetHeightForWidth', e) then raise; + end; +end; + +procedure TCustomTextfieldDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnParentViewChanged', e) then raise; + end; +end; + +procedure TCustomTextfieldDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnChildViewChanged(view, added, child); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnChildViewChanged', e) then raise; + end; +end; + +procedure TCustomTextfieldDelegate.OnFocus(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnFocus(view); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnFocus', e) then raise; + end; +end; + +procedure TCustomTextfieldDelegate.OnBlur(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnBlur(view); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnBlur', e) then raise; + end; +end; + +procedure TCustomTextfieldDelegate.OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnKeyEvent(textfield, event, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnKeyEvent', e) then raise; + end; +end; + +procedure TCustomTextfieldDelegate.OnAfterUserAction(const textfield: ICefTextfield); +begin + try + if (FEvents <> nil) then + ICefTextfieldDelegateEvents(FEvents).doOnAfterUserAction(textfield); + except + on e : exception do + if CustomExceptionHandler('TCustomTextfieldDelegate.OnAfterUserAction', e) then raise; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFThread.pas b/windows/src/ext/cef4delphi/source/uCEFThread.pas index c8434f4d12dc33920bd94a6935a77212d83d3ece..c130d5b0bb123c19f1568f02319361cd3566911a 100644 --- a/windows/src/ext/cef4delphi/source/uCEFThread.pas +++ b/windows/src/ext/cef4delphi/source/uCEFThread.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFThread; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFTypes.pas b/windows/src/ext/cef4delphi/source/uCEFTypes.pas index 586bbcf468a7912702bfe8160fae12f94b67ad60..183d7252aac5ff8b66540b3e545857946537e9de 100644 --- a/windows/src/ext/cef4delphi/source/uCEFTypes.pas +++ b/windows/src/ext/cef4delphi/source/uCEFTypes.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFTypes; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -52,9 +50,14 @@ interface uses {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Math; + {$IFDEF MSWINDOWS} + WinApi.Windows, + {$ELSE} + System.Types, {$IFDEF LINUX}uCEFLinuxTypes,{$ENDIF} + {$ENDIF} + System.Math; {$ELSE} - {$IFDEF FPC}{$IFDEF LINUX}xlib,{$ENDIF}{$ENDIF} + {$IFDEF FPC}{$IFDEF LINUX}xlib, ctypes,{$ENDIF}{$ENDIF} {$IFDEF MSWINDOWS}Windows,{$ENDIF} Math; {$ENDIF} @@ -92,7 +95,6 @@ type PCefStringVisitor = ^TCefStringVisitor; PCefRequest = ^TCefRequest; PCefPostData = ^TCefPostData; - PCefPostDataElementArray = ^TCefPostDataElementArray; PCefPostDataElement = ^TCefPostDataElement; PPCefPostDataElement = ^PCefPostDataElement; PCefv8Context = ^TCefv8Context; @@ -136,6 +138,8 @@ type PCefLifeSpanHandler = ^TCefLifeSpanHandler; PCefGetExtensionResourceCallback = ^TCefGetExtensionResourceCallback; PCefExtensionHandler = ^TCefExtensionHandler; + PCefAudioHandler = ^TCefAudioHandler; + PCefAudioParameters = ^TCefAudioParameters; PCefExtension = ^TCefExtension; PCefPopupFeatures = ^TCefPopupFeatures; PCefBrowserSettings = ^TCefBrowserSettings; @@ -151,7 +155,11 @@ type PCefProcessMessage = ^TCefProcessMessage; PCefRequestHandler = ^TCefRequestHandler; PCefRequestCallback = ^TCefRequestCallback; + PCefResourceSkipCallback = ^TCefResourceSkipCallback; + PCefResourceReadCallback = ^TCefResourceReadCallback; PCefResourceHandler = ^TCefResourceHandler; + PCefResourceRequestHandler = ^TCefResourceRequestHandler; + PCefCookieAccessFilter = ^TCefCookieAccessFilter; PCefResponse = ^TCefResponse; PCefResponseFilter = ^TCefResponseFilter; PCefAuthCallback = ^TCefAuthCallback; @@ -179,11 +187,11 @@ type PCefNavigationEntryVisitor = ^TCefNavigationEntryVisitor; PCefNavigationEntry = ^TCefNavigationEntry; PCefMouseEvent = ^TCefMouseEvent; + PCefTouchEvent = ^TCefTouchEvent; PCefPrintSettings = ^TCefPrintSettings; PCefPrintDialogCallback = ^TCefPrintDialogCallback; PCefPrintJobCallback = ^TCefPrintJobCallback; PCefUrlParts = ^TCefUrlParts; - PCefJsonParserError = ^TCefJsonParserError; PCefStreamReader = ^TCefStreamReader; PCefReadHandler = ^TCefReadHandler; PCefWriteHandler = ^TCefWriteHandler; @@ -206,6 +214,7 @@ type PCefX509Certificate = ^TCefX509Certificate; PPCefX509Certificate = ^PCefX509Certificate; PCefDisplay = ^TCefDisplay; + PPCefDisplay = ^PCefDisplay; PCefLayout = ^TCefLayout; PCefBoxLayout = ^TCefBoxLayout; PCefFillLayout = ^TCefFillLayout; @@ -227,31 +236,62 @@ type PCefWindow = ^TCefWindow; PCefWindowDelegate = ^TCefWindowDelegate; PCefBoxLayoutSettings = ^TCefBoxLayoutSettings; - - {$IFDEF LINUX} - PXEvent = Pointer; - TXDisplay = record end; - PXDisplay = ^TXDisplay; - {$ENDIF} + PCefRegistration = ^TCefRegistration; + PCefDevToolsMessageObserver = ^TCefDevToolsMessageObserver; + PCefMediaRouter = ^TCefMediaRouter; + PCefMediaRoute = ^TCefMediaRoute; + PPCefMediaRoute = ^PCefMediaRoute; + PCefMediaRouteCreateCallback = ^TCefMediaRouteCreateCallback; + PCefMediaObserver = ^TCefMediaObserver; + PCefMediaSink = ^TCefMediaSink; + PPCefMediaSink = ^PCefMediaSink; + PCefMediaSinkDeviceInfoCallback = ^TCefMediaSinkDeviceInfoCallback; + PCefMediaSource = ^TCefMediaSource; + PCefMediaSinkDeviceInfo = ^TCefMediaSinkDeviceInfo; {$IFDEF MSWINDOWS} - TCefWindowHandle = HWND; // /include/internal/cef_types_win.h (cef_window_handle_t) - TCefCursorHandle = HCURSOR; // /include/internal/cef_types_win.h (cef_cursor_handle_t) - TCefEventHandle = PMsg; // /include/internal/cef_types_win.h (cef_event_handle_t) + TCefWindowHandle = type HWND; // /include/internal/cef_types_win.h (cef_window_handle_t) + TCefCursorHandle = type HCURSOR; // /include/internal/cef_types_win.h (cef_cursor_handle_t) + TCefEventHandle = type PMsg; // /include/internal/cef_types_win.h (cef_event_handle_t) {$ENDIF} - {$IFDEF MACOS} - TCefWindowHandle = Pointer; // /include/internal/cef_types_win.h (cef_window_handle_t) - TCefCursorHandle = Pointer; // /include/internal/cef_types_win.h (cef_cursor_handle_t) - TCefEventHandle = Pointer; // /include/internal/cef_types_win.h (cef_event_handle_t) + + {$IFDEF MACOSX} + {$IFDEF FPC} + TCefWindowHandle = type PtrUInt; // /include/internal/cef_types_mac.h (cef_window_handle_t) + TCefCursorHandle = type PtrUInt; // /include/internal/cef_types_mac.h (cef_cursor_handle_t) + TCefEventHandle = type PtrUInt; // /include/internal/cef_types_mac.h (cef_event_handle_t) + {$ELSE} + TCefWindowHandle = type Pointer; // /include/internal/cef_types_mac.h (cef_window_handle_t) + TCefCursorHandle = type Pointer; // /include/internal/cef_types_mac.h (cef_cursor_handle_t) + TCefEventHandle = type Pointer; // /include/internal/cef_types_mac.h (cef_event_handle_t) + {$ENDIF} {$ENDIF} + {$IFDEF LINUX} - TCefWindowHandle = cardinal; // /include/internal/cef_types_win.h (cef_window_handle_t) - TCefCursorHandle = cardinal; // /include/internal/cef_types_win.h (cef_cursor_handle_t) - TCefEventHandle = PXEvent; // /include/internal/cef_types_win.h (cef_event_handle_t) + {$IFDEF FPC} + TCefWindowHandle = type culong; // /include/internal/cef_types_linux.h (cef_window_handle_t) + TCefCursorHandle = type culong; // /include/internal/cef_types_linux.h (cef_cursor_handle_t) + {$ELSE} + TCefWindowHandle = type LongWord; // /include/internal/cef_types_linux.h (cef_window_handle_t) + TCefCursorHandle = type LongWord; // /include/internal/cef_types_linux.h (cef_cursor_handle_t) + {$ENDIF} + TCefEventHandle = type PXEvent; // /include/internal/cef_types_linux.h (cef_event_handle_t) {$ENDIF} + + + // All these types are declared as constants in uCEFConstants.pas. + // Search the type name between the parentheses in uCEFConstants.pas. + // + // Open the original header file for more details : + // https://github.com/chromiumembedded/cef/blob/master/include/internal/cef_types.h + // https://github.com/chromiumembedded/cef/blob/master/include/internal/cef_thread_internal.h + // https://github.com/chromiumembedded/cef/blob/master/include/internal/cef_string_list.h + // https://github.com/chromiumembedded/cef/blob/master/include/internal/cef_string_map.h + // https://github.com/chromiumembedded/cef/blob/master/include/internal/cef_string_multimap.h + TCefPlatformThreadId = DWORD; // /include/internal/cef_thread_internal.h (cef_platform_thread_id_t) TCefPlatformThreadHandle = DWORD; // /include/internal/cef_thread_internal.h (cef_platform_thread_handle_t) TCefTransitionType = Cardinal; // /include/internal/cef_types.h (cef_transition_type_t) @@ -276,6 +316,13 @@ type TCefJsonWriterOptions = Cardinal; // /include/internal/cef_types.h (cef_json_writer_options_t) TCefSSLContentStatus = Cardinal; // /include/internal/cef_types.h (cef_ssl_content_status_t) TCefLogSeverity = Cardinal; // /include/internal/cef_types.h (cef_log_severity_t) + TCefFileDialogMode = Cardinal; // /include/internal/cef_types.h (cef_file_dialog_mode_t) + TCefDuplexMode = Integer; // /include/internal/cef_types.h (cef_duplex_mode_t) + TCefSchemeOptions = Integer; // /include/internal/cef_types.h (cef_scheme_options_t) + TCefMediaRouterCreateResult = Integer; // /include/internal/cef_types.h (cef_media_route_create_result_t) + TCefCookiePriority = Integer; // /include/internal/cef_types.h (cef_cookie_priority_t) + TCefTextFieldCommands = Integer; // /include/internal/cef_types.h (cef_text_field_commands_t) + {$IFDEF FPC} NativeInt = PtrInt; @@ -302,6 +349,49 @@ type {$ENDIF} {$ENDIF} + TCefCustomByteArray = array of byte; // Needed only for backwards compatibility with old Delphi versions + + {$IFDEF MSWINDOWS} + TMyMemoryStatusEx = record + dwLength : DWORD; + dwMemoryLoad : DWORD; + ullTotalPhys : uint64; + ullAvailPhys : uint64; + ullTotalPageFile : uint64; + ullAvailPageFile : uint64; + ullTotalVirtual : uint64; + ullAvailVirtual : uint64; + ullAvailExtendedVirtual : uint64; + end; + + TOSVersionInfoEx = record + dwOSVersionInfoSize: DWORD; + dwMajorVersion: DWORD; + dwMinorVersion: DWORD; + dwBuildNumber: DWORD; + dwPlatformId: DWORD; + szCSDVersion: array[0..127] of WideChar; + wServicePackMajor: WORD; + wServicePackMinor: WORD; + wSuiteMask: WORD; + wProductType: BYTE; + wReserved:BYTE; + end; + + {$IFDEF DELPHI14_UP} + TDigitizerStatus = record + IntegratedTouch : boolean; + ExternalTouch : boolean; + IntegratedPen : boolean; + ExternalPen : boolean; + MultiInput : boolean; + Ready : boolean; + end; + {$ENDIF} + {$ENDIF} + + PPSingle = ^PSingle; + Char16 = WideChar; PChar16 = PWideChar; @@ -344,7 +434,23 @@ type Build : uint16; end; - TCefProcessType = (ptBrowser, ptRenderer, ptZygote, ptGPU, ptOther); + // Used in TChromium.Onclose + // ------------------------- + // cbaCancel : stop closing the browser + // cbaClose : continue closing the browser + // cbaDelay : stop closing the browser momentarily. Used when the application + // needs to execute some custom processes before closing the + // browser. This is usually needed to destroy a TCEFWindowParent + // in the main thread before closing the browser. + TCefCloseBrowserAction = (cbaClose, cbaDelay, cbaCancel); + + TCefProcessType = (ptBrowser, ptRenderer, ptZygote, ptGPU, ptUtility, ptBroker, ptOther); + + // Used in TChromium preferences to allow or block cookies. + TCefCookiePref = (cpDefault, cpAllow, cpBlock); + + // Used by TCefBrowserNavigationTask to navigate in the right CEF thread + TCefBrowserNavigation = (bnBack, bnForward, bnReload, bnReloadIgnoreCache, bnStopLoad); TCefAplicationStatus = (asLoading, asLoaded, @@ -359,6 +465,22 @@ type TCefProxyScheme = (psHTTP, psSOCKS4, psSOCKS5); + TCefClearDataStorageTypes = (cdstAppCache, + cdstCookies, + cdstFileSystems, + cdstIndexeddb, + cdstLocalStorage, + cdstShaderCache, + cdstWebsql, + cdstServiceWorkers, + cdstCacheStorage, + cdstAll); + + TCefAutoplayPolicy = (appDefault, + appDocumentUserActivationRequired, + appNoUserGestureRequired, + appUserGestureRequired); + TCefWebRTCHandlingPolicy = ( hpDefault, hpDefaultPublicAndPrivateInterfaces, @@ -366,6 +488,9 @@ type hpDisableNonProxiedUDP ); + // Used by TCefMediaSinkInfo and TCefMediaSourceInfo + TCefMediaType = (mtCast, mtDial, mtUnknown); + // /include/internal/cef_types_win.h (cef_main_args_t) TCefMainArgs = record {$IFDEF MSWINDOWS} @@ -383,7 +508,8 @@ type width : Integer; height : Integer; end; - TCefRectArray = array[0..(High(Integer) div SizeOf(TCefRect))-1] of TCefRect; + TCefRectArray = array[0..(High(Integer) div SizeOf(TCefRect))-1] of TCefRect; + TCefRectDynArray = array of TCefRect; // /include/internal/cef_types.h (cef_point_t) TCefPoint = record @@ -423,6 +549,7 @@ type origin : TCefString; path : TCefString; query : TCefString; + fragment : TCefString; end; TUrlParts = record @@ -435,6 +562,7 @@ type origin : ustring; path : ustring; query : ustring; + fragment : ustring; end; // /include/internal/cef_types.h (cef_insets_t) @@ -445,20 +573,6 @@ type right : Integer; end; - // /include/internal/cef_types.h (cef_json_parser_error_t) - TCefJsonParserError = ( - JSON_NO_ERROR = 0, - JSON_INVALID_ESCAPE, - JSON_SYNTAX_ERROR, - JSON_UNEXPECTED_TOKEN, - JSON_TRAILING_COMMA, - JSON_TOO_MUCH_NESTING, - JSON_UNEXPECTED_DATA_AFTER_ROOT, - JSON_UNSUPPORTED_ENCODING, - JSON_UNQUOTED_DICTIONARY_KEY, - JSON_PARSE_ERROR_COUNT - ); - // /include/internal/cef_types.h (cef_state_t) TCefState = ( STATE_DEFAULT = 0, @@ -493,6 +607,28 @@ type VTYPE_LIST ); + // /include/internal/cef_types.h (cef_media_route_connection_state_t) + TCefMediaRouteConnectionState = ( + CEF_MRCS_UNKNOWN, + CEF_MRCS_CONNECTING, + CEF_MRCS_CONNECTED, + CEF_MRCS_CLOSED, + CEF_MRCS_TERMINATED + ); + + // /include/internal/cef_types.h (cef_media_sink_icon_type_t) + TCefMediaSinkIconType = ( + CEF_MSIT_CAST, + CEF_MSIT_CAST_AUDIO_GROUP, + CEF_MSIT_CAST_AUDIO, + CEF_MSIT_MEETING, + CEF_MSIT_HANGOUT, + CEF_MSIT_EDUCATION, + CEF_MSIT_WIRED_DISPLAY, + CEF_MSIT_GENERIC, + CEF_MSIT_TOTAL_COUNT + ); + // /include/internal/cef_types.h (cef_referrer_policy_t) TCefReferrerPolicy = ( REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, // same value as REFERRER_POLICY_DEFAULT @@ -502,8 +638,7 @@ type REFERRER_POLICY_ORIGIN, REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN, REFERRER_POLICY_ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE, - REFERRER_POLICY_NO_REFERRER, - REFERRER_POLICY_LAST_VALUE + REFERRER_POLICY_NO_REFERRER // REFERRER_POLICY_LAST_VALUE = REFERRER_POLICY_NO_REFERRER ); // /include/internal/cef_types.h (cef_postdataelement_type_t) @@ -577,17 +712,6 @@ type MENUITEMTYPE_SUBMENU ); - // /include/internal/cef_types.h (cef_file_dialog_mode_t) - TCefFileDialogMode = ( - FILE_DIALOG_OPEN, - FILE_DIALOG_OPEN_MULTIPLE, - FILE_DIALOG_OPEN_FOLDER, - FILE_DIALOG_SAVE, - FILE_DIALOG_TYPE_MASK = $FF, - FILE_DIALOG_OVERWRITEPROMPT_FLAG = $01000000, - FILE_DIALOG_HIDEREADONLY_FLAG = $02000000 - ); - // /include/internal/cef_types.h (cef_focus_source_t) TCefFocusSource = ( FOCUS_SOURCE_NAVIGATION = 0, @@ -623,6 +747,81 @@ type WOD_IGNORE_ACTION ); + // /include/internal/cef_types.h (cef_text_input_mode_t) + TCefTextInpuMode = ( + CEF_TEXT_INPUT_MODE_DEFAULT, + CEF_TEXT_INPUT_MODE_NONE, + CEF_TEXT_INPUT_MODE_TEXT, + CEF_TEXT_INPUT_MODE_TEL, + CEF_TEXT_INPUT_MODE_URL, + CEF_TEXT_INPUT_MODE_EMAIL, + CEF_TEXT_INPUT_MODE_NUMERIC, + CEF_TEXT_INPUT_MODE_DECIMAL, + CEF_TEXT_INPUT_MODE_SEARCH // CEF_TEXT_INPUT_MODE_MAX = CEF_TEXT_INPUT_MODE_SEARCH + ); + + // /include/internal/cef_types.h (cef_touch_event_type_t) + TCefTouchEeventType = ( + CEF_TET_RELEASED = 0, + CEF_TET_PRESSED, + CEF_TET_MOVED, + CEF_TET_CANCELLED + ); + + // /include/internal/cef_types.h (cef_pointer_type_t) + TCefPointerType = ( + CEF_POINTER_TYPE_TOUCH = 0, + CEF_POINTER_TYPE_MOUSE, + CEF_POINTER_TYPE_PEN, + CEF_POINTER_TYPE_ERASER, + CEF_POINTER_TYPE_UNKNOWN + ); + + // /include/internal/cef_types.h (cef_channel_layout_t) + TCefChannelLayout = ( + CEF_CHANNEL_LAYOUT_NONE = 0, + CEF_CHANNEL_LAYOUT_UNSUPPORTED, + CEF_CHANNEL_LAYOUT_MONO, + CEF_CHANNEL_LAYOUT_STEREO, + CEF_CHANNEL_LAYOUT_2_1, + CEF_CHANNEL_LAYOUT_SURROUND, + CEF_CHANNEL_LAYOUT_4_0, + CEF_CHANNEL_LAYOUT_2_2, + CEF_CHANNEL_LAYOUT_QUAD, + CEF_CHANNEL_LAYOUT_5_0, + CEF_CHANNEL_LAYOUT_5_1, + CEF_CHANNEL_LAYOUT_5_0_BACK, + CEF_CHANNEL_LAYOUT_5_1_BACK, + CEF_CHANNEL_LAYOUT_7_0, + CEF_CHANNEL_LAYOUT_7_1, + CEF_CHANNEL_LAYOUT_7_1_WIDE, + CEF_CHANNEL_LAYOUT_STEREO_DOWNMIX, + CEF_CHANNEL_LAYOUT_2POINT1, + CEF_CHANNEL_LAYOUT_3_1, + CEF_CHANNEL_LAYOUT_4_1, + CEF_CHANNEL_LAYOUT_6_0, + CEF_CHANNEL_LAYOUT_6_0_FRONT, + CEF_CHANNEL_LAYOUT_HEXAGONAL, + CEF_CHANNEL_LAYOUT_6_1, + CEF_CHANNEL_LAYOUT_6_1_BACK, + CEF_CHANNEL_LAYOUT_6_1_FRONT, + CEF_CHANNEL_LAYOUT_7_0_FRONT, + CEF_CHANNEL_LAYOUT_7_1_WIDE_BACK, + CEF_CHANNEL_LAYOUT_OCTAGONAL, + CEF_CHANNEL_LAYOUT_DISCRETE, + CEF_CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, + CEF_CHANNEL_LAYOUT_4_1_QUAD_SIDE, + CEF_CHANNEL_LAYOUT_BITSTREAM // CEF_CHANNEL_LAYOUT_MAX = CEF_CHANNEL_LAYOUT_BITSTREAM + ); + + // /include/internal/cef_types.h (cef_cookie_same_site_t) + TCefCookieSameSite = ( + CEF_COOKIE_SAME_SITE_UNSPECIFIED, + CEF_COOKIE_SAME_SITE_NO_RESTRICTION, + CEF_COOKIE_SAME_SITE_LAX_MODE, + CEF_COOKIE_SAME_SITE_STRICT_MODE + ); + // /include/internal/cef_types.h (cef_paint_element_type_t) TCefPaintElementType = ( PET_VIEW, @@ -674,7 +873,13 @@ type CT_ZOOMOUT, CT_GRAB, CT_GRABBING, - CT_CUSTOM + CT_MIDDLE_PANNING_VERTICAL, + CT_MIDDLE_PANNING_HORIZONTAL, + CT_CUSTOM, + CT_DND_NONE, + CT_DND_MOVE, + CT_DND_COPY, + CT_DND_LIN ); // /include/internal/cef_types.h (cef_navigation_type_t) @@ -753,7 +958,8 @@ type TCefTerminationStatus = ( TS_ABNORMAL_TERMINATION, TS_PROCESS_WAS_KILLED, - TS_PROCESS_CRASHED + TS_PROCESS_CRASHED, + TS_PROCESS_OOM ); // /include/internal/cef_types.h (cef_path_key_t) @@ -790,6 +996,13 @@ type PLUGIN_POLICY_DISABLE ); + // cef/libcef/common/cef_switches.cc (values for the --plugin-policy switch) + TCefPluginPolicySwitch = ( + PLUGIN_POLICY_SWITCH_ALLOW, // Default value + PLUGIN_POLICY_SWITCH_DETECT, + PLUGIN_POLICY_SWITCH_BLOCK + ); + // /include/internal/cef_types.h (cef_color_type_t) TCefColorType = ( CEF_COLOR_TYPE_RGBA_8888, @@ -860,14 +1073,6 @@ type COLOR_MODEL_PROCESSCOLORMODEL_RGB ); - // /include/internal/cef_types.h (cef_duplex_mode_t) - TCefDuplexMode = ( - DUPLEX_MODE_UNKNOWN = -1, - DUPLEX_MODE_SIMPLEX, - DUPLEX_MODE_LONG_EDGE, - DUPLEX_MODE_SHORT_EDGE - ); - // /include/internal/cef_types.h (cef_json_parser_options_t) TCefJsonParserOptions = ( JSON_PARSER_RFC = 0, @@ -947,13 +1152,32 @@ type CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED ); + // Values for browser preference "net.network_prediction_options" + // https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/net/prediction_options.h + TCefNetworkPredictionOptions = ( + CEF_NETWORK_PREDICTION_ALWAYS, + CEF_NETWORK_PREDICTION_WIFI_ONLY, + CEF_NETWORK_PREDICTION_NEVER + // CEF_NETWORK_PREDICTION_DEFAULT = CEF_NETWORK_PREDICTION_WIFI_ONLY; + ); + + // /include/internal/cef_types.h (cef_composition_underline_style_t) + TCefCompositionUnderlineStyle = ( + CEF_CUS_SOLID, + CEF_CUS_DOT, + CEF_CUS_DASH, + CEF_CUS_NONE + ); + // /include/internal/cef_types.h (cef_composition_underline_t) TCefCompositionUnderline = record range : TCefRange; color : TCefColor; background_color : TCefColor; thick : integer; + style : TCefCompositionUnderlineStyle; end; + TCefCompositionUnderlineDynArray = array of TCefCompositionUnderline; // /include/internal/cef_time.h (cef_time_t) TCefTime = record @@ -982,34 +1206,36 @@ type // /include/internal/cef_types.h (cef_settings_t) TCefSettings = record - size : NativeUInt; - single_process : Integer; - no_sandbox : Integer; - browser_subprocess_path : TCefString; - framework_dir_path : TCefString; - multi_threaded_message_loop : Integer; - external_message_pump : Integer; - windowless_rendering_enabled : Integer; - command_line_args_disabled : Integer; - cache_path : TCefString; - user_data_path : TCefString; - persist_session_cookies : Integer; - persist_user_preferences : Integer; - user_agent : TCefString; - product_version : TCefString; - locale : TCefString; - log_file : TCefString; - log_severity : TCefLogSeverity; - javascript_flags : TCefString; - resources_dir_path : TCefString; - locales_dir_path : TCefString; - pack_loading_disabled : Integer; - remote_debugging_port : Integer; - uncaught_exception_stack_size : Integer; - ignore_certificate_errors : Integer; - enable_net_security_expiration : integer; - background_color : TCefColor; - accept_language_list : TCefString; + size : NativeUInt; + no_sandbox : Integer; + browser_subprocess_path : TCefString; + framework_dir_path : TCefString; + main_bundle_path : TCefString; // Only used in macOS + chrome_runtime : Integer; + multi_threaded_message_loop : Integer; + external_message_pump : Integer; + windowless_rendering_enabled : Integer; + command_line_args_disabled : Integer; + cache_path : TCefString; + root_cache_path : TCefString; + user_data_path : TCefString; + persist_session_cookies : Integer; + persist_user_preferences : Integer; + user_agent : TCefString; + product_version : TCefString; + locale : TCefString; + log_file : TCefString; + log_severity : TCefLogSeverity; + javascript_flags : TCefString; + resources_dir_path : TCefString; + locales_dir_path : TCefString; + pack_loading_disabled : Integer; + remote_debugging_port : Integer; + uncaught_exception_stack_size : Integer; + ignore_certificate_errors : Integer; + background_color : TCefColor; + accept_language_list : TCefString; + application_client_id_for_file_scanning : TCefString; end; // /include/internal/cef_types_win.h (cef_window_info_t) @@ -1025,9 +1251,11 @@ type parent_window : TCefWindowHandle; menu : HMENU; windowless_rendering_enabled : Integer; + shared_texture_enabled : Integer; + external_begin_frame_enabled : Integer; window : TCefWindowHandle; {$ENDIF} - {$IFDEF MACOS} + {$IFDEF MACOSX} window_name : TCefString; x : Integer; y : Integer; @@ -1036,15 +1264,20 @@ type hidden : Integer; parent_view : TCefWindowHandle; windowless_rendering_enabled : Integer; + shared_texture_enabled : Integer; + external_begin_frame_enabled : Integer; view : TCefWindowHandle; {$ENDIF} {$IFDEF LINUX} + window_name : TCefString; x : uint32; y : uint32; width : uint32; height : uint32; parent_window : TCefWindowHandle; windowless_rendering_enabled : Integer; + shared_texture_enabled : Integer; + external_begin_frame_enabled : Integer; window : TCefWindowHandle; {$ENDIF} end; @@ -1059,7 +1292,7 @@ type // /include/internal/cef_types.h (cef_key_event_t) TCefKeyEvent = record - kind : TCefKeyEventType; // called 'type' in the original CEF3 source code + kind : TCefKeyEventType; // called 'type' in the original CEF source code modifiers : TCefEventFlags; windows_key_code : Integer; native_key_code : Integer; @@ -1138,7 +1371,6 @@ type persist_session_cookies : Integer; persist_user_preferences : Integer; ignore_certificate_errors : Integer; - enable_net_security_expiration : integer; accept_language_list : TCefString; end; @@ -1154,6 +1386,8 @@ type last_access : TCefTime; has_expires : Integer; expires : TCefTime; + same_site : TCefCookieSameSite; + priority : TCefCookiePriority; end; TCookie = record @@ -1167,6 +1401,8 @@ type secure : boolean; httponly : boolean; has_expires : boolean; + same_site : TCefCookieSameSite; + priority : TCefCookiePriority; end; // /include/internal/cef_types.h (cef_pdf_print_settings_t) @@ -1176,10 +1412,10 @@ type page_width : Integer; page_height : Integer; scale_factor : Integer; - margin_top : double; - margin_right : double; - margin_bottom : double; - margin_left : double; + margin_top : Integer; + margin_right : Integer; + margin_bottom : Integer; + margin_left : Integer; margin_type : TCefPdfPrintMarginType; header_footer_enabled : Integer; selection_only : Integer; @@ -1194,12 +1430,41 @@ type modifiers : TCefEventFlags; end; + // /include/internal/cef_types.h (cef_touch_event_t) + TCefTouchEvent = record + id : integer; + x : single; + y : single; + radius_x : single; + radius_y : single; + rotation_angle : single; + pressure : single; + type_ : TCefTouchEeventType; + modifiers : TCefEventFlags; + pointer_type : TCefPointerType; + end; + + // /include/internal/cef_types.h (cef_audio_parameters_t) + TCefAudioParameters = record + channel_layout : TCefChannelLayout; + sample_rate : integer; + frames_per_buffer : integer; + end; + + // /include/internal/cef_types.h (cef_media_sink_device_info_t) + TCefMediaSinkDeviceInfo = record + ip_address : TCefString; + port : integer; + model_name : TCefString; + end; + // /include/capi/cef_base_capi.h (cef_base_ref_counted_t) TCefBaseRefCounted = record - size : NativeUInt; - add_ref : procedure(self: PCefBaseRefCounted); stdcall; - release : function(self: PCefBaseRefCounted): Integer; stdcall; - has_one_ref : function(self: PCefBaseRefCounted): Integer; stdcall; + size : NativeUInt; + add_ref : procedure(self: PCefBaseRefCounted); stdcall; + release : function(self: PCefBaseRefCounted): Integer; stdcall; + has_one_ref : function(self: PCefBaseRefCounted): Integer; stdcall; + has_at_least_one_ref : function(self: PCefBaseRefCounted): Integer; stdcall; end; // /include/capi/cef_base_capi.h (cef_base_scoped_t) @@ -1302,6 +1567,7 @@ type on_console_message : function(self: PCefDisplayHandler; browser: PCefBrowser; level: TCefLogSeverity; const message_, source: PCefString; line: Integer): Integer; stdcall; on_auto_resize : function(self: PCefDisplayHandler; browser: PCefBrowser; const new_size: PCefSize): Integer; stdcall; on_loading_progress_change : procedure(self: PCefDisplayHandler; browser: PCefBrowser; progress: double); stdcall; + on_cursor_change : function(self: PCefDisplayHandler; browser: PCefBrowser; cursor: TCefCursorHandle; type_: TCefCursorType; const custom_cursor_info: PCefCursorInfo): Integer; stdcall; end; // /include/capi/cef_download_handler_capi.h (cef_download_handler_t) @@ -1315,7 +1581,7 @@ type TCefDragHandler = record base : TCefBaseRefCounted; on_drag_enter : function(self: PCefDragHandler; browser: PCefBrowser; dragData: PCefDragData; mask: TCefDragOperations): Integer; stdcall; - on_draggable_regions_changed : procedure(self: PCefDragHandler; browser: PCefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); stdcall; + on_draggable_regions_changed : procedure(self: PCefDragHandler; browser: PCefBrowser; frame: PCefFrame; regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); stdcall; end; // /include/capi/cef_find_handler_capi.h (cef_find_handler_t) @@ -1357,12 +1623,89 @@ type // /include/capi/cef_life_span_handler_capi.h (cef_life_span_handler_t) TCefLifeSpanHandler = record base : TCefBaseRefCounted; - on_before_popup : function(self: PCefLifeSpanHandler; browser: PCefBrowser; frame: PCefFrame; const target_url, target_frame_name: PCefString; target_disposition: TCefWindowOpenDisposition; user_gesture: Integer; const popupFeatures: PCefPopupFeatures; windowInfo: PCefWindowInfo; var client: PCefClient; settings: PCefBrowserSettings; no_javascript_access: PInteger): Integer; stdcall; + on_before_popup : function(self: PCefLifeSpanHandler; browser: PCefBrowser; frame: PCefFrame; const target_url, target_frame_name: PCefString; target_disposition: TCefWindowOpenDisposition; user_gesture: Integer; const popupFeatures: PCefPopupFeatures; windowInfo: PCefWindowInfo; var client: PCefClient; settings: PCefBrowserSettings; var extra_info: PCefDictionaryValue; no_javascript_access: PInteger): Integer; stdcall; on_after_created : procedure(self: PCefLifeSpanHandler; browser: PCefBrowser); stdcall; do_close : function(self: PCefLifeSpanHandler; browser: PCefBrowser): Integer; stdcall; on_before_close : procedure(self: PCefLifeSpanHandler; browser: PCefBrowser); stdcall; end; + // /include/capi/cef_registration_capi.h (cef_registration_t) + TCefRegistration = record + base : TCefBaseRefCounted; + end; + + // /include/capi/cef_devtools_message_observer_capi.h (cef_dev_tools_message_observer_t) + TCefDevToolsMessageObserver = record + base : TCefBaseRefCounted; + on_dev_tools_message : function(self: PCefDevToolsMessageObserver; browser: PCefBrowser; const message_: Pointer; message_size: NativeUInt): Integer; stdcall; + on_dev_tools_method_result : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser; message_id, success: Integer; const result: Pointer; result_size: NativeUInt); stdcall; + on_dev_tools_event : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser; const method: PCefString; const params: Pointer; params_size: NativeUInt); stdcall; + on_dev_tools_agent_attached : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser); stdcall; + on_dev_tools_agent_detached : procedure(self: PCefDevToolsMessageObserver; browser: PCefBrowser); stdcall; + end; + + // /include/capi/cef_media_router_capi.h (cef_media_router_t) + TCefMediaRouter = record + base : TCefBaseRefCounted; + add_observer : function(self: PCefMediaRouter; observer: PCefMediaObserver): PCefRegistration; stdcall; + get_source : function(self: PCefMediaRouter; const urn: PCefString): PCefMediaSource; stdcall; + notify_current_sinks : procedure(self: PCefMediaRouter); stdcall; + create_route : procedure(self: PCefMediaRouter; source: PCefMediaSource; sink: PCefMediaSink; callback: PCefMediaRouteCreateCallback); stdcall; + notify_current_routes : procedure(self: PCefMediaRouter); stdcall; + end; + + // /include/capi/cef_media_router_capi.h (cef_media_observer_t) + TCefMediaObserver = record + base : TCefBaseRefCounted; + on_sinks : procedure(self: PCefMediaObserver; sinksCount: NativeUInt; const sinks: PPCefMediaSink); stdcall; + on_routes : procedure(self: PCefMediaObserver; routesCount: NativeUInt; const routes: PPCefMediaRoute); stdcall; + on_route_state_changed : procedure(self: PCefMediaObserver; route: PCefMediaRoute; state: TCefMediaRouteConnectionState); stdcall; + on_route_message_received : procedure(self: PCefMediaObserver; route: PCefMediaRoute; const message_: Pointer; message_size: NativeUInt); stdcall; + end; + + // /include/capi/cef_media_router_capi.h (cef_media_route_t) + TCefMediaRoute = record + base : TCefBaseRefCounted; + get_id : function(self: PCefMediaRoute): PCefStringUserFree; stdcall; + get_source : function(self: PCefMediaRoute): PCefMediaSource; stdcall; + get_sink : function(self: PCefMediaRoute): PCefMediaSink; stdcall; + send_route_message : procedure(self: PCefMediaRoute; const message_: Pointer; message_size: NativeUInt); stdcall; + terminate : procedure(self: PCefMediaRoute); stdcall; + end; + + // /include/capi/cef_media_router_capi.h (cef_media_route_create_callback_t) + TCefMediaRouteCreateCallback = record + base : TCefBaseRefCounted; + on_media_route_create_finished : procedure(self: PCefMediaRouteCreateCallback; result: TCefMediaRouterCreateResult; const error: PCefString; route: PCefMediaRoute); stdcall; + end; + + // /include/capi/cef_media_router_capi.h (cef_media_sink_t) + TCefMediaSink = record + base : TCefBaseRefCounted; + get_id : function(self: PCefMediaSink): PCefStringUserFree; stdcall; + get_name : function(self: PCefMediaSink): PCefStringUserFree; stdcall; + get_description : function(self: PCefMediaSink): PCefStringUserFree; stdcall; + get_icon_type : function(self: PCefMediaSink): TCefMediaSinkIconType; stdcall; + get_device_info : procedure(self: PCefMediaSink; callback: PCefMediaSinkDeviceInfoCallback); stdcall; + is_cast_sink : function(self: PCefMediaSink): Integer; stdcall; + is_dial_sink : function(self: PCefMediaSink): Integer; stdcall; + is_compatible_with : function(self: PCefMediaSink; source: PCefMediaSource): Integer; stdcall; + end; + + // /include/capi/cef_media_router_capi.h (cef_media_sink_device_info_callback_t) + TCefMediaSinkDeviceInfoCallback = record + base : TCefBaseRefCounted; + on_media_sink_device_info : procedure(self: PCefMediaSinkDeviceInfoCallback; device_info: PCefMediaSinkDeviceInfo); stdcall; + end; + + // /include/capi/cef_media_router_capi.h (cef_media_source_t) + TCefMediaSource = record + base : TCefBaseRefCounted; + get_id : function(self: PCefMediaSource): PCefStringUserFree; stdcall; + is_cast_source : function(self: PCefMediaSource): Integer; stdcall; + is_dial_source : function(self: PCefMediaSource): Integer; stdcall; + end; + // /include/capi/cef_extension_handler_capi.h (cef_get_extension_resource_callback_t) TCefGetExtensionResourceCallback = record base : TCefBaseRefCounted; @@ -1383,6 +1726,16 @@ type get_extension_resource : function(self: PCefExtensionHandler; extension: PCefExtension; browser: PCefBrowser; const file_: PCefString; callback: PCefGetExtensionResourceCallback): Integer; stdcall; end; + // /include/capi/cef_audio_handler_capi.h (cef_audio_handler_t) + TCefAudioHandler = record + base : TCefBaseRefCounted; + get_audio_parameters : function(self: PCefAudioHandler; browser: PCefBrowser; params: PCefAudioParameters): Integer; stdcall; + on_audio_stream_started : procedure(self: PCefAudioHandler; browser: PCefBrowser; const params: PCefAudioParameters; channels: integer); stdcall; + on_audio_stream_packet : procedure(self: PCefAudioHandler; browser: PCefBrowser; const data : PPSingle; frames: integer; pts: int64); stdcall; + on_audio_stream_stopped : procedure(self: PCefAudioHandler; browser: PCefBrowser); stdcall; + on_audio_stream_error : procedure(self: PCefAudioHandler; browser: PCefBrowser; const message_: PCefString); stdcall; + end; + // /include/capi/cef_extension_capi.h (cef_extension_t) TCefExtension = record base : TCefBaseRefCounted; @@ -1410,18 +1763,19 @@ type base : TCefBaseRefCounted; get_accessibility_handler : function(self: PCefRenderHandler): PCefAccessibilityHandler; stdcall; get_root_screen_rect : function(self: PCefRenderHandler; browser: PCefBrowser; rect: PCefRect): Integer; stdcall; - get_view_rect : function(self: PCefRenderHandler; browser: PCefBrowser; rect: PCefRect): Integer; stdcall; + get_view_rect : procedure(self: PCefRenderHandler; browser: PCefBrowser; rect: PCefRect); stdcall; get_screen_point : function(self: PCefRenderHandler; browser: PCefBrowser; viewX, viewY: Integer; screenX, screenY: PInteger): Integer; stdcall; get_screen_info : function(self: PCefRenderHandler; browser: PCefBrowser; screen_info: PCefScreenInfo): Integer; stdcall; on_popup_show : procedure(self: PCefRenderHandler; browser: PCefBrowser; show: Integer); stdcall; on_popup_size : procedure(self: PCefRenderHandler; browser: PCefBrowser; const rect: PCefRect); stdcall; - on_paint : procedure(self: PCefRenderHandler; browser: PCefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); stdcall; - on_cursor_change : procedure(self: PCefRenderHandler; browser: PCefBrowser; cursor: TCefCursorHandle; type_: TCefCursorType; const custom_cursor_info: PCefCursorInfo); stdcall; + on_paint : procedure(self: PCefRenderHandler; browser: PCefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); stdcall; + on_accelerated_paint : procedure(self: PCefRenderHandler; browser: PCefBrowser; type_: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; shared_handle: Pointer); stdcall; start_dragging : function(self: PCefRenderHandler; browser: PCefBrowser; drag_data: PCefDragData; allowed_ops: TCefDragOperations; x, y: Integer): Integer; stdcall; update_drag_cursor : procedure(self: PCefRenderHandler; browser: PCefBrowser; operation: TCefDragOperation); stdcall; on_scroll_offset_changed : procedure(self: PCefRenderHandler; browser: PCefBrowser; x, y: Double); stdcall; on_ime_composition_range_changed : procedure(self: PCefRenderHandler; browser: PCefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); stdcall; on_text_selection_changed : procedure(self: PCefRenderHandler; browser: PCefBrowser; const selected_text: PCefString; const selected_range: PCefRange); stdcall; + on_virtual_keyboard_requested : procedure(self: PCefRenderHandler; browser: PCefBrowser; input_mode: TCefTextInpuMode); stdcall; end; // /include/capi/cef_v8_capi.h (cef_v8stack_trace_t) @@ -1606,8 +1960,8 @@ type TCefResourceBundle = record base : TCefBaseRefCounted; get_localized_string : function(self: PCefResourceBundle; string_id: Integer): PCefStringUserFree; stdcall; - get_data_resource : function(self: PCefResourceBundle; resource_id: Integer; var data: Pointer; var data_size: NativeUInt): Integer; stdcall; - get_data_resource_for_scale : function(self: PCefResourceBundle; resource_id: Integer; scale_factor: TCefScaleFactor; var data: Pointer; var data_size: NativeUInt): Integer; stdcall; + get_data_resource : function(self: PCefResourceBundle; resource_id: Integer): PCefBinaryValue; stdcall; + get_data_resource_for_scale : function(self: PCefResourceBundle; resource_id: Integer; scale_factor: TCefScaleFactor): PCefBinaryValue; stdcall; end; // /include/capi/cef_menu_model_delegate_capi.h (cef_menu_model_delegate_t) @@ -1635,76 +1989,104 @@ type // /include/capi/cef_render_process_handler_capi.h (cef_render_process_handler_t) TCefRenderProcessHandler = record base : TCefBaseRefCounted; - on_render_thread_created : procedure(self: PCefRenderProcessHandler; extra_info: PCefListValue); stdcall; on_web_kit_initialized : procedure(self: PCefRenderProcessHandler); stdcall; - on_browser_created : procedure(self: PCefRenderProcessHandler; browser: PCefBrowser); stdcall; + on_browser_created : procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; extra_info: PCefDictionaryValue); stdcall; on_browser_destroyed : procedure(self: PCefRenderProcessHandler; browser: PCefBrowser); stdcall; get_load_handler : function(self: PCefRenderProcessHandler): PCefLoadHandler; stdcall; on_context_created : procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context); stdcall; on_context_released : procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context); stdcall; on_uncaught_exception : procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; context: PCefv8Context; exception: PCefV8Exception; stackTrace: PCefV8StackTrace); stdcall; on_focused_node_changed : procedure(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; node: PCefDomNode); stdcall; - on_process_message_received : function(self: PCefRenderProcessHandler; browser: PCefBrowser; source_process: TCefProcessId; message_: PCefProcessMessage): Integer; stdcall; + on_process_message_received : function(self: PCefRenderProcessHandler; browser: PCefBrowser; frame: PCefFrame; source_process: TCefProcessId; message_: PCefProcessMessage): Integer; stdcall; end; // /include/capi/cef_request_handler_capi.h (cef_request_handler_t) TCefRequestHandler = record - base : TCefBaseRefCounted; - on_before_browse : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; user_gesture, isRedirect: Integer): Integer; stdcall; - on_open_urlfrom_tab : function(self: PCefRequestHandler; browser:PCefBrowser; frame: PCefFrame; const target_url: PCefString; target_disposition: TCefWindowOpenDisposition; user_gesture: Integer): Integer; stdcall; - on_before_resource_load : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; callback: PCefRequestCallback): TCefReturnValue; stdcall; - get_resource_handler : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest): PCefResourceHandler; stdcall; - on_resource_redirect : procedure(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse; new_url: PCefString); stdcall; - on_resource_response : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse): Integer; stdcall; - get_resource_response_filter : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse): PCefResponseFilter; stdcall; - on_resource_load_complete : procedure(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse; status: TCefUrlRequestStatus; received_content_length: Int64); stdcall; - get_auth_credentials : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; isProxy: Integer; const host: PCefString; port: Integer; const realm, scheme: PCefString; callback: PCefAuthCallback): Integer; stdcall; - can_get_cookies : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest): Integer; stdcall; - can_set_cookie : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; const cookie: PCefCookie): Integer; stdcall; - on_quota_request : function(self: PCefRequestHandler; browser: PCefBrowser; const origin_url: PCefString; new_size: Int64; callback: PCefRequestCallback): Integer; stdcall; - on_protocol_execution : procedure(self: PCefRequestHandler; browser: PCefBrowser; const url: PCefString; allow_os_execution: PInteger); stdcall; - on_certificate_error : function(self: PCefRequestHandler; browser: PCefBrowser; cert_error: TCefErrorcode; const request_url: PCefString; ssl_info: PCefSslInfo; callback: PCefRequestCallback): Integer; stdcall; - on_select_client_certificate : function(self: PCefRequestHandler; browser: PCefBrowser; isProxy: integer; const host: PCefString; port: integer; certificatesCount: NativeUInt; const certificates: PPCefX509Certificate; callback: PCefSelectClientCertificateCallback): integer; stdcall; - on_plugin_crashed : procedure(self: PCefRequestHandler; browser: PCefBrowser; const plugin_path: PCefString); stdcall; - on_render_view_ready : procedure(self: PCefRequestHandler; browser: PCefBrowser); stdcall; - on_render_process_terminated : procedure(self: PCefRequestHandler; browser: PCefBrowser; status: TCefTerminationStatus); stdcall; - end; - - // /include/capi/cef_request_handler_capi.h (cef_request_callback_t) + base : TCefBaseRefCounted; + on_before_browse : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; user_gesture, isRedirect: Integer): Integer; stdcall; + on_open_urlfrom_tab : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; const target_url: PCefString; target_disposition: TCefWindowOpenDisposition; user_gesture: Integer): Integer; stdcall; + get_resource_request_handler : function(self: PCefRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; is_navigation, is_download: Integer; const request_initiator: PCefString; disable_default_handling: PInteger): PCefResourceRequestHandler; stdcall; + get_auth_credentials : function(self: PCefRequestHandler; browser: PCefBrowser; const origin_url: PCefString; isProxy: Integer; const host: PCefString; port: Integer; const realm, scheme: PCefString; callback: PCefAuthCallback): Integer; stdcall; + on_quota_request : function(self: PCefRequestHandler; browser: PCefBrowser; const origin_url: PCefString; new_size: Int64; callback: PCefRequestCallback): Integer; stdcall; + on_certificate_error : function(self: PCefRequestHandler; browser: PCefBrowser; cert_error: TCefErrorcode; const request_url: PCefString; ssl_info: PCefSslInfo; callback: PCefRequestCallback): Integer; stdcall; + on_select_client_certificate : function(self: PCefRequestHandler; browser: PCefBrowser; isProxy: integer; const host: PCefString; port: integer; certificatesCount: NativeUInt; const certificates: PPCefX509Certificate; callback: PCefSelectClientCertificateCallback): integer; stdcall; + on_plugin_crashed : procedure(self: PCefRequestHandler; browser: PCefBrowser; const plugin_path: PCefString); stdcall; + on_render_view_ready : procedure(self: PCefRequestHandler; browser: PCefBrowser); stdcall; + on_render_process_terminated : procedure(self: PCefRequestHandler; browser: PCefBrowser; status: TCefTerminationStatus); stdcall; + on_document_available_in_main_frame : procedure(self: PCefRequestHandler; browser: PCefBrowser); stdcall; + end; + + // /include/capi/cef_request_callback_capi.h (cef_request_callback_t) TCefRequestCallback = record base : TCefBaseRefCounted; cont : procedure(self: PCefRequestCallback; allow: Integer); stdcall; cancel : procedure(self: PCefRequestCallback); stdcall; end; + // /include/capi/cef_resource_handler_capi.h (cef_resource_skip_callback_t) + TCefResourceSkipCallback = record + base : TCefBaseRefCounted; + cont : procedure(self: PCefResourceSkipCallback; bytes_skipped: int64); stdcall; + end; + + // /include/capi/cef_resource_handler_capi.h (cef_resource_read_callback_t) + TCefResourceReadCallback = record + base : TCefBaseRefCounted; + cont : procedure(self: PCefResourceReadCallback; bytes_read: int64); stdcall; + end; + // /include/capi/cef_resource_handler_capi.h (cef_resource_handler_t) TCefResourceHandler = record base : TCefBaseRefCounted; - process_request : function(self: PCefResourceHandler; request: PCefRequest; callback: PCefCallback): Integer; stdcall; + open : function(self: PCefResourceHandler; request: PCefRequest; handle_request: PInteger; callback: PCefCallback): Integer; stdcall; + process_request : function(self: PCefResourceHandler; request: PCefRequest; callback: PCefCallback): Integer; stdcall; // deprecated get_response_headers : procedure(self: PCefResourceHandler; response: PCefResponse; response_length: PInt64; redirectUrl: PCefString); stdcall; - read_response : function(self: PCefResourceHandler; data_out: Pointer; bytes_to_read: Integer; bytes_read: PInteger; callback: PCefCallback): Integer; stdcall; - can_get_cookie : function(self: PCefResourceHandler; const cookie: PCefCookie): Integer; stdcall; - can_set_cookie : function(self: PCefResourceHandler; const cookie: PCefCookie): Integer; stdcall; + skip : function(self: PCefResourceHandler; bytes_to_skip: int64; bytes_skipped: PInt64; callback: PCefResourceSkipCallback): Integer; stdcall; + read : function(self: PCefResourceHandler; data_out: Pointer; bytes_to_read: Integer; bytes_read: PInteger; callback: PCefResourceReadCallback): Integer; stdcall; + read_response : function(self: PCefResourceHandler; data_out: Pointer; bytes_to_read: Integer; bytes_read: PInteger; callback: PCefCallback): Integer; stdcall; // deprecated cancel : procedure(self: PCefResourceHandler); stdcall; end; + // /include/capi/cef_resource_request_handler_capi.h (cef_resource_request_handler_t) + TCefResourceRequestHandler = record + base : TCefBaseRefCounted; + get_cookie_access_filter : function(self: PCefResourceRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest): PCefCookieAccessFilter; stdcall; + on_before_resource_load : function(self: PCefResourceRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; callback: PCefRequestCallback): TCefReturnValue; stdcall; + get_resource_handler : function(self: PCefResourceRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest): PCefResourceHandler; stdcall; + on_resource_redirect : procedure(self: PCefResourceRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse; new_url: PCefString); stdcall; + on_resource_response : function(self: PCefResourceRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse): Integer; stdcall; + get_resource_response_filter : function(self: PCefResourceRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse): PCefResponseFilter; stdcall; + on_resource_load_complete : procedure(self: PCefResourceRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse; status: TCefUrlRequestStatus; received_content_length: Int64); stdcall; + on_protocol_execution : procedure(self: PCefResourceRequestHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; allow_os_execution: PInteger); stdcall; + end; + + // /include/capi/cef_resource_request_handler_capi.h (cef_cookie_access_filter_t) + TCefCookieAccessFilter = record + base : TCefBaseRefCounted; + can_send_cookie : function(self: PCefCookieAccessFilter; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; const cookie: PCefCookie): Integer; stdcall; + can_save_cookie : function(self: PCefCookieAccessFilter; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; response: PCefResponse; const cookie: PCefCookie): Integer; stdcall; + end; + // /include/capi/cef_response_capi.h (cef_response_t) TCefResponse = record - base : TCefBaseRefCounted; - is_read_only : function(self: PCefResponse): Integer; stdcall; - get_error : function(self: PCefResponse): TCefErrorCode; stdcall; - set_error : procedure(self: PCefResponse; error: TCefErrorCode); stdcall; - get_status : function(self: PCefResponse): Integer; stdcall; - set_status : procedure(self: PCefResponse; status: Integer); stdcall; - get_status_text : function(self: PCefResponse): PCefStringUserFree; stdcall; - set_status_text : procedure(self: PCefResponse; const statusText: PCefString); stdcall; - get_mime_type : function(self: PCefResponse): PCefStringUserFree; stdcall; - set_mime_type : procedure(self: PCefResponse; const mimeType: PCefString); stdcall; - get_header : function(self: PCefResponse; const name: PCefString): PCefStringUserFree; stdcall; - get_header_map : procedure(self: PCefResponse; headerMap: TCefStringMultimap); stdcall; - set_header_map : procedure(self: PCefResponse; headerMap: TCefStringMultimap); stdcall; - get_url : function(self: PCefResponse): PCefStringUserFree; stdcall; - set_url : procedure(self: PCefResponse; const url: PCefString); stdcall; + base : TCefBaseRefCounted; + is_read_only : function(self: PCefResponse): Integer; stdcall; + get_error : function(self: PCefResponse): TCefErrorCode; stdcall; + set_error : procedure(self: PCefResponse; error: TCefErrorCode); stdcall; + get_status : function(self: PCefResponse): Integer; stdcall; + set_status : procedure(self: PCefResponse; status: Integer); stdcall; + get_status_text : function(self: PCefResponse): PCefStringUserFree; stdcall; + set_status_text : procedure(self: PCefResponse; const statusText: PCefString); stdcall; + get_mime_type : function(self: PCefResponse): PCefStringUserFree; stdcall; + set_mime_type : procedure(self: PCefResponse; const mimeType: PCefString); stdcall; + get_charset : function(self: PCefResponse): PCefStringUserFree; stdcall; + set_charset : procedure(self: PCefResponse; const charset: PCefString); stdcall; + get_header_by_name : function(self: PCefResponse; const name: PCefString): PCefStringUserFree; stdcall; + set_header_by_name : procedure(self: PCefResponse; const name: PCefString; const value: PCefString; overwrite: integer); stdcall; + get_header_map : procedure(self: PCefResponse; headerMap: TCefStringMultimap); stdcall; + set_header_map : procedure(self: PCefResponse; headerMap: TCefStringMultimap); stdcall; + get_url : function(self: PCefResponse): PCefStringUserFree; stdcall; + set_url : procedure(self: PCefResponse; const url: PCefString); stdcall; end; // /include/capi/cef_response_filter_capi.h (cef_response_filter_t) @@ -1736,7 +2118,7 @@ type is_global : function(self: PCefRequestContext): Integer; stdcall; get_handler : function(self: PCefRequestContext): PCefRequestContextHandler; stdcall; get_cache_path : function(self: PCefRequestContext): PCefStringUserFree; stdcall; - get_default_cookie_manager : function(self: PCefRequestContext; callback: PCefCompletionCallback): PCefCookieManager; stdcall; + get_cookie_manager : function(self: PCefRequestContext; callback: PCefCompletionCallback): PCefCookieManager; stdcall; register_scheme_handler_factory : function(self: PCefRequestContext; const scheme_name, domain_name: PCefString; factory: PCefSchemeHandlerFactory): Integer; stdcall; clear_scheme_handler_factories : function(self: PCefRequestContext): Integer; stdcall; purge_plugin_list_cache : procedure(self: PCefRequestContext; reload_pages: Integer); stdcall; @@ -1746,22 +2128,23 @@ type can_set_preference : function(self: PCefRequestContext; const name: PCefString): Integer; stdcall; set_preference : function(self: PCefRequestContext; const name: PCefString; value: PCefValue; error: PCefString): Integer; stdcall; clear_certificate_exceptions : procedure(self: PCefRequestContext; callback: PCefCompletionCallback); stdcall; + clear_http_auth_credentials : procedure(self: PCefRequestContext; callback: PCefCompletionCallback); stdcall; close_all_connections : procedure(self: PCefRequestContext; callback: PCefCompletionCallback); stdcall; resolve_host : procedure(self: PCefRequestContext; const origin: PCefString; callback: PCefResolveCallback); stdcall; - resolve_host_cached : function(self: PCefRequestContext; const origin: PCefString; resolved_ips: TCefStringList): TCefErrorCode; stdcall; load_extension : procedure(self: PCefRequestContext; const root_directory: PCefString; manifest: PCefDictionaryValue; handler: PCefExtensionHandler); stdcall; did_load_extension : function(self: PCefRequestContext; const extension_id: PCefString): Integer; stdcall; has_extension : function(self: PCefRequestContext; const extension_id: PCefString): Integer; stdcall; get_extensions : function(self: PCefRequestContext; extension_ids: TCefStringList): Integer; stdcall; get_extension : function(self: PCefRequestContext; const extension_id: PCefString): PCefExtension; stdcall; + get_media_router : function(self: PCefRequestContext): PCefMediaRouter; stdcall; end; // /include/capi/cef_request_context_handler_capi.h (cef_request_context_handler_t) TCefRequestContextHandler = record base : TCefBaseRefCounted; on_request_context_initialized : procedure(self: PCefRequestContextHandler; request_context: PCefRequestContext); stdcall; - get_cookie_manager : function(self: PCefRequestContextHandler): PCefCookieManager; stdcall; on_before_plugin_load : function(self: PCefRequestContextHandler; const mime_type, plugin_url : PCefString; is_main_frame : integer; const top_origin_url: PCefString; plugin_info: PCefWebPluginInfo; plugin_policy: PCefPluginPolicy): Integer; stdcall; + get_resource_request_handler : function(self: PCefRequestContextHandler; browser: PCefBrowser; frame: PCefFrame; request: PCefRequest; is_navigation, is_download: Integer; const request_initiator: PCefString; disable_default_handling: PInteger): PCefResourceRequestHandler; stdcall; end; // /include/capi/cef_callback_capi.h (cef_completion_callback_t) @@ -1773,13 +2156,12 @@ type // /include/capi/cef_cookie_capi.h (cef_cookie_manager_t) TCefCookieManager = record base : TCefBaseRefCounted; - set_supported_schemes : procedure(self: PCefCookieManager; schemes: TCefStringList; callback: PCefCompletionCallback); stdcall; + set_supported_schemes : procedure(self: PCefCookieManager; schemes: TCefStringList; include_defaults: Integer; callback: PCefCompletionCallback); stdcall; visit_all_cookies : function(self: PCefCookieManager; visitor: PCefCookieVisitor): Integer; stdcall; visit_url_cookies : function(self: PCefCookieManager; const url: PCefString; includeHttpOnly: Integer; visitor: PCefCookieVisitor): Integer; stdcall; set_cookie : function(self: PCefCookieManager; const url: PCefString; const cookie: PCefCookie; callback: PCefSetCookieCallback): Integer; stdcall; delete_cookies : function(self: PCefCookieManager; const url, cookie_name: PCefString; callback: PCefDeleteCookiesCallback): Integer; stdcall; - set_storage_path : function(self: PCefCookieManager; const path: PCefString; persist_session_cookies: Integer; callback: PCefCompletionCallback): Integer; stdcall; - flush_store : function(self: PCefCookieManager; handler: PCefCompletionCallback): Integer; stdcall; + flush_store : function(self: PCefCookieManager; callback: PCefCompletionCallback): Integer; stdcall; end; // /include/capi/cef_scheme_capi.h (cef_scheme_handler_factory_t) @@ -1883,7 +2265,6 @@ type base : TCefBaseRefCounted; is_valid : function(self: PCefPrintSettings): Integer; stdcall; is_read_only : function(self: PCefPrintSettings): Integer; stdcall; - copy : function(self: PCefPrintSettings): PCefPrintSettings; stdcall; set_orientation : procedure(self: PCefPrintSettings; landscape: Integer); stdcall; is_landscape : function(self: PCefPrintSettings): Integer; stdcall; set_printer_printable_area : procedure(self: PCefPrintSettings; const physical_size_device_units: PCefSize; const printable_area_device_units: PCefRect; landscape_needs_flip: Integer); stdcall; @@ -1988,7 +2369,7 @@ type // /include/capi/cef_scheme_capi.h (cef_scheme_registrar_t) TCefSchemeRegistrar = record base : TCefBaseScoped; - add_custom_scheme : function(self: PCefSchemeRegistrar; const scheme_name: PCefString; is_standard, is_local, is_display_isolated, is_secure, is_cors_enabled, is_csp_bypassing: Integer): Integer; stdcall; + add_custom_scheme : function(self: PCefSchemeRegistrar; const scheme_name: PCefString; options : TCefSchemeOptions): Integer; stdcall; end; // /include/capi/cef_values_capi.h (cef_binary_value_t) @@ -2103,8 +2484,6 @@ type visit : procedure(self: PCefStringVisitor; const str: PCefString); stdcall; end; - TCefPostDataElementArray = array[0..(High(Integer) div SizeOf(PCefPostDataElement)) - 1] of PCefPostDataElement; - // /include/capi/cef_request_capi.h (cef_post_data_element_t) TCefPostDataElement = record base : TCefBaseRefCounted; @@ -2121,10 +2500,10 @@ type // /include/capi/cef_request_capi.h (cef_post_data_t) TCefPostData = record base : TCefBaseRefCounted; - is_read_only : function(self: PCefPostData):Integer; stdcall; + is_read_only : function(self: PCefPostData): Integer; stdcall; has_excluded_elements : function(self: PCefPostData): Integer; stdcall; get_element_count : function(self: PCefPostData): NativeUInt; stdcall; - get_elements : procedure(self: PCefPostData; elementsCount: PNativeUInt; elements: PCefPostDataElementArray); stdcall; + get_elements : procedure(self: PCefPostData; var elementsCount: NativeUInt; var elements: PCefPostDataElement); stdcall; remove_element : function(self: PCefPostData; element: PCefPostDataElement): Integer; stdcall; add_element : function(self: PCefPostData; element: PCefPostDataElement): Integer; stdcall; remove_elements : procedure(self: PCefPostData); stdcall; @@ -2145,6 +2524,8 @@ type set_post_data : procedure(self: PCefRequest; postData: PCefPostData); stdcall; get_header_map : procedure(self: PCefRequest; headerMap: TCefStringMultimap); stdcall; set_header_map : procedure(self: PCefRequest; headerMap: TCefStringMultimap); stdcall; + get_header_by_name : function(self: PCefRequest; const name: PCefString): PCefStringUserFree; stdcall; + set_header_by_name : procedure(self: PCefRequest; const name, value: PCefString; overwrite: integer); stdcall; set_ : procedure(self: PCefRequest; const url, method: PCefString; postData: PCefPostData; headerMap: TCefStringMultimap); stdcall; get_flags : function(self: PCefRequest): Integer; stdcall; set_flags : procedure(self: PCefRequest; flags: Integer); stdcall; @@ -2345,7 +2726,7 @@ type // /include/capi/cef_v8_capi.h (cef_v8handler_t) TCefv8Handler = record base : TCefBaseRefCounted; - execute : function(self: PCefv8Handler; const name: PCefString; obj: PCefv8Value; argumentsCount: NativeUInt; const arguments: PPCefV8Value; var retval: PCefV8Value; var exception: TCefString): Integer; stdcall; + execute : function(self: PCefv8Handler; const name: PCefString; object_: PCefv8Value; argumentsCount: NativeUInt; const arguments: PPCefV8Value; var retval: PCefV8Value; exception: PCefString): Integer; stdcall; end; // /include/capi/cef_v8_capi.h (cef_v8exception_t) @@ -2436,46 +2817,47 @@ type // /include/capi/cef_v8_capi.h (cef_v8interceptor_t) TCefV8Interceptor = record base : TCefBaseRefCounted; - get_byname : function(self: PCefV8Interceptor; const name: PCefString; obj: PCefV8Value; out retval: PCefv8Value; exception: PCefString): integer; stdcall; - get_byindex : function(self: PCefV8Interceptor; index: integer; obj: PCefV8Value; out retval: PCefv8Value; exception: PCefString): integer; stdcall; - set_byname : function(self: PCefV8Interceptor; const name: PCefString; obj, value: PCefv8Value; exception: PCefString): integer; stdcall; - set_byindex : function(self: PCefV8Interceptor; index: integer; obj, value: PCefv8Value; exception: PCefString): integer; stdcall; + get_byname : function(self: PCefV8Interceptor; const name: PCefString; object_: PCefV8Value; out retval: PCefv8Value; exception: PCefString): integer; stdcall; + get_byindex : function(self: PCefV8Interceptor; index: integer; object_: PCefV8Value; out retval: PCefv8Value; exception: PCefString): integer; stdcall; + set_byname : function(self: PCefV8Interceptor; const name: PCefString; object_, value: PCefv8Value; exception: PCefString): integer; stdcall; + set_byindex : function(self: PCefV8Interceptor; index: integer; object_, value: PCefv8Value; exception: PCefString): integer; stdcall; end; // /include/capi/cef_v8_capi.h (cef_v8accessor_t) TCefV8Accessor = record base : TCefBaseRefCounted; - get : function(self: PCefV8Accessor; const name: PCefString; obj: PCefv8Value; out retval: PCefv8Value; exception: PCefString): Integer; stdcall; - put : function(self: PCefV8Accessor; const name: PCefString; obj, value: PCefv8Value; exception: PCefString): Integer; stdcall; + get : function(self: PCefV8Accessor; const name: PCefString; object_: PCefv8Value; out retval: PCefv8Value; exception: PCefString): Integer; stdcall; + set_ : function(self: PCefV8Accessor; const name: PCefString; object_, value: PCefv8Value; exception: PCefString): Integer; stdcall; end; // /include/capi/cef_frame_capi.h (cef_frame_t) TCefFrame = record - base : TCefBaseRefCounted; - is_valid : function(self: PCefFrame): Integer; stdcall; - undo : procedure(self: PCefFrame); stdcall; - redo : procedure(self: PCefFrame); stdcall; - cut : procedure(self: PCefFrame); stdcall; - copy : procedure(self: PCefFrame); stdcall; - paste : procedure(self: PCefFrame); stdcall; - del : procedure(self: PCefFrame); stdcall; - select_all : procedure(self: PCefFrame); stdcall; - view_source : procedure(self: PCefFrame); stdcall; - get_source : procedure(self: PCefFrame; visitor: PCefStringVisitor); stdcall; - get_text : procedure(self: PCefFrame; visitor: PCefStringVisitor); stdcall; - load_request : procedure(self: PCefFrame; request: PCefRequest); stdcall; - load_url : procedure(self: PCefFrame; const url: PCefString); stdcall; - load_string : procedure(self: PCefFrame; const stringVal, url: PCefString); stdcall; - execute_java_script : procedure(self: PCefFrame; const code, script_url: PCefString; start_line: Integer); stdcall; - is_main : function(self: PCefFrame): Integer; stdcall; - is_focused : function(self: PCefFrame): Integer; stdcall; - get_name : function(self: PCefFrame): PCefStringUserFree; stdcall; - get_identifier : function(self: PCefFrame): Int64; stdcall; - get_parent : function(self: PCefFrame): PCefFrame; stdcall; - get_url : function(self: PCefFrame): PCefStringUserFree; stdcall; - get_browser : function(self: PCefFrame): PCefBrowser; stdcall; - get_v8context : function(self: PCefFrame): PCefv8Context; stdcall; - visit_dom : procedure(self: PCefFrame; visitor: PCefDomVisitor); stdcall; + base : TCefBaseRefCounted; + is_valid : function(self: PCefFrame): Integer; stdcall; + undo : procedure(self: PCefFrame); stdcall; + redo : procedure(self: PCefFrame); stdcall; + cut : procedure(self: PCefFrame); stdcall; + copy : procedure(self: PCefFrame); stdcall; + paste : procedure(self: PCefFrame); stdcall; + del : procedure(self: PCefFrame); stdcall; + select_all : procedure(self: PCefFrame); stdcall; + view_source : procedure(self: PCefFrame); stdcall; + get_source : procedure(self: PCefFrame; visitor: PCefStringVisitor); stdcall; + get_text : procedure(self: PCefFrame; visitor: PCefStringVisitor); stdcall; + load_request : procedure(self: PCefFrame; request: PCefRequest); stdcall; + load_url : procedure(self: PCefFrame; const url: PCefString); stdcall; + execute_java_script : procedure(self: PCefFrame; const code, script_url: PCefString; start_line: Integer); stdcall; + is_main : function(self: PCefFrame): Integer; stdcall; + is_focused : function(self: PCefFrame): Integer; stdcall; + get_name : function(self: PCefFrame): PCefStringUserFree; stdcall; + get_identifier : function(self: PCefFrame): Int64; stdcall; + get_parent : function(self: PCefFrame): PCefFrame; stdcall; + get_url : function(self: PCefFrame): PCefStringUserFree; stdcall; + get_browser : function(self: PCefFrame): PCefBrowser; stdcall; + get_v8context : function(self: PCefFrame): PCefv8Context; stdcall; + visit_dom : procedure(self: PCefFrame; visitor: PCefDomVisitor); stdcall; + create_urlrequest : function(self: PCefFrame; request: PCefRequest; client: PCefUrlrequestClient): PCefUrlRequest; stdcall; + send_process_message : procedure(self: PCefFrame; target_process: TCefProcessId; message_: PCefProcessMessage); stdcall; end; // /include/capi/cef_accessibility_handler_capi.h (cef_accessibility_handler_t) @@ -2497,6 +2879,7 @@ type // /include/capi/cef_client_capi.h (cef_client_t) TCefClient = record base : TCefBaseRefCounted; + get_audio_handler : function(self: PCefClient): PCefAudioHandler; stdcall; get_context_menu_handler : function(self: PCefClient): PCefContextMenuHandler; stdcall; get_dialog_handler : function(self: PCefClient): PCefDialogHandler; stdcall; get_display_handler : function(self: PCefClient): PCefDisplayHandler; stdcall; @@ -2510,7 +2893,7 @@ type get_load_handler : function(self: PCefClient): PCefLoadHandler; stdcall; get_render_handler : function(self: PCefClient): PCefRenderHandler; stdcall; get_request_handler : function(self: PCefClient): PCefRequestHandler; stdcall; - on_process_message_received : function(self: PCefClient; browser: PCefBrowser; source_process: TCefProcessId; message: PCefProcessMessage): Integer; stdcall; + on_process_message_received : function(self: PCefClient; browser: PCefBrowser; frame: PCefFrame; source_process: TCefProcessId; message_: PCefProcessMessage): Integer; stdcall; end; // /include/capi/cef_browser_capi.h (cef_browser_host_t) @@ -2532,25 +2915,28 @@ type download_image : procedure(self: PCefBrowserHost; const image_url: PCefString; is_favicon: Integer; max_image_size: Cardinal; bypass_cache: Integer; callback: PCefDownloadImageCallback); stdcall; print : procedure(self: PCefBrowserHost); stdcall; print_to_pdf : procedure(self: PCefBrowserHost; const path: PCefString; const settings: PCefPdfPrintSettings; callback: PCefPdfPrintCallback); stdcall; - find : procedure(self: PCefBrowserHost; identifier: Integer; const searchText: PCefString; forward, matchCase, findNext: Integer); stdcall; + find : procedure(self: PCefBrowserHost; identifier: Integer; const searchText: PCefString; forward_, matchCase, findNext: Integer); stdcall; stop_finding : procedure(self: PCefBrowserHost; clearSelection: Integer); stdcall; show_dev_tools : procedure(self: PCefBrowserHost; const windowInfo: PCefWindowInfo; client: PCefClient; const settings: PCefBrowserSettings; const inspect_element_at: PCefPoint); stdcall; close_dev_tools : procedure(self: PCefBrowserHost); stdcall; has_dev_tools : function(self: PCefBrowserHost): Integer; stdcall; + send_dev_tools_message : function(self: PCefBrowserHost; const message_: Pointer; message_size: NativeUInt): Integer; stdcall; + execute_dev_tools_method : function(self: PCefBrowserHost; message_id: integer; const method: PCefString; params: PCefDictionaryValue): Integer; stdcall; + add_dev_tools_message_observer : function(self: PCefBrowserHost; observer: PCefDevToolsMessageObserver): PCefRegistration; stdcall; get_navigation_entries : procedure(self: PCefBrowserHost; visitor: PCefNavigationEntryVisitor; current_only: Integer); stdcall; - set_mouse_cursor_change_disabled : procedure(self: PCefBrowserHost; disabled: Integer); stdcall; - is_mouse_cursor_change_disabled : function(self: PCefBrowserHost): Integer; stdcall; replace_misspelling : procedure(self: PCefBrowserHost; const word: PCefString); stdcall; add_word_to_dictionary : procedure(self: PCefBrowserHost; const word: PCefString); stdcall; is_window_rendering_disabled : function(self: PCefBrowserHost): Integer; stdcall; was_resized : procedure(self: PCefBrowserHost); stdcall; was_hidden : procedure(self: PCefBrowserHost; hidden: Integer); stdcall; notify_screen_info_changed : procedure(self: PCefBrowserHost); stdcall; - invalidate : procedure(self: PCefBrowserHost; kind: TCefPaintElementType); stdcall; + invalidate : procedure(self: PCefBrowserHost; type_: TCefPaintElementType); stdcall; + send_external_begin_frame : procedure(self: PCefBrowserHost); stdcall; send_key_event : procedure(self: PCefBrowserHost; const event: PCefKeyEvent); stdcall; - send_mouse_click_event : procedure(self: PCefBrowserHost; const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp, clickCount: Integer); stdcall; + send_mouse_click_event : procedure(self: PCefBrowserHost; const event: PCefMouseEvent; type_: TCefMouseButtonType; mouseUp, clickCount: Integer); stdcall; send_mouse_move_event : procedure(self: PCefBrowserHost; const event: PCefMouseEvent; mouseLeave: Integer); stdcall; send_mouse_wheel_event : procedure(self: PCefBrowserHost; const event: PCefMouseEvent; deltaX, deltaY: Integer); stdcall; + send_touch_event : procedure(self: PCefBrowserHost; const event: PCefTouchEvent); stdcall; send_focus_event : procedure(self: PCefBrowserHost; setFocus: Integer); stdcall; send_capture_lost_event : procedure(self: PCefBrowserHost); stdcall; notify_move_or_resize_started : procedure(self: PCefBrowserHost); stdcall; @@ -2563,7 +2949,7 @@ type drag_target_drag_enter : procedure(self: PCefBrowserHost; drag_data: PCefDragData; const event: PCefMouseEvent; allowed_ops: TCefDragOperations); stdcall; drag_target_drag_over : procedure(self: PCefBrowserHost; const event: PCefMouseEvent; allowed_ops: TCefDragOperations); stdcall; drag_target_drag_leave : procedure(self: PCefBrowserHost); stdcall; - drag_target_drop : procedure(self: PCefBrowserHost; event: PCefMouseEvent); stdcall; + drag_target_drop : procedure(self: PCefBrowserHost; const event: PCefMouseEvent); stdcall; drag_source_ended_at : procedure(self: PCefBrowserHost; x, y: Integer; op: TCefDragOperation); stdcall; drag_source_system_drag_ended : procedure(self: PCefBrowserHost); stdcall; get_visible_navigation_entry : function(self: PCefBrowserHost): PCefNavigationEntry; stdcall; @@ -2571,6 +2957,8 @@ type set_auto_resize_enabled : procedure(self: PCefBrowserHost; enabled: integer; const min_size, max_size: PCefSize); stdcall; get_extension : function(self: PCefBrowserHost): PCefExtension; stdcall; is_background_host : function(self: PCefBrowserHost): integer; stdcall; + set_audio_muted : procedure(self: PCefBrowserHost; mute: integer); stdcall; + is_audio_muted : function(self: PCefBrowserHost): integer; stdcall; end; // /include/capi/cef_browser_capi.h (cef_browser_t) @@ -2596,7 +2984,6 @@ type get_frame_count : function(self: PCefBrowser): NativeUInt; stdcall; get_frame_identifiers : procedure(self: PCefBrowser; var identifiersCount: NativeUInt; var identifiers: Int64); stdcall; get_frame_names : procedure(self: PCefBrowser; names: TCefStringList); stdcall; - send_process_message : function(self: PCefBrowser; target_process: TCefProcessId; message: PCefProcessMessage): Integer; stdcall; end; // /include/capi/cef_resource_bundle_handler_capi.h (cef_resource_bundle_handler_t) @@ -2610,11 +2997,12 @@ type // /include/capi/cef_browser_process_handler_capi.h (cef_browser_process_handler_t) TCefBrowserProcessHandler = record base : TCefBaseRefCounted; + get_cookieable_schemes : procedure(self: PCefBrowserProcessHandler; schemes: TCefStringList; include_defaults: PInteger); stdcall; on_context_initialized : procedure(self: PCefBrowserProcessHandler); stdcall; on_before_child_process_launch : procedure(self: PCefBrowserProcessHandler; command_line: PCefCommandLine); stdcall; - on_render_process_thread_created : procedure(self: PCefBrowserProcessHandler; extra_info: PCefListValue); stdcall; get_print_handler : function(self: PCefBrowserProcessHandler): PCefPrintHandler; stdcall; on_schedule_message_pump_work : procedure(self: PCefBrowserProcessHandler; delay_ms: Int64); stdcall; + get_default_client : function(self: PCefBrowserProcessHandler): PCefClient; stdcall; end; // /include/capi/cef_app_capi.h (cef_app_t) @@ -2663,7 +3051,39 @@ type // ********************************* // ************* Views ************* // ********************************* - + // + // (*) Has CEF creation function + // (d) Has delegate + // + // ---------------- ---------------------- + // | TCefView (d) | -------> | TCefTextfield (*d) | + // ---------------- | ---------------------- + // | + // | ---------------------- + // |---> | TCefScrollView (*) | + // | ---------------------- + // | + // | ------------------ ------------------- + // |---> | TCefPanel (*d) | -------> | TCefWindow (*d) | + // | ------------------ ------------------- + // | + // | ------------------------ + // |---> | TCefBrowserView (*d) | + // | ------------------------ + // | + // | ------------------ ----------------------- ----------------------- + // |---> | TCefButton (d) | -------> | TCefLabelButton (*) | -------> | TCefMenuButton (*d) | + // ------------------ ----------------------- ----------------------- + // + // + // -------------- ----------------- + // | TCefLayout | -------> | TCefBoxLayout | + // -------------- | ----------------- + // | + // | ------------------ + // |---> | TCefFillLayout | + // ------------------ + // // /include/capi/views/cef_display_capi.h (cef_display_t) TCefDisplay = record @@ -2790,8 +3210,8 @@ type set_font_list : procedure(self: PCefTextfield; const font_list: PCefString); stdcall; apply_text_color : procedure(self: PCefTextfield; color: TCefColor; const range: PCefRange); stdcall; apply_text_style : procedure(self: PCefTextfield; style: TCefTextStyle; add: Integer; const range: PCefRange); stdcall; - is_command_enabled : function(self: PCefTextfield; command_id: Integer): Integer; stdcall; - execute_command : procedure(self: PCefTextfield; command_id: Integer); stdcall; + is_command_enabled : function(self: PCefTextfield; command_id: TCefTextFieldCommands): Integer; stdcall; + execute_command : procedure(self: PCefTextfield; command_id: TCefTextFieldCommands); stdcall; clear_edit_history : procedure(self: PCefTextfield); stdcall; set_placeholder_text : procedure(self: PCefTextfield; const text: PCefString); stdcall; get_placeholder_text : function(self: PCefTextfield): PCefStringUserFree; stdcall; @@ -2877,7 +3297,7 @@ type // /include/capi/views/cef_label_button_capi.h (cef_label_button_t) TCefLabelButton = record base : TCefButton; - get_state : function(self: PCefLabelButton): PCefMenuButton; stdcall; + as_menu_button : function(self: PCefLabelButton): PCefMenuButton; stdcall; set_text : procedure(self: PCefLabelButton; const text: PCefString); stdcall; get_text : function(self: PCefLabelButton): PCefStringUserFree; stdcall; set_image : procedure(self: PCefLabelButton; button_state: TCefButtonState; image: PCefImage); stdcall; @@ -2939,7 +3359,7 @@ type cancel_menu : procedure(self: PCefWindow); stdcall; get_display : function(self: PCefWindow): PCefDisplay; stdcall; get_client_area_bounds_in_screen : function(self: PCefWindow): TCefRect; stdcall; - set_draggable_regions : procedure(self: PCefWindow; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); stdcall; + set_draggable_regions : procedure(self: PCefWindow; regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); stdcall; get_window_handle : function(self: PCefWindow): TCefWindowHandle; stdcall; send_key_press : procedure(self: PCefWindow; key_code: Integer; event_flags: cardinal); stdcall; send_mouse_move : procedure(self: PCefWindow; screen_x, screen_y: Integer); stdcall; @@ -2955,6 +3375,7 @@ type on_window_created : procedure(self: PCefWindowDelegate; window: PCefWindow); stdcall; on_window_destroyed : procedure(self: PCefWindowDelegate; window: PCefWindow); stdcall; get_parent_window : function(self: PCefWindowDelegate; window: PCefWindow; is_menu, can_activate_menu: PInteger): PCefWindow; stdcall; + get_initial_bounds : function(self: PCefWindowDelegate; window: PCefWindow): TCefRect; stdcall; is_frameless : function(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall; can_resize : function(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall; can_maximize : function(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall; diff --git a/windows/src/ext/cef4delphi/source/uCEFUrlRequest.pas b/windows/src/ext/cef4delphi/source/uCEFUrlRequest.pas index f0a35af8f1a60c28e02145f066059c558bb28032..320fc130b433a8ba8432baa55d0642dce0240fb6 100644 --- a/windows/src/ext/cef4delphi/source/uCEFUrlRequest.pas +++ b/windows/src/ext/cef4delphi/source/uCEFUrlRequest.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFUrlRequest; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFUrlRequestClientComponent.pas b/windows/src/ext/cef4delphi/source/uCEFUrlRequestClientComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..37ac6998bbf242afe4e219a5bdedf2d6be80fd41 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFUrlRequestClientComponent.pas @@ -0,0 +1,243 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFUrlRequestClientComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, WinApi.ActiveX,{$ENDIF} + System.Classes, System.Math, + {$ELSE} + {$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} Classes, Math, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, + {$ELSE} + Messages, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFUrlRequestClientEvents, uCEFUrlrequestClient, uCEFUrlRequest; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFUrlRequestClientComponent = class(TComponent, ICEFUrlRequestClientEvents) + protected + FClient : ICefUrlrequestClient; + FThreadID : TCefThreadId; + + FOnRequestComplete : TOnRequestComplete; + FOnUploadProgress : TOnUploadProgress; + FOnDownloadProgress : TOnDownloadProgress; + FOnDownloadData : TOnDownloadData; + FOnGetAuthCredentials : TOnGetAuthCredentials; + FOnCreateURLRequest : TNotifyEvent; + + // ICefUrlrequestClient + procedure doOnRequestComplete(const request: ICefUrlRequest); + procedure doOnUploadProgress(const request: ICefUrlRequest; current, total: Int64); + procedure doOnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); + procedure doOnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); + function doOnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; + + // Custom + procedure doOnCreateURLRequest; + + procedure DestroyRequestClient; + + public + constructor Create(AOwner: TComponent); override; + procedure AfterConstruction; override; + procedure BeforeDestruction; override; + + procedure AddURLRequest; + + property Client : ICefUrlrequestClient read FClient; + property ThreadID : TCefThreadId read FThreadID write FThreadID; + + published + property OnRequestComplete : TOnRequestComplete read FOnRequestComplete write FOnRequestComplete; + property OnUploadProgress : TOnUploadProgress read FOnUploadProgress write FOnUploadProgress; + property OnDownloadProgress : TOnDownloadProgress read FOnDownloadProgress write FOnDownloadProgress; + property OnDownloadData : TOnDownloadData read FOnDownloadData write FOnDownloadData; + property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials; + property OnCreateURLRequest : TNotifyEvent read FOnCreateURLRequest write FOnCreateURLRequest; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} + uCEFRequest, uCEFTask, uCEFMiscFunctions; + + +constructor TCEFUrlRequestClientComponent.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + FClient := nil; + FThreadID := TID_UI; + FOnRequestComplete := nil; + FOnUploadProgress := nil; + FOnDownloadProgress := nil; + FOnDownloadData := nil; + FOnGetAuthCredentials := nil; + FOnCreateURLRequest := nil; +end; + +procedure TCEFUrlRequestClientComponent.AfterConstruction; +begin + inherited AfterConstruction; + + if not(csDesigning in ComponentState) then + FClient := TCustomCefUrlrequestClient.Create(self); +end; + +procedure TCEFUrlRequestClientComponent.BeforeDestruction; +begin + DestroyRequestClient; + + inherited BeforeDestruction; +end; + +procedure TCEFUrlRequestClientComponent.DestroyRequestClient; +begin + try + if (FClient <> nil) then + begin + FClient.RemoveReferences; + FClient := nil; + end; + except + on e : exception do + if CustomExceptionHandler('TCEFUrlRequestClientComponent.DestroyRequestClient', e) then raise; + end; +end; + +procedure TCEFUrlRequestClientComponent.doOnRequestComplete(const request: ICefUrlRequest); +begin + if assigned(FOnRequestComplete) then FOnRequestComplete(self, request); +end; + +procedure TCEFUrlRequestClientComponent.doOnUploadProgress(const request: ICefUrlRequest; current, total: Int64); +begin + if assigned(FOnUploadProgress) then FOnUploadProgress(self, request, current, total); +end; + +procedure TCEFUrlRequestClientComponent.doOnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); +begin + if assigned(FOnDownloadProgress) then FOnDownloadProgress(self, request, current, total); +end; + +procedure TCEFUrlRequestClientComponent.doOnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); +begin + if assigned(FOnDownloadData) then FOnDownloadData(self, request, data, datalength); +end; + +function TCEFUrlRequestClientComponent.doOnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; +begin + Result := False; + + if assigned(FOnGetAuthCredentials) then FOnGetAuthCredentials(self, isProxy, host, port, realm, scheme, callback, Result); +end; + +procedure TCEFUrlRequestClientComponent.doOnCreateURLRequest; +begin + if assigned(FOnCreateURLRequest) then FOnCreateURLRequest(self); +end; + +procedure TCEFUrlRequestClientComponent.AddURLRequest; +var + TempTask : ICefTask; +begin + TempTask := TCefURLRequestTask.Create(self); + CefPostTask(FThreadID, TempTask); +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tcefurlrequestclientcomponent.lrs} + RegisterComponents('Chromium', [TCEFUrlRequestClientComponent]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFUrlRequestClientEvents.pas b/windows/src/ext/cef4delphi/source/uCEFUrlRequestClientEvents.pas new file mode 100644 index 0000000000000000000000000000000000000000..d03fc683d958c70569e159aa192a73bcda93381b --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFUrlRequestClientEvents.pas @@ -0,0 +1,68 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFUrlRequestClientEvents; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, + {$ELSE} + Classes, + {$ENDIF} + uCEFTypes, uCEFInterfaces; + +type + TOnRequestComplete = procedure(Sender: TObject; const request: ICefUrlRequest) of object; + TOnUploadProgress = procedure(Sender: TObject; const request: ICefUrlRequest; current, total: Int64) of object; + TOnDownloadProgress = procedure(Sender: TObject; const request: ICefUrlRequest; current, total: Int64) of object; + TOnDownloadData = procedure(Sender: TObject; const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt) of object; + TOnGetAuthCredentials = procedure(Sender: TObject; isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback; var aResult : Boolean) of object; + +implementation + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFUrlrequestClient.pas b/windows/src/ext/cef4delphi/source/uCEFUrlrequestClient.pas index 217a72af9c37719ffbdb0afd51dff16a129eca10..92e2f70b05bda7a72c38652628325ee08c59e9c8 100644 --- a/windows/src/ext/cef4delphi/source/uCEFUrlrequestClient.pas +++ b/windows/src/ext/cef4delphi/source/uCEFUrlrequestClient.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFUrlrequestClient; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -55,22 +53,49 @@ uses type TCefUrlrequestClientOwn = class(TCefBaseRefCountedOwn, ICefUrlrequestClient) - protected - procedure OnRequestComplete(const request: ICefUrlRequest); virtual; - procedure OnUploadProgress(const request: ICefUrlRequest; current, total: Int64); virtual; - procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); virtual; - procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); virtual; - function OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual; - public - constructor Create; virtual; + protected + procedure OnRequestComplete(const request: ICefUrlRequest); virtual; + procedure OnUploadProgress(const request: ICefUrlRequest; current, total: Int64); virtual; + procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); virtual; + procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); virtual; + function OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; virtual; + + procedure RemoveReferences; virtual; + + public + constructor Create; virtual; + end; + + TCustomCefUrlrequestClient = class(TCefUrlrequestClientOwn) + protected + FEvents : Pointer; + + procedure OnRequestComplete(const request: ICefUrlRequest); override; + procedure OnUploadProgress(const request: ICefUrlRequest; current, total: Int64); override; + procedure OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); override; + procedure OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); override; + function OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; override; + + procedure RemoveReferences; override; + + public + constructor Create(const events: ICEFUrlRequestClientEvents); reintroduce; + destructor Destroy; override; end; implementation uses + {$IFDEF DELPHI16_UP} + System.SysUtils, + {$ELSE} + SysUtils, + {$ENDIF} uCEFMiscFunctions, uCEFLibFunctions, uCEFUrlRequest, uCEFAuthCallback; +// TCefUrlrequestClientOwn + procedure cef_url_request_client_on_request_complete(self : PCefUrlRequestClient; request : PCefUrlRequest); stdcall; var @@ -179,6 +204,11 @@ begin Result := False; end; +procedure TCefUrlrequestClientOwn.RemoveReferences; +begin + // +end; + procedure TCefUrlrequestClientOwn.OnRequestComplete(const request: ICefUrlRequest); begin // @@ -189,4 +219,82 @@ begin // end; + +// TCustomCefUrlrequestClient + +constructor TCustomCefUrlrequestClient.Create(const events: ICEFUrlRequestClientEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +destructor TCustomCefUrlrequestClient.Destroy; +begin + RemoveReferences; + + inherited Destroy; +end; + +procedure TCustomCefUrlrequestClient.OnRequestComplete(const request: ICefUrlRequest); +begin + try + if (FEvents <> nil) then + ICEFUrlRequestClientEvents(FEvents).doOnRequestComplete(request); + except + on e : exception do + if CustomExceptionHandler('TCustomCefUrlrequestClient.OnRequestComplete', e) then raise; + end; +end; + +procedure TCustomCefUrlrequestClient.OnUploadProgress(const request: ICefUrlRequest; current, total: Int64); +begin + try + if (FEvents <> nil) then + ICEFUrlRequestClientEvents(FEvents).doOnUploadProgress(request, current, total); + except + on e : exception do + if CustomExceptionHandler('TCustomCefUrlrequestClient.OnUploadProgress', e) then raise; + end; +end; + +procedure TCustomCefUrlrequestClient.OnDownloadProgress(const request: ICefUrlRequest; current, total: Int64); +begin + try + if (FEvents <> nil) then + ICEFUrlRequestClientEvents(FEvents).doOnDownloadProgress(request, current, total); + except + on e : exception do + if CustomExceptionHandler('TCustomCefUrlrequestClient.OnDownloadProgress', e) then raise; + end; +end; + +procedure TCustomCefUrlrequestClient.OnDownloadData(const request: ICefUrlRequest; data: Pointer; dataLength: NativeUInt); +begin + try + if (FEvents <> nil) then + ICEFUrlRequestClientEvents(FEvents).doOnDownloadData(request, data, dataLength); + except + on e : exception do + if CustomExceptionHandler('TCustomCefUrlrequestClient.OnDownloadData', e) then raise; + end; +end; + +function TCustomCefUrlrequestClient.OnGetAuthCredentials(isProxy: Boolean; const host: ustring; port: Integer; const realm, scheme: ustring; const callback: ICefAuthCallback): Boolean; +begin + Result := False; + try + if (FEvents <> nil) then + Result := ICEFUrlRequestClientEvents(FEvents).doOnGetAuthCredentials(isProxy, host, port, realm, scheme, callback); + except + on e : exception do + if CustomExceptionHandler('TCustomCefUrlrequestClient.OnGetAuthCredentials', e) then raise; + end; +end; + +procedure TCustomCefUrlrequestClient.RemoveReferences; +begin + FEvents := nil; +end; + end. diff --git a/windows/src/ext/cef4delphi/source/uCEFV8Exception.pas b/windows/src/ext/cef4delphi/source/uCEFV8Exception.pas index bbb374dc98b3dd582126b44023e93fca4880b369..34e55235a8c02e23edc366e6336c7d614893721e 100644 --- a/windows/src/ext/cef4delphi/source/uCEFV8Exception.pas +++ b/windows/src/ext/cef4delphi/source/uCEFV8Exception.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -35,16 +35,14 @@ * *) -unit uCEFV8Exception; +unit uCEFv8Exception; {$IFDEF FPC} {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFValue.pas b/windows/src/ext/cef4delphi/source/uCEFValue.pas index 5856996eced2c8976fd2938bcc238d9fbd0f9aa0..b0c32bf0b5febbc6a25b67a69214f3eb6e428294 100644 --- a/windows/src/ext/cef4delphi/source/uCEFValue.pas +++ b/windows/src/ext/cef4delphi/source/uCEFValue.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFValue; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -71,7 +69,7 @@ type function GetDictionary: ICefDictionaryValue; function GetList: ICefListValue; function SetNull: Boolean; - function SetBool(value: Integer): Boolean; + function SetBool(value: boolean): Boolean; function SetInt(value: Integer): Boolean; function SetDouble(value: Double): Boolean; function SetString(const value: ustring): Boolean; @@ -169,9 +167,9 @@ begin Result := PCefValue(FData)^.set_binary(PCefValue(FData), CefGetData(value)) <> 0; end; -function TCefValueRef.SetBool(value: Integer): Boolean; +function TCefValueRef.SetBool(value: boolean): Boolean; begin - Result := PCefValue(FData)^.set_bool(PCefValue(FData), value) <> 0; + Result := PCefValue(FData)^.set_bool(PCefValue(FData), ord(value)) <> 0; end; function TCefValueRef.SetDictionary(const value: ICefDictionaryValue): Boolean; diff --git a/windows/src/ext/cef4delphi/source/uCEFView.pas b/windows/src/ext/cef4delphi/source/uCEFView.pas new file mode 100644 index 0000000000000000000000000000000000000000..154c658d4b8e3b90e066355e28a245bd873534d8 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFView.pas @@ -0,0 +1,370 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFView; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefViewRef = class(TCefBaseRefCountedRef, ICefView) + protected + function AsBrowserView : ICefBrowserView; + function AsButton : ICefButton; + function AsPanel : ICefPanel; + function AsScrollView : ICefScrollView; + function AsTextfield : ICefTextfield; + function GetTypeString : ustring; + function ToStringEx(include_children: boolean): ustring; + function IsValid : boolean; + function IsAttached : boolean; + function IsSame(const that: ICefView): boolean; + function GetDelegate : ICefViewDelegate; + function GetWindow : ICefWindow; + function GetID : Integer; + procedure SetID(id_: Integer); + function GetGroupID : Integer; + procedure SetGroupID(group_id: Integer); + function GetParentView : ICefView; + function GetViewForID(id_: Integer): ICefView; + procedure SetBounds(const bounds_: TCefRect); + function GetBounds : TCefRect; + function GetBoundsInScreen : TCefRect; + procedure SetSize(const size_: TCefSize); + function GetSize : TCefSize; + procedure SetPosition(const position_: TCefPoint); + function GetPosition : TCefPoint; + function GetPreferredSize : TCefSize; + procedure SizeToPreferredSize; + function GetMinimumSize : TCefSize; + function GetMaximumSize : TCefSize; + function GetHeightForWidth(width: Integer): Integer; + procedure InvalidateLayout; + procedure SetVisible(visible_: boolean); + function IsVisible : boolean; + function IsDrawn : boolean; + procedure SetEnabled(enabled_: boolean); + function IsEnabled : boolean; + procedure SetFocusable(focusable_: boolean); + function IsFocusable : boolean; + function IsAccessibilityFocusable : boolean; + procedure RequestFocus; + procedure SetBackgroundColor(color: TCefColor); + function GetBackgroundColor : TCefColor; + function ConvertPointToScreen(var point: TCefPoint): boolean; + function ConvertPointFromScreen(var point: TCefPoint): boolean; + function ConvertPointToWindow(var point: TCefPoint): boolean; + function ConvertPointFromWindow(var point: TCefPoint): boolean; + function ConvertPointToView(const view : ICefView; var point: TCefPoint): boolean; + function ConvertPointFromView(const view : ICefView; var point: TCefPoint): boolean; + + public + class function UnWrap(data: Pointer): ICefView; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFBrowserView, uCEFButton, uCEFPanel, + uCEFScrollView, uCEFTextfield, uCEFViewDelegate, uCEFWindow; + +function TCefViewRef.AsBrowserView : ICefBrowserView; +begin + Result := TCefBrowserViewRef.UnWrap(PCefView(FData)^.as_browser_view(PCefView(FData))); +end; + +function TCefViewRef.AsButton : ICefButton; +begin + Result := TCefButtonRef.UnWrap(PCefView(FData)^.as_button(PCefView(FData))); +end; + +function TCefViewRef.AsPanel : ICefPanel; +begin + Result := TCefPanelRef.UnWrap(PCefView(FData)^.as_panel(PCefView(FData))); +end; + +function TCefViewRef.AsScrollView : ICefScrollView; +begin + Result := TCefScrollViewRef.UnWrap(PCefView(FData)^.as_scroll_view(PCefView(FData))); +end; + +function TCefViewRef.AsTextfield : ICefTextfield; +begin + Result := TCefTextfieldRef.UnWrap(PCefView(FData)^.as_textfield(PCefView(FData))); +end; + +function TCefViewRef.GetTypeString : ustring; +begin + Result := CefStringFreeAndGet(PCefView(FData)^.get_type_string(PCefView(FData))); +end; + +function TCefViewRef.ToStringEx(include_children: boolean): ustring; +begin + Result := CefStringFreeAndGet(PCefView(FData)^.to_string(PCefView(FData), ord(include_children))); +end; + +function TCefViewRef.IsValid : boolean; +begin + Result := (PCefView(FData)^.is_valid(PCefView(FData)) <> 0); +end; + +function TCefViewRef.IsAttached : boolean; +begin + Result := (PCefView(FData)^.is_attached(PCefView(FData)) <> 0); +end; + +function TCefViewRef.IsSame(const that: ICefView): boolean; +begin + Result := PCefView(FData)^.is_same(PCefView(FData), CefGetData(that)) <> 0; +end; + +function TCefViewRef.GetDelegate : ICefViewDelegate; +begin + Result := TCefViewDelegateRef.UnWrap(PCefView(FData)^.get_delegate(PCefView(FData))); +end; + +function TCefViewRef.GetWindow : ICefWindow; +begin + Result := TCefWindowRef.UnWrap(PCefView(FData)^.get_window(PCefView(FData))); +end; + +function TCefViewRef.GetID : Integer; +begin + Result := PCefView(FData)^.get_id(PCefView(FData)); +end; + +procedure TCefViewRef.SetID(id_: Integer); +begin + PCefView(FData)^.set_id(PCefView(FData), id_); +end; + +function TCefViewRef.GetGroupID : Integer; +begin + Result := PCefView(FData)^.get_group_id(PCefView(FData)); +end; + +procedure TCefViewRef.SetGroupID(group_id: Integer); +begin + PCefView(FData)^.set_group_id(PCefView(FData), group_id); +end; + +function TCefViewRef.GetParentView : ICefView; +begin + Result := UnWrap(PCefView(FData)^.get_parent_view(PCefView(FData))); +end; + +function TCefViewRef.GetViewForID(id_: Integer): ICefView; +begin + Result := UnWrap(PCefView(FData)^.get_view_for_id(PCefView(FData), id_)); +end; + +procedure TCefViewRef.SetBounds(const bounds_: TCefRect); +begin + PCefView(FData)^.set_bounds(PCefView(FData), @bounds_); +end; + +function TCefViewRef.GetBounds : TCefRect; +begin + Result := PCefView(FData)^.get_bounds(PCefView(FData)); +end; + +function TCefViewRef.GetBoundsInScreen : TCefRect; +begin + Result := PCefView(FData)^.get_bounds_in_screen(PCefView(FData)); +end; + +procedure TCefViewRef.SetSize(const size_: TCefSize); +begin + PCefView(FData)^.set_size(PCefView(FData), @size_); +end; + +function TCefViewRef.GetSize : TCefSize; +begin + Result := PCefView(FData)^.get_size(PCefView(FData)); +end; + +procedure TCefViewRef.SetPosition(const position_: TCefPoint); +begin + PCefView(FData)^.set_position(PCefView(FData), @position_); +end; + +function TCefViewRef.GetPosition : TCefPoint; +begin + Result := PCefView(FData)^.get_position(PCefView(FData)); +end; + +function TCefViewRef.GetPreferredSize : TCefSize; +begin + Result := PCefView(FData)^.get_preferred_size(PCefView(FData)); +end; + +procedure TCefViewRef.SizeToPreferredSize; +begin + PCefView(FData)^.size_to_preferred_size(PCefView(FData)); +end; + +function TCefViewRef.GetMinimumSize : TCefSize; +begin + Result := PCefView(FData)^.get_minimum_size(PCefView(FData)); +end; + +function TCefViewRef.GetMaximumSize : TCefSize; +begin + Result := PCefView(FData)^.get_maximum_size(PCefView(FData)); +end; + +function TCefViewRef.GetHeightForWidth(width: Integer): Integer; +begin + Result := PCefView(FData)^.get_height_for_width(PCefView(FData), width); +end; + +procedure TCefViewRef.InvalidateLayout; +begin + PCefView(FData)^.invalidate_layout(PCefView(FData)); +end; + +procedure TCefViewRef.SetVisible(visible_: boolean); +begin + PCefView(FData)^.set_visible(PCefView(FData), ord(visible_)); +end; + +function TCefViewRef.IsVisible : boolean; +begin + Result := (PCefView(FData)^.is_visible(PCefView(FData)) <> 0); +end; + +function TCefViewRef.IsDrawn : boolean; +begin + Result := (PCefView(FData)^.is_drawn(PCefView(FData)) <> 0); +end; + +procedure TCefViewRef.SetEnabled(enabled_: boolean); +begin + PCefView(FData)^.set_enabled(PCefView(FData), ord(enabled_)); +end; + +function TCefViewRef.IsEnabled : boolean; +begin + Result := (PCefView(FData)^.is_enabled(PCefView(FData)) <> 0); +end; + +procedure TCefViewRef.SetFocusable(focusable_: boolean); +begin + PCefView(FData)^.set_focusable(PCefView(FData), ord(focusable_)); +end; + +function TCefViewRef.IsFocusable : boolean; +begin + Result := (PCefView(FData)^.is_focusable(PCefView(FData)) <> 0); +end; + +function TCefViewRef.IsAccessibilityFocusable : boolean; +begin + Result := (PCefView(FData)^.is_accessibility_focusable(PCefView(FData)) <> 0); +end; + +procedure TCefViewRef.RequestFocus; +begin + PCefView(FData)^.request_focus(PCefView(FData)); +end; + +procedure TCefViewRef.SetBackgroundColor(color: TCefColor); +begin + PCefView(FData)^.set_background_color(PCefView(FData), color); +end; + +function TCefViewRef.GetBackgroundColor : TCefColor; +begin + Result := PCefView(FData)^.get_background_color(PCefView(FData)); +end; + +function TCefViewRef.ConvertPointToScreen(var point: TCefPoint): boolean; +begin + Result := (PCefView(FData)^.convert_point_to_screen(PCefView(FData), @point) <> 0); +end; + +function TCefViewRef.ConvertPointFromScreen(var point: TCefPoint): boolean; +begin + Result := (PCefView(FData)^.convert_point_from_screen(PCefView(FData), @point) <> 0); +end; + +function TCefViewRef.ConvertPointToWindow(var point: TCefPoint): boolean; +begin + Result := (PCefView(FData)^.convert_point_to_window(PCefView(FData), @point) <> 0); +end; + +function TCefViewRef.ConvertPointFromWindow(var point: TCefPoint): boolean; +begin + Result := (PCefView(FData)^.convert_point_from_window(PCefView(FData), @point) <> 0); +end; + +function TCefViewRef.ConvertPointToView(const view : ICefView; var point: TCefPoint): boolean; +begin + Result := (PCefView(FData)^.convert_point_to_view(PCefView(FData), CefGetData(view), @point) <> 0); +end; + +function TCefViewRef.ConvertPointFromView(const view : ICefView; var point: TCefPoint): boolean; +begin + Result := (PCefView(FData)^.convert_point_from_view(PCefView(FData), CefGetData(view), @point) <> 0); +end; + +class function TCefViewRef.UnWrap(data: Pointer): ICefView; +begin + if (data <> nil) then + Result := Create(data) as ICefView + else + Result := nil; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFViewComponent.pas b/windows/src/ext/cef4delphi/source/uCEFViewComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..fc503edbd55ed6e60c0f0b840441288a3efc5bf8 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFViewComponent.pas @@ -0,0 +1,714 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFViewComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents; + +type + TCEFViewComponent = class(TComponent, ICefViewDelegateEvents) + protected + // ICefViewDelegateEvents + FOnGetPreferredSize : TOnGetPreferredSizeEvent; + FOnGetMinimumSize : TOnGetMinimumSizeEvent; + FOnGetMaximumSize : TOnGetMaximumSizeEvent; + FOnGetHeightForWidth : TOnGetHeightForWidthEvent; + FOnParentViewChanged : TOnParentViewChangedEvent; + FOnChildViewChanged : TOnChildViewChangedEvent; + FOnFocus : TOnFocusEvent; + FOnBlur : TOnBlurEvent; + + procedure CreateView; virtual; + procedure DestroyView; virtual; + procedure Initialize; virtual; + + function GetInitialized : boolean; virtual; + function GetAsView : ICefView; virtual; + function GetTypeString : ustring; + function GetAsBrowserView : ICefBrowserView; virtual; + function GetAsButton : ICefButton; virtual; + function GetAsPanel : ICefPanel; virtual; + function GetAsScrollView : ICefScrollView; virtual; + function GetAsTextfield : ICefTextfield; virtual; + function GetIsValid : boolean; + function GetIsAttached : boolean; + function GetDelegate : ICefViewDelegate; + function GetWindow : ICefWindow; + function GetID : Integer; + function GetGroupID : Integer; + function GetParentView : ICefView; + function GetBounds : TCefRect; + function GetBoundsInScreen : TCefRect; + function GetSize : TCefSize; + function GetPosition : TCefPoint; + function GetPreferredSize : TCefSize; + function GetMinimumSize : TCefSize; + function GetMaximumSize : TCefSize; + function GetIsVisible : boolean; + function GetIsDrawn : boolean; + function GetIsEnabled : boolean; + function GetIsFocusable : boolean; + function GetIsAccessibilityFocusable : boolean; + function GetBackgroundColor : TCefColor; + function GetViewForID(id_: Integer): ICefView; + function GetHeightForWidth(width: Integer): Integer; + + procedure SetID(id_: Integer); + procedure SetGroupID(group_id: Integer); + procedure SetBounds(const bounds_: TCefRect); + procedure SetSize(const size_: TCefSize); + procedure SetPosition(const position_: TCefPoint); + procedure SetVisible(visible_: boolean); + procedure SetEnabled(enabled_: boolean); + procedure SetFocusable(focusable_: boolean); + procedure SetBackgroundColor(color: TCefColor); + + // ICefViewDelegateEvents + procedure doOnGetPreferredSize(const view: ICefView; var aResult : TCefSize); virtual; + procedure doOnGetMinimumSize(const view: ICefView; var aResult : TCefSize); virtual; + procedure doOnGetMaximumSize(const view: ICefView; var aResult : TCefSize); virtual; + procedure doOnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); virtual; + procedure doOnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); virtual; + procedure doOnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); virtual; + procedure doOnFocus(const view: ICefView); virtual; + procedure doOnBlur(const view: ICefView); virtual; + procedure doCreateCustomView; virtual; + + public + constructor Create(AOwner: TComponent); override; + procedure BeforeDestruction; override; + + function ToStringEx(include_children: boolean): ustring; + function IsSame(const that: ICefView): boolean; + procedure SizeToPreferredSize; + procedure InvalidateLayout; + procedure RequestFocus; + + function ConvertPointToScreen(var point: TCefPoint): boolean; + function ConvertPointFromScreen(var point: TCefPoint): boolean; + function ConvertPointToWindow(var point: TCefPoint): boolean; + function ConvertPointFromWindow(var point: TCefPoint): boolean; + function ConvertPointToView(const view : ICefView; var point: TCefPoint): boolean; + function ConvertPointFromView(const view : ICefView; var point: TCefPoint): boolean; + + property Initialized : boolean read GetInitialized; + property AsView : ICefView read GetAsView; + property AsBrowserView : ICefBrowserView read GetAsBrowserView; + property AsButton : ICefButton read GetAsButton; + property AsPanel : ICefPanel read GetAsPanel; + property AsScrollView : ICefScrollView read GetAsScrollView; + property AsTextfield : ICefTextfield read GetAsTextfield; + property ViewForID[id_: Integer] : ICefView read GetViewForID; + property Valid : boolean read GetIsValid; + property Attached : boolean read GetIsAttached; + property Delegate : ICefViewDelegate read GetDelegate; + property Window : ICefWindow read GetWindow; + property ParentView : ICefView read GetParentView; + property BoundsInScreen : TCefRect read GetBoundsInScreen; + property PreferredSize : TCefSize read GetPreferredSize; + property MinimumSize : TCefSize read GetMinimumSize; + property MaximumSize : TCefSize read GetMaximumSize; + property Visible : boolean read GetIsVisible write SetVisible; + property Drawn : boolean read GetIsDrawn; + property Enabled : boolean read GetIsEnabled write SetEnabled; + property Focusable : boolean read GetIsFocusable write SetFocusable; + property AccessibilityFocusable : boolean read GetIsAccessibilityFocusable; + property BackgroundColor : TCefColor read GetBackgroundColor write SetBackgroundColor; + property ID : integer read GetID write SetID; + property GroupID : integer read GetGroupID write SetGroupID; + property Bounds : TCefRect read GetBounds write SetBounds; + property Size : TCefSize read GetSize write SetSize; + property Position : TCefPoint read GetPosition write SetPosition; + property TypeString : ustring read GetTypeString; + property HeightForWidth[width: Integer] : Integer read GetHeightForWidth; + + published + property OnGetPreferredSize : TOnGetPreferredSizeEvent read FOnGetPreferredSize write FOnGetPreferredSize; + property OnGetMinimumSize : TOnGetMinimumSizeEvent read FOnGetMinimumSize write FOnGetMinimumSize; + property OnGetMaximumSize : TOnGetMaximumSizeEvent read FOnGetMaximumSize write FOnGetMaximumSize; + property OnGetHeightForWidth : TOnGetHeightForWidthEvent read FOnGetHeightForWidth write FOnGetHeightForWidth; + property OnParentViewChanged : TOnParentViewChangedEvent read FOnParentViewChanged write FOnParentViewChanged; + property OnChildViewChanged : TOnChildViewChangedEvent read FOnChildViewChanged write FOnChildViewChanged; + property OnFocus : TOnFocusEvent read FOnFocus write FOnFocus; + property OnBlur : TOnBlurEvent read FOnBlur write FOnBlur; + end; + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + uCEFViewDelegate, uCEFMiscFunctions, uCEFTask; + +constructor TCEFViewComponent.Create(AOwner: TComponent); +begin + inherited Create(aOwner); + + Initialize; +end; + +procedure TCEFViewComponent.BeforeDestruction; +begin + DestroyView; + + inherited BeforeDestruction; +end; + +procedure TCEFViewComponent.Initialize; +begin + FOnGetPreferredSize := nil; + FOnGetMinimumSize := nil; + FOnGetMaximumSize := nil; + FOnGetHeightForWidth := nil; + FOnParentViewChanged := nil; + FOnChildViewChanged := nil; + FOnFocus := nil; + FOnBlur := nil; +end; + +procedure TCEFViewComponent.CreateView; +var + TempTask : ICefTask; +begin + if CefCurrentlyOn(TID_UI) then + doCreateCustomView + else + try + TempTask := TCefCreateCustomViewTask.Create(self); + CefPostTask(TID_UI, TempTask); + finally + TempTask := nil; + end; +end; + +procedure TCEFViewComponent.DestroyView; +begin + // +end; + +function TCEFViewComponent.GetInitialized : boolean; +begin + Result := False; +end; + +function TCEFViewComponent.GetAsView : ICefView; +begin + Result := nil; +end; + +function TCEFViewComponent.GetAsBrowserView : ICefBrowserView; +begin + if Initialized then + Result := AsView.AsBrowserView + else + Result := nil; +end; + +function TCEFViewComponent.GetAsButton : ICefButton; +begin + if Initialized then + Result := AsView.AsButton + else + Result := nil; +end; + +function TCEFViewComponent.GetAsPanel : ICefPanel; +begin + if Initialized then + Result := AsView.AsPanel + else + Result := nil; +end; + +function TCEFViewComponent.GetAsScrollView : ICefScrollView; +begin + if Initialized then + Result := AsView.AsScrollView + else + Result := nil; +end; + +function TCEFViewComponent.GetAsTextfield : ICefTextfield; +begin + if Initialized then + Result := AsView.AsTextfield + else + Result := nil; +end; + +function TCEFViewComponent.GetTypeString : ustring; +begin + if Initialized then + Result := AsView.GetTypeString + else + Result := ''; +end; + +function TCEFViewComponent.ToStringEx(include_children: boolean): ustring; +begin + if Initialized then + Result := AsView.ToStringEx(include_children) + else + Result := ''; +end; + +function TCEFViewComponent.GetIsValid : boolean; +begin + Result := Initialized and AsView.IsValid; +end; + +function TCEFViewComponent.GetIsAttached : boolean; +begin + Result := Initialized and AsView.IsAttached; +end; + +function TCEFViewComponent.IsSame(const that: ICefView): boolean; +begin + if Initialized then + Result := AsView.IsSame(that) + else + Result := False; +end; + +function TCEFViewComponent.GetDelegate : ICefViewDelegate; +begin + if Initialized then + Result := AsView.GetDelegate + else + Result := nil; +end; + +function TCEFViewComponent.GetWindow : ICefWindow; +begin + if Initialized then + Result := AsView.GetWindow + else + Result := nil; +end; + +function TCEFViewComponent.GetID : Integer; +begin + if Initialized then + Result := AsView.GetID + else + Result := 0; +end; + +procedure TCEFViewComponent.SetID(id_: Integer); +begin + if Initialized then + AsView.SetID(id_); +end; + +function TCEFViewComponent.GetGroupID : Integer; +begin + if Initialized then + Result := AsView.GetGroupID + else + Result := -1; +end; + +procedure TCEFViewComponent.SetGroupID(group_id: Integer); +begin + if Initialized then + AsView.SetGroupID(group_id); +end; + +function TCEFViewComponent.GetParentView : ICefView; +begin + if Initialized then + Result := AsView.GetParentView + else + Result := nil; +end; + +function TCEFViewComponent.GetViewForID(id_: Integer): ICefView; +begin + if Initialized then + Result := AsView.GetViewForID(id_) + else + Result := nil; +end; + +procedure TCEFViewComponent.SetBounds(const bounds_: TCefRect); +begin + if Initialized then + AsView.SetBounds(bounds_); +end; + +function TCEFViewComponent.GetBounds : TCefRect; +var + TempRect : TCefRect; +begin + if Initialized then + TempRect := AsView.GetBounds + else + begin + TempRect.x := 0; + TempRect.y := 0; + TempRect.width := 0; + TempRect.height := 0; + end; + + Result := TempRect; +end; + +function TCEFViewComponent.GetBoundsInScreen : TCefRect; +var + TempRect : TCefRect; +begin + if Initialized then + TempRect := AsView.GetBoundsInScreen + else + begin + TempRect.x := 0; + TempRect.y := 0; + TempRect.width := 0; + TempRect.height := 0; + end; + + Result := TempRect; +end; + +procedure TCEFViewComponent.SetSize(const size_: TCefSize); +begin + if Initialized then + AsView.SetSize(size_); +end; + +function TCEFViewComponent.GetSize : TCefSize; +var + TempSize : TCefSize; +begin + if Initialized then + TempSize := AsView.GetSize + else + begin + TempSize.width := 0; + TempSize.height := 0; + end; + + Result := TempSize; +end; + +procedure TCEFViewComponent.SetPosition(const position_: TCefPoint); +begin + if Initialized then + AsView.SetPosition(position_); +end; + +function TCEFViewComponent.GetPosition : TCefPoint; +var + TempPoint : TCefPoint; +begin + if Initialized then + TempPoint := AsView.GetPosition + else + begin + TempPoint.x := 0; + TempPoint.y := 0; + end; + + Result := TempPoint; +end; + +function TCEFViewComponent.GetPreferredSize : TCefSize; +var + TempSize : TCefSize; +begin + if Initialized then + TempSize := AsView.GetPreferredSize + else + begin + TempSize.width := 0; + TempSize.height := 0; + end; + + Result := TempSize; +end; + +procedure TCEFViewComponent.SizeToPreferredSize; +begin + if Initialized then + AsView.SizeToPreferredSize; +end; + +function TCEFViewComponent.GetMinimumSize : TCefSize; +var + TempSize : TCefSize; +begin + if Initialized then + TempSize := AsView.GetMinimumSize + else + begin + TempSize.width := 0; + TempSize.height := 0; + end; + + Result := TempSize; +end; + +function TCEFViewComponent.GetMaximumSize : TCefSize; +var + TempSize : TCefSize; +begin + if Initialized then + TempSize := AsView.GetMaximumSize + else + begin + TempSize.width := 0; + TempSize.height := 0; + end; + + Result := TempSize; +end; + +function TCEFViewComponent.GetHeightForWidth(width: Integer): Integer; +begin + if Initialized then + Result := AsView.GetHeightForWidth(width) + else + Result := 0; +end; + +procedure TCEFViewComponent.InvalidateLayout; +begin + if Initialized then + AsView.InvalidateLayout; +end; + +procedure TCEFViewComponent.SetVisible(visible_: boolean); +begin + if Initialized then + AsView.SetVisible(visible_); +end; + +function TCEFViewComponent.GetIsVisible : boolean; +begin + Result := Initialized and AsView.IsVisible; +end; + +function TCEFViewComponent.GetIsDrawn : boolean; +begin + Result := Initialized and AsView.IsDrawn; +end; + +procedure TCEFViewComponent.SetEnabled(enabled_: boolean); +begin + if Initialized then + AsView.SetEnabled(enabled_); +end; + +function TCEFViewComponent.GetIsEnabled : boolean; +begin + Result := Initialized and AsView.IsEnabled; +end; + +procedure TCEFViewComponent.SetFocusable(focusable_: boolean); +begin + if Initialized then + AsView.SetFocusable(focusable_); +end; + +function TCEFViewComponent.GetIsFocusable : boolean; +begin + Result := Initialized and AsView.IsFocusable; +end; + +function TCEFViewComponent.GetIsAccessibilityFocusable : boolean; +begin + Result := Initialized and AsView.IsAccessibilityFocusable; +end; + +procedure TCEFViewComponent.RequestFocus; +begin + if Initialized then + AsView.RequestFocus; +end; + +procedure TCEFViewComponent.SetBackgroundColor(color: TCefColor); +begin + if Initialized then + AsView.SetBackgroundColor(color); +end; + +function TCEFViewComponent.GetBackgroundColor : TCefColor; +begin + if Initialized then + Result := AsView.GetBackgroundColor + else + Result := 0; +end; + +function TCEFViewComponent.ConvertPointToScreen(var point: TCefPoint): boolean; +begin + Result := Initialized and AsView.ConvertPointToScreen(point); +end; + +function TCEFViewComponent.ConvertPointFromScreen(var point: TCefPoint): boolean; +begin + Result := Initialized and AsView.ConvertPointFromScreen(point); +end; + +function TCEFViewComponent.ConvertPointToWindow(var point: TCefPoint): boolean; +begin + Result := Initialized and AsView.ConvertPointToWindow(point); +end; + +function TCEFViewComponent.ConvertPointFromWindow(var point: TCefPoint): boolean; +begin + Result := Initialized and AsView.ConvertPointFromWindow(point); +end; + +function TCEFViewComponent.ConvertPointToView(const view : ICefView; var point: TCefPoint): boolean; +begin + Result := Initialized and AsView.ConvertPointToView(view, point); +end; + +function TCEFViewComponent.ConvertPointFromView(const view : ICefView; var point: TCefPoint): boolean; +begin + Result := Initialized and AsView.ConvertPointFromView(view, point); +end; + +procedure TCEFViewComponent.doOnGetPreferredSize(const view : ICefView; + var aResult : TCefSize); +begin + if assigned(FOnGetPreferredSize) then + FOnGetPreferredSize(self, view, aResult); +end; + +procedure TCEFViewComponent.doOnGetMinimumSize(const view : ICefView; + var aResult : TCefSize); +begin + if assigned(FOnGetMinimumSize) then + FOnGetMinimumSize(self, view, aResult); +end; + +procedure TCEFViewComponent.doOnGetMaximumSize(const view : ICefView; + var aResult : TCefSize); +begin + if assigned(FOnGetMaximumSize) then + FOnGetMaximumSize(self, view, aResult); +end; + +procedure TCEFViewComponent.doOnGetHeightForWidth(const view : ICefView; + width : Integer; + var aResult : Integer); +begin + if assigned(FOnGetHeightForWidth) then + FOnGetHeightForWidth(self, view, width, aResult); +end; + +procedure TCEFViewComponent.doOnParentViewChanged(const view : ICefView; + added : boolean; + const parent : ICefView); +begin + if assigned(FOnParentViewChanged) then + FOnParentViewChanged(self, view, added, Parent); +end; + +procedure TCEFViewComponent.doOnChildViewChanged(const view : ICefView; + added : boolean; + const child : ICefView); +begin + if assigned(FOnChildViewChanged) then + FOnChildViewChanged(self, view, added, child); +end; + +procedure TCEFViewComponent.doOnFocus(const view: ICefView); +begin + if assigned(FOnFocus) then + FOnFocus(self, view); +end; + +procedure TCEFViewComponent.doOnBlur(const view: ICefView); +begin + if assigned(FOnBlur) then + FOnBlur(self, view); +end; + +procedure TCEFViewComponent.doCreateCustomView; +begin + // +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFViewDelegate.pas b/windows/src/ext/cef4delphi/source/uCEFViewDelegate.pas new file mode 100644 index 0000000000000000000000000000000000000000..592e0748ede1b3d9cb9061203e467b68cdae361e --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFViewDelegate.pas @@ -0,0 +1,464 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFViewDelegate; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; + +type + TCefViewDelegateRef = class(TCefBaseRefCountedRef, ICefViewDelegate) + protected + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); + procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); + procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); + procedure OnFocus(const view: ICefView); + procedure OnBlur(const view: ICefView); + + public + class function UnWrap(data: Pointer): ICefViewDelegate; + end; + + TCefViewDelegateOwn = class(TCefBaseRefCountedOwn, ICefViewDelegate) + protected + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); virtual; + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); virtual; + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); virtual; + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); virtual; + procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); virtual; + procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); virtual; + procedure OnFocus(const view: ICefView); virtual; + procedure OnBlur(const view: ICefView); virtual; + + procedure InitializeCEFMethods; virtual; + public + constructor Create; virtual; + end; + + TCustomViewDelegate = class(TCefViewDelegateOwn) + protected + FEvents : Pointer; + + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); override; + procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); override; + procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); override; + procedure OnFocus(const view: ICefView); override; + procedure OnBlur(const view: ICefView); override; + + public + constructor Create(const events: ICefViewDelegateEvents); reintroduce; + destructor Destroy; override; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFView; + + +// ************************************************************** +// ******************** TCefViewDelegateRef ********************* +// ************************************************************** + +procedure TCefViewDelegateRef.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); +begin + aResult := PCefViewDelegate(FData)^.get_preferred_size(PCefViewDelegate(FData), + CefGetData(view)); +end; + +procedure TCefViewDelegateRef.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); +begin + aResult := PCefViewDelegate(FData)^.get_minimum_size(PCefViewDelegate(FData), + CefGetData(view)); +end; + +procedure TCefViewDelegateRef.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); +begin + aResult := PCefViewDelegate(FData)^.get_maximum_size(PCefViewDelegate(FData), + CefGetData(view)); +end; + +procedure TCefViewDelegateRef.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); +begin + aResult := PCefViewDelegate(FData)^.get_height_for_width(PCefViewDelegate(FData), + CefGetData(view), + width); +end; + +procedure TCefViewDelegateRef.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); +begin + PCefViewDelegate(FData)^.on_parent_view_changed(PCefViewDelegate(FData), + CefGetData(view), + ord(added), + CefGetData(parent)); +end; + +procedure TCefViewDelegateRef.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); +begin + PCefViewDelegate(FData)^.on_child_view_changed(PCefViewDelegate(FData), + CefGetData(view), + ord(added), + CefGetData(child)); +end; + +procedure TCefViewDelegateRef.OnFocus(const view: ICefView); +begin + PCefViewDelegate(FData)^.on_focus(PCefViewDelegate(FData), + CefGetData(view)); +end; + +procedure TCefViewDelegateRef.OnBlur(const view: ICefView); +begin + PCefViewDelegate(FData)^.on_blur(PCefViewDelegate(FData), + CefGetData(view)); +end; + +class function TCefViewDelegateRef.UnWrap(data: Pointer): ICefViewDelegate; +begin + if (data <> nil) then + Result := Create(data) as ICefViewDelegate + else + Result := nil; +end; + + + +// ************************************************************** +// ******************** TCefViewDelegateOwn ********************* +// ************************************************************** + +function cef_view_delegate_get_preferred_size(self: PCefViewDelegate; view: PCefView): TCefSize; stdcall; +var + TempObject : TObject; + TempSize : TCefSize; +begin + TempObject := CefGetObject(self); + TempSize.width := 100; + TempSize.height := 100; + + if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then + TCefViewDelegateOwn(TempObject).OnGetPreferredSize(TCefViewRef.UnWrap(view), + TempSize); + + Result := TempSize; +end; + +function cef_view_delegate_get_minimum_size(self: PCefViewDelegate; view: PCefView): TCefSize; stdcall; +var + TempObject : TObject; + TempSize : TCefSize; +begin + TempObject := CefGetObject(self); + TempSize.width := 0; + TempSize.height := 0; + + if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then + TCefViewDelegateOwn(TempObject).OnGetMinimumSize(TCefViewRef.UnWrap(view), + TempSize); + + Result := TempSize; +end; + +function cef_view_delegate_get_maximum_size(self: PCefViewDelegate; view: PCefView): TCefSize; stdcall; +var + TempObject : TObject; + TempSize : TCefSize; +begin + TempObject := CefGetObject(self); + TempSize.width := 0; + TempSize.height := 0; + + if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then + TCefViewDelegateOwn(TempObject).OnGetMaximumSize(TCefViewRef.UnWrap(view), + TempSize); + + Result := TempSize; +end; + +function cef_view_delegate_get_height_for_width(self: PCefViewDelegate; view: PCefView; width: Integer): Integer; stdcall; +var + TempObject : TObject; + TempHeight : integer; +begin + TempObject := CefGetObject(self); + TempHeight := 0; + + if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then + TCefViewDelegateOwn(TempObject).OnGetHeightForWidth(TCefViewRef.UnWrap(view), + width, + TempHeight); + + Result := TempHeight; +end; + +procedure cef_view_delegate_on_parent_view_changed(self: PCefViewDelegate; view: PCefView; added: Integer; parent: PCefView); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then + TCefViewDelegateOwn(TempObject).OnParentViewChanged(TCefViewRef.UnWrap(view), + added <> 0, + TCefViewRef.UnWrap(parent)); +end; + +procedure cef_view_delegate_on_child_view_changed(self: PCefViewDelegate; view: PCefView; added: Integer; child: PCefView); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then + TCefViewDelegateOwn(TempObject).OnChildViewChanged(TCefViewRef.UnWrap(view), + added <> 0, + TCefViewRef.UnWrap(child)); +end; + +procedure cef_view_delegate_on_focus(self: PCefViewDelegate; view: PCefView); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then + TCefViewDelegateOwn(TempObject).OnFocus(TCefViewRef.UnWrap(view)); +end; + +procedure cef_view_delegate_on_blur(self: PCefViewDelegate; view: PCefView); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then + TCefViewDelegateOwn(TempObject).OnBlur(TCefViewRef.UnWrap(view)); +end; + +constructor TCefViewDelegateOwn.Create; +begin + inherited CreateData(SizeOf(TCefViewDelegate)); + + InitializeCEFMethods; +end; + +procedure TCefViewDelegateOwn.InitializeCEFMethods; +begin + with PCefViewDelegate(FData)^ do + begin + get_preferred_size := {$IFDEF FPC}@{$ENDIF}cef_view_delegate_get_preferred_size; + get_minimum_size := {$IFDEF FPC}@{$ENDIF}cef_view_delegate_get_minimum_size; + get_maximum_size := {$IFDEF FPC}@{$ENDIF}cef_view_delegate_get_maximum_size; + get_height_for_width := {$IFDEF FPC}@{$ENDIF}cef_view_delegate_get_height_for_width; + on_parent_view_changed := {$IFDEF FPC}@{$ENDIF}cef_view_delegate_on_parent_view_changed; + on_child_view_changed := {$IFDEF FPC}@{$ENDIF}cef_view_delegate_on_child_view_changed; + on_focus := {$IFDEF FPC}@{$ENDIF}cef_view_delegate_on_focus; + on_blur := {$IFDEF FPC}@{$ENDIF}cef_view_delegate_on_blur; + end; +end; + +procedure TCefViewDelegateOwn.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); +begin + // +end; + +procedure TCefViewDelegateOwn.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); +begin + // +end; + +procedure TCefViewDelegateOwn.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); +begin + // +end; + +procedure TCefViewDelegateOwn.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); +begin + // +end; + +procedure TCefViewDelegateOwn.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); +begin + // +end; + +procedure TCefViewDelegateOwn.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); +begin + // +end; + +procedure TCefViewDelegateOwn.OnFocus(const view: ICefView); +begin + // +end; + +procedure TCefViewDelegateOwn.OnBlur(const view: ICefView); +begin + // +end; + + +// ************************************************************** +// ******************** TCustomViewDelegate ********************* +// ************************************************************** + +constructor TCustomViewDelegate.Create(const events: ICefViewDelegateEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +destructor TCustomViewDelegate.Destroy; +begin + FEvents := nil; + + inherited Destroy; +end; + +procedure TCustomViewDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefViewDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomViewDelegate.OnGetPreferredSize', e) then raise; + end; +end; + +procedure TCustomViewDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefViewDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomViewDelegate.OnGetMinimumSize', e) then raise; + end; +end; + +procedure TCustomViewDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefViewDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomViewDelegate.OnGetMaximumSize', e) then raise; + end; +end; + +procedure TCustomViewDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); +begin + try + if (FEvents <> nil) then + ICefViewDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomViewDelegate.OnGetHeightForWidth', e) then raise; + end; +end; + +procedure TCustomViewDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); +begin + try + if (FEvents <> nil) then + ICefViewDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent); + except + on e : exception do + if CustomExceptionHandler('TCustomViewDelegate.OnParentViewChanged', e) then raise; + end; +end; + +procedure TCustomViewDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); +begin + try + if (FEvents <> nil) then + ICefViewDelegateEvents(FEvents).doOnChildViewChanged(view, added, child); + except + on e : exception do + if CustomExceptionHandler('TCustomViewDelegate.OnChildViewChanged', e) then raise; + end; +end; + +procedure TCustomViewDelegate.OnFocus(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefViewDelegateEvents(FEvents).doOnFocus(view); + except + on e : exception do + if CustomExceptionHandler('TCustomViewDelegate.OnFocus', e) then raise; + end; +end; + +procedure TCustomViewDelegate.OnBlur(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefViewDelegateEvents(FEvents).doOnBlur(view); + except + on e : exception do + if CustomExceptionHandler('TCustomViewDelegate.OnBlur', e) then raise; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFViewsFrameworkEvents.pas b/windows/src/ext/cef4delphi/source/uCEFViewsFrameworkEvents.pas new file mode 100644 index 0000000000000000000000000000000000000000..04174808e58cb9c23081495046760782c2f37af0 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFViewsFrameworkEvents.pas @@ -0,0 +1,104 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFViewsFrameworkEvents; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, + {$ELSE} + Classes, + {$ENDIF} + uCEFTypes, uCEFInterfaces; + +type + // ICefViewDelegate + TOnGetPreferredSizeEvent = procedure(const Sender: TObject; const view: ICefView; var aResult : TCefSize) of object; + TOnGetMinimumSizeEvent = procedure(const Sender: TObject; const view: ICefView; var aResult : TCefSize) of object; + TOnGetMaximumSizeEvent = procedure(const Sender: TObject; const view: ICefView; var aResult : TCefSize) of object; + TOnGetHeightForWidthEvent = procedure(const Sender: TObject; const view: ICefView; width: Integer; var aResult: Integer) of object; + TOnParentViewChangedEvent = procedure(const Sender: TObject; const view: ICefView; added: boolean; const parent: ICefView) of object; + TOnChildViewChangedEvent = procedure(const Sender: TObject; const view: ICefView; added: boolean; const child: ICefView) of object; + TOnFocusEvent = procedure(const Sender: TObject; const view: ICefView) of object; + TOnBlurEvent = procedure(const Sender: TObject; const view: ICefView) of object; + + // ICefTextfieldDelegate + TOnTextfieldKeyEventEvent = procedure(const Sender: TObject; const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean) of object; + TOnAfterUserActionEvent = procedure(const Sender: TObject; const textfield: ICefTextfield) of object; + + // ICefPanelDelegate + + // ICefBrowserViewDelegate + TOnBrowserCreatedEvent = procedure(const Sender: TObject; const browser_view: ICefBrowserView; const browser: ICefBrowser) of object; + TOnBrowserDestroyedEvent = procedure(const Sender: TObject; const browser_view: ICefBrowserView; const browser: ICefBrowser) of object; + TOnGetDelegateForPopupBrowserViewEvent = procedure(const Sender: TObject; const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate) of object; + TOnPopupBrowserViewCreatedEvent = procedure(const Sender: TObject; const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean) of object; + + // ICefButtonDelegate + TOnButtonPressedEvent = procedure(const Sender: TObject; const button: ICefButton) of object; + TOnButtonStateChangedEvent = procedure(const Sender: TObject; const button: ICefButton) of object; + + // ICefMenuButtonDelegate + TOnMenuButtonPressedEvent = procedure(const Sender: TObject; const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock) of object; + + // ICefWindowDelegate + TOnWindowCreatedEvent = procedure(const Sender: TObject; const window: ICefWindow) of object; + TOnWindowDestroyedEvent = procedure(const Sender: TObject; const window: ICefWindow) of object; + TOnGetParentWindowEvent = procedure(const Sender: TObject; const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow) of object; + TOnGetInitialBoundsEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : TCefRect) of object; + TOnIsFramelessEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object; + TOnCanResizeEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object; + TOnCanMaximizeEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object; + TOnCanMinimizeEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object; + TOnCanCloseEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object; + TOnAcceleratorEvent = procedure(const Sender: TObject; const window: ICefWindow; command_id: Integer; var aResult : boolean) of object; + TOnWindowKeyEventEvent = procedure(const Sender: TObject; const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean) of object; + +implementation + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFWaitableEvent.pas b/windows/src/ext/cef4delphi/source/uCEFWaitableEvent.pas index c5d5fa9fa63389434d0d2f382ba56104df94bf40..1dbd17f862fca0831ddd97d9a51f80288bcde57f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFWaitableEvent.pas +++ b/windows/src/ext/cef4delphi/source/uCEFWaitableEvent.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFWaitableEvent; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -64,7 +62,7 @@ type public class function UnWrap(data: Pointer): ICefWaitableEvent; - class function New(automatic_reset, initially_signaled : integer): ICefWaitableEvent; + class function New(automatic_reset, initially_signaled : boolean): ICefWaitableEvent; end; implementation @@ -105,9 +103,9 @@ begin Result := nil; end; -class function TCefWaitableEventRef.New(automatic_reset, initially_signaled : integer): ICefWaitableEvent; +class function TCefWaitableEventRef.New(automatic_reset, initially_signaled : boolean): ICefWaitableEvent; begin - Result := UnWrap(cef_waitable_event_create(automatic_reset, initially_signaled)); + Result := UnWrap(cef_waitable_event_create(Ord(automatic_reset), Ord(initially_signaled))); end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFWebPluginInfo.pas b/windows/src/ext/cef4delphi/source/uCEFWebPluginInfo.pas index 709c1d64703f5561a7ad92146b5732f48536653b..9ec7537526e990f5318c0f6000c4f734669cb71e 100644 --- a/windows/src/ext/cef4delphi/source/uCEFWebPluginInfo.pas +++ b/windows/src/ext/cef4delphi/source/uCEFWebPluginInfo.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFWebPluginInfo; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFWebPluginInfoVisitor.pas b/windows/src/ext/cef4delphi/source/uCEFWebPluginInfoVisitor.pas index 65d9be732ae0b8a167dc50136ea38dbafdc35abf..0429655c0aaa23b9de93ca6c3411d74843488c19 100644 --- a/windows/src/ext/cef4delphi/source/uCEFWebPluginInfoVisitor.pas +++ b/windows/src/ext/cef4delphi/source/uCEFWebPluginInfoVisitor.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFWebPluginInfoVisitor; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFWebPluginUnstableCallback.pas b/windows/src/ext/cef4delphi/source/uCEFWebPluginUnstableCallback.pas index 6eb9985795c8eae9c9d248d1276e2b8d6f71f9c0..5bc2571d26e199328351d60955b26b385978e124 100644 --- a/windows/src/ext/cef4delphi/source/uCEFWebPluginUnstableCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFWebPluginUnstableCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFWebPluginUnstableCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFWinControl.pas b/windows/src/ext/cef4delphi/source/uCEFWinControl.pas new file mode 100644 index 0000000000000000000000000000000000000000..9eccbb1ab3fb40a1c83b95366ea83a37154ce289 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFWinControl.pas @@ -0,0 +1,224 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWinControl; + +{$I cef.inc} + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} + {$IFDEF MACOSX} + {$ModeSwitch objectivec1} + {$ENDIF} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows, {$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + {$IFDEF FPC}{$IFDEF MACOSX} + CocoaAll, + {$ENDIF}{$ENDIF} + uCEFTypes, uCEFInterfaces; + +type + TCEFWinControl = class(TWinControl) + protected + function GetChildWindowHandle : {$IFNDEF MSWINDOWS}{$IFDEF FPC}LclType.{$ENDIF}{$ENDIF}THandle; virtual; + procedure Resize; override; + + public + function TakeSnapshot(var aBitmap : TBitmap) : boolean; + function DestroyChildWindow : boolean; + procedure CreateHandle; override; + procedure InvalidateChildren; + procedure UpdateSize; virtual; + + property ChildWindowHandle : THandle read GetChildWindowHandle; + + published + property Align; + property Anchors; + property Color; + property Constraints; + property TabStop; + property TabOrder; + property Visible; + property Enabled; + property ShowHint; + property Hint; + property DragKind; + property DragCursor; + property DragMode; + property OnResize; + property OnEnter; + property OnExit; + property OnDragDrop; + property OnDragOver; + property OnStartDrag; + property OnEndDrag; + {$IFDEF DELPHI14_UP} + property Touch; + property OnGesture; + {$ENDIF} + property DoubleBuffered; + {$IFDEF DELPHI12_UP} + property ParentDoubleBuffered; + {$ENDIF} + end; + +implementation + +uses + uCEFMiscFunctions, uCEFClient, uCEFConstants; + +function TCEFWinControl.GetChildWindowHandle : {$IFNDEF MSWINDOWS}{$IFDEF FPC}LclType.{$ENDIF}{$ENDIF}THandle; +begin + {$IFDEF MSWINDOWS} + if not(csDesigning in ComponentState) and HandleAllocated then + Result := GetWindow(Handle, GW_CHILD) + else + {$ENDIF} + Result := 0; +end; + +procedure TCEFWinControl.CreateHandle; +begin + inherited CreateHandle; +end; + +procedure TCEFWinControl.InvalidateChildren; +begin + if HandleAllocated then RedrawWindow(Handle, nil, 0, RDW_INVALIDATE or RDW_ALLCHILDREN); +end; + +procedure TCEFWinControl.UpdateSize; +{$IFDEF MSWINDOWS} +var + TempRect : TRect; + TempHWND : THandle; +{$ENDIF} +begin + {$IFDEF MSWINDOWS} + TempHWND := ChildWindowHandle; + if (TempHWND = 0) then exit; + + TempRect := GetClientRect; + + SetWindowPos(TempHWND, 0, + 0, 0, TempRect.right, TempRect.bottom, + SWP_NOZORDER); + {$ENDIF} +end; + +function TCEFWinControl.TakeSnapshot(var aBitmap : TBitmap) : boolean; +{$IFDEF MSWINDOWS} +var + TempHWND : HWND; + TempDC : HDC; + TempRect : TRect; + TempWidth : Integer; + TempHeight : Integer; +{$ENDIF} +begin + Result := False; + {$IFDEF MSWINDOWS} + if (aBitmap = nil) then exit; + + TempHWND := ChildWindowHandle; + if (TempHWND = 0) then exit; + {$IFDEF DELPHI16_UP}Winapi.{$ENDIF}Windows.GetClientRect(TempHWND, TempRect); + TempDC := GetDC(TempHWND); + TempWidth := TempRect.Right - TempRect.Left; + TempHeight := TempRect.Bottom - TempRect.Top; + + aBitmap := TBitmap.Create; + aBitmap.Height := TempHeight; + aBitmap.Width := TempWidth; + + Result := BitBlt(aBitmap.Canvas.Handle, 0, 0, TempWidth, TempHeight, + TempDC, 0, 0, SRCCOPY); + + ReleaseDC(TempHWND, TempDC); + {$ENDIF} +end; + +function TCEFWinControl.DestroyChildWindow : boolean; +{$IFDEF MSWINDOWS} +var + TempHWND : HWND; +{$ENDIF} +{$IFDEF FPC}{$IFDEF MACOSX} +var + ViewObj: NSObject; +{$ENDIF}{$ENDIF} +begin + {$IFDEF MSWINDOWS} + TempHWND := ChildWindowHandle; + Result := (TempHWND <> 0) and DestroyWindow(TempHWND); + {$ELSE} + Result := False; + {$IFDEF FPC}{$IFDEF MACOSX} + ViewObj := NSObject(ChildWindowHandle); + if ViewObj <> nil then begin + if ViewObj.isKindOfClass_(nsview) then begin + NSView(ViewObj).removeFromSuperview; + Result := True; + end; + end; + {$ENDIF}{$ENDIF} + {$ENDIF} +end; + +procedure TCEFWinControl.Resize; +begin + inherited Resize; + + UpdateSize; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFWindow.pas b/windows/src/ext/cef4delphi/source/uCEFWindow.pas new file mode 100644 index 0000000000000000000000000000000000000000..d730c734e9107d4d078860ebc545b2a144ecce7d --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFWindow.pas @@ -0,0 +1,335 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWindow; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFPanel; + +type + TCefWindowRef = class(TCefPanelRef, ICefWindow) + protected + procedure Show; + procedure Hide; + procedure CenterWindow(const size_: TCefSize); + procedure Close; + function IsClosed : boolean; + procedure Activate; + procedure Deactivate; + function IsActive : boolean; + procedure BringToTop; + procedure SetAlwaysOnTop(on_top: boolean); + function IsAlwaysOnTop : boolean; + procedure Maximize; + procedure Minimize; + procedure Restore; + procedure SetFullscreen(fullscreen: boolean); + function IsMaximized : boolean; + function IsMinimized : boolean; + function IsFullscreen : boolean; + procedure SetTitle(const title_: ustring); + function GetTitle : ustring; + procedure SetWindowIcon(const image: ICefImage); + function GetWindowIcon : ICefImage; + procedure SetWindowAppIcon(const image: ICefImage); + function GetWindowAppIcon : ICefImage; + procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position : TCefMenuAnchorPosition); + procedure CancelMenu; + function GetDisplay : ICefDisplay; + function GetClientAreaBoundsInScreen : TCefRect; + procedure SetDraggableRegions(regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); + function GetWindowHandle : TCefWindowHandle; + procedure SendKeyPress(key_code: Integer; event_flags: cardinal); + procedure SendMouseMove(screen_x, screen_y: Integer); + procedure SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: boolean); + procedure SetAccelerator(command_id, key_code : Integer; shift_pressed, ctrl_pressed, alt_pressed: boolean); + procedure RemoveAccelerator(command_id: Integer); + procedure RemoveAllAccelerators; + + public + class function UnWrap(data: Pointer): ICefWindow; + class function CreateTopLevel(const delegate: ICefWindowDelegate): ICefWindow; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFImage, uCEFDisplay; + +procedure TCefWindowRef.Show; +begin + PCefWindow(FData)^.show(PCefWindow(FData)); +end; + +procedure TCefWindowRef.Hide; +begin + PCefWindow(FData)^.hide(PCefWindow(FData)); +end; + +procedure TCefWindowRef.CenterWindow(const size_: TCefSize); +begin + PCefWindow(FData)^.center_window(PCefWindow(FData), @size_); +end; + +procedure TCefWindowRef.Close; +begin + PCefWindow(FData)^.close(PCefWindow(FData)); +end; + +function TCefWindowRef.IsClosed : boolean; +begin + Result := (PCefWindow(FData)^.is_closed(PCefWindow(FData)) <> 0); +end; + +procedure TCefWindowRef.Activate; +begin + PCefWindow(FData)^.activate(PCefWindow(FData)); +end; + +procedure TCefWindowRef.Deactivate; +begin + PCefWindow(FData)^.deactivate(PCefWindow(FData)); +end; + +function TCefWindowRef.IsActive : boolean; +begin + Result := (PCefWindow(FData)^.is_active(PCefWindow(FData)) <> 0); +end; + +procedure TCefWindowRef.BringToTop; +begin + PCefWindow(FData)^.bring_to_top(PCefWindow(FData)); +end; + +procedure TCefWindowRef.SetAlwaysOnTop(on_top: boolean); +begin + PCefWindow(FData)^.set_always_on_top(PCefWindow(FData), ord(on_top)); +end; + +function TCefWindowRef.IsAlwaysOnTop : boolean; +begin + Result := (PCefWindow(FData)^.is_always_on_top(PCefWindow(FData)) <> 0); +end; + +procedure TCefWindowRef.Maximize; +begin + PCefWindow(FData)^.maximize(PCefWindow(FData)); +end; + +procedure TCefWindowRef.Minimize; +begin + PCefWindow(FData)^.minimize(PCefWindow(FData)); +end; + +procedure TCefWindowRef.Restore; +begin + PCefWindow(FData)^.restore(PCefWindow(FData)); +end; + +procedure TCefWindowRef.SetFullscreen(fullscreen: boolean); +begin + PCefWindow(FData)^.set_fullscreen(PCefWindow(FData), ord(fullscreen)); +end; + +function TCefWindowRef.IsMaximized : boolean; +begin + Result := (PCefWindow(FData)^.is_maximized(PCefWindow(FData)) <> 0); +end; + +function TCefWindowRef.IsMinimized : boolean; +begin + Result := (PCefWindow(FData)^.is_minimized(PCefWindow(FData)) <> 0); +end; + +function TCefWindowRef.IsFullscreen : boolean; +begin + Result := (PCefWindow(FData)^.is_fullscreen(PCefWindow(FData)) <> 0); +end; + +procedure TCefWindowRef.SetTitle(const title_: ustring); +var + TempTitle : TCefString; +begin + TempTitle := CefString(title_); + PCefWindow(FData)^.set_title(PCefWindow(FData), @TempTitle); +end; + +function TCefWindowRef.GetTitle : ustring; +begin + Result := CefStringFreeAndGet(PCefWindow(FData)^.get_title(PCefWindow(FData))); +end; + +procedure TCefWindowRef.SetWindowIcon(const image: ICefImage); +begin + PCefWindow(FData)^.set_window_icon(PCefWindow(FData), CefGetData(image)); +end; + +function TCefWindowRef.GetWindowIcon : ICefImage; +begin + Result := TCefImageRef.UnWrap(PCefWindow(FData)^.get_window_icon(PCefWindow(FData))); +end; + +procedure TCefWindowRef.SetWindowAppIcon(const image: ICefImage); +begin + PCefWindow(FData)^.set_window_app_icon(PCefWindow(FData), CefGetData(image)); +end; + +function TCefWindowRef.GetWindowAppIcon : ICefImage; +begin + Result := TCefImageRef.UnWrap(PCefWindow(FData)^.get_window_app_icon(PCefWindow(FData))); +end; + +procedure TCefWindowRef.ShowMenu(const menu_model : ICefMenuModel; + const screen_point : TCefPoint; + anchor_position : TCefMenuAnchorPosition); +begin + PCefWindow(FData)^.show_menu(PCefWindow(FData), + CefGetData(menu_model), + @screen_point, + anchor_position); +end; + +procedure TCefWindowRef.CancelMenu; +begin + PCefWindow(FData)^.cancel_menu(PCefWindow(FData)); +end; + +function TCefWindowRef.GetDisplay : ICefDisplay; +begin + Result := TCefDisplayRef.UnWrap(PCefWindow(FData)^.get_display(PCefWindow(FData))); +end; + +function TCefWindowRef.GetClientAreaBoundsInScreen : TCefRect; +begin + Result := PCefWindow(FData)^.get_client_area_bounds_in_screen(PCefWindow(FData)); +end; + +procedure TCefWindowRef.SetDraggableRegions(regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); +begin + PCefWindow(FData)^.set_draggable_regions(PCefWindow(FData), regionsCount, regions); +end; + +function TCefWindowRef.GetWindowHandle : TCefWindowHandle; +begin + Result := PCefWindow(FData)^.get_window_handle(PCefWindow(FData)); +end; + +procedure TCefWindowRef.SendKeyPress(key_code: Integer; event_flags: cardinal); +begin + PCefWindow(FData)^.send_key_press(PCefWindow(FData), key_code, event_flags); +end; + +procedure TCefWindowRef.SendMouseMove(screen_x, screen_y: Integer); +begin + PCefWindow(FData)^.send_mouse_move(PCefWindow(FData), screen_x, screen_y); +end; + +procedure TCefWindowRef.SendMouseEvents(button : TCefMouseButtonType; + mouse_down : boolean; + mouse_up : boolean); +begin + PCefWindow(FData)^.send_mouse_events(PCefWindow(FData), + button, + ord(mouse_down), + ord(mouse_up)); +end; + +procedure TCefWindowRef.SetAccelerator(command_id : Integer; + key_code : Integer; + shift_pressed : boolean; + ctrl_pressed : boolean; + alt_pressed : boolean); +begin + PCefWindow(FData)^.set_accelerator(PCefWindow(FData), + command_id, + key_code, + ord(shift_pressed), + ord(ctrl_pressed), + ord(alt_pressed)); +end; + +procedure TCefWindowRef.RemoveAccelerator(command_id: Integer); +begin + PCefWindow(FData)^.remove_accelerator(PCefWindow(FData), command_id); +end; + +procedure TCefWindowRef.RemoveAllAccelerators; +begin + PCefWindow(FData)^.remove_all_accelerators(PCefWindow(FData)); +end; + +class function TCefWindowRef.UnWrap(data: Pointer): ICefWindow; +begin + if (data <> nil) then + Result := Create(data) as ICefWindow + else + Result := nil; +end; + +class function TCefWindowRef.CreateTopLevel(const delegate: ICefWindowDelegate): ICefWindow; +var + TempWindow : PCefWindow; +begin + Result := nil; + + if (delegate <> nil) then + begin + TempWindow := cef_window_create_top_level(CefGetData(delegate)); + + if (TempWindow <> nil) then + Result := Create(TempWindow) as ICefWindow; + end; +end; + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFWindowComponent.pas b/windows/src/ext/cef4delphi/source/uCEFWindowComponent.pas new file mode 100644 index 0000000000000000000000000000000000000000..f5116598261d553715229fc39540f83bc42846ed --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFWindowComponent.pas @@ -0,0 +1,568 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWindowComponent; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes, + {$ELSE} + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, + {$IFDEF FPC} + LCLProc, LCLType, LCLIntf, LResources, InterfaceBase, + {$ENDIF} + {$ENDIF} + uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents, uCEFPanelComponent; + +type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFWindowComponent = class(TCEFPanelComponent, ICefWindowDelegateEvents) + protected + FWindow : ICefWindow; + FWindowDlg : ICefWindowDelegate; + + // ICefWindowDelegateEvents + FOnWindowCreated : TOnWindowCreatedEvent; + FOnWindowDestroyed : TOnWindowDestroyedEvent; + FOnGetParentWindow : TOnGetParentWindowEvent; + FOnGetInitialBounds : TOnGetInitialBoundsEvent; + FOnIsFrameless : TOnIsFramelessEvent; + FOnCanResize : TOnCanResizeEvent; + FOnCanMaximize : TOnCanMaximizeEvent; + FOnCanMinimize : TOnCanMinimizeEvent; + FOnCanClose : TOnCanCloseEvent; + FOnAccelerator : TOnAcceleratorEvent; + FOnKeyEvent : TOnWindowKeyEventEvent; + + procedure DestroyView; override; + procedure Initialize; override; + + function GetInitialized : boolean; override; + function GetAsView : ICefView; override; + function GetAsPanel : ICefPanel; override; + function GetAsWindow : ICefWindow; override; + function GetIsClosed : boolean; + function GetIsActive : boolean; + function GetIsAlwaysOnTop : boolean; + function GetIsMaximized : boolean; + function GetIsMinimized : boolean; + function GetIsFullscreen : boolean; + function GetTitle : ustring; + function GetWindowIcon : ICefImage; + function GetWindowAppIcon : ICefImage; + function GetDisplay : ICefDisplay; + function GetClientAreaBoundsInScreen : TCefRect; + function GetWindowHandle : TCefWindowHandle; + + procedure SetAlwaysOnTop(on_top: boolean); + procedure SetFullscreen(fullscreen: boolean); + procedure SetTitle(const title_: ustring); + procedure SetWindowIcon(const image: ICefImage); + procedure SetWindowAppIcon(const image: ICefImage); + + // ICefWindowDelegateEvents + procedure doOnWindowCreated(const window_: ICefWindow); + procedure doOnWindowDestroyed(const window_: ICefWindow); + procedure doOnGetParentWindow(const window_: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); + procedure doOnGetInitialBounds(const window_: ICefWindow; var aResult : TCefRect); + procedure doOnIsFrameless(const window_: ICefWindow; var aResult : boolean); + procedure doOnCanResize(const window_: ICefWindow; var aResult : boolean); + procedure doOnCanMaximize(const window_: ICefWindow; var aResult : boolean); + procedure doOnCanMinimize(const window_: ICefWindow; var aResult : boolean); + procedure doOnCanClose(const window_: ICefWindow; var aResult : boolean); + procedure doOnAccelerator(const window_: ICefWindow; command_id: Integer; var aResult : boolean); + procedure doOnKeyEvent(const window_: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); + + // ICefViewDelegateEvents + procedure doCreateCustomView; override; + + public + procedure CreateTopLevelWindow; + procedure Show; + procedure Hide; + procedure CenterWindow(const size_: TCefSize); + procedure Close; + procedure Activate; + procedure Deactivate; + procedure BringToTop; + procedure Maximize; + procedure Minimize; + procedure Restore; + procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position : TCefMenuAnchorPosition); + procedure CancelMenu; + procedure SetDraggableRegions(regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); + procedure SendKeyPress(key_code: Integer; event_flags: cardinal); + procedure SendMouseMove(screen_x, screen_y: Integer); + procedure SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: boolean); + procedure SetAccelerator(command_id, key_code : Integer; shift_pressed, ctrl_pressed, alt_pressed: boolean); + procedure RemoveAccelerator(command_id: Integer); + procedure RemoveAllAccelerators; + + property Title : ustring read GetTitle write SetTitle; + property WindowIcon : ICefImage read GetWindowIcon write SetWindowIcon; + property WindowAppIcon : ICefImage read GetWindowAppIcon write SetWindowAppIcon; + property Display : ICefDisplay read GetDisplay; + property ClientAreaBoundsInScreen : TCefRect read GetClientAreaBoundsInScreen; + property WindowHandle : TCefWindowHandle read GetWindowHandle; + property IsClosed : boolean read GetIsClosed; + property IsActive : boolean read GetIsActive; + property IsAlwaysOnTop : boolean read GetIsAlwaysOnTop write SetAlwaysOnTop; + property IsFullscreen : boolean read GetIsFullscreen write SetFullscreen; + property IsMaximized : boolean read GetIsMaximized; + property IsMinimized : boolean read GetIsMinimized; + + published + property OnWindowCreated : TOnWindowCreatedEvent read FOnWindowCreated write FOnWindowCreated; + property OnWindowDestroyed : TOnWindowDestroyedEvent read FOnWindowDestroyed write FOnWindowDestroyed; + property OnGetParentWindow : TOnGetParentWindowEvent read FOnGetParentWindow write FOnGetParentWindow; + property OnGetInitialBounds : TOnGetInitialBoundsEvent read FOnGetInitialBounds write FOnGetInitialBounds; + property OnIsFrameless : TOnIsFramelessEvent read FOnIsFrameless write FOnIsFrameless; + property OnCanResize : TOnCanResizeEvent read FOnCanResize write FOnCanResize; + property OnCanMaximize : TOnCanMaximizeEvent read FOnCanMaximize write FOnCanMaximize; + property OnCanMinimize : TOnCanMinimizeEvent read FOnCanMinimize write FOnCanMinimize; + property OnCanClose : TOnCanCloseEvent read FOnCanClose write FOnCanClose; + property OnAccelerator : TOnAcceleratorEvent read FOnAccelerator write FOnAccelerator; + property OnKeyEvent : TOnWindowKeyEventEvent read FOnKeyEvent write FOnKeyEvent; + end; + +{$IFDEF FPC} +procedure Register; +{$ENDIF} + +// ********************************************************* +// ********************** ATTENTION ! ********************** +// ********************************************************* +// ** ** +// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE ** +// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE ** +// ** EXECUTED IN A CEF THREAD BY DEFAULT. ** +// ** ** +// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN ** +// ** THE SAME THREAD TO AVOID ERRORS. ** +// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE ** +// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. ** +// ** ** +// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS ** +// ** INSIDE THE CEF4DELPHI EVENTS AND USE ** +// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND ** +// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. ** +// ** ** +// ** READ THIS FOR MORE INFORMATION : ** +// ** https://www.briskbard.com/index.php?pageid=cef ** +// ** ** +// ** USE OUR FORUMS FOR MORE QUESTIONS : ** +// ** https://www.briskbard.com/forum/ ** +// ** ** +// ********************************************************* +// ********************************************************* + +implementation + +uses + uCEFMiscFunctions, uCEFWindowDelegate, uCEFWindow, uCEFTask; + +procedure TCEFWindowComponent.Initialize; +begin + inherited Initialize; + + FWindow := nil; + FWindowDlg := nil; + FOnWindowCreated := nil; + FOnWindowDestroyed := nil; + FOnGetParentWindow := nil; + FOnGetInitialBounds := nil; + FOnIsFrameless := nil; + FOnCanResize := nil; + FOnCanMaximize := nil; + FOnCanMinimize := nil; + FOnCanClose := nil; + FOnAccelerator := nil; + FOnKeyEvent := nil; +end; + +procedure TCEFWindowComponent.CreateTopLevelWindow; +begin + CreateView; +end; + +procedure TCEFWindowComponent.doCreateCustomView; +var + TempWindow : ICefWindow; +begin + if (FWindow = nil) then + begin + if (FWindowDlg = nil) then + FWindowDlg := TCustomWindowDelegate.Create(self); + + TempWindow := TCefWindowRef.CreateTopLevel(FWindowDlg); + + if (FWindow = nil) then FWindow := TempWindow; + end; +end; + +procedure TCEFWindowComponent.DestroyView; +begin + if (FWindowDlg <> nil) then + begin + FWindowDlg.DestroyOtherRefs; + FWindowDlg := nil; + end; + + FWindow := nil; +end; + +function TCEFWindowComponent.GetInitialized : boolean; +begin + Result := (FWindow <> nil); +end; + +function TCEFWindowComponent.GetAsView : ICefView; +begin + Result := FWindow as ICefView; +end; + +function TCEFWindowComponent.GetAsPanel : ICefPanel; +begin + if Initialized then + Result := FWindow as ICefPanel + else + Result := nil; +end; + +function TCEFWindowComponent.GetAsWindow : ICefWindow; +begin + Result := FWindow; +end; + +procedure TCEFWindowComponent.doOnWindowCreated(const window_: ICefWindow); +begin + if (FWindow = nil) then FWindow := window_; + + if assigned(FOnWindowCreated) then + FOnWindowCreated(self, window_); +end; + +procedure TCEFWindowComponent.doOnWindowDestroyed(const window_: ICefWindow); +begin + if assigned(FOnWindowDestroyed) then + FOnWindowDestroyed(self, window_); + + FWindow := nil; +end; + +procedure TCEFWindowComponent.doOnGetParentWindow(const window_: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); +begin + if assigned(FOnGetParentWindow) then + FOnGetParentWindow(self, window_, is_menu, can_activate_menu, aResult); +end; + +procedure TCEFWindowComponent.doOnGetInitialBounds(const window_: ICefWindow; var aResult : TCefRect); +begin + if assigned(FOnGetInitialBounds) then + FOnGetInitialBounds(self, window_, aResult); +end; + +procedure TCEFWindowComponent.doOnIsFrameless(const window_: ICefWindow; var aResult : boolean); +begin + if assigned(FOnIsFrameless) then + FOnIsFrameless(self, window_, aResult); +end; + +procedure TCEFWindowComponent.doOnCanResize(const window_: ICefWindow; var aResult : boolean); +begin + if assigned(FOnCanResize) then + FOnCanResize(self, window_, aResult); +end; + +procedure TCEFWindowComponent.doOnCanMaximize(const window_: ICefWindow; var aResult : boolean); +begin + if assigned(FOnCanMaximize) then + FOnCanMaximize(self, window_, aResult); +end; + +procedure TCEFWindowComponent.doOnCanMinimize(const window_: ICefWindow; var aResult : boolean); +begin + if assigned(FOnCanMinimize) then + FOnCanMinimize(self, window_, aResult); +end; + +procedure TCEFWindowComponent.doOnCanClose(const window_: ICefWindow; var aResult : boolean); +begin + if assigned(FOnCanClose) then + FOnCanClose(self, window_, aResult); +end; + +procedure TCEFWindowComponent.doOnAccelerator(const window_: ICefWindow; command_id: Integer; var aResult : boolean); +begin + if assigned(FOnAccelerator) then + FOnAccelerator(self, window_, command_id, aResult); +end; + +procedure TCEFWindowComponent.doOnKeyEvent(const window_: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); +begin + if assigned(FOnKeyEvent) then + FOnKeyEvent(self, window_, event, aResult); +end; + +procedure TCEFWindowComponent.Show; +begin + if Initialized then FWindow.Show; +end; + +procedure TCEFWindowComponent.Hide; +begin + if Initialized then FWindow.Hide; +end; + +procedure TCEFWindowComponent.CenterWindow(const size_: TCefSize); +begin + if Initialized then FWindow.CenterWindow(size_); +end; + +procedure TCEFWindowComponent.Close; +begin + if Initialized then FWindow.Close; +end; + +function TCEFWindowComponent.GetIsClosed : boolean; +begin + Result := Initialized and FWindow.IsClosed; +end; + +procedure TCEFWindowComponent.Activate; +begin + if Initialized then FWindow.Activate; +end; + +procedure TCEFWindowComponent.Deactivate; +begin + if Initialized then FWindow.Deactivate; +end; + +function TCEFWindowComponent.GetIsActive : boolean; +begin + Result := Initialized and FWindow.IsActive; +end; + +procedure TCEFWindowComponent.BringToTop; +begin + if Initialized then FWindow.BringToTop; +end; + +procedure TCEFWindowComponent.SetAlwaysOnTop(on_top: boolean); +begin + if Initialized then FWindow.SetAlwaysOnTop(on_top); +end; + +function TCEFWindowComponent.GetIsAlwaysOnTop : boolean; +begin + Result := Initialized and FWindow.IsAlwaysOnTop; +end; + +procedure TCEFWindowComponent.Maximize; +begin + if Initialized then FWindow.Maximize; +end; + +procedure TCEFWindowComponent.Minimize; +begin + if Initialized then FWindow.Minimize; +end; + +procedure TCEFWindowComponent.Restore; +begin + if Initialized then FWindow.Restore; +end; + +procedure TCEFWindowComponent.SetFullscreen(fullscreen: boolean); +begin + if Initialized then FWindow.SetFullscreen(fullscreen); +end; + +function TCEFWindowComponent.GetIsMaximized : boolean; +begin + Result := Initialized and FWindow.IsMaximized; +end; + +function TCEFWindowComponent.GetIsMinimized : boolean; +begin + Result := Initialized and FWindow.IsMinimized; +end; + +function TCEFWindowComponent.GetIsFullscreen : boolean; +begin + Result := Initialized and FWindow.IsFullscreen; +end; + +procedure TCEFWindowComponent.SetTitle(const title_: ustring); +begin + if Initialized then FWindow.SetTitle(title_); +end; + +function TCEFWindowComponent.GetTitle : ustring; +begin + if Initialized then + Result := FWindow.GetTitle + else + Result := ''; +end; + +procedure TCEFWindowComponent.SetWindowIcon(const image: ICefImage); +begin + if Initialized then FWindow.SetWindowIcon(image); +end; + +function TCEFWindowComponent.GetWindowIcon : ICefImage; +begin + if Initialized then + Result := FWindow.GetWindowIcon + else + Result := nil; +end; + +procedure TCEFWindowComponent.SetWindowAppIcon(const image: ICefImage); +begin + if Initialized then FWindow.SetWindowAppIcon(image); +end; + +function TCEFWindowComponent.GetWindowAppIcon : ICefImage; +begin + if Initialized then + Result := FWindow.GetWindowAppIcon + else + Result := nil; +end; + +procedure TCEFWindowComponent.ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position : TCefMenuAnchorPosition); +begin + if Initialized then FWindow.ShowMenu(menu_model, screen_point, anchor_position); +end; + +procedure TCEFWindowComponent.CancelMenu; +begin + if Initialized then FWindow.CancelMenu; +end; + +function TCEFWindowComponent.GetDisplay : ICefDisplay; +begin + if Initialized then + Result := FWindow.GetDisplay + else + Result := nil; +end; + +function TCEFWindowComponent.GetClientAreaBoundsInScreen : TCefRect; +var + TempRect : TCefRect; +begin + if Initialized then + TempRect := FWindow.GetClientAreaBoundsInScreen + else + begin + TempRect.x := 0; + TempRect.y := 0; + TempRect.width := 0; + TempRect.height := 0; + end; + + Result := TempRect; +end; + +procedure TCEFWindowComponent.SetDraggableRegions(regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); +begin + if Initialized then FWindow.SetDraggableRegions(regionsCount, regions); +end; + +function TCEFWindowComponent.GetWindowHandle : TCefWindowHandle; +var + TempHandle : TCefWindowHandle; +begin + InitializeWindowHandle(TempHandle); + if Initialized then TempHandle := FWindow.GetWindowHandle; + Result := TempHandle; +end; + +procedure TCEFWindowComponent.SendKeyPress(key_code: Integer; event_flags: cardinal); +begin + if Initialized then FWindow.SendKeyPress(key_code, event_flags); +end; + +procedure TCEFWindowComponent.SendMouseMove(screen_x, screen_y: Integer); +begin + if Initialized then FWindow.SendMouseMove(screen_x, screen_y); +end; + +procedure TCEFWindowComponent.SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: boolean); +begin + if Initialized then FWindow.SendMouseEvents(button, mouse_down, mouse_up); +end; + +procedure TCEFWindowComponent.SetAccelerator(command_id, key_code : Integer; shift_pressed, ctrl_pressed, alt_pressed: boolean); +begin + if Initialized then FWindow.SetAccelerator(command_id, key_code, shift_pressed, ctrl_pressed, alt_pressed); +end; + +procedure TCEFWindowComponent.RemoveAccelerator(command_id: Integer); +begin + if Initialized then FWindow.RemoveAccelerator(command_id); +end; + +procedure TCEFWindowComponent.RemoveAllAccelerators; +begin + if Initialized then FWindow.RemoveAllAccelerators; +end; + +{$IFDEF FPC} +procedure Register; +begin + {$I res/tcefwindowcomponent.lrs} + RegisterComponents('Chromium Views Framework', [TCEFWindowComponent]); +end; +{$ENDIF} + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFWindowDelegate.pas b/windows/src/ext/cef4delphi/source/uCEFWindowDelegate.pas new file mode 100644 index 0000000000000000000000000000000000000000..230a410277f65ef47fe0fb006b0ed24417e1c2c6 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFWindowDelegate.pas @@ -0,0 +1,692 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWindowDelegate; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SysUtils, + {$ELSE} + Classes, SysUtils, + {$ENDIF} + uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFPanelDelegate; + +type + TCefWindowDelegateRef = class(TCefPanelDelegateRef, ICefWindowDelegate) + protected + procedure OnWindowCreated(const window: ICefWindow); + procedure OnWindowDestroyed(const window: ICefWindow); + procedure OnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); + procedure OnGetInitialBounds(const window: ICefWindow; var aResult : TCefRect); + procedure OnIsFrameless(const window: ICefWindow; var aResult : boolean); + procedure OnCanResize(const window: ICefWindow; var aResult : boolean); + procedure OnCanMaximize(const window: ICefWindow; var aResult : boolean); + procedure OnCanMinimize(const window: ICefWindow; var aResult : boolean); + procedure OnCanClose(const window: ICefWindow; var aResult : boolean); + procedure OnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean); + procedure OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); + + public + class function UnWrap(data: Pointer): ICefWindowDelegate; + end; + + TCefWindowDelegateOwn = class(TCefPanelDelegateOwn, ICefWindowDelegate) + protected + procedure OnWindowCreated(const window: ICefWindow); virtual; + procedure OnWindowDestroyed(const window: ICefWindow); virtual; + procedure OnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); virtual; + procedure OnGetInitialBounds(const window: ICefWindow; var aResult : TCefRect); virtual; + procedure OnIsFrameless(const window: ICefWindow; var aResult : boolean); virtual; + procedure OnCanResize(const window: ICefWindow; var aResult : boolean); virtual; + procedure OnCanMaximize(const window: ICefWindow; var aResult : boolean); virtual; + procedure OnCanMinimize(const window: ICefWindow; var aResult : boolean); virtual; + procedure OnCanClose(const window: ICefWindow; var aResult : boolean); virtual; + procedure OnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean); virtual; + procedure OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); virtual; + + procedure InitializeCEFMethods; override; + + public + constructor Create; override; + end; + + TCustomWindowDelegate = class(TCefWindowDelegateOwn) + protected + FEvents : Pointer; + + // ICefViewDelegate + procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); override; + procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); override; + procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); override; + procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); override; + procedure OnFocus(const view: ICefView); override; + procedure OnBlur(const view: ICefView); override; + + // ICefWindowDelegate + procedure OnWindowCreated(const window: ICefWindow); override; + procedure OnWindowDestroyed(const window: ICefWindow); override; + procedure OnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); override; + procedure OnGetInitialBounds(const window: ICefWindow; var aResult : TCefRect); override; + procedure OnIsFrameless(const window: ICefWindow; var aResult : boolean); override; + procedure OnCanResize(const window: ICefWindow; var aResult : boolean); override; + procedure OnCanMaximize(const window: ICefWindow; var aResult : boolean); override; + procedure OnCanMinimize(const window: ICefWindow; var aResult : boolean); override; + procedure OnCanClose(const window: ICefWindow; var aResult : boolean); override; + procedure OnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean); override; + procedure OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); override; + + public + constructor Create(const events: ICefWindowDelegateEvents); reintroduce; + end; + +implementation + +uses + uCEFLibFunctions, uCEFMiscFunctions, uCEFWindow; + + +// ************************************************************** +// ******************* TCefWindowDelegateRef ******************** +// ************************************************************** + +procedure TCefWindowDelegateRef.OnWindowCreated(const window: ICefWindow); +begin + PCefWindowDelegate(FData)^.on_window_created(PCefWindowDelegate(FData), CefGetData(window)); +end; + +procedure TCefWindowDelegateRef.OnWindowDestroyed(const window: ICefWindow); +begin + PCefWindowDelegate(FData)^.on_window_destroyed(PCefWindowDelegate(FData), CefGetData(window)); +end; + +procedure TCefWindowDelegateRef.OnGetParentWindow(const window : ICefWindow; + var is_menu : boolean; + var can_activate_menu : boolean; + var aResult : ICefWindow); +var + TempIsMenu, TempCanActivateMenu : integer; +begin + TempIsMenu := ord(is_menu); + TempCanActivateMenu := ord(can_activate_menu); + aResult := TCefWindowRef.UnWrap(PCefWindowDelegate(FData)^.get_parent_window(PCefWindowDelegate(FData), + CefGetData(window), + @TempIsMenu, + @TempCanActivateMenu)); + is_menu := TempIsMenu <> 0; + can_activate_menu := TempCanActivateMenu <> 0; +end; + +procedure TCefWindowDelegateRef.OnGetInitialBounds(const window: ICefWindow; var aResult : TCefRect); +begin + aResult := PCefWindowDelegate(FData)^.get_initial_bounds(PCefWindowDelegate(FData), CefGetData(window)); +end; + +procedure TCefWindowDelegateRef.OnIsFrameless(const window: ICefWindow; var aResult : boolean); +begin + aResult := (PCefWindowDelegate(FData)^.is_frameless(PCefWindowDelegate(FData), CefGetData(window)) <> 0); +end; + +procedure TCefWindowDelegateRef.OnCanResize(const window: ICefWindow; var aResult : boolean); +begin + aResult := (PCefWindowDelegate(FData)^.can_resize(PCefWindowDelegate(FData), CefGetData(window)) <> 0); +end; + +procedure TCefWindowDelegateRef.OnCanMaximize(const window: ICefWindow; var aResult : boolean); +begin + aResult := (PCefWindowDelegate(FData)^.can_maximize(PCefWindowDelegate(FData), CefGetData(window)) <> 0); +end; + +procedure TCefWindowDelegateRef.OnCanMinimize(const window: ICefWindow; var aResult : boolean); +begin + aResult := (PCefWindowDelegate(FData)^.can_minimize(PCefWindowDelegate(FData), CefGetData(window)) <> 0); +end; + +procedure TCefWindowDelegateRef.OnCanClose(const window: ICefWindow; var aResult : boolean); +begin + aResult := (PCefWindowDelegate(FData)^.can_close(PCefWindowDelegate(FData), CefGetData(window)) <> 0); +end; + +procedure TCefWindowDelegateRef.OnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean); +begin + aResult := (PCefWindowDelegate(FData)^.on_accelerator(PCefWindowDelegate(FData), CefGetData(window), command_id) <> 0); +end; + +procedure TCefWindowDelegateRef.OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); +begin + aResult := (PCefWindowDelegate(FData)^.on_key_event(PCefWindowDelegate(FData), CefGetData(window), @event) <> 0); +end; + +class function TCefWindowDelegateRef.UnWrap(data: Pointer): ICefWindowDelegate; +begin + if (data <> nil) then + Result := Create(data) as ICefWindowDelegate + else + Result := nil; +end; + + +// ************************************************************** +// ******************* TCefWindowDelegateOwn ******************** +// ************************************************************** + +procedure cef_window_delegate_on_window_created(self: PCefWindowDelegate; window: PCefWindow); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnWindowCreated(TCefWindowRef.UnWrap(window)); +end; + +procedure cef_window_delegate_on_window_destroyed(self: PCefWindowDelegate; window: PCefWindow); stdcall; +var + TempObject : TObject; +begin + TempObject := CefGetObject(self); + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnWindowDestroyed(TCefWindowRef.UnWrap(window)); +end; + +function cef_window_delegate_get_parent_window(self : PCefWindowDelegate; + window : PCefWindow; + is_menu : PInteger; + can_activate_menu : PInteger): PCefWindow; stdcall; +var + TempObject : TObject; + TempWindow : ICefWindow; + TempIsMenu, TempCanActivateMenu : boolean; +begin + TempObject := CefGetObject(self); + TempWindow := nil; + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) and (is_menu <> nil) and (can_activate_menu <> nil) then + begin + TempIsMenu := (is_menu^ <> 0); + TempCanActivateMenu := (can_activate_menu^ <> 0); + + TCefWindowDelegateOwn(TempObject).OnGetParentWindow(TCefWindowRef.UnWrap(window), + TempIsMenu, + TempCanActivateMenu, + TempWindow); + is_menu^ := ord(TempIsMenu); + can_activate_menu^ := ord(TempCanActivateMenu); + end; + + Result := CefGetData(TempWindow); +end; + +function cef_window_delegate_get_initial_bounds(self: PCefWindowDelegate; window: PCefWindow): TCefRect; stdcall; +var + TempObject : TObject; + TempRect : TCefRect; +begin + TempObject := CefGetObject(self); + TempRect.x := 0; + TempRect.y := 0; + TempRect.width := 0; + TempRect.height := 0; + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnGetInitialBounds(TCefWindowRef.UnWrap(window), + TempRect); + + Result := TempRect; +end; + +function cef_window_delegate_is_frameless(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall; +var + TempObject : TObject; + TempIsFrameless : boolean; +begin + TempObject := CefGetObject(self); + TempIsFrameless := False; + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnIsFrameless(TCefWindowRef.UnWrap(window), TempIsFrameless); + + Result := ord(TempIsFrameless); +end; + +function cef_window_delegate_can_resize(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall; +var + TempObject : TObject; + TempCanResize : boolean; +begin + TempObject := CefGetObject(self); + TempCanResize := True; + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnCanResize(TCefWindowRef.UnWrap(window), TempCanResize); + + Result := ord(TempCanResize); +end; + +function cef_window_delegate_can_maximize(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall; +var + TempObject : TObject; + TempCanMaximize : boolean; +begin + TempObject := CefGetObject(self); + TempCanMaximize := True; + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnCanMaximize(TCefWindowRef.UnWrap(window), TempCanMaximize); + + Result := ord(TempCanMaximize); +end; + +function cef_window_delegate_can_minimize(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall; +var + TempObject : TObject; + TempCanMinimize : boolean; +begin + TempObject := CefGetObject(self); + TempCanMinimize := True; + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnCanMinimize(TCefWindowRef.UnWrap(window), TempCanMinimize); + + Result := ord(TempCanMinimize); +end; + +function cef_window_delegate_can_close(self: PCefWindowDelegate; window: PCefWindow): Integer; stdcall; +var + TempObject : TObject; + TempCanClose : boolean; +begin + TempObject := CefGetObject(self); + TempCanClose := True; + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnCanClose(TCefWindowRef.UnWrap(window), TempCanClose); + + Result := ord(TempCanClose); +end; + +function cef_window_delegate_on_accelerator(self : PCefWindowDelegate; + window : PCefWindow; + command_id : Integer): Integer; stdcall; +var + TempObject : TObject; + TempResult : boolean; +begin + TempObject := CefGetObject(self); + TempResult := False; + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnAccelerator(TCefWindowRef.UnWrap(window), command_id, TempResult); + + Result := ord(TempResult); +end; + +function cef_window_delegate_on_key_event( self : PCefWindowDelegate; + window : PCefWindow; + const event : PCefKeyEvent): Integer; stdcall; +var + TempObject : TObject; + TempResult : boolean; +begin + TempObject := CefGetObject(self); + TempResult := False; + + if (TempObject <> nil) and (TempObject is TCefWindowDelegateOwn) then + TCefWindowDelegateOwn(TempObject).OnKeyEvent(TCefWindowRef.UnWrap(window), event^, TempResult); + + Result := ord(TempResult); +end; + +constructor TCefWindowDelegateOwn.Create; +begin + inherited CreateData(SizeOf(TCefWindowDelegate)); + + InitializeCEFMethods; +end; + +procedure TCefWindowDelegateOwn.InitializeCEFMethods; +begin + inherited InitializeCEFMethods; + + with PCefWindowDelegate(FData)^ do + begin + on_window_created := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_on_window_created; + on_window_destroyed := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_on_window_destroyed; + get_parent_window := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_get_parent_window; + get_initial_bounds := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_get_initial_bounds; + is_frameless := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_is_frameless; + can_resize := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_can_resize; + can_maximize := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_can_maximize; + can_minimize := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_can_minimize; + can_close := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_can_close; + on_accelerator := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_on_accelerator; + on_key_event := {$IFDEF FPC}@{$ENDIF}cef_window_delegate_on_key_event; + end; +end; + +procedure TCefWindowDelegateOwn.OnWindowCreated(const window: ICefWindow); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnWindowDestroyed(const window: ICefWindow); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnGetInitialBounds(const window: ICefWindow; var aResult : TCefRect); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnIsFrameless(const window: ICefWindow; var aResult : boolean); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnCanResize(const window: ICefWindow; var aResult : boolean); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnCanMaximize(const window: ICefWindow; var aResult : boolean); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnCanMinimize(const window: ICefWindow; var aResult : boolean); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnCanClose(const window: ICefWindow; var aResult : boolean); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean); +begin + // +end; + +procedure TCefWindowDelegateOwn.OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); +begin + // +end; + + +// ************************************************************** +// ******************* TCustomWindowDelegate ******************** +// ************************************************************** + +constructor TCustomWindowDelegate.Create(const events: ICefWindowDelegateEvents); +begin + inherited Create; + + FEvents := Pointer(events); +end; + +procedure TCustomWindowDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnGetPreferredSize', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnGetMinimumSize', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnGetMaximumSize', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnGetHeightForWidth', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnParentViewChanged', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnChildViewChanged(view, added, child); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnChildViewChanged', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnFocus(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnFocus(view); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnFocus', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnBlur(const view: ICefView); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnBlur(view); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnBlur', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnWindowCreated(const window: ICefWindow); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnWindowCreated(window); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnWindowCreated', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnWindowDestroyed(const window: ICefWindow); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnWindowDestroyed(window); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnWindowDestroyed', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnGetParentWindow(window, is_menu, can_activate_menu, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnGetParentWindow', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnGetInitialBounds(const window: ICefWindow; var aResult : TCefRect); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnGetInitialBounds(window, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnGetInitialBounds', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnIsFrameless(const window: ICefWindow; var aResult : boolean); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnIsFrameless(window, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnIsFrameless', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnCanResize(const window: ICefWindow; var aResult : boolean); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnCanResize(window, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnCanResize', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnCanMaximize(const window: ICefWindow; var aResult : boolean); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnCanMaximize(window, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnCanMaximize', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnCanMinimize(const window: ICefWindow; var aResult : boolean); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnCanMinimize(window, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnCanMinimize', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnCanClose(const window: ICefWindow; var aResult : boolean); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnCanClose(window, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnCanClose', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnAccelerator(window, command_id, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnAccelerator', e) then raise; + end; +end; + +procedure TCustomWindowDelegate.OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); +begin + try + if (FEvents <> nil) then + ICefWindowDelegateEvents(FEvents).doOnKeyEvent(window, event, aResult); + except + on e : exception do + if CustomExceptionHandler('TCustomWindowDelegate.OnKeyEvent', e) then raise; + end; +end; + + +end. + diff --git a/windows/src/ext/cef4delphi/source/uCEFWindowParent.pas b/windows/src/ext/cef4delphi/source/uCEFWindowParent.pas index 750f7765f80ee131bacc00832a47020a897b49cf..b198cddd34cf3ae1740928782cd05ea0a464de00 100644 --- a/windows/src/ext/cef4delphi/source/uCEFWindowParent.pas +++ b/windows/src/ext/cef4delphi/source/uCEFWindowParent.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFWindowParent; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -52,7 +50,7 @@ interface uses {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics, + {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics, {$ELSE} {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics, {$IFDEF FPC} @@ -61,38 +59,14 @@ uses Messages, {$ENDIF} {$ENDIF} - uCEFTypes, uCEFInterfaces; + uCEFWinControl, uCEFTypes, uCEFInterfaces; type - TCEFWindowParent = class(TWinControl) + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} + TCEFWindowParent = class(TCEFWinControl) protected - function GetChildWindowHandle : THandle; virtual; - + {$IFDEF MSWINDOWS} procedure WndProc(var aMessage: TMessage); override; - - public - procedure UpdateSize; - function TakeSnapshot(var aBitmap : TBitmap) : boolean; - function DestroyChildWindow : boolean; - procedure CreateHandle; override; - procedure Resize; override; - - property ChildWindowHandle : THandle read GetChildWindowHandle; - - published - property Align; - property Anchors; - property Color; - property Constraints; - property TabStop; - property TabOrder; - property Visible; - property Enabled; - property ShowHint; - property Hint; - property DoubleBuffered; - {$IFDEF DELPHI12_UP} - property ParentDoubleBuffered; {$ENDIF} end; @@ -105,47 +79,7 @@ implementation uses uCEFMiscFunctions, uCEFClient, uCEFConstants; -function TCEFWindowParent.GetChildWindowHandle : THandle; -begin - if not(csDesigning in ComponentState) and HandleAllocated then - Result := GetWindow(Handle, GW_CHILD) - else - Result := 0; -end; - -procedure TCEFWindowParent.Resize; -begin - inherited Resize; - - UpdateSize; -end; - -procedure TCEFWindowParent.CreateHandle; -begin - inherited; -end; - -procedure TCEFWindowParent.UpdateSize; -var - TempRect : TRect; - hdwp: THandle; - TempHandle : THandle; -begin - TempHandle := ChildWindowHandle; - if (TempHandle = 0) then Exit; - - TempRect := GetClientRect; - hdwp := BeginDeferWindowPos(1); - - try - hdwp := DeferWindowPos(hdwp, TempHandle, HWND_TOP, - TempRect.left, TempRect.top, TempRect.right - TempRect.left, TempRect.bottom - TempRect.top, - SWP_NOZORDER); - finally - EndDeferWindowPos(hdwp); - end; -end; - +{$IFDEF MSWINDOWS} procedure TCEFWindowParent.WndProc(var aMessage: TMessage); var TempHandle : THandle; @@ -159,10 +93,7 @@ begin end; WM_ERASEBKGND: - begin - TempHandle := ChildWindowHandle; - if (TempHandle = 0) then inherited WndProc(aMessage); - end; + if (ChildWindowHandle = 0) then inherited WndProc(aMessage); CM_WANTSPECIALKEY: if not(TWMKey(aMessage).CharCode in [VK_LEFT .. VK_DOWN, VK_RETURN, VK_ESCAPE]) then @@ -175,43 +106,7 @@ begin else inherited WndProc(aMessage); end; end; - -function TCEFWindowParent.TakeSnapshot(var aBitmap : TBitmap) : boolean; -var - TempHWND : HWND; - TempDC : HDC; - TempRect : TRect; - TempWidth : Integer; - TempHeight : Integer; -begin - Result := False; - TempHWND := ChildWindowHandle; - - if (TempHWND <> 0) then - begin - {$IFDEF DELPHI16_UP}Winapi.{$ENDIF}Windows.GetClientRect(TempHWND, TempRect); - TempDC := GetDC(TempHWND); - TempWidth := TempRect.Right - TempRect.Left; - TempHeight := TempRect.Bottom - TempRect.Top; - - aBitmap := TBitmap.Create; - aBitmap.Height := TempHeight; - aBitmap.Width := TempWidth; - - Result := BitBlt(aBitmap.Canvas.Handle, 0, 0, TempWidth, TempHeight, - TempDC, 0, 0, SRCCOPY); - - ReleaseDC(TempHWND, TempDC); - end; -end; - -function TCEFWindowParent.DestroyChildWindow : boolean; -var - TempHWND : HWND; -begin - TempHWND := ChildWindowHandle; - Result := (TempHWND <> 0) and DestroyWindow(TempHWND); -end; +{$ENDIF} {$IFDEF FPC} procedure Register; diff --git a/windows/src/ext/cef4delphi/source/uCEFWorkScheduler.pas b/windows/src/ext/cef4delphi/source/uCEFWorkScheduler.pas index d145da903ef12ee15da783a0ee0cac4af1554fa0..840129eb110a9a39f41220e800c6376669236248 100644 --- a/windows/src/ext/cef4delphi/source/uCEFWorkScheduler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFWorkScheduler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,52 +41,74 @@ unit uCEFWorkScheduler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} +// Define this conditional to use TCEFWorkSchedulerQueueThread instead of using +// PostMessage, Application.QueueAsyncCall or TThread.Queue inside +// TCEFWorkScheduler.ScheduleMessagePumpWork +// TCEFWorkSchedulerQueueThread is just a new experimental way to handle the +// external message pump events for all platforms. +{.$DEFINE USEQUEUETHREAD} + interface uses {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics, Vcl.Forms, + {$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, {$ELSE} - {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics, + {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, {$IFDEF FPC} - LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, + LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase, {$IFNDEF MSWINDOWS}forms,{$ENDIF} {$ELSE} Messages, {$ENDIF} {$ENDIF} - uCEFConstants, uCEFWorkSchedulerThread; + uCEFConstants, {$IFDEF USEQUEUETHREAD}uCEFWorkSchedulerQueueThread,{$ENDIF} uCEFWorkSchedulerThread; + type + {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF} TCEFWorkScheduler = class(TComponent) protected - FCompHandle : HWND; FThread : TCEFWorkSchedulerThread; + {$IFDEF USEQUEUETHREAD} + FQueueThread : TCEFWorkSchedulerQueueThread; + {$ENDIF} FDepleteWorkCycles : cardinal; FDepleteWorkDelay : cardinal; FDefaultInterval : integer; FStopped : boolean; {$IFDEF MSWINDOWS} {$WARN SYMBOL_PLATFORM OFF} + FCompHandle : HWND; FPriority : TThreadPriority; {$WARN SYMBOL_PLATFORM ON} {$ENDIF} - procedure CreateThread; + {$IFDEF USEQUEUETHREAD} + procedure CreateQueueThread; + procedure DestroyQueueThread; + procedure QueueThread_OnPulse(Sender : TObject; aDelay : integer); + {$ENDIF} + procedure DestroyThread; - procedure DeallocateWindowHandle; procedure DepleteWork; + {$IFDEF MSWINDOWS} procedure WndProc(var aMessage: TMessage); + procedure DeallocateWindowHandle; + {$ELSE} + {$IFDEF FPC} + procedure ScheduleWorkAsync(Data: PtrInt); + {$ENDIF} + {$ENDIF} procedure NextPulse(aInterval : integer); procedure ScheduleWork(const delay_ms : int64); procedure DoWork; procedure DoMessageLoopWork; + procedure Initialize; procedure SetDefaultInterval(aValue : integer); {$IFDEF MSWINDOWS} @@ -99,10 +121,11 @@ type public constructor Create(AOwner: TComponent); override; + constructor CreateDelayed; destructor Destroy; override; - procedure AfterConstruction; override; procedure ScheduleMessagePumpWork(const delay_ms : int64); procedure StopScheduler; + procedure CreateThread; published {$IFDEF MSWINDOWS} @@ -132,7 +155,7 @@ uses {$ELSE} SysUtils, Math, {$ENDIF} - uCEFMiscFunctions, uCEFApplication; + uCEFMiscFunctions, uCEFApplicationCore, uCEFTypes; procedure DestroyGlobalCEFWorkScheduler; begin @@ -143,50 +166,70 @@ constructor TCEFWorkScheduler.Create(AOwner: TComponent); begin inherited Create(AOwner); - FThread := nil; - FCompHandle := 0; - FStopped := False; - {$IFDEF MSWINDOWS} - {$WARN SYMBOL_PLATFORM OFF} - FPriority := tpNormal; - {$WARN SYMBOL_PLATFORM ON} - {$ENDIF} - FDefaultInterval := CEF_TIMER_MAXDELAY; - FDepleteWorkCycles := CEF_TIMER_DEPLETEWORK_CYCLES; - FDepleteWorkDelay := CEF_TIMER_DEPLETEWORK_DELAY; -end; + Initialize; -destructor TCEFWorkScheduler.Destroy; -begin - DestroyThread; - DeallocateWindowHandle; + if not(csDesigning in ComponentState) then + begin + {$IFDEF MSWINDOWS} + if (GlobalCEFApp <> nil) and + ((GlobalCEFApp.ProcessType = ptBrowser) or GlobalCEFApp.SingleProcess) then + FCompHandle := AllocateHWnd({$IFDEF FPC}@{$ENDIF}WndProc); + {$ENDIF} - inherited Destroy; + CreateThread; + end; end; -procedure TCEFWorkScheduler.AfterConstruction; -{$IFDEF FPC} -var - TempWndMethod : TWndMethod; -{$ENDIF} +constructor TCEFWorkScheduler.CreateDelayed; begin - inherited AfterConstruction; + inherited Create(nil); + + Initialize; if not(csDesigning in ComponentState) then begin - {$IFDEF FPC} - TempWndMethod := @WndProc; - FCompHandle := AllocateHWnd(TempWndMethod); - {$ELSE} - FCompHandle := AllocateHWnd(WndProc); + {$IFDEF MSWINDOWS} + if (GlobalCEFApp <> nil) and + ((GlobalCEFApp.ProcessType = ptBrowser) or GlobalCEFApp.SingleProcess) then + FCompHandle := AllocateHWnd({$IFDEF FPC}@{$ENDIF}WndProc); {$ENDIF} - - CreateThread; end; end; +destructor TCEFWorkScheduler.Destroy; +begin + DestroyThread; + {$IFDEF USEQUEUETHREAD} + DestroyQueueThread; + {$ENDIF} + {$IFDEF MSWINDOWS} + DeallocateWindowHandle; + {$ENDIF} + inherited Destroy; +end; + +procedure TCEFWorkScheduler.Initialize; +begin + FThread := nil; + {$IFDEF USEQUEUETHREAD} + FQueueThread := nil; + {$ENDIF} + FStopped := False; + {$IFDEF MSWINDOWS} + {$WARN SYMBOL_PLATFORM OFF} + FCompHandle := 0; + FPriority := tpNormal; + {$WARN SYMBOL_PLATFORM ON} + {$ENDIF} + FDefaultInterval := CEF_TIMER_MAXDELAY; + FDepleteWorkCycles := CEF_TIMER_DEPLETEWORK_CYCLES; + FDepleteWorkDelay := CEF_TIMER_DEPLETEWORK_DELAY; +end; + procedure TCEFWorkScheduler.CreateThread; begin + if (FThread <> nil) then exit; + FThread := TCEFWorkSchedulerThread.Create; {$IFDEF MSWINDOWS} FThread.Priority := FPriority; @@ -196,10 +239,56 @@ begin {$IFDEF DELPHI14_UP} FThread.Start; {$ELSE} + {$IFNDEF FPC} FThread.Resume; + {$ELSE} + FThread.Start; + {$ENDIF} + {$ENDIF} + + {$IFDEF USEQUEUETHREAD} + CreateQueueThread; + {$ENDIF} +end; + +{$IFDEF USEQUEUETHREAD} +procedure TCEFWorkScheduler.CreateQueueThread; +begin + FQueueThread := TCEFWorkSchedulerQueueThread.Create; + FQueueThread.OnPulse := {$IFDEF FPC}@{$ENDIF}QueueThread_OnPulse; + {$IFDEF DELPHI14_UP} + FQueueThread.Start; + {$ELSE} + {$IFNDEF FPC} + FQueueThread.Resume; + {$ELSE} + FQueueThread.Start; {$ENDIF} + {$ENDIF} +end; + +procedure TCEFWorkScheduler.DestroyQueueThread; +begin + try + if (FQueueThread <> nil) then + begin + FQueueThread.Terminate; + FQueueThread.StopThread; + FQueueThread.WaitFor; + FreeAndNil(FQueueThread); + end; + except + on e : exception do + if CustomExceptionHandler('TCEFWorkScheduler.DestroyQueueThread', e) then raise; + end; end; +procedure TCEFWorkScheduler.QueueThread_OnPulse(Sender : TObject; aDelay : integer); +begin + ScheduleWork(aDelay); +end; +{$ENDIF} + procedure TCEFWorkScheduler.DestroyThread; begin try @@ -216,6 +305,7 @@ begin end; end; +{$IFDEF MSWINDOWS} procedure TCEFWorkScheduler.WndProc(var aMessage: TMessage); begin if (aMessage.Msg = CEF_PUMPHAVEWORK) then @@ -232,6 +322,7 @@ begin FCompHandle := 0; end; end; +{$ENDIF} procedure TCEFWorkScheduler.DoMessageLoopWork; begin @@ -270,16 +361,46 @@ end; procedure TCEFWorkScheduler.ScheduleMessagePumpWork(const delay_ms : int64); begin - if not(FStopped) and (FCompHandle <> 0) then - PostMessage(FCompHandle, CEF_PUMPHAVEWORK, 0, LPARAM(delay_ms)); + if FStopped then exit; + + {$IFDEF USEQUEUETHREAD} + if (FQueueThread <> nil) and FQueueThread.Ready then + begin + FQueueThread.EnqueueValue(integer(delay_ms)); + exit; + end; + {$ENDIF} + + {$IFDEF MSWINDOWS} + if (FCompHandle <> 0) then + PostMessage(FCompHandle, CEF_PUMPHAVEWORK, 0, LPARAM(delay_ms)); + {$ELSE} + {$IFDEF FPC} + Application.QueueAsyncCall(@ScheduleWorkAsync, integer(delay_ms)); + {$ELSE} + TThread.Queue(nil, procedure + begin + ScheduleWork(delay_ms); + end); + {$ENDIF} + {$ENDIF} end; +{$IFNDEF MSWINDOWS}{$IFDEF FPC} +procedure TCEFWorkScheduler.ScheduleWorkAsync(Data: PtrInt); +begin + ScheduleWork(integer(Data)); +end; +{$ENDIF}{$ENDIF} + procedure TCEFWorkScheduler.StopScheduler; begin FStopped := True; NextPulse(0); DepleteWork; + {$IFDEF MSWINDOWS} DeallocateWindowHandle; + {$ENDIF} end; procedure TCEFWorkScheduler.Thread_OnPulse(Sender: TObject); diff --git a/windows/src/ext/cef4delphi/source/uCEFWorkSchedulerQueueThread.pas b/windows/src/ext/cef4delphi/source/uCEFWorkSchedulerQueueThread.pas new file mode 100644 index 0000000000000000000000000000000000000000..26f02cf635886337e901f0aeadae9536c8d1fcc3 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uCEFWorkSchedulerQueueThread.pas @@ -0,0 +1,272 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uCEFWorkSchedulerQueueThread; + +{$IFDEF FPC} + {$MODE OBJFPC}{$H+} +{$ENDIF} + +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} + +{$I cef.inc} + +interface + +uses + {$IFDEF DELPHI16_UP} + System.Classes, System.SyncObjs, System.SysUtils, + {$ELSE} + Classes, SyncObjs, SysUtils, + {$ENDIF} + uCEFConstants; + +type + TOnPulseEvent = procedure(Sender: TObject; aDelay: integer) of object; + TValuesArray = array of integer; + + TCEFWorkSchedulerQueueThread = class(TThread) + protected + FQueueCS : TCriticalSection; + FEvent : TEvent; + FWaiting : boolean; + FStop : boolean; + FReady : boolean; + FValues : TValuesArray; + FOnPulse : TOnPulseEvent; + + function GetAvailableValue : integer; + function GetHasPendingValue : boolean; + function Lock : boolean; + procedure Unlock; + function CanContinue : boolean; + procedure ReadAllPendingValues; + procedure DoOnPulse; + + procedure Execute; override; + + property AvailableValue : integer read GetAvailableValue; + property HasPendingValue : boolean read GetHasPendingValue; + + public + constructor Create; + destructor Destroy; override; + procedure AfterConstruction; override; + procedure StopThread; + procedure EnqueueValue(aValue : integer); + + property Ready : boolean read FReady; + property OnPulse : TOnPulseEvent read FOnPulse write FOnPulse; + end; + +implementation + +constructor TCEFWorkSchedulerQueueThread.Create; +begin + inherited Create(True); + + FReady := False; + FQueueCS := nil; + FWaiting := False; + FStop := False; + FEvent := nil; + FValues := nil; + FOnPulse := nil; + FreeOnTerminate := False; +end; + +destructor TCEFWorkSchedulerQueueThread.Destroy; +begin + if (FEvent <> nil) then FreeAndNil(FEvent); + if (FQueueCS <> nil) then FreeAndNil(FQueueCS); + + if (FValues <> nil) then + begin + Finalize(FValues); + FValues := nil; + end; + + inherited Destroy; +end; + +procedure TCEFWorkSchedulerQueueThread.AfterConstruction; +begin + inherited AfterConstruction; + + FEvent := TEvent.Create(nil, False, False, ''); + FQueueCS := TCriticalSection.Create; +end; + +function TCEFWorkSchedulerQueueThread.Lock : boolean; +begin + if (FQueueCS <> nil) then + begin + FQueueCS.Acquire; + Result := True; + end + else + Result := False; +end; + +procedure TCEFWorkSchedulerQueueThread.Unlock; +begin + if (FQueueCS <> nil) then FQueueCS.Release; +end; + +function TCEFWorkSchedulerQueueThread.GetAvailableValue : integer; +var + TempLen : integer; + TempNewValues : TValuesArray; +begin + Result := 0; + + if Lock then + begin + TempLen := length(FValues); + + if (TempLen > 0) then + begin + Result := FValues[0]; + + if (TempLen = 1) then + SetLength(FValues, 0) + else + begin + SetLength(TempNewValues, TempLen - 1); + TempNewValues := copy(FValues, 1, high(integer)); + SetLength(FValues, length(TempNewValues)); + FValues := Copy(TempNewValues); + Finalize(TempNewValues); + end; + end; + + Unlock; + end; +end; + +function TCEFWorkSchedulerQueueThread.GetHasPendingValue : boolean; +begin + Result := False; + + if Lock then + begin + if not(Terminated) and not(FStop) then + begin + FWaiting := False; + Result := (Length(FValues) > 0); + end; + + Unlock; + end; +end; + +procedure TCEFWorkSchedulerQueueThread.StopThread; +begin + if Lock then + begin + FStop := True; + + if FWaiting then + begin + FWaiting := False; + FEvent.SetEvent; + end; + + Unlock; + end; +end; + +procedure TCEFWorkSchedulerQueueThread.EnqueueValue(aValue : integer); +begin + if Lock then + try + SetLength(FValues, Length(FValues) + 1); + FValues[Length(FValues) - 1] := aValue; + + if FWaiting then + begin + FWaiting := False; + FEvent.SetEvent; + end; + finally + Unlock; + end; +end; + +procedure TCEFWorkSchedulerQueueThread.ReadAllPendingValues; +begin + while HasPendingValue do + if not(Terminated) then + Synchronize({$IFDEF FPC}self, @{$ENDIF}DoOnPulse); +end; + +procedure TCEFWorkSchedulerQueueThread.DoOnPulse; +begin + if assigned(FOnPulse) then + FOnPulse(self, AvailableValue); +end; + +function TCEFWorkSchedulerQueueThread.CanContinue : boolean; +begin + Result := False; + + if Lock then + try + if not(Terminated) and not(FStop) then + begin + Result := True; + FWaiting := True; + FEvent.ResetEvent; + end; + finally + Unlock; + end; +end; + +procedure TCEFWorkSchedulerQueueThread.Execute; +begin + FReady := True; + + while CanContinue do + begin + FEvent.WaitFor(INFINITE); + ReadAllPendingValues; + end; +end; + +end. diff --git a/windows/src/ext/cef4delphi/source/uCEFWorkSchedulerThread.pas b/windows/src/ext/cef4delphi/source/uCEFWorkSchedulerThread.pas index e9c24cd659699bda438320bb814dee3a5d0f0a93..c2eba4af3cfdb80ffecb5fb11796e9590795122c 100644 --- a/windows/src/ext/cef4delphi/source/uCEFWorkSchedulerThread.pas +++ b/windows/src/ext/cef4delphi/source/uCEFWorkSchedulerThread.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFWorkSchedulerThread; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -91,11 +89,10 @@ implementation uses {$IFDEF DELPHI16_UP} - System.SysUtils, System.Math, + System.SysUtils, System.Math; {$ELSE} - SysUtils, Math, + SysUtils, Math; {$ENDIF} - uCEFApplication; constructor TCEFWorkSchedulerThread.Create; begin diff --git a/windows/src/ext/cef4delphi/source/uCEFWriteHandler.pas b/windows/src/ext/cef4delphi/source/uCEFWriteHandler.pas index 20c6aadcc8ed9c539c82d496d21fdfdfe9a63b20..28eae6ef961268d463bc4e43898188c9f25021bf 100644 --- a/windows/src/ext/cef4delphi/source/uCEFWriteHandler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFWriteHandler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,20 +41,20 @@ unit uCEFWriteHandler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} interface uses - {$IFDEF DELPHI16_UP} - {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} - {$ELSE} - Windows, + {$IFDEF MSWINDOWS} + {$IFDEF DELPHI16_UP} + WinApi.Windows, + {$ELSE} + Windows, + {$ENDIF} {$ENDIF} uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; @@ -98,6 +98,11 @@ type implementation uses + {$IFDEF DELPHI16_UP} + System.Math, + {$ELSE} + Math, + {$ENDIF} uCEFMiscFunctions, uCEFLibFunctions; @@ -215,9 +220,11 @@ end; constructor TCefBytesWriteHandler.Create(aGrow : NativeUInt); begin inherited Create; - + {$IFDEF MSWINDOWS} InitializeCriticalSection(FCriticalSection); - + {$ELSE} + InitCriticalSection(FCriticalSection); + {$ENDIF} FGrow := aGrow; FBufferSize := aGrow; FOffset := 0; @@ -229,15 +236,11 @@ destructor TCefBytesWriteHandler.Destroy; begin if (FBuffer <> nil) then FreeMem(FBuffer); - DeleteCriticalSection(FCriticalSection); - - FCriticalSection.DebugInfo := nil; - FCriticalSection.LockCount := 0; - FCriticalSection.RecursionCount := 0; - FCriticalSection.OwningThread := 0; - FCriticalSection.LockSemaphore := 0; - {$IFNDEF FPC} - FCriticalSection.Reserved := 0; + {$IFDEF MSWINDOWS} + DeleteCriticalSection(FCriticalSection); + FillChar(FCriticalSection, SizeOf(FCriticalSection), 0); + {$ELSE} + DoneCriticalSection(FCriticalSection); {$ENDIF} inherited Destroy; @@ -246,22 +249,27 @@ end; function TCefBytesWriteHandler.Write(const ptr: Pointer; size, n: NativeUInt): NativeUInt; var TempPointer : pointer; + TempSize : int64; begin EnterCriticalSection(FCriticalSection); + try + TempSize := size * n; - if ((FOffset + (size * n)) >= FBufferSize) and (Grow(size * n) = 0) then - Result := 0 - else - begin - TempPointer := Pointer(cardinal(FBuffer) + FOffset); + if ((FOffset + TempSize) >= FBufferSize) and (Grow(TempSize) = 0) then + Result := 0 + else + begin + TempPointer := Pointer(cardinal(FBuffer) + FOffset); - CopyMemory(TempPointer, ptr, size * n); + Move(ptr^, TempPointer^, TempSize); - FOffset := FOffset + (size * n); - Result := n; - end; + FOffset := FOffset + TempSize; + Result := n; + end; - LeaveCriticalSection(FCriticalSection); + finally + LeaveCriticalSection(FCriticalSection); + end; end; function TCefBytesWriteHandler.Seek(offset: Int64; whence: Integer): Integer; @@ -337,21 +345,25 @@ end; function TCefBytesWriteHandler.Grow(size : NativeUInt) : NativeUInt; var - s : NativeUInt; + TempTotal : int64; begin EnterCriticalSection(FCriticalSection); + try - if (size > FGrow) then - s := size - else - s := FGrow; + if (size < FGrow) then + TempTotal := FGrow + else + TempTotal := size; - ReallocMem(FBuffer, FBufferSize + s); + inc(TempTotal, FBufferSize); - FBufferSize := FBufferSize + s; - Result := FBufferSize; + ReallocMem(FBuffer, TempTotal); - LeaveCriticalSection(FCriticalSection); + FBufferSize := TempTotal; + Result := FBufferSize; + finally + LeaveCriticalSection(FCriticalSection); + end; end; end. diff --git a/windows/src/ext/cef4delphi/source/uCEFX509CertPrincipal.pas b/windows/src/ext/cef4delphi/source/uCEFX509CertPrincipal.pas index aef8b0e3610e7df9ab66cbd6d71a56d4b5875cc2..7a4c2bf55ee2b33359107e6300eb6ca27e2dd918 100644 --- a/windows/src/ext/cef4delphi/source/uCEFX509CertPrincipal.pas +++ b/windows/src/ext/cef4delphi/source/uCEFX509CertPrincipal.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFX509CertPrincipal; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -83,7 +81,7 @@ uses {$ELSE} {$IFDEF MSWINDOWS}Windows,{$ENDIF} SysUtils, {$ENDIF} - uCEFMiscFunctions, uCEFLibFunctions, uCEFApplication, uCEFStringList; + uCEFMiscFunctions, uCEFStringList; function TCefX509CertPrincipalRef.GetDisplayName: ustring; begin diff --git a/windows/src/ext/cef4delphi/source/uCEFX509Certificate.pas b/windows/src/ext/cef4delphi/source/uCEFX509Certificate.pas index 818aa3ee74f43d55544d443a35079ea0e5bba36a..64ab9949ead75b096bff65e60bac21e4e42c1599 100644 --- a/windows/src/ext/cef4delphi/source/uCEFX509Certificate.pas +++ b/windows/src/ext/cef4delphi/source/uCEFX509Certificate.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFX509Certificate; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFXmlReader.pas b/windows/src/ext/cef4delphi/source/uCEFXmlReader.pas index 795fd65ab0b6fbf5bb6471a01fbfdc598dc4ec72..cfef44a19dac70423b749bb6f7c72e99e1314e8f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFXmlReader.pas +++ b/windows/src/ext/cef4delphi/source/uCEFXmlReader.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFXmlReader; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFZipReader.pas b/windows/src/ext/cef4delphi/source/uCEFZipReader.pas index ad2b9391c68e84761f677719688f8c41cc4c1e6e..e8bbfb33bd82e4f9ebb82145da0fd189b0ab0348 100644 --- a/windows/src/ext/cef4delphi/source/uCEFZipReader.pas +++ b/windows/src/ext/cef4delphi/source/uCEFZipReader.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFZipReader; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFv8Accessor.pas b/windows/src/ext/cef4delphi/source/uCEFv8Accessor.pas index 83371dd5c598078c5f53b8d1ed1f4f1a0d7f765e..f9004373dbe5fd6e150a78195d6cc7833a356f17 100644 --- a/windows/src/ext/cef4delphi/source/uCEFv8Accessor.pas +++ b/windows/src/ext/cef4delphi/source/uCEFv8Accessor.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFv8Accessor; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,8 +54,8 @@ uses type TCefV8AccessorOwn = class(TCefBaseRefCountedOwn, ICefV8Accessor) protected - function Get(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; var exception: ustring): Boolean; virtual; - function Put(const name: ustring; const obj, value: ICefv8Value; var exception: ustring): Boolean; virtual; + function Get(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): Boolean; virtual; + function Set_(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): Boolean; virtual; public constructor Create; virtual; @@ -68,8 +66,8 @@ type FGetter: TCefV8AccessorGetterProc; FSetter: TCefV8AccessorSetterProc; - function Get(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; var exception: ustring): Boolean; override; - function Put(const name: ustring; const obj, value: ICefv8Value; var exception: ustring): Boolean; override; + function Get(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): Boolean; override; + function Set_(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): Boolean; override; public constructor Create(const getter: TCefV8AccessorGetterProc; const setter: TCefV8AccessorSetterProc); reintroduce; @@ -82,48 +80,76 @@ uses function cef_v8_accessor_get( self : PCefV8Accessor; const name : PCefString; - obj : PCefv8Value; + object_ : PCefv8Value; out retval : PCefv8Value; exception : PCefString): Integer; stdcall; var - ret : ICefv8Value; - TempExcept : ustring; - TempObject : TObject; + TempObject : TObject; + TempException : ustring; + TempReturnValue : ICefv8Value; + TempRecObject : ICefv8Value; begin Result := Ord(False); - TempExcept := CefString(exception); TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefV8AccessorOwn) then - Result := Ord(TCefV8AccessorOwn(TempObject).Get(CefString(name), - TCefv8ValueRef.UnWrap(obj), - ret, - TempExcept)); - - retval := CefGetData(ret); - exception^ := CefString(TempExcept); + try + TempRecObject := TCefv8ValueRef.UnWrap(object_); + TempException := ''; + TempReturnValue := nil; + + Result := Ord(TCefV8AccessorOwn(TempObject).Get(CefString(name), + TempRecObject, + TempReturnValue, + TempException)); + + retval := CefGetData(TempReturnValue); + + if (exception <> nil) then + begin + CefStringFree(exception); + exception^ := CefStringAlloc(TempException); + end; + finally + TempRecObject := nil; + TempReturnValue := nil; + end; end; -function cef_v8_accessor_put( self : PCefV8Accessor; +function cef_v8_accessor_set( self : PCefV8Accessor; const name : PCefString; - obj : PCefv8Value; + object_ : PCefv8Value; value : PCefv8Value; exception : PCefString): Integer; stdcall; var - TempExcept : ustring; - TempObject : TObject; + TempObject : TObject; + TempException : ustring; + TempValue : ICefv8Value; + TempRecObject : ICefv8Value; begin Result := Ord(False); - TempExcept := CefString(exception); TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefV8AccessorOwn) then - Result := Ord(TCefV8AccessorOwn(TempObject).Put(CefString(name), - TCefv8ValueRef.UnWrap(obj), - TCefv8ValueRef.UnWrap(value), - TempExcept)); - - exception^ := CefString(TempExcept); + try + TempRecObject := TCefv8ValueRef.UnWrap(object_); + TempValue := TCefv8ValueRef.UnWrap(value); + TempException := ''; + + Result := Ord(TCefV8AccessorOwn(TempObject).Set_(CefString(name), + TempRecObject, + TempValue, + TempException)); + + if (exception <> nil) then + begin + CefStringFree(exception); + exception^ := CefStringAlloc(TempException); + end; + finally + TempRecObject := nil; + TempValue := nil; + end; end; // TCefV8AccessorOwn @@ -134,17 +160,17 @@ begin with PCefV8Accessor(FData)^ do begin - get := {$IFDEF FPC}@{$ENDIF}cef_v8_accessor_get; - put := {$IFDEF FPC}@{$ENDIF}cef_v8_accessor_put; + get := {$IFDEF FPC}@{$ENDIF}cef_v8_accessor_get; + set_ := {$IFDEF FPC}@{$ENDIF}cef_v8_accessor_set; end; end; -function TCefV8AccessorOwn.Get(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; var exception: ustring): Boolean; +function TCefV8AccessorOwn.Get(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): Boolean; begin Result := False; end; -function TCefV8AccessorOwn.Put(const name: ustring; const obj, value: ICefv8Value; var exception: ustring): Boolean; +function TCefV8AccessorOwn.Set_(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): Boolean; begin Result := False; end; @@ -157,18 +183,18 @@ begin FSetter := setter; end; -function TCefFastV8Accessor.Get(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; var exception: ustring): Boolean; +function TCefFastV8Accessor.Get(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): Boolean; begin if Assigned(FGetter) then - Result := FGetter(name, obj, retval, exception) + Result := FGetter(name, object_, retval, exception) else Result := False; end; -function TCefFastV8Accessor.Put(const name: ustring; const obj, value: ICefv8Value; var exception: ustring): Boolean; +function TCefFastV8Accessor.Set_(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): Boolean; begin if Assigned(FSetter) then - Result := FSetter(name, obj, value, exception) + Result := FSetter(name, object_, value, exception) else Result := False; end; diff --git a/windows/src/ext/cef4delphi/source/uCEFv8ArrayBufferReleaseCallback.pas b/windows/src/ext/cef4delphi/source/uCEFv8ArrayBufferReleaseCallback.pas index f871f80b6def2bf87e57b35c69e36178b2c981d2..011e1693f6d8aebec8f184b8a9faf669c34b2e55 100644 --- a/windows/src/ext/cef4delphi/source/uCEFv8ArrayBufferReleaseCallback.pas +++ b/windows/src/ext/cef4delphi/source/uCEFv8ArrayBufferReleaseCallback.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFv8ArrayBufferReleaseCallback; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFv8Context.pas b/windows/src/ext/cef4delphi/source/uCEFv8Context.pas index b663589e9c5767b1f4b5230ec76471a81318fdc6..f3c185d433786dbedc74a6ff992cc323fe7fa9c5 100644 --- a/windows/src/ext/cef4delphi/source/uCEFv8Context.pas +++ b/windows/src/ext/cef4delphi/source/uCEFv8Context.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFv8Context; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -79,7 +77,7 @@ uses class function TCefv8ContextRef.Current: ICefv8Context; begin - Result := UnWrap(cef_v8context_get_current_context()) + Result := UnWrap(cef_v8context_get_current_context()); end; function TCefv8ContextRef.Enter: Boolean; @@ -89,7 +87,7 @@ end; class function TCefv8ContextRef.Entered: ICefv8Context; begin - Result := UnWrap(cef_v8context_get_entered_context()) + Result := UnWrap(cef_v8context_get_entered_context()); end; function TCefv8ContextRef.Exit: Boolean; diff --git a/windows/src/ext/cef4delphi/source/uCEFv8Handler.pas b/windows/src/ext/cef4delphi/source/uCEFv8Handler.pas index 11bf0aa5f33569963631fd2b197e0560f03f8ca6..dcc62407e0e5896176a82e2fbf5ac8a797ba4b1f 100644 --- a/windows/src/ext/cef4delphi/source/uCEFv8Handler.pas +++ b/windows/src/ext/cef4delphi/source/uCEFv8Handler.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFv8Handler; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -55,14 +53,14 @@ uses {$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Rtti, System.TypInfo, System.Variants, System.SysUtils, System.Classes, System.Math, System.SyncObjs, {$ELSE} - {$IFDEF DELPHI14_UP}Rtti,{$ENDIF} TypInfo, Variants, SysUtils, Classes, Math, SyncObjs, Windows, + {$IFDEF DELPHI14_UP}Rtti,{$ENDIF} TypInfo, Variants, SysUtils, Classes, Math, SyncObjs, {$IFDEF MSWINDOWS}Windows,{$ENDIF} {$ENDIF} uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes; type TCefv8HandlerRef = class(TCefBaseRefCountedRef, ICefv8Handler) protected - function Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; + function Execute(const name: ustring; const object_: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; public class function UnWrap(data: Pointer): ICefv8Handler; @@ -70,7 +68,7 @@ type TCefv8HandlerOwn = class(TCefBaseRefCountedOwn, ICefv8Handler) protected - function Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; virtual; + function Execute(const name: ustring; const object_: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; virtual; public constructor Create; virtual; @@ -89,12 +87,12 @@ type class function StrToPtr(const str: ustring): Pointer; class function PtrToStr(p: Pointer): ustring; {$ENDIF} - function Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; override; + function Execute(const name: ustring; const object_: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; override; public constructor Create(const value: TValue; SyncMainThread: Boolean = False); reintroduce; destructor Destroy; override; - class procedure Register(const name: ustring; const value: TValue; SyncMainThread: Boolean = False); + class function Register(const name: ustring; const value: TValue; SyncMainThread: Boolean = False) : boolean; end; {$ENDIF} @@ -105,70 +103,97 @@ uses function cef_v8_handler_execute( self : PCefv8Handler; const name : PCefString; - obj : PCefv8Value; + object_ : PCefv8Value; argumentsCount : NativeUInt; const arguments : PPCefV8Value; var retval : PCefV8Value; - var exception : TCefString): Integer; stdcall; + exception : PCefString): Integer; stdcall; var - args : TCefv8ValueArray; - i, j : NativeInt; - ret : ICefv8Value; - exc : ustring; - TempObject : TObject; + TempArgs : TCefv8ValueArray; + i : NativeUInt; + TempReturnValue : ICefv8Value; + TempException : ustring; + TempObject : TObject; + TempRecObject : ICefv8Value; begin - Result := -Ord(False); + Result := Ord(False); TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefv8HandlerOwn) then - begin - i := 0; - j := argumentsCount; + try + TempRecObject := TCefv8ValueRef.UnWrap(object_); + TempReturnValue := nil; + TempArgs := nil; + TempException := ''; + + if (arguments <> nil) and (argumentsCount > 0) then + begin + SetLength(TempArgs, argumentsCount); + + i := 0; + while (i < argumentsCount) do + begin + TempArgs[i] := TCefv8ValueRef.UnWrap(arguments^[i]); + inc(i); + end; + end; - SetLength(args, j); + Result := Ord(TCefv8HandlerOwn(TempObject).Execute(CefString(name), + TempRecObject, + TempArgs, + TempReturnValue, + TempException)); - while (i < j) do + retval := CefGetData(TempReturnValue); + + if (exception <> nil) then + begin + CefStringFree(exception); + exception^ := CefStringAlloc(TempException); + end; + finally + i := 0; + while (i < argumentsCount) do begin - args[i] := TCefv8ValueRef.UnWrap(arguments^[i]); + TempArgs[i] := nil; inc(i); end; - Result := -Ord(TCefv8HandlerOwn(TempObject).Execute(CefString(name), TCefv8ValueRef.UnWrap(obj), args, ret, exc)); - retval := CefGetData(ret); - ret := nil; - exception := CefString(exc); + TempRecObject := nil; + TempReturnValue := nil; end; end; function TCefv8HandlerRef.Execute(const name : ustring; - const obj : ICefv8Value; + const object_ : ICefv8Value; const arguments : TCefv8ValueArray; var retval : ICefv8Value; var exception : ustring): Boolean; var - args : array of PCefV8Value; - i, j : Integer; - ret : PCefV8Value; - exc : TCefString; - n : TCefString; + TempArgs : array of PCefV8Value; + TempLen, i : integer; + TempReturnValue : PCefV8Value; + TempException : TCefString; + TempName : TCefString; begin - i := 0; - j := Length(arguments); + i := 0; + TempLen := Length(arguments); - SetLength(args, j); + SetLength(TempArgs, TempLen); - while (i < j) do + while (i < TempLen) do begin - args[i] := CefGetData(arguments[i]); + TempArgs[i] := CefGetData(arguments[i]); inc(i); end; - FillChar(exc, SizeOf(exc), 0); - ret := nil; - n := CefString(name); - Result := PCefv8Handler(FData)^.execute(PCefv8Handler(FData), @n, CefGetData(obj), Length(arguments), @args, ret, exc) <> 0; - retval := TCefv8ValueRef.UnWrap(ret); - exception := CefStringClearAndGet(exc); + CefStringInitialize(@TempException); + + TempReturnValue := nil; + TempName := CefString(name); + Result := PCefv8Handler(FData)^.execute(PCefv8Handler(FData), @TempName, CefGetData(object_), TempLen, @TempArgs, TempReturnValue, @TempException) <> 0; + retval := TCefv8ValueRef.UnWrap(TempReturnValue); + exception := CefStringClearAndGet(@TempException); end; class function TCefv8HandlerRef.UnWrap(data: Pointer): ICefv8Handler; @@ -188,7 +213,7 @@ begin PCefv8Handler(FData)^.execute := {$IFDEF FPC}@{$ENDIF}cef_v8_handler_execute; end; -function TCefv8HandlerOwn.Execute(const name: ustring; const obj: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; +function TCefv8HandlerOwn.Execute(const name: ustring; const object_: ICefv8Value; const arguments: TCefv8ValueArray; var retval: ICefv8Value; var exception: ustring): Boolean; begin Result := False; end; @@ -750,17 +775,21 @@ begin Result := True; end; -class procedure TCefRTTIExtension.Register(const name: ustring; const value: TValue; SyncMainThread: Boolean); +class function TCefRTTIExtension.Register(const name: ustring; const value: TValue; SyncMainThread: Boolean) : boolean; var TempCode : ustring; TempHandler : ICefv8Handler; begin - TempHandler := TCefRTTIExtension.Create(value, SyncMainThread); - TempCode := format('this.__defineSetter__(''%s'', function(v){native function $s();$s(v)});' + - 'this.__defineGetter__(''%0:s'', function(){native function $g();return $g()});', - [name]); - - CefRegisterExtension(name, TempCode, TempHandler); + try + TempHandler := TCefRTTIExtension.Create(value, SyncMainThread); + TempCode := format('this.__defineSetter__(''%s'', function(v){native function $s();$s(v)});' + + 'this.__defineGetter__(''%0:s'', function(){native function $g();return $g()});', + [name]); + + Result := CefRegisterExtension(name, TempCode, TempHandler); + finally + TempHandler := nil; + end; end; {$IFDEF CPUX64} @@ -776,9 +805,11 @@ begin end; {$ENDIF} -function TCefRTTIExtension.Execute(const name: ustring; const obj: ICefv8Value; - const arguments: TCefv8ValueArray; var retval: ICefv8Value; - var exception: ustring): Boolean; +function TCefRTTIExtension.Execute(const name : ustring; + const object_ : ICefv8Value; + const arguments : TCefv8ValueArray; + var retval : ICefv8Value; + var exception : ustring): Boolean; var p: PChar; ud: ICefv8Value; @@ -796,9 +827,9 @@ begin Result := True; p := PChar(name); m := nil; - if obj <> nil then + if object_ <> nil then begin - ud := obj.GetUserData; + ud := object_.GetUserData; if ud <> nil then begin {$IFDEF CPUX64} diff --git a/windows/src/ext/cef4delphi/source/uCEFv8Interceptor.pas b/windows/src/ext/cef4delphi/source/uCEFv8Interceptor.pas index f6291f31faa688852692ec88ebaeec9e0fec92d0..077a446a9ce17287d31909ace7b49486038d315a 100644 --- a/windows/src/ext/cef4delphi/source/uCEFv8Interceptor.pas +++ b/windows/src/ext/cef4delphi/source/uCEFv8Interceptor.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFv8Interceptor; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -56,10 +54,10 @@ uses type TCefV8InterceptorOwn = class(TCefBaseRefCountedOwn, ICefV8Interceptor) protected - function GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; virtual; - function GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; virtual; - function SetByName(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): boolean; virtual; - function SetByIndex(index: integer; const obj, value: ICefv8Value; const exception: ustring): boolean; virtual; + function GetByName(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; virtual; + function GetByIndex(index: integer; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; virtual; + function SetByName(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): boolean; virtual; + function SetByIndex(index: integer; const object_, value: ICefv8Value; var exception: ustring): boolean; virtual; public constructor Create; virtual; @@ -72,10 +70,10 @@ type FGetterByIndex : TCefV8InterceptorGetterByIndexProc; FSetterByIndex : TCefV8InterceptorSetterByIndexProc; - function GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; override; - function GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; override; - function SetByName(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): boolean; override; - function SetByIndex(index: integer; const obj, value: ICefv8Value; const exception: ustring): boolean; override; + function GetByName(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; override; + function GetByIndex(index: integer; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; override; + function SetByName(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): boolean; override; + function SetByIndex(index: integer; const object_, value: ICefv8Value; var exception: ustring): boolean; override; public constructor Create(const getterbyname : TCefV8InterceptorGetterByNameProc; @@ -91,86 +89,152 @@ uses function cef_v8_interceptor_get_byname( self : PCefV8Interceptor; const name : PCefString; - obj : PCefV8Value; + object_ : PCefV8Value; out retval : PCefv8Value; exception : PCefString): Integer; stdcall; var - ret: ICefv8Value; - TempObject : TObject; + TempObject : TObject; + TempException : ustring; + TempReturnValue : ICefv8Value; + TempRecObject : ICefv8Value; begin Result := Ord(False); retval := nil; TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefV8InterceptorOwn) then - begin - Result := Ord(TCefV8InterceptorOwn(TempObject).GetByName(CefString(name), - TCefv8ValueRef.UnWrap(obj), - ret, - CefString(exception))); + try + TempRecObject := TCefv8ValueRef.UnWrap(object_); + TempException := ''; + TempReturnValue := nil; - retval := CefGetData(ret); + Result := Ord(TCefV8InterceptorOwn(TempObject).GetByName(CefString(name), + TempRecObject, + TempReturnValue, + TempException)); + + retval := CefGetData(TempReturnValue); + + if (exception <> nil) then + begin + CefStringFree(exception); + exception^ := CefStringAlloc(TempException); + end; + finally + TempRecObject := nil; + TempReturnValue := nil; end; end; function cef_v8_interceptor_get_byindex( self : PCefV8Interceptor; index : integer; - obj : PCefV8Value; + object_ : PCefV8Value; out retval : PCefv8Value; exception : PCefString): integer; stdcall; var - ret: ICefv8Value; - TempObject : TObject; + TempObject : TObject; + TempException : ustring; + TempReturnValue : ICefv8Value; + TempRecObject : ICefv8Value; begin Result := Ord(False); retval := nil; TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefV8InterceptorOwn) then - begin - Result := Ord(TCefV8InterceptorOwn(TempObject).GetByIndex(index, - TCefv8ValueRef.UnWrap(obj), - ret, - CefString(exception))); + try + TempRecObject := TCefv8ValueRef.UnWrap(object_); + TempException := ''; + TempReturnValue := nil; - retval := CefGetData(ret); + Result := Ord(TCefV8InterceptorOwn(TempObject).GetByIndex(index, + TempRecObject, + TempReturnValue, + TempException)); + + retval := CefGetData(TempReturnValue); + + if (exception <> nil) then + begin + CefStringFree(exception); + exception^ := CefStringAlloc(TempException); + end; + finally + TempRecObject := nil; + TempReturnValue := nil; end; end; function cef_v8_interceptor_set_byname( self : PCefV8Interceptor; const name : PCefString; - obj : PCefV8Value; + object_ : PCefV8Value; value : PCefv8Value; exception : PCefString): integer; stdcall; var - TempObject : TObject; + TempObject : TObject; + TempException : ustring; + TempValue : ICefv8Value; + TempRecObject : ICefv8Value; begin Result := Ord(False); TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefV8InterceptorOwn) then - Result := Ord(TCefV8InterceptorOwn(TempObject).SetByName(CefString(name), - TCefv8ValueRef.UnWrap(obj), - TCefv8ValueRef.UnWrap(value), - CefString(exception))); + try + TempRecObject := TCefv8ValueRef.UnWrap(object_); + TempValue := TCefv8ValueRef.UnWrap(value); + TempException := ''; + + Result := Ord(TCefV8InterceptorOwn(TempObject).SetByName(CefString(name), + TempRecObject, + TempValue, + TempException)); + + if (exception <> nil) then + begin + CefStringFree(exception); + exception^ := CefStringAlloc(TempException); + end; + finally + TempRecObject := nil; + TempValue := nil; + end; end; function cef_v8_interceptor_set_byindex(self : PCefV8Interceptor; index : integer; - obj : PCefV8Value; + object_ : PCefV8Value; value : PCefv8Value; exception : PCefString): integer; stdcall; var - TempObject : TObject; + TempObject : TObject; + TempException : ustring; + TempValue : ICefv8Value; + TempRecObject : ICefv8Value; begin Result := Ord(False); TempObject := CefGetObject(self); if (TempObject <> nil) and (TempObject is TCefV8InterceptorOwn) then - Result := Ord(TCefV8InterceptorOwn(TempObject).SetByIndex(index, - TCefv8ValueRef.UnWrap(obj), - TCefv8ValueRef.UnWrap(value), - CefString(exception))); + try + TempRecObject := TCefv8ValueRef.UnWrap(object_); + TempValue := TCefv8ValueRef.UnWrap(value); + TempException := ''; + + Result := Ord(TCefV8InterceptorOwn(TempObject).SetByIndex(index, + TempRecObject, + TempValue, + TempException)); + + if (exception <> nil) then + begin + CefStringFree(exception); + exception^ := CefStringAlloc(TempException); + end; + finally + TempRecObject := nil; + TempValue := nil; + end; end; // TCefV8InterceptorOwn @@ -188,22 +252,22 @@ begin end; end; -function TCefV8InterceptorOwn.GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; +function TCefV8InterceptorOwn.GetByName(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; begin Result := False; end; -function TCefV8InterceptorOwn.GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; +function TCefV8InterceptorOwn.GetByIndex(index: integer; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; begin Result := False; end; -function TCefV8InterceptorOwn.SetByName(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): boolean; +function TCefV8InterceptorOwn.SetByName(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): boolean; begin Result := False; end; -function TCefV8InterceptorOwn.SetByIndex(index: integer; const obj, value: ICefv8Value; const exception: ustring): boolean; +function TCefV8InterceptorOwn.SetByIndex(index: integer; const object_, value: ICefv8Value; var exception: ustring): boolean; begin Result := False; end; @@ -221,34 +285,34 @@ begin FSetterByIndex := setterbyindex; end; -function TCefFastV8Interceptor.GetByName(const name: ustring; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; +function TCefFastV8Interceptor.GetByName(const name: ustring; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; begin if assigned(FGetterByName) then - Result := FGetterByName(name, obj, retval, exception) + Result := FGetterByName(name, object_, retval, exception) else Result := False; end; -function TCefFastV8Interceptor.GetByIndex(index: integer; const obj: ICefv8Value; out retval: ICefv8Value; const exception: ustring): boolean; +function TCefFastV8Interceptor.GetByIndex(index: integer; const object_: ICefv8Value; var retval: ICefv8Value; var exception: ustring): boolean; begin if assigned(FGetterByIndex) then - Result := FGetterByIndex(index, obj, retval, exception) + Result := FGetterByIndex(index, object_, retval, exception) else Result := False; end; -function TCefFastV8Interceptor.SetByName(const name: ustring; const obj, value: ICefv8Value; const exception: ustring): boolean; +function TCefFastV8Interceptor.SetByName(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): boolean; begin if assigned(FSetterByName) then - Result := FSetterByName(name, obj, value, exception) + Result := FSetterByName(name, object_, value, exception) else Result := False; end; -function TCefFastV8Interceptor.SetByIndex(index: integer; const obj, value: ICefv8Value; const exception: ustring): boolean; +function TCefFastV8Interceptor.SetByIndex(index: integer; const object_, value: ICefv8Value; var exception: ustring): boolean; begin if assigned(FSetterByIndex) then - Result := FSetterByIndex(index, obj, value, exception) + Result := FSetterByIndex(index, object_, value, exception) else Result := False; end; diff --git a/windows/src/ext/cef4delphi/source/uCEFv8StackFrame.pas b/windows/src/ext/cef4delphi/source/uCEFv8StackFrame.pas index cf16df5ae7bf3da12099abd37a14418398398672..d0096a38ea87ce934582fa085297dc3fa156c981 100644 --- a/windows/src/ext/cef4delphi/source/uCEFv8StackFrame.pas +++ b/windows/src/ext/cef4delphi/source/uCEFv8StackFrame.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFv8StackFrame; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFv8StackTrace.pas b/windows/src/ext/cef4delphi/source/uCEFv8StackTrace.pas index 521a249c46972d94a007388f75160b8df20025ec..6f45d7a5d3687cc5c3fd072b125178c010d72154 100644 --- a/windows/src/ext/cef4delphi/source/uCEFv8StackTrace.pas +++ b/windows/src/ext/cef4delphi/source/uCEFv8StackTrace.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFv8StackTrace; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} diff --git a/windows/src/ext/cef4delphi/source/uCEFv8Value.pas b/windows/src/ext/cef4delphi/source/uCEFv8Value.pas index d1beed88da88a363ef43f9044acfd90c4605f14a..63386c0458a5e5b1d82aaf5e08bc8d0d57deff29 100644 --- a/windows/src/ext/cef4delphi/source/uCEFv8Value.pas +++ b/windows/src/ext/cef4delphi/source/uCEFv8Value.pas @@ -2,7 +2,7 @@ // ***************************** CEF4Delphi ******************************* // ************************************************************************ // -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based // browser in Delphi applications. // // The original license of DCEF3 still applies to CEF4Delphi. @@ -10,7 +10,7 @@ // For more information about CEF4Delphi visit : // https://www.briskbard.com/index.php?lang=en&pageid=cef // -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. // // ************************************************************************ // ************ vvvv Original license and comments below vvvv ************* @@ -41,10 +41,8 @@ unit uCEFv8Value; {$MODE OBJFPC}{$H+} {$ENDIF} -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} +{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF} +{$MINENUMSIZE 4} {$I cef.inc} @@ -135,7 +133,7 @@ implementation uses uCEFMiscFunctions, uCEFLibFunctions, uCEFv8Accessor, uCEFv8Handler, uCEFv8Exception, - uCEFv8Interceptor, uCEFStringList, uCefv8ArrayBufferReleaseCallback; + uCEFv8Interceptor, uCEFStringList, uCEFv8ArrayBufferReleaseCallback; function TCefv8ValueRef.AdjustExternallyAllocatedMemory(changeInBytes: Integer): Integer; begin diff --git a/windows/src/ext/cef4delphi/source/uFMXChromium.pas b/windows/src/ext/cef4delphi/source/uFMXChromium.pas deleted file mode 100644 index 44bc224393f505a710487df111e335a6ba45b630..0000000000000000000000000000000000000000 --- a/windows/src/ext/cef4delphi/source/uFMXChromium.pas +++ /dev/null @@ -1,3629 +0,0 @@ -// ************************************************************************ -// ***************************** CEF4Delphi ******************************* -// ************************************************************************ -// -// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based -// browser in Delphi applications. -// -// The original license of DCEF3 still applies to CEF4Delphi. -// -// For more information about CEF4Delphi visit : -// https://www.briskbard.com/index.php?lang=en&pageid=cef -// -// Copyright © 2018 Salvador Diaz Fau. All rights reserved. -// -// ************************************************************************ -// ************ vvvv Original license and comments below vvvv ************* -// ************************************************************************ -(* - * Delphi Chromium Embedded 3 - * - * Usage allowed under the restrictions of the Lesser GNU General Public License - * or alternatively the restrictions of the Mozilla Public License 1.1 - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for - * the specific language governing rights and limitations under the License. - * - * Unit owner : Henri Gourvest - * Web site : http://www.progdigy.com - * Repository : http://code.google.com/p/delphichromiumembedded/ - * Group : http://groups.google.com/group/delphichromiumembedded - * - * Embarcadero Technologies, Inc is not permitted to use or redistribute - * this source code without explicit permission. - * - *) - -unit uFMXChromium; - -{$IFNDEF CPUX64} - {$ALIGN ON} - {$MINENUMSIZE 4} -{$ENDIF} - -{$I cef.inc} - -interface - -uses - System.Classes, System.Types, - {$IFDEF MSWINDOWS} - WinApi.Windows, WinApi.Messages, - {$ENDIF} - FMX.Types, FMX.Platform, FMX.Controls, FMX.Forms, - uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFMiscFunctions, uCEFClient, - uCEFConstants, uCEFTask, uCEFChromiumEvents, uCEFChromiumOptions, uCEFChromiumFontOptions, - uCEFPDFPrintOptions; - -type - TFMXChromium = class(TComponent, IChromiumEvents) - protected - FHandler : ICefClient; - FBrowser : ICefBrowser; - FBrowserId : Integer; - FDefaultUrl : ustring; - FOptions : TChromiumOptions; - FFontOptions : TChromiumFontOptions; - FPDFPrintOptions : TPDFPrintOptions; - FDefaultEncoding : ustring; - FProxyType : integer; - FProxyScheme : TCefProxyScheme; - FProxyServer : ustring; - FProxyPort : integer; - FProxyUsername : ustring; - FProxyPassword : ustring; - FProxyScriptURL : ustring; - FProxyByPassList : ustring; - FUpdatePreferences : boolean; - FCustomHeaderName : ustring; - FCustomHeaderValue : ustring; - FAddCustomHeader : boolean; - FDoNotTrack : boolean; - FSendReferrer : boolean; - FHyperlinkAuditing : boolean; - FRunAllFlashInAllowMode : boolean; - FAllowOutdatedPlugins : boolean; - FAlwaysAuthorizePlugins : boolean; - FCookiePrefs : integer; - FImagesPrefs : integer; - FZoomStep : byte; - FPrefsFileName : string; - FIsOSR : boolean; - FInitialized : boolean; - FClosing : boolean; - FWindowInfo : TCefWindowInfo; - FBrowserSettings : TCefBrowserSettings; - FDevWindowInfo : TCefWindowInfo; - FDevBrowserSettings : TCefBrowserSettings; - FDragOperations : TCefDragOperations; - FDragAndDropInitialized : boolean; - FWebRTCIPHandlingPolicy : TCefWebRTCHandlingPolicy; - FWebRTCMultipleRoutes : TCefState; - FWebRTCNonProxiedUDP : TCefState; - - {$IFDEF MSWINDOWS} - FOldBrowserCompWndPrc : TFNWndProc; - FOldWidgetCompWndPrc : TFNWndProc; - FOldRenderCompWndPrc : TFNWndProc; - FBrowserCompHWND : THandle; - FWidgetCompHWND : THandle; - FRenderCompHWND : THandle; - FBrowserCompStub : Pointer; - FWidgetCompStub : Pointer; - FRenderCompStub : Pointer; - {$ENDIF} - - // ICefClient - FOnProcessMessageReceived : TOnProcessMessageReceived; - - // ICefLoadHandler - FOnLoadStart : TOnLoadStart; - FOnLoadEnd : TOnLoadEnd; - FOnLoadError : TOnLoadError; - FOnLoadingStateChange : TOnLoadingStateChange; - - // ICefFocusHandler - FOnTakeFocus : TOnTakeFocus; - FOnSetFocus : TOnSetFocus; - FOnGotFocus : TOnGotFocus; - - // ICefContextMenuHandler - FOnBeforeContextMenu : TOnBeforeContextMenu; - FOnRunContextMenu : TOnRunContextMenu; - FOnContextMenuCommand : TOnContextMenuCommand; - FOnContextMenuDismissed : TOnContextMenuDismissed; - - // ICefKeyboardHandler - FOnPreKeyEvent : TOnPreKeyEvent; - FOnKeyEvent : TOnKeyEvent; - - // ICefDisplayHandler - FOnAddressChange : TOnAddressChange; - FOnTitleChange : TOnTitleChange; - FOnFavIconUrlChange : TOnFavIconUrlChange; - FOnFullScreenModeChange : TOnFullScreenModeChange; - FOnTooltip : TOnTooltip; - FOnStatusMessage : TOnStatusMessage; - FOnConsoleMessage : TOnConsoleMessage; - FOnAutoResize : TOnAutoResize; - FOnLoadingProgressChange : TOnLoadingProgressChange; - - // ICefDownloadHandler - FOnBeforeDownload : TOnBeforeDownload; - FOnDownloadUpdated : TOnDownloadUpdated; - - // ICefJsDialogHandler - FOnJsdialog : TOnJsdialog; - FOnBeforeUnloadDialog : TOnBeforeUnloadDialog; - FOnResetDialogState : TOnResetDialogState; - FOnDialogClosed : TOnDialogClosed; - - // ICefLifeSpanHandler - FOnBeforePopup : TOnBeforePopup; - FOnAfterCreated : TOnAfterCreated; - FOnBeforeClose : TOnBeforeClose; - FOnClose : TOnClose; - - // ICefRequestHandler - FOnBeforeBrowse : TOnBeforeBrowse; - FOnOpenUrlFromTab : TOnOpenUrlFromTab; - FOnBeforeResourceLoad : TOnBeforeResourceLoad; - FOnGetResourceHandler : TOnGetResourceHandler; - FOnResourceRedirect : TOnResourceRedirect; - FOnResourceResponse : TOnResourceResponse; - FOnGetResourceResponseFilter : TOnGetResourceResponseFilter; - FOnResourceLoadComplete : TOnResourceLoadComplete; - FOnGetAuthCredentials : TOnGetAuthCredentials; - FOnCanGetCookies : TOnCanGetCookies; - FOnCanSetCookie : TOnCanSetCookie; - FOnQuotaRequest : TOnQuotaRequest; - FOnProtocolExecution : TOnProtocolExecution; - FOnCertificateError : TOnCertificateError; - FOnSelectClientCertificate : TOnSelectClientCertificate; - FOnPluginCrashed : TOnPluginCrashed; - FOnRenderViewReady : TOnRenderViewReady; - FOnRenderProcessTerminated : TOnRenderProcessTerminated; - - // ICefDialogHandler - FOnFileDialog : TOnFileDialog; - - // ICefRenderHandler - FOnGetAccessibilityHandler : TOnGetAccessibilityHandler; - FOnGetRootScreenRect : TOnGetRootScreenRect; - FOnGetViewRect : TOnGetViewRect; - FOnGetScreenPoint : TOnGetScreenPoint; - FOnGetScreenInfo : TOnGetScreenInfo; - FOnPopupShow : TOnPopupShow; - FOnPopupSize : TOnPopupSize; - FOnPaint : TOnPaint; - FOnCursorChange : TOnCursorChange; - FOnScrollOffsetChanged : TOnScrollOffsetChanged; - FOnIMECompositionRangeChanged : TOnIMECompositionRangeChanged; - FOnTextSelectionChanged : TOnTextSelectionChanged; - - // ICefDragHandler - FOnDragEnter : TOnDragEnter; - FOnDraggableRegionsChanged : TOnDraggableRegionsChanged; - - // ICefFindHandler - FOnFindResult : TOnFindResult; - - // Custom - FOnTextResultAvailable : TOnTextResultAvailableEvent; - FOnPdfPrintFinished : TOnPdfPrintFinishedEvent; - FOnCookiesDeleted : TOnCookiesDeletedEvent; - FOnResolvedHostAvailable : TOnResolvedIPsAvailableEvent; - {$IFDEF MSWINDOWS} - FOnBrowserCompMsg : TOnCompMsgEvent; - FOnWidgetCompMsg : TOnCompMsgEvent; - FOnRenderCompMsg : TOnCompMsgEvent; - {$ENDIF} - - function GetIsLoading : boolean; - function GetMultithreadApp : boolean; - function GetHasDocument : boolean; - function GetHasView : boolean; - function GetHasDevTools : boolean; - function GetHasClientHandler : boolean; - function GetHasBrowser : boolean; - function GetCanGoBack : boolean; - function GetCanGoForward : boolean; - function GetDocumentURL : ustring; - function GetZoomLevel : double; - function GetZoomPct : double; - function GetIsPopUp : boolean; - function GetWindowHandle : THandle; - function GetWindowlessFrameRate : integer; - function GetFrameIsFocused : boolean; - function GetInitialized : boolean; - function GetVisibleNavigationEntry : ICefNavigationEntry; - function GetHasValidMainFrame : boolean; - function GetFrameCount : NativeUInt; - function GetRequestContextCache : ustring; - function GetRequestContextIsGlobal : boolean; - - procedure SetDoNotTrack(aValue : boolean); - procedure SetSendReferrer(aValue : boolean); - procedure SetHyperlinkAuditing(aValue : boolean); - procedure SetRunAllFlashInAllowMode(aValue : boolean); - procedure SetAllowOutdatedPlugins(aValue : boolean); - procedure SetAlwaysAuthorizePlugins(aValue : boolean); - procedure SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); - procedure SetWebRTCMultipleRoutes(aValue : TCefState); - procedure SetWebRTCNonProxiedUDP(aValue : TCefState); - procedure SetCookiePrefs(aValue : integer); - procedure SetImagesPrefs(aValue : integer); - procedure SetProxyType(aValue : integer); - procedure SetProxyScheme(aValue : TCefProxyScheme); - procedure SetProxyServer(const aValue : ustring); - procedure SetProxyPort(aValue : integer); - procedure SetProxyUsername(const aValue : ustring); - procedure SetProxyPassword(const aValue : ustring); - procedure SetProxyScriptURL(const aValue : ustring); - procedure SetProxyByPassList(const aValue : ustring); - procedure SetCustomHeaderName(const aValue : ustring); - procedure SetCustomHeaderValue(const aValue : ustring); - procedure SetZoomLevel(const aValue : double); - procedure SetZoomPct(const aValue : double); - procedure SetZoomStep(aValue : byte); - procedure SetWindowlessFrameRate(aValue : integer); - - - function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aContext : ICefRequestContext): boolean; - function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aContext : ICefRequestContext): boolean; - - procedure DestroyClientHandler; - - procedure ClearBrowserReference; - - procedure InitializeEvents; - procedure InitializeSettings(var aSettings : TCefBrowserSettings); - - procedure GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : ustring); - - function UpdateProxyPrefs(const aBrowser: ICefBrowser) : boolean; - function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : boolean) : boolean; overload; - function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : integer) : boolean; overload; - function UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; const aValue : double) : boolean; overload; - function UpdatePreference(const aBrowser: ICefBrowser; const aName, aValue : ustring) : boolean; overload; - - procedure HandleDictionary(const aDict : ICefDictionaryValue; var aResultSL : TStringList; const aRoot : string); - procedure HandleNull(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleBool(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleInteger(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleDouble(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleString(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleBinary(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - procedure HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); - - function MustCreateLoadHandler : boolean; virtual; - function MustCreateFocusHandler : boolean; virtual; - function MustCreateContextMenuHandler : boolean; virtual; - function MustCreateDialogHandler : boolean; virtual; - function MustCreateKeyboardHandler : boolean; virtual; - function MustCreateDisplayHandler : boolean; virtual; - function MustCreateDownloadHandler : boolean; virtual; - function MustCreateJsDialogHandler : boolean; virtual; - function MustCreateDragHandler : boolean; virtual; - function MustCreateFindHandler : boolean; virtual; - - procedure ApplyZoomStep; - function GetParentForm : TCustomForm; - - {$IFDEF MSWINDOWS} - procedure FreeAndNilStub(var aStub : pointer); - procedure CreateStub(const aMethod : TWndMethod; var aStub : Pointer); - procedure BrowserCompWndProc(var aMessage: TMessage); - procedure WidgetCompWndProc(var aMessage: TMessage); - procedure RenderCompWndProc(var aMessage: TMessage); - {$ENDIF} - - // IChromiumEvents - procedure GetSettings(var aSettings : TCefBrowserSettings); - - // ICefClient - function doOnProcessMessageReceived(const browser: ICefBrowser; sourceProcess: TCefProcessId; const aMessage: ICefProcessMessage): Boolean; virtual; - - // ICefLoadHandler - procedure doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); 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; - procedure doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); virtual; - - // ICefFocusHandler - procedure doOnTakeFocus(const browser: ICefBrowser; next: Boolean); virtual; - function doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; virtual; - procedure doOnGotFocus(const browser: ICefBrowser); virtual; - - // ICefContextMenuHandler - procedure doOnBeforeContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); virtual; - function doRunContextMenu(const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel; const callback: ICefRunContextMenuCallback): Boolean; 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; - - // ICefKeyboardHandler - 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; - - // ICefDisplayHandler - procedure doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); virtual; - procedure doOnTitleChange(const browser: ICefBrowser; const title: ustring); virtual; - procedure doOnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); virtual; - procedure doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); virtual; - function doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; virtual; - procedure doOnStatusMessage(const browser: ICefBrowser; const value: ustring); virtual; - function doOnConsoleMessage(const browser: ICefBrowser; level: TCefLogSeverity; const aMessage, source: ustring; line: Integer): Boolean; virtual; - function doOnAutoResize(const browser: ICefBrowser; const new_size: PCefSize): Boolean; virtual; - procedure doOnLoadingProgressChange(const browser: ICefBrowser; const progress: double); virtual; - - // ICefDownloadHandler - 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; - - // ICefJsDialogHandler - function doOnJsdialog(const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const 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; - procedure doOnDialogClosed(const browser: ICefBrowser); virtual; - - // ICefLifeSpanHandler - function doOnBeforePopup(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const 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 doOnClose(const browser: ICefBrowser): Boolean; virtual; - - // ICefRequestHandler - function doOnBeforeBrowse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; user_gesture, isRedirect: Boolean): Boolean; virtual; - function doOnOpenUrlFromTab(const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean): Boolean; virtual; - function doOnBeforeResourceLoad(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback): TCefReturnValue; virtual; - function doOnGetResourceHandler(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): ICefResourceHandler; virtual; - procedure doOnResourceRedirect(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; var newUrl: ustring); virtual; - function doOnResourceResponse(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): Boolean; virtual; - function doOnGetResourceResponseFilter(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse): ICefResponseFilter; virtual; - procedure doOnResourceLoadComplete(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const response: ICefResponse; status: TCefUrlRequestStatus; receivedContentLength: Int64); 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 doCanGetCookies(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest): boolean; virtual; - function doCanSetCookie(const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const cookie : PCefCookie): boolean; virtual; - function doOnQuotaRequest(const browser: ICefBrowser; const originUrl: ustring; newSize: Int64; const callback: ICefRequestCallback): Boolean; virtual; - procedure doOnProtocolExecution(const browser: ICefBrowser; const url: ustring; out allowOsExecution: Boolean); virtual; - function doOnCertificateError(const browser: ICefBrowser; certError: TCefErrorcode; const requestUrl: ustring; const sslInfo: ICefSslInfo; const callback: ICefRequestCallback): Boolean; virtual; - function doOnSelectClientCertificate(const browser: ICefBrowser; isProxy: boolean; const host: ustring; port: integer; certificatesCount: NativeUInt; const certificates: TCefX509CertificateArray; const callback: ICefSelectClientCertificateCallback): boolean; virtual; - procedure doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); virtual; - procedure doOnRenderViewReady(const browser: ICefBrowser); virtual; - procedure doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); virtual; - - // ICefDialogHandler - function doOnFileDialog(const browser: ICefBrowser; mode: TCefFileDialogMode; const title, defaultFilePath: ustring; const acceptFilters: TStrings; selectedAcceptFilter: Integer; const callback: ICefFileDialogCallback): Boolean; virtual; - - // ICefRenderHandler - procedure doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); virtual; - function doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; - function doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; virtual; - function doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; virtual; - function doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; virtual; - procedure doOnPopupShow(const browser: ICefBrowser; show: Boolean); virtual; - procedure doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); virtual; - procedure doOnPaint(const browser: ICefBrowser; kind: TCefPaintElementType; dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray; const buffer: Pointer; width, height: Integer); virtual; - procedure doOnCursorChange(const browser: ICefBrowser; cursor: TCefCursorHandle; cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo); virtual; - function doOnStartDragging(const browser: ICefBrowser; const dragData: ICefDragData; allowedOps: TCefDragOperations; x, y: Integer): Boolean; virtual; - procedure doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); virtual; - procedure doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); virtual; - procedure doOnIMECompositionRangeChanged(const browser: ICefBrowser; const selected_range: PCefRange; character_boundsCount: NativeUInt; const character_bounds: PCefRect); virtual; - procedure doOnTextSelectionChanged(const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange); virtual; - - // ICefDragHandler - function doOnDragEnter(const browser: ICefBrowser; const dragData: ICefDragData; mask: TCefDragOperations): Boolean; virtual; - procedure doOnDraggableRegionsChanged(const browser: ICefBrowser; regionsCount: NativeUInt; regions: PCefDraggableRegionArray); virtual; - - // ICefFindHandler - procedure doOnFindResult(const browser: ICefBrowser; identifier, count: Integer; const selectionRect: PCefRect; activeMatchOrdinal: Integer; finalUpdate: Boolean); virtual; - - // Custom - procedure doCookiesDeleted(numDeleted : integer); virtual; - procedure doPdfPrintFinished(aResultOK : boolean); virtual; - procedure doTextResultAvailable(const aText : ustring); virtual; - procedure doUpdatePreferences(const aBrowser: ICefBrowser); virtual; - procedure doUpdateOwnPreferences; virtual; - function doSavePreferences : boolean; virtual; - procedure doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); virtual; - - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure AfterConstruction; override; - procedure BeforeDestruction; override; - function CreateClientHandler(aIsOSR : boolean = True) : boolean; overload; - function CreateClientHandler(var aClient : ICefClient; aIsOSR : boolean = True) : boolean; overload; - procedure CloseBrowser(aForceClose : boolean); - function ShareRequestContext(var aContext : ICefRequestContext; const aHandler : ICefRequestContextHandler = nil) : boolean; - function CreateBrowser(const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aCookiesPath : ustring = ''; aPersistSessionCookies : boolean = False) : boolean; overload; virtual; - {$IFDEF MSWINDOWS} - function CreateBrowser(aParentHandle : HWND; aParentRect : TRect; const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aCookiesPath : ustring = ''; aPersistSessionCookies : boolean = False) : boolean; overload; virtual; - {$ENDIF} - - procedure LoadURL(const aURL : ustring; const aFrameName : ustring = ''); overload; - procedure LoadURL(const aURL : ustring; const aFrame : ICefFrame); overload; - procedure LoadURL(const aURL : ustring; const aFrameIdentifier : int64); overload; - procedure LoadString(const aString : ustring; const aURL : ustring = ''); - procedure LoadRequest(const aRequest: ICefRequest); - - procedure GoBack; - procedure GoForward; - procedure Reload; - procedure ReloadIgnoreCache; - procedure StopLoad; - procedure StartDownload(const aURL : ustring); - - procedure SimulateMouseWheel(aDeltaX, aDeltaY : integer); - function DeleteCookies(const url : ustring = ''; const cookieName : ustring = '') : boolean; - procedure RetrieveHTML(const aFrameName : ustring = ''); overload; - procedure RetrieveHTML(const aFrame : ICefFrame); overload; - procedure RetrieveHTML(const aFrameIdentifier : int64); overload; - procedure RetrieveText(const aFrameName : ustring = ''); overload; - procedure RetrieveText(const aFrame : ICefFrame); overload; - procedure RetrieveText(const aFrameIdentifier : int64); overload; - function GetFrameNames(var aFrameNames : TStrings) : boolean; - function GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean; - procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameName : ustring = ''; aStartLine : integer = 0); overload; - procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrame : ICefFrame; aStartLine : integer = 0); overload; - procedure ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameIdentifier : int64; aStartLine : integer = 0); overload; - procedure UpdatePreferences; - procedure SavePreferences(const aFileName : string); - procedure ResolveHost(const aURL : ustring); - function IsSameBrowser(const aBrowser : ICefBrowser) : boolean; - - procedure Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); - procedure StopFinding(aClearSelection : Boolean); - - procedure Print; - procedure PrintToPDF(const aFilePath, aTitle, aURL : ustring); - - procedure ClipboardCopy; - procedure ClipboardPaste; - procedure ClipboardCut; - procedure ClipboardUndo; - procedure ClipboardRedo; - procedure ClipboardDel; - procedure SelectAll; - - procedure IncZoomStep; - procedure DecZoomStep; - procedure ResetZoomStep; - - procedure MoveFormTo(const x, y: Integer); - procedure MoveFormBy(const x, y: Integer); - procedure ResizeFormWidthTo(const x : Integer); - procedure ResizeFormHeightTo(const y : Integer); - procedure SetFormLeftTo(const x : Integer); - procedure SetFormTopTo(const y : Integer); - - procedure WasResized; - procedure WasHidden(hidden: Boolean); - procedure NotifyScreenInfoChanged; - procedure NotifyMoveOrResizeStarted; - procedure Invalidate(kind: TCefPaintElementType = PET_VIEW); - procedure SendKeyEvent(const event: PCefKeyEvent); - procedure SendMouseClickEvent(const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer); - procedure SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); - procedure SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); - procedure SendFocusEvent(setFocus: Boolean); - procedure SendCaptureLostEvent; - function SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; - procedure SetFocus(focus: Boolean); - procedure SetAccessibilityState(accessibilityState: TCefState); - - procedure DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); - procedure DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); - procedure DragTargetDragLeave; - procedure DragTargetDrop(event: PCefMouseEvent); - procedure DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); - procedure DragSourceSystemDragEnded; - - - property DefaultUrl : ustring read FDefaultUrl write FDefaultUrl; - property Options : TChromiumOptions read FOptions write FOptions; - property FontOptions : TChromiumFontOptions read FFontOptions write FFontOptions; - property PDFPrintOptions : TPDFPrintOptions read FPDFPrintOptions write FPDFPrintOptions; - property DefaultEncoding : ustring read FDefaultEncoding write FDefaultEncoding; - property BrowserId : integer read FBrowserId; - property Browser : ICefBrowser read FBrowser; - property CefClient : ICefClient read FHandler; - property CefWindowInfo : TCefWindowInfo read FWindowInfo; - property VisibleNavigationEntry : ICefNavigationEntry read GetVisibleNavigationEntry; - property MultithreadApp : boolean read GetMultithreadApp; - property IsLoading : boolean read GetIsLoading; - property HasDocument : boolean read GetHasDocument; - property HasView : boolean read GetHasView; - property HasDevTools : boolean read GetHasDevTools; - property HasClientHandler : boolean read GetHasClientHandler; - property HasBrowser : boolean read GetHasBrowser; - property CanGoBack : boolean read GetCanGoBack; - property CanGoForward : boolean read GetCanGoForward; - property IsPopUp : boolean read GetIsPopUp; - property WindowHandle : THandle read GetWindowHandle; - property BrowserHandle : THandle read FBrowserCompHWND; - property WidgetHandle : THandle read FWidgetCompHWND; - property RenderHandle : THandle read FRenderCompHWND; - property FrameIsFocused : boolean read GetFrameIsFocused; - property Initialized : boolean read GetInitialized; - property RequestContextCache : ustring read GetRequestContextCache; - property RequestContextIsGlobal : boolean read GetRequestContextIsGlobal; - property CookiePrefs : integer read FCookiePrefs write SetCookiePrefs; - property ImagesPrefs : integer read FImagesPrefs write SetImagesPrefs; - property DocumentURL : ustring read GetDocumentURL; - property ZoomLevel : double read GetZoomLevel write SetZoomLevel; - property ZoomPct : double read GetZoomPct write SetZoomPct; - property ZoomStep : byte read FZoomStep write SetZoomStep; - property WindowlessFrameRate : integer read GetWindowlessFrameRate write SetWindowlessFrameRate; - property CustomHeaderName : ustring read FCustomHeaderName write SetCustomHeaderName; - property CustomHeaderValue : ustring read FCustomHeaderValue write SetCustomHeaderValue; - property DoNotTrack : boolean read FDoNotTrack write SetDoNotTrack; - property SendReferrer : boolean read FSendReferrer write SetSendReferrer; - property HyperlinkAuditing : boolean read FHyperlinkAuditing write SetHyperlinkAuditing; - property RunAllFlashInAllowMode : boolean read FRunAllFlashInAllowMode write SetRunAllFlashInAllowMode; - property AllowOutdatedPlugins : boolean read FAllowOutdatedPlugins write SetAllowOutdatedPlugins; - property AlwaysAuthorizePlugins : boolean read FAlwaysAuthorizePlugins write SetAlwaysAuthorizePlugins; - property HasValidMainFrame : boolean read GetHasValidMainFrame; - property FrameCount : NativeUInt read GetFrameCount; - property DragOperations : TCefDragOperations read FDragOperations write FDragOperations; - - property WebRTCIPHandlingPolicy : TCefWebRTCHandlingPolicy read FWebRTCIPHandlingPolicy write SetWebRTCIPHandlingPolicy; - property WebRTCMultipleRoutes : TCefState read FWebRTCMultipleRoutes write SetWebRTCMultipleRoutes; - property WebRTCNonproxiedUDP : TCefState read FWebRTCNonProxiedUDP write SetWebRTCNonProxiedUDP; - - property ProxyType : integer read FProxyType write SetProxyType; - property ProxyScheme : TCefProxyScheme read FProxyScheme write SetProxyScheme; - property ProxyServer : ustring read FProxyServer write SetProxyServer; - property ProxyPort : integer read FProxyPort write SetProxyPort; - property ProxyUsername : ustring read FProxyUsername write SetProxyUsername; - property ProxyPassword : ustring read FProxyPassword write SetProxyPassword; - property ProxyScriptURL : ustring read FProxyScriptURL write SetProxyScriptURL; - property ProxyByPassList : ustring read FProxyByPassList write SetProxyByPassList; - - published - property OnTextResultAvailable : TOnTextResultAvailableEvent read FOnTextResultAvailable write FOnTextResultAvailable; - property OnPdfPrintFinished : TOnPdfPrintFinishedEvent read FOnPdfPrintFinished write FOnPdfPrintFinished; - property OnCookiesDeleted : TOnCookiesDeletedEvent read FOnCookiesDeleted write FOnCookiesDeleted; - property OnResolvedHostAvailable : TOnResolvedIPsAvailableEvent read FOnResolvedHostAvailable write FOnResolvedHostAvailable; - {$IFDEF MSWINDOWS} - property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg; - property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg; - property OnRenderCompMsg : TOnCompMsgEvent read FOnRenderCompMsg write FOnRenderCompMsg; - {$ENDIF} - - // ICefClient - property OnProcessMessageReceived : TOnProcessMessageReceived read FOnProcessMessageReceived write FOnProcessMessageReceived; - - // ICefLoadHandler - property OnLoadStart : TOnLoadStart read FOnLoadStart write FOnLoadStart; - property OnLoadEnd : TOnLoadEnd read FOnLoadEnd write FOnLoadEnd; - property OnLoadError : TOnLoadError read FOnLoadError write FOnLoadError; - property OnLoadingStateChange : TOnLoadingStateChange read FOnLoadingStateChange write FOnLoadingStateChange; - - // ICefFocusHandler - property OnTakeFocus : TOnTakeFocus read FOnTakeFocus write FOnTakeFocus; - property OnSetFocus : TOnSetFocus read FOnSetFocus write FOnSetFocus; - property OnGotFocus : TOnGotFocus read FOnGotFocus write FOnGotFocus; - - // ICefContextMenuHandler - property OnBeforeContextMenu : TOnBeforeContextMenu read FOnBeforeContextMenu write FOnBeforeContextMenu; - property OnRunContextMenu : TOnRunContextMenu read FOnRunContextMenu write FOnRunContextMenu; - property OnContextMenuCommand : TOnContextMenuCommand read FOnContextMenuCommand write FOnContextMenuCommand; - property OnContextMenuDismissed : TOnContextMenuDismissed read FOnContextMenuDismissed write FOnContextMenuDismissed; - - // ICefKeyboardHandler - property OnPreKeyEvent : TOnPreKeyEvent read FOnPreKeyEvent write FOnPreKeyEvent; - property OnKeyEvent : TOnKeyEvent read FOnKeyEvent write FOnKeyEvent; - - // ICefDisplayHandler - property OnAddressChange : TOnAddressChange read FOnAddressChange write FOnAddressChange; - property OnTitleChange : TOnTitleChange read FOnTitleChange write FOnTitleChange; - property OnFavIconUrlChange : TOnFavIconUrlChange read FOnFavIconUrlChange write FOnFavIconUrlChange; - property OnFullScreenModeChange : TOnFullScreenModeChange read FOnFullScreenModeChange write FOnFullScreenModeChange; - property OnTooltip : TOnTooltip read FOnTooltip write FOnTooltip; - property OnStatusMessage : TOnStatusMessage read FOnStatusMessage write FOnStatusMessage; - property OnConsoleMessage : TOnConsoleMessage read FOnConsoleMessage write FOnConsoleMessage; - property OnAutoResize : TOnAutoResize read FOnAutoResize write FOnAutoResize; - property OnLoadingProgressChange : TOnLoadingProgressChange read FOnLoadingProgressChange write FOnLoadingProgressChange; - - // ICefDownloadHandler - property OnBeforeDownload : TOnBeforeDownload read FOnBeforeDownload write FOnBeforeDownload; - property OnDownloadUpdated : TOnDownloadUpdated read FOnDownloadUpdated write FOnDownloadUpdated; - - // ICefJsDialogHandler - property OnJsdialog : TOnJsdialog read FOnJsdialog write FOnJsdialog; - property OnBeforeUnloadDialog : TOnBeforeUnloadDialog read FOnBeforeUnloadDialog write FOnBeforeUnloadDialog; - property OnResetDialogState : TOnResetDialogState read FOnResetDialogState write FOnResetDialogState; - property OnDialogClosed : TOnDialogClosed read FOnDialogClosed write FOnDialogClosed; - - // ICefLifeSpanHandler - property OnBeforePopup : TOnBeforePopup read FOnBeforePopup write FOnBeforePopup; - property OnAfterCreated : TOnAfterCreated read FOnAfterCreated write FOnAfterCreated; - property OnBeforeClose : TOnBeforeClose read FOnBeforeClose write FOnBeforeClose; - property OnClose : TOnClose read FOnClose write FOnClose; - - // ICefRequestHandler - property OnBeforeBrowse : TOnBeforeBrowse read FOnBeforeBrowse write FOnBeforeBrowse; - property OnOpenUrlFromTab : TOnOpenUrlFromTab read FOnOpenUrlFromTab write FOnOpenUrlFromTab; - property OnBeforeResourceLoad : TOnBeforeResourceLoad read FOnBeforeResourceLoad write FOnBeforeResourceLoad; - property OnGetResourceHandler : TOnGetResourceHandler read FOnGetResourceHandler write FOnGetResourceHandler; - property OnResourceRedirect : TOnResourceRedirect read FOnResourceRedirect write FOnResourceRedirect; - property OnResourceResponse : TOnResourceResponse read FOnResourceResponse write FOnResourceResponse; - property OnGetResourceResponseFilter : TOnGetResourceResponseFilter read FOnGetResourceResponseFilter write FOnGetResourceResponseFilter; - property OnResourceLoadComplete : TOnResourceLoadComplete read FOnResourceLoadComplete write FOnResourceLoadComplete; - property OnGetAuthCredentials : TOnGetAuthCredentials read FOnGetAuthCredentials write FOnGetAuthCredentials; - property OnCanGetCookies : TOnCanGetCookies read FOnCanGetCookies write FOnCanGetCookies; - property OnCanSetCookie : TOnCanSetCookie read FOnCanSetCookie write FOnCanSetCookie; - property OnQuotaRequest : TOnQuotaRequest read FOnQuotaRequest write FOnQuotaRequest; - property OnProtocolExecution : TOnProtocolExecution read FOnProtocolExecution write FOnProtocolExecution; - property OnCertificateError : TOnCertificateError read FOnCertificateError write FOnCertificateError; - property OnSelectClientCertificate : TOnSelectClientCertificate read FOnSelectClientCertificate write FOnSelectClientCertificate; - property OnPluginCrashed : TOnPluginCrashed read FOnPluginCrashed write FOnPluginCrashed; - property OnRenderViewReady : TOnRenderViewReady read FOnRenderViewReady write FOnRenderViewReady; - property OnRenderProcessTerminated : TOnRenderProcessTerminated read FOnRenderProcessTerminated write FOnRenderProcessTerminated; - - // ICefDialogHandler - property OnFileDialog : TOnFileDialog read FOnFileDialog write FOnFileDialog; - - // ICefRenderHandler - property OnGetAccessibilityHandler : TOnGetAccessibilityHandler read FOnGetAccessibilityHandler write FOnGetAccessibilityHandler; - 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; - property OnIMECompositionRangeChanged : TOnIMECompositionRangeChanged read FOnIMECompositionRangeChanged write FOnIMECompositionRangeChanged; - property OnTextSelectionChanged : TOnTextSelectionChanged read FOnTextSelectionChanged write FOnTextSelectionChanged; - - // ICefDragHandler - property OnDragEnter : TOnDragEnter read FOnDragEnter write FOnDragEnter; - property OnDraggableRegionsChanged : TOnDraggableRegionsChanged read FOnDraggableRegionsChanged write FOnDraggableRegionsChanged; - - // ICefFindHandler - property OnFindResult : TOnFindResult read FOnFindResult write FOnFindResult; - - end; - -implementation - -uses - System.SysUtils, System.Math, - uCEFBrowser, uCEFValue, uCEFDictionaryValue, uCEFStringMultimap, uCEFFrame, - uCEFApplication, uCEFProcessMessage, uCEFRequestContext, - uCEFPDFPrintCallback, uCEFResolveCallback, uCEFDeleteCookiesCallback, uCEFStringVisitor; - -constructor TFMXChromium.Create(AOwner: TComponent); -begin - FBrowser := nil; - FBrowserId := 0; - FClosing := False; - FIsOSR := False; - FInitialized := False; - FDefaultUrl := 'about:blank'; - FHandler := nil; - FOptions := nil; - FFontOptions := nil; - FDefaultEncoding := ''; - FPDFPrintOptions := nil; - FUpdatePreferences := False; - FCustomHeaderName := ''; - FCustomHeaderValue := ''; - FPrefsFileName := ''; - FAddCustomHeader := False; - FDoNotTrack := True; - FSendReferrer := True; - FHyperlinkAuditing := False; - FRunAllFlashInAllowMode := False; - FAllowOutdatedPlugins := False; - FAlwaysAuthorizePlugins := False; - FCookiePrefs := CEF_CONTENT_SETTING_ALLOW; - FImagesPrefs := CEF_CONTENT_SETTING_ALLOW; - FZoomStep := ZOOM_STEP_DEF; - - {$IFDEF MSWINDOWS} - FOldBrowserCompWndPrc := nil; - FOldWidgetCompWndPrc := nil; - FOldRenderCompWndPrc := nil; - FBrowserCompHWND := 0; - FWidgetCompHWND := 0; - FRenderCompHWND := 0; - FBrowserCompStub := nil; - FWidgetCompStub := nil; - FRenderCompStub := nil; - {$ENDIF} - - FDragOperations := DRAG_OPERATION_NONE; - FDragAndDropInitialized := False; - - FWebRTCIPHandlingPolicy := hpDefault; - FWebRTCMultipleRoutes := STATE_DEFAULT; - FWebRTCNonProxiedUDP := STATE_DEFAULT; - - FProxyType := CEF_PROXYTYPE_DIRECT; - FProxyScheme := psHTTP; - FProxyServer := ''; - FProxyPort := 80; - FProxyUsername := ''; - FProxyPassword := ''; - FProxyScriptURL := ''; - FProxyByPassList := ''; - - FillChar(FWindowInfo, SizeOf(TCefWindowInfo), 0); - FillChar(FDevWindowInfo, SizeOf(TCefWindowInfo), 0); - - InitializeSettings(FBrowserSettings); - InitializeSettings(FDevBrowserSettings); - - InitializeEvents; - - inherited Create(AOwner); -end; - -destructor TFMXChromium.Destroy; -begin - try - try - ClearBrowserReference; - - if (FFontOptions <> nil) then FreeAndNil(FFontOptions); - if (FOptions <> nil) then FreeAndNil(FOptions); - if (FPDFPrintOptions <> nil) then FreeAndNil(FPDFPrintOptions); - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.Destroy', e) then raise; - end; - finally - inherited Destroy; - end; -end; - -procedure TFMXChromium.BeforeDestruction; -begin - {$IFDEF MSWINDOWS} - if (FBrowserCompHWND <> 0) and (FOldBrowserCompWndPrc <> nil) then - begin - SetWindowLongPtr(FBrowserCompHWND, GWL_WNDPROC, NativeInt(FOldBrowserCompWndPrc)); - FreeAndNilStub(FBrowserCompStub); - FOldBrowserCompWndPrc := nil; - end; - - if (FWidgetCompHWND <> 0) and (FOldWidgetCompWndPrc <> nil) then - begin - SetWindowLongPtr(FWidgetCompHWND, GWL_WNDPROC, NativeInt(FOldWidgetCompWndPrc)); - FreeAndNilStub(FWidgetCompStub); - FOldWidgetCompWndPrc := nil; - end; - - if (FRenderCompHWND <> 0) and (FOldRenderCompWndPrc <> nil) then - begin - SetWindowLongPtr(FRenderCompHWND, GWL_WNDPROC, NativeInt(FOldRenderCompWndPrc)); - FreeAndNilStub(FRenderCompStub); - FOldRenderCompWndPrc := nil; - end; - {$ENDIF} - - DestroyClientHandler; - - inherited BeforeDestruction; -end; - -procedure TFMXChromium.ClearBrowserReference; -begin - FBrowser := nil; - FBrowserId := 0; -end; - -procedure TFMXChromium.DestroyClientHandler; -begin - try - if (FHandler <> nil) then - begin - FHandler.RemoveReferences; - FHandler := nil; - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.DestroyClientHandler', e) then raise; - end; -end; - -procedure TFMXChromium.AfterConstruction; -begin - inherited AfterConstruction; - - try - if not(csDesigning in ComponentState) then - begin - FOptions := TChromiumOptions.Create; - FFontOptions := TChromiumFontOptions.Create; - FPDFPrintOptions := TPDFPrintOptions.Create; - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.AfterConstruction', e) then raise; - end; -end; - -function TFMXChromium.CreateClientHandler(aIsOSR : boolean) : boolean; -begin - Result := False; - - try - if (FHandler = nil) then - begin - FIsOSR := aIsOsr; - FHandler := TCustomClientHandler.Create(Self, - MustCreateLoadHandler, - MustCreateFocusHandler, - MustCreateContextMenuHandler, - MustCreateDialogHandler, - MustCreateKeyboardHandler, - MustCreateDisplayHandler, - MustCreateDownloadHandler, - MustCreateJsDialogHandler, - True, - FIsOSR, - True, - MustCreateDragHandler, - MustCreateFindHandler); - - Result := True; - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.CreateClientHandler', e) then raise; - end; -end; - -function TFMXChromium.CreateClientHandler(var aClient : ICefClient; aIsOSR : boolean) : boolean; -begin - if CreateClientHandler(aIsOSR) then - begin - aClient := FHandler; - Result := True; - end - else - Result := False; -end; - -procedure TFMXChromium.InitializeEvents; -begin - // ICefClient - FOnProcessMessageReceived := nil; - - // ICefLoadHandler - FOnLoadStart := nil; - FOnLoadEnd := nil; - FOnLoadError := nil; - FOnLoadingStateChange := nil; - - // ICefFocusHandler - FOnTakeFocus := nil; - FOnSetFocus := nil; - FOnGotFocus := nil; - - // ICefContextMenuHandler - FOnBeforeContextMenu := nil; - FOnRunContextMenu := nil; - FOnContextMenuCommand := nil; - FOnContextMenuDismissed := nil; - - // ICefKeyboardHandler - FOnPreKeyEvent := nil; - FOnKeyEvent := nil; - - // ICefDisplayHandler - FOnAddressChange := nil; - FOnTitleChange := nil; - FOnFavIconUrlChange := nil; - FOnFullScreenModeChange := nil; - FOnTooltip := nil; - FOnStatusMessage := nil; - FOnConsoleMessage := nil; - FOnAutoResize := nil; - FOnLoadingProgressChange := nil; - - // ICefDownloadHandler - FOnBeforeDownload := nil; - FOnDownloadUpdated := nil; - - // ICefJsDialogHandler - FOnJsdialog := nil; - FOnBeforeUnloadDialog := nil; - FOnResetDialogState := nil; - FOnDialogClosed := nil; - - // ICefLifeSpanHandler - FOnBeforePopup := nil; - FOnAfterCreated := nil; - FOnBeforeClose := nil; - FOnClose := nil; - - // ICefRequestHandler - FOnBeforeBrowse := nil; - FOnOpenUrlFromTab := nil; - FOnBeforeResourceLoad := nil; - FOnGetResourceHandler := nil; - FOnResourceRedirect := nil; - FOnResourceResponse := nil; - FOnGetResourceResponseFilter := nil; - FOnResourceLoadComplete := nil; - FOnGetAuthCredentials := nil; - FOnCanGetCookies := nil; - FOnCanSetCookie := nil; - FOnQuotaRequest := nil; - FOnProtocolExecution := nil; - FOnCertificateError := nil; - FOnSelectClientCertificate := nil; - FOnPluginCrashed := nil; - FOnRenderViewReady := nil; - FOnRenderProcessTerminated := nil; - - // ICefDialogHandler - FOnFileDialog := nil; - - // ICefRenderHandler - FOnGetAccessibilityHandler := nil; - FOnGetRootScreenRect := nil; - FOnGetViewRect := nil; - FOnGetScreenPoint := nil; - FOnGetScreenInfo := nil; - FOnPopupShow := nil; - FOnPopupSize := nil; - FOnPaint := nil; - FOnCursorChange := nil; - FOnScrollOffsetChanged := nil; - FOnIMECompositionRangeChanged := nil; - FOnTextSelectionChanged := nil; - - // ICefDragHandler - FOnDragEnter := nil; - FOnDraggableRegionsChanged := nil; - - // ICefFindHandler - FOnFindResult := nil; - - // Custom - FOnTextResultAvailable := nil; - FOnPdfPrintFinished := nil; - FOnCookiesDeleted := nil; - FOnResolvedHostAvailable := nil; -end; - -function TFMXChromium.CreateBrowser(const aWindowName : ustring; - const aContext : ICefRequestContext; - const aCookiesPath : ustring; - aPersistSessionCookies : boolean) : boolean; -var - TempCookieManager : ICefCookieManager; -begin - Result := False; - - try - // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser - // even if you use a custom request context. - // If you create a browser in the initialization of your app, make sure you call this - // function when GlobalCEFApp.GlobalContextInitialized is TRUE. - // Use the GlobalCEFApp.OnContextInitialized event to know when - // GlobalCEFApp.GlobalContextInitialized is set to TRUE. - - if not(csDesigning in ComponentState) and - not(FClosing) and - (FBrowser = nil) and - (FBrowserId = 0) and - (GlobalCEFApp <> nil) and - GlobalCEFApp.GlobalContextInitialized and - CreateClientHandler then - begin - GetSettings(FBrowserSettings); - WindowInfoAsWindowless(FWindowInfo, 0, aWindowName); - - if (aContext <> nil) and (length(aCookiesPath) > 0) then - begin - TempCookieManager := aContext.GetDefaultCookieManager(nil); - - if (TempCookieManager = nil) or - not(TempCookieManager.SetStoragePath(aCookiesPath, aPersistSessionCookies, nil)) then - OutputDebugMessage('TFMXChromium.CreateBrowser error : cookies cannot be accessed'); - end; - - - if GlobalCEFApp.MultiThreadedMessageLoop then - Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aContext) - else - Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aContext); - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.CreateBrowser', e) then raise; - end; -end; - -{$IFDEF MSWINDOWS} -function TFMXChromium.CreateBrowser( aParentHandle : HWND; - aParentRect : TRect; - const aWindowName : ustring; - const aContext : ICefRequestContext; - const aCookiesPath : ustring; - aPersistSessionCookies : boolean) : boolean; -var - TempCookieManager : ICefCookieManager; -begin - Result := False; - - try - // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser - // even if you use a custom request context. - // If you create a browser in the initialization of your app, make sure you call this - // function when GlobalCEFApp.GlobalContextInitialized is TRUE. - // Use the GlobalCEFApp.OnContextInitialized event to know when - // GlobalCEFApp.GlobalContextInitialized is set to TRUE. - - if not(csDesigning in ComponentState) and - not(FClosing) and - (FBrowser = nil) and - (FBrowserId = 0) and - (GlobalCEFApp <> nil) and - GlobalCEFApp.GlobalContextInitialized and - CreateClientHandler(aParentHandle = 0) then - begin - GetSettings(FBrowserSettings); - - if FIsOSR then - WindowInfoAsWindowless(FWindowInfo, 0, aWindowName) - else - WindowInfoAsChild(FWindowInfo, aParentHandle, aParentRect, aWindowName); - - - if (aContext <> nil) and (length(aCookiesPath) > 0) then - begin - TempCookieManager := aContext.GetDefaultCookieManager(nil); - - if (TempCookieManager = nil) or - not(TempCookieManager.SetStoragePath(aCookiesPath, aPersistSessionCookies, nil)) then - OutputDebugMessage('TChromium.CreateBrowser error : cookies cannot be accessed'); - end; - - - if GlobalCEFApp.MultiThreadedMessageLoop then - Result := CreateBrowserHost(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aContext) - else - Result := CreateBrowserHostSync(@FWindowInfo, FDefaultUrl, @FBrowserSettings, aContext); - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.CreateBrowser', e) then raise; - end; -end; -{$ENDIF} - -function TFMXChromium.ShareRequestContext(var aContext : ICefRequestContext; - const aHandler : ICefRequestContextHandler) : boolean; -begin - Result := False; - aContext := nil; - - if Initialized then - begin - aContext := TCefRequestContextRef.Shared(FBrowser.Host.RequestContext, aHandler); - Result := (aContext <> nil); - end; -end; - -procedure TFMXChromium.CloseBrowser(aForceClose : boolean); -begin - if Initialized then FBrowser.Host.CloseBrowser(aForceClose); -end; - -function TFMXChromium.CreateBrowserHost(aWindowInfo : PCefWindowInfo; - const aURL : ustring; - const aSettings : PCefBrowserSettings; - const aContext : ICefRequestContext): Boolean; -var - TempURL : TCefString; -begin - TempURL := CefString(aURL); - Result := cef_browser_host_create_browser(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aContext)) <> 0; -end; - -function TFMXChromium.CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; - const aURL : ustring; - const aSettings : PCefBrowserSettings; - const aContext : ICefRequestContext): boolean; -var - TempURL : TCefString; -begin - TempURL := CefString(aURL); - FBrowser := TCefBrowserRef.UnWrap(cef_browser_host_create_browser_sync(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, CefGetData(aContext))); - - if (FBrowser <> nil) then - begin - FBrowserId := FBrowser.Identifier; - FInitialized := (FBrowserId <> 0); - Result := FInitialized; - end - else - Result := False; -end; - -procedure TFMXChromium.Find(aIdentifier : integer; const aSearchText : ustring; aForward, aMatchCase, aFindNext : Boolean); -begin - if Initialized then FBrowser.Host.Find(aIdentifier, aSearchText, aForward, aMatchCase, aFindNext); -end; - -procedure TFMXChromium.StopFinding(aClearSelection : Boolean); -begin - if Initialized then FBrowser.Host.StopFinding(aClearSelection); -end; - -procedure TFMXChromium.Print; -begin - if Initialized then FBrowser.Host.Print; -end; - -procedure TFMXChromium.PrintToPDF(const aFilePath, aTitle, aURL : ustring); -var - TempSettings : TCefPdfPrintSettings; - TempCallback : ICefPdfPrintCallback; -begin - if Initialized then - begin - GetPrintPDFSettings(TempSettings, aTitle, aURL); - TempCallback := TCefCustomPDFPrintCallBack.Create(self); - FBrowser.Host.PrintToPdf(aFilePath, @TempSettings, TempCallback); - end; -end; - -procedure TFMXChromium.ClipboardCopy; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Copy; - end; -end; - -procedure TFMXChromium.ClipboardPaste; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Paste; - end; -end; - -procedure TFMXChromium.ClipboardCut; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Cut; - end; -end; - -procedure TFMXChromium.ClipboardUndo; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Undo; - end; -end; - -procedure TFMXChromium.ClipboardRedo; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Redo; - end; -end; - -procedure TFMXChromium.ClipboardDel; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.Del; - end; -end; - -procedure TFMXChromium.SelectAll; -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.FocusedFrame; - if (TempFrame = nil) then TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.SelectAll; - end; -end; - -procedure TFMXChromium.GetPrintPDFSettings(var aSettings : TCefPdfPrintSettings; const aTitle, aURL : ustring); -begin - if (FPDFPrintOptions <> nil) then - begin - aSettings.header_footer_title := CefString(aTitle); - aSettings.header_footer_url := CefString(aURL); - aSettings.page_width := FPDFPrintOptions.page_width; - aSettings.page_height := FPDFPrintOptions.page_height; - aSettings.scale_factor := FPDFPrintOptions.scale_factor; - aSettings.margin_top := FPDFPrintOptions.margin_top; - aSettings.margin_right := FPDFPrintOptions.margin_right; - aSettings.margin_bottom := FPDFPrintOptions.margin_bottom; - aSettings.margin_left := FPDFPrintOptions.margin_left; - aSettings.margin_type := FPDFPrintOptions.margin_type; - aSettings.header_footer_enabled := FPDFPrintOptions.header_footer_enabled; - aSettings.selection_only := FPDFPrintOptions.selection_only; - aSettings.landscape := FPDFPrintOptions.landscape; - aSettings.backgrounds_enabled := FPDFPrintOptions.backgrounds_enabled; - end; -end; - -procedure TFMXChromium.GetSettings(var aSettings : TCefBrowserSettings); -begin - if (FFontOptions <> nil) and (FOptions <> nil) then - begin - aSettings.size := SizeOf(TCefBrowserSettings); - aSettings.windowless_frame_rate := FOptions.WindowlessFrameRate; - aSettings.standard_font_family := CefString(FFontOptions.StandardFontFamily); - aSettings.fixed_font_family := CefString(FFontOptions.FixedFontFamily); - aSettings.serif_font_family := CefString(FFontOptions.SerifFontFamily); - aSettings.sans_serif_font_family := CefString(FFontOptions.SansSerifFontFamily); - aSettings.cursive_font_family := CefString(FFontOptions.CursiveFontFamily); - aSettings.fantasy_font_family := CefString(FFontOptions.FantasyFontFamily); - aSettings.default_font_size := FFontOptions.DefaultFontSize; - aSettings.default_fixed_font_size := FFontOptions.DefaultFixedFontSize; - aSettings.minimum_font_size := FFontOptions.MinimumFontSize; - aSettings.minimum_logical_font_size := FFontOptions.MinimumLogicalFontSize; - aSettings.remote_fonts := FFontOptions.RemoteFonts; - aSettings.default_encoding := CefString(DefaultEncoding); - aSettings.javascript := FOptions.Javascript; - aSettings.javascript_close_windows := FOptions.JavascriptCloseWindows; - aSettings.javascript_access_clipboard := FOptions.JavascriptAccessClipboard; - aSettings.javascript_dom_paste := FOptions.JavascriptDomPaste; - aSettings.plugins := FOptions.Plugins; - aSettings.universal_access_from_file_urls := FOptions.UniversalAccessFromFileUrls; - aSettings.file_access_from_file_urls := FOptions.FileAccessFromFileUrls; - aSettings.web_security := FOptions.WebSecurity; - aSettings.image_loading := FOptions.ImageLoading; - aSettings.image_shrink_standalone_to_fit := FOptions.ImageShrinkStandaloneToFit; - aSettings.text_area_resize := FOptions.TextAreaResize; - aSettings.tab_to_links := FOptions.TabToLinks; - aSettings.local_storage := FOptions.LocalStorage; - aSettings.databases := FOptions.Databases; - aSettings.application_cache := FOptions.ApplicationCache; - aSettings.webgl := FOptions.Webgl; - aSettings.background_color := FOptions.BackgroundColor; - aSettings.accept_language_list := CefString(FOptions.AcceptLanguageList); - end; -end; - -procedure TFMXChromium.InitializeSettings(var aSettings : TCefBrowserSettings); -begin - aSettings.size := SizeOf(TCefBrowserSettings); - aSettings.windowless_frame_rate := 30; - aSettings.standard_font_family := CefString(''); - aSettings.fixed_font_family := CefString(''); - aSettings.serif_font_family := CefString(''); - aSettings.sans_serif_font_family := CefString(''); - aSettings.cursive_font_family := CefString(''); - aSettings.fantasy_font_family := CefString(''); - aSettings.default_font_size := 0; - aSettings.default_fixed_font_size := 0; - aSettings.minimum_font_size := 0; - aSettings.minimum_logical_font_size := 0; - aSettings.remote_fonts := STATE_DEFAULT; - aSettings.default_encoding := CefString(''); - aSettings.javascript := STATE_DEFAULT; - aSettings.javascript_close_windows := STATE_DEFAULT; - aSettings.javascript_access_clipboard := STATE_DEFAULT; - aSettings.javascript_dom_paste := STATE_DEFAULT; - aSettings.plugins := STATE_DEFAULT; - aSettings.universal_access_from_file_urls := STATE_DEFAULT; - aSettings.file_access_from_file_urls := STATE_DEFAULT; - aSettings.web_security := STATE_DEFAULT; - aSettings.image_loading := STATE_DEFAULT; - aSettings.image_shrink_standalone_to_fit := STATE_DEFAULT; - aSettings.text_area_resize := STATE_DEFAULT; - aSettings.tab_to_links := STATE_DEFAULT; - aSettings.local_storage := STATE_DEFAULT; - aSettings.databases := STATE_DEFAULT; - aSettings.application_cache := STATE_DEFAULT; - aSettings.webgl := STATE_DEFAULT; - aSettings.background_color := 0; - aSettings.accept_language_list := CefString(''); -end; - -// Leave aFrameName empty to load the URL in the main frame -procedure TFMXChromium.LoadURL(const aURL : ustring; const aFrameName : ustring = ''); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - if (length(aFrameName) > 0) then - TempFrame := FBrowser.GetFrame(aFrameName) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.LoadUrl(aURL); - end; -end; - -procedure TFMXChromium.LoadURL(const aURL : ustring; const aFrame : ICefFrame); -begin - if Initialized and (aFrame <> nil) then aFrame.LoadUrl(aURL); -end; - -procedure TFMXChromium.LoadURL(const aURL : ustring; const aFrameIdentifier : int64); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - if (aFrameIdentifier <> 0) then - TempFrame := FBrowser.GetFrameByident(aFrameIdentifier) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then TempFrame.LoadUrl(aURL); - end; -end; - -procedure TFMXChromium.LoadString(const aString : ustring; const aURL : ustring); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then TempFrame.LoadString(aString, aURL); - end; -end; - -procedure TFMXChromium.LoadRequest(const aRequest: ICefRequest); -var - TempFrame : ICefFrame; -begin - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then TempFrame.LoadRequest(aRequest); - end; -end; - -procedure TFMXChromium.GoBack; -begin - if Initialized and CanGoBack then FBrowser.GoBack; -end; - -procedure TFMXChromium.GoForward; -begin - if Initialized and CanGoForward then FBrowser.GoForward; -end; - -procedure TFMXChromium.Reload; -begin - if Initialized then FBrowser.Reload; -end; - -procedure TFMXChromium.ReloadIgnoreCache; -begin - if Initialized then FBrowser.ReloadIgnoreCache; -end; - -procedure TFMXChromium.StopLoad; -begin - if Initialized then FBrowser.StopLoad; -end; - -procedure TFMXChromium.StartDownload(const aURL : ustring); -begin - if Initialized then FBrowser.Host.StartDownload(aURL); -end; - -function TFMXChromium.GetIsLoading : boolean; -begin - Result := Initialized and FBrowser.IsLoading; -end; - -function TFMXChromium.GetMultithreadApp : boolean; -begin - Result := (GlobalCEFApp <> nil) and GlobalCEFApp.MultiThreadedMessageLoop; -end; - -function TFMXChromium.GetHasDocument : boolean; -begin - Result := Initialized and FBrowser.HasDocument; -end; - -function TFMXChromium.GetHasView : boolean; -begin - Result := Initialized and FBrowser.Host.HasView; -end; - -function TFMXChromium.GetHasDevTools : boolean; -begin - Result := Initialized and FBrowser.Host.HasDevTools; -end; - -function TFMXChromium.GetHasClientHandler : boolean; -begin - Result := (FHandler <> nil); -end; - -function TFMXChromium.GetHasBrowser : boolean; -begin - Result := (FBrowser <> nil); -end; - -function TFMXChromium.GetWindowHandle : THandle; -begin - if Initialized then - Result := FBrowser.Host.WindowHandle - else - Result := 0; -end; - -function TFMXChromium.GetFrameIsFocused : boolean; -begin - Result := Initialized and (FBrowser.FocusedFrame <> nil); -end; - -function TFMXChromium.GetWindowlessFrameRate : integer; -begin - if Initialized then - Result := FBrowser.Host.GetWindowlessFrameRate - else - Result := 0; -end; - -function TFMXChromium.GetVisibleNavigationEntry : ICefNavigationEntry; -begin - if Initialized then - Result := FBrowser.Host.VisibleNavigationEntry - else - Result := nil; -end; - -function TFMXChromium.GetHasValidMainFrame : boolean; -begin - Result := Initialized and (FBrowser.MainFrame <> nil) and FBrowser.MainFrame.IsValid; -end; - -function TFMXChromium.GetFrameCount : NativeUInt; -begin - if Initialized then - Result := FBrowser.GetFrameCount - else - Result := 0; -end; - -function TFMXChromium.GetRequestContextCache : ustring; -begin - if Initialized then - Result := FBrowser.host.RequestContext.CachePath - else - if (GlobalCEFApp <> nil) then - Result := GlobalCEFApp.cache - else - Result := ''; -end; - -function TFMXChromium.GetRequestContextIsGlobal : boolean; -begin - Result := Initialized and FBrowser.host.RequestContext.IsGlobal; -end; - -procedure TFMXChromium.SetWindowlessFrameRate(aValue : integer); -begin - if Initialized then FBrowser.Host.SetWindowlessFrameRate(aValue); -end; - -function TFMXChromium.GetCanGoBack : boolean; -begin - Result := Initialized and FBrowser.CanGoBack; -end; - -function TFMXChromium.GetCanGoForward : boolean; -begin - Result := Initialized and FBrowser.CanGoForward; -end; - -function TFMXChromium.GetIsPopUp : boolean; -begin - Result := Initialized and FBrowser.IsPopUp; -end; - -function TFMXChromium.GetInitialized : boolean; -begin - Result := FInitialized and not(FClosing) and (FBrowser <> nil); -end; - -function TFMXChromium.GetDocumentURL : ustring; -var - TempFrame : ICefFrame; -begin - Result := ''; - - if Initialized then - begin - TempFrame := FBrowser.MainFrame; - if (TempFrame <> nil) then Result := TempFrame.URL; - end; -end; - -function TFMXChromium.GetZoomLevel : double; -begin - Result := 0; - - if Initialized then Result := FBrowser.Host.ZoomLevel; -end; - -procedure TFMXChromium.SetZoomLevel(const aValue : double); -begin - if Initialized then FBrowser.Host.ZoomLevel := aValue; -end; - -function TFMXChromium.GetZoomPct : double; -begin - Result := power(1.2, ZoomLevel) * 100; -end; - -procedure TFMXChromium.SetZoomPct(const aValue : double); -begin - if Initialized and (aValue > 0) then ZoomLevel := LogN(1.2, aValue / 100); -end; - -procedure TFMXChromium.ApplyZoomStep; -begin - case FZoomStep of - ZOOM_STEP_25 : ZoomPct := 25; - ZOOM_STEP_33 : ZoomPct := 33; - ZOOM_STEP_50 : ZoomPct := 50; - ZOOM_STEP_67 : ZoomPct := 67; - ZOOM_STEP_75 : ZoomPct := 75; - ZOOM_STEP_90 : ZoomPct := 90; - ZOOM_STEP_100 : ZoomPct := 100; - ZOOM_STEP_110 : ZoomPct := 110; - ZOOM_STEP_125 : ZoomPct := 125; - ZOOM_STEP_150 : ZoomPct := 150; - ZOOM_STEP_175 : ZoomPct := 175; - ZOOM_STEP_200 : ZoomPct := 200; - ZOOM_STEP_250 : ZoomPct := 250; - ZOOM_STEP_300 : ZoomPct := 300; - ZOOM_STEP_400 : ZoomPct := 400; - ZOOM_STEP_500 : ZoomPct := 500; - end; -end; - -procedure TFMXChromium.SetZoomStep(aValue : byte); -begin - if Initialized and (aValue in [ZOOM_STEP_MIN..ZOOM_STEP_MAX]) then - begin - FZoomStep := aValue; - ApplyZoomStep; - end; -end; - -procedure TFMXChromium.IncZoomStep; -begin - if Initialized and (FZoomStep < ZOOM_STEP_MAX) then - begin - inc(FZoomStep); - ApplyZoomStep; - end; -end; - -procedure TFMXChromium.DecZoomStep; -begin - if Initialized and (FZoomStep > ZOOM_STEP_MIN) then - begin - dec(FZoomStep); - ApplyZoomStep; - end; -end; - -procedure TFMXChromium.ResetZoomStep; -begin - ZoomStep := ZOOM_STEP_DEF; -end; - -procedure TFMXChromium.SetDoNotTrack(aValue : boolean); -begin - if (FDoNotTrack <> aValue) then - begin - FDoNotTrack := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetSendReferrer(aValue : boolean); -begin - if (FSendReferrer <> aValue) then - begin - FSendReferrer := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetHyperlinkAuditing(aValue : boolean); -begin - if (FHyperlinkAuditing <> aValue) then - begin - FHyperlinkAuditing := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetRunAllFlashInAllowMode(aValue : boolean); -begin - if (FRunAllFlashInAllowMode <> aValue) then - begin - FRunAllFlashInAllowMode := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetAllowOutdatedPlugins(aValue : boolean); -begin - if (FAllowOutdatedPlugins <> aValue) then - begin - FAllowOutdatedPlugins := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetAlwaysAuthorizePlugins(aValue : boolean); -begin - if (FAlwaysAuthorizePlugins <> aValue) then - begin - FAlwaysAuthorizePlugins := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); -begin - if (FWebRTCIPHandlingPolicy <> aValue) then - begin - FWebRTCIPHandlingPolicy := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetWebRTCMultipleRoutes(aValue : TCefState); -begin - if (FWebRTCMultipleRoutes <> aValue) then - begin - FWebRTCMultipleRoutes := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetWebRTCNonProxiedUDP(aValue : TCefState); -begin - if (FWebRTCNonProxiedUDP <> aValue) then - begin - FWebRTCNonProxiedUDP := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetCookiePrefs(aValue : integer); -begin - if (FCookiePrefs <> aValue) then - begin - FCookiePrefs := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetImagesPrefs(aValue : integer); -begin - if (FImagesPrefs <> aValue) then - begin - FImagesPrefs := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetProxyType(aValue : integer); -begin - if (FProxyType <> aValue) then - begin - FProxyType := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetProxyScheme(aValue : TCefProxyScheme); -begin - if (FProxyScheme <> aValue) then - begin - FProxyScheme := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetProxyServer(const aValue : ustring); -begin - if (FProxyServer <> aValue) then - begin - FProxyServer := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetProxyPort(aValue : integer); -begin - if (FProxyPort <> aValue) then - begin - FProxyPort := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetProxyUsername(const aValue : ustring); -begin - if (FProxyUsername <> aValue) then - begin - FProxyUsername := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetProxyPassword(const aValue : ustring); -begin - if (FProxyPassword <> aValue) then - begin - FProxyPassword := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetProxyScriptURL(const aValue : ustring); -begin - if (FProxyScriptURL <> aValue) then - begin - FProxyScriptURL := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetProxyByPassList(const aValue : ustring); -begin - if (FProxyByPassList <> aValue) then - begin - FProxyByPassList := aValue; - FUpdatePreferences := True; - end; -end; - -procedure TFMXChromium.SetCustomHeaderName(const aValue : ustring); -begin - if (FCustomHeaderName <> aValue) then - begin - FCustomHeaderName := aValue; - FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); - end; -end; - -procedure TFMXChromium.SetCustomHeaderValue(const aValue : ustring); -begin - if (FCustomHeaderValue <> aValue) then - begin - FCustomHeaderValue := aValue; - FAddCustomHeader := (length(FCustomHeaderName) > 0) and (length(FCustomHeaderValue) > 0); - end; -end; - -function TFMXChromium.DeleteCookies(const url, cookieName: ustring) : boolean; -var - TempManager : ICefCookieManager; - TempCallback : ICefDeleteCookiesCallback; -begin - Result := False; - - if Initialized and (FBrowser.Host <> nil) and (FBrowser.Host.RequestContext <> nil) then - begin - TempManager := FBrowser.Host.RequestContext.GetDefaultCookieManager(nil); - - if (TempManager <> nil) then - begin - TempCallback := TCefCustomDeleteCookiesCallback.Create(self); - Result := TempManager.DeleteCookies(url, cookieName, TempCallback); - end; - end; -end; - -// Leave aFrameName empty to get the HTML source from the main frame -procedure TFMXChromium.RetrieveHTML(const aFrameName : ustring); -var - TempFrame : ICefFrame; - TempVisitor : ICefStringVisitor; -begin - if Initialized then - begin - if (length(aFrameName) > 0) then - TempFrame := FBrowser.GetFrame(aFrameName) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - TempFrame.GetSource(TempVisitor); - end; - end; -end; - -procedure TFMXChromium.RetrieveHTML(const aFrame : ICefFrame); -var - TempVisitor : ICefStringVisitor; -begin - if Initialized and (aFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - aFrame.GetSource(TempVisitor); - end; -end; - -procedure TFMXChromium.RetrieveHTML(const aFrameIdentifier : int64); -var - TempFrame : ICefFrame; - TempVisitor : ICefStringVisitor; -begin - if Initialized then - begin - if (aFrameIdentifier <> 0) then - TempFrame := FBrowser.GetFrameByident(aFrameIdentifier) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - TempFrame.GetSource(TempVisitor); - end; - end; -end; - -// Leave aFrameName empty to get the HTML source from the main frame -procedure TFMXChromium.RetrieveText(const aFrameName : ustring); -var - TempFrame : ICefFrame; - TempVisitor : ICefStringVisitor; -begin - if Initialized then - begin - if (length(aFrameName) > 0) then - TempFrame := FBrowser.GetFrame(aFrameName) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - TempFrame.GetText(TempVisitor); - end; - end; -end; - -procedure TFMXChromium.RetrieveText(const aFrame : ICefFrame); -var - TempVisitor : ICefStringVisitor; -begin - if Initialized and (aFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - aFrame.GetText(TempVisitor); - end; -end; - -procedure TFMXChromium.RetrieveText(const aFrameIdentifier : int64); -var - TempFrame : ICefFrame; - TempVisitor : ICefStringVisitor; -begin - if Initialized then - begin - if (aFrameIdentifier <> 0) then - TempFrame := FBrowser.GetFrameByident(aFrameIdentifier) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - begin - TempVisitor := TCustomCefStringVisitor.Create(self); - TempFrame.GetText(TempVisitor); - end; - end; -end; - -function TFMXChromium.GetFrameNames(var aFrameNames : TStrings) : boolean; -begin - Result := Initialized and FBrowser.GetFrameNames(aFrameNames); -end; - -function TFMXChromium.GetFrameIdentifiers(var aFrameCount : NativeUInt; var aFrameIdentifierArray : TCefFrameIdentifierArray) : boolean; -begin - Result := Initialized and FBrowser.GetFrameIdentifiers(aFrameCount, aFrameIdentifierArray); -end; - -procedure TFMXChromium.UpdatePreferences; -var - TempTask: ICefTask; -begin - if Initialized then - begin - TempTask := TCefUpdatePrefsTask.Create(self); - CefPostTask(TID_UI, TempTask); - end; -end; - -procedure TFMXChromium.SavePreferences(const aFileName : string); -var - TempTask: ICefTask; -begin - if Initialized and (length(aFileName) > 0) then - begin - FPrefsFileName := aFileName; - TempTask := TCefSavePrefsTask.Create(self); - CefPostTask(TID_UI, TempTask); - end; -end; - -procedure TFMXChromium.ResolveHost(const aURL : ustring); -var - TempCallback : ICefResolveCallback; -begin - // Results will be received in the OnResolvedHostAvailable event of this class - if Initialized and (length(aURL) > 0) then - begin - TempCallback := TCefCustomResolveCallback.Create(self); - FBrowser.Host.RequestContext.ResolveHost(aURL, TempCallback); - end; -end; - -function TFMXChromium.IsSameBrowser(const aBrowser : ICefBrowser) : boolean; -begin - Result := Initialized and (aBrowser <> nil) and FBrowser.IsSame(aBrowser); -end; - -procedure TFMXChromium.SimulateMouseWheel(aDeltaX, aDeltaY : integer); -var - TempEvent : TCefMouseEvent; -begin - if Initialized then - begin - TempEvent.x := 0; - TempEvent.y := 0; - TempEvent.modifiers := EVENTFLAG_NONE; - FBrowser.Host.SendMouseWheelEvent(@TempEvent, aDeltaX, aDeltaY); - end; -end; - -procedure TFMXChromium.doUpdatePreferences(const aBrowser: ICefBrowser); -begin - FUpdatePreferences := False; - - UpdateProxyPrefs(aBrowser); - UpdatePreference(aBrowser, 'enable_do_not_track', FDoNotTrack); - UpdatePreference(aBrowser, 'enable_referrers', FSendReferrer); - UpdatePreference(aBrowser, 'enable_a_ping', FHyperlinkAuditing); - UpdatePreference(aBrowser, 'plugins.run_all_flash_in_allow_mode', FRunAllFlashInAllowMode); - UpdatePreference(aBrowser, 'plugins.allow_outdated', FAllowOutdatedPlugins); - UpdatePreference(aBrowser, 'plugins.always_authorize', FAlwaysAuthorizePlugins); - - if FRunAllFlashInAllowMode then - UpdatePreference(aBrowser, 'profile.default_content_setting_values.plugins', 1); - - case FWebRTCIPHandlingPolicy of - hpDefaultPublicAndPrivateInterfaces : - UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'default_public_and_private_interfaces'); - - hpDefaultPublicInterfaceOnly : - UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'default_public_interface_only'); - - hpDisableNonProxiedUDP : - UpdatePreference(aBrowser, 'webrtc.ip_handling_policy', 'disable_non_proxied_udp'); - end; - - if (FWebRTCMultipleRoutes <> STATE_DEFAULT) then - UpdatePreference(aBrowser, 'webrtc.multiple_routes_enabled', (FWebRTCMultipleRoutes = STATE_ENABLED)); - - if (FWebRTCNonProxiedUDP <> STATE_DEFAULT) then - UpdatePreference(aBrowser, 'webrtc.nonproxied_udp_enabled', (FWebRTCNonProxiedUDP = STATE_ENABLED)); -end; - -procedure TFMXChromium.doUpdateOwnPreferences; -begin - if Initialized then doUpdatePreferences(FBrowser); -end; - -function TFMXChromium.UpdateProxyPrefs(const aBrowser: ICefBrowser) : boolean; -var - TempError : ustring; - TempProxy : ICefValue; - TempValue : ICefValue; - TempDict : ICefDictionaryValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference('proxy') then - begin - TempProxy := TCefValueRef.New; - TempValue := TCefValueRef.New; - TempDict := TCefDictionaryValueRef.New; - - case FProxyType of - CEF_PROXYTYPE_AUTODETECT : - begin - TempValue.SetString('auto_detect'); - TempDict.SetValue('mode', TempValue); - end; - - CEF_PROXYTYPE_SYSTEM : - begin - TempValue.SetString('system'); - TempDict.SetValue('mode', TempValue); - end; - - CEF_PROXYTYPE_FIXED_SERVERS : - begin - TempValue.SetString('fixed_servers'); - TempDict.SetValue('mode', TempValue); - - case FProxyScheme of - psSOCKS4 : TempDict.SetString('server', 'socks4://' + FProxyServer + ':' + inttostr(FProxyPort)); - psSOCKS5 : TempDict.SetString('server', 'socks5://' + FProxyServer + ':' + inttostr(FProxyPort)); - else TempDict.SetString('server', FProxyServer + ':' + inttostr(FProxyPort)); - end; - - if (length(FProxyByPassList) > 0) then TempDict.SetString('bypass_list', FProxyByPassList); - end; - - CEF_PROXYTYPE_PAC_SCRIPT : - begin - TempValue.SetString('pac_script'); - TempDict.SetValue('mode', TempValue); - TempDict.SetString('pac_url', FProxyScriptURL); - end; - - else // CEF_PROXYTYPE_DIRECT - begin - TempValue.SetString('direct'); - TempDict.SetValue('mode', TempValue); - end; - end; - - Result := TempProxy.SetDictionary(TempDict) and - aBrowser.Host.RequestContext.SetPreference('proxy', TempProxy, TempError); - - if not(Result) then - OutputDebugMessage('TFMXChromium.UpdateProxyPrefs error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.UpdateProxyPrefs', e) then raise; - end; -end; - -function TFMXChromium.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : boolean) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - - if aValue then - TempValue.SetBool(1) - else - TempValue.SetBool(0); - - Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TFMXChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.UpdatePreference', e) then raise; - end; -end; - -function TFMXChromium.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; aValue : integer) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - TempValue.SetInt(aValue); - Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TFMXChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.UpdatePreference', e) then raise; - end; -end; - -function TFMXChromium.UpdatePreference(const aBrowser: ICefBrowser; const aName : ustring; const aValue : double) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - TempValue.SetDouble(aValue); - Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TFMXChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.UpdatePreference', e) then raise; - end; -end; - -function TFMXChromium.UpdatePreference(const aBrowser: ICefBrowser; const aName, aValue : ustring) : boolean; -var - TempError : ustring; - TempValue : ICefValue; -begin - Result := False; - - try - if (aBrowser <> nil) and - (aBrowser.Host <> nil) and - aBrowser.Host.RequestContext.CanSetPreference(aName) then - begin - TempValue := TCefValueRef.New; - TempValue.SetString(aValue); - Result := aBrowser.Host.RequestContext.SetPreference(aName, TempValue, TempError); - - if not(Result) then - OutputDebugMessage('TFMXChromium.UpdatePreference error : ' + quotedstr(TempError)); - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.UpdatePreference', e) then raise; - end; -end; - -procedure TFMXChromium.HandleNull(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : -null-') - else - aResultSL.Add('-null-'); -end; - -procedure TFMXChromium.HandleBool(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + BoolToStr(aValue.GetBool, true)) - else - aResultSL.Add(BoolToStr(aValue.GetBool, true)); -end; - -procedure TFMXChromium.HandleInteger(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + IntToStr(aValue.GetInt)) - else - aResultSL.Add(IntToStr(aValue.GetInt)); -end; - -procedure TFMXChromium.HandleDouble(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + FloatToStr(aValue.GetDouble)) - else - aResultSL.Add(FloatToStr(aValue.GetDouble)); -end; - -procedure TFMXChromium.HandleString(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + aValue.GetString) - else - aResultSL.Add(aValue.GetString); -end; - -procedure TFMXChromium.HandleBinary(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : -binary-') - else - aResultSL.Add('-binary-'); -end; - -procedure TFMXChromium.HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey, TempResult : string; - i, j : integer; - TempList : ICefListValue; - TempValue : ICefValue; - TempSL : TStringList; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - TempList := aValue.GetList; - TempSL := TStringList.Create; - - i := 0; - j := TempList.GetSize; - - TempResult := '(' + inttostr(j) + '){'; - - while (i < j) do - begin - TempValue := TempList.GetValue(i); - - case TempValue.GetType of - VTYPE_NULL : TempResult := TempResult + '-null-,'; - VTYPE_BOOL : TempResult := TempResult + BoolToStr(aValue.GetBool, true) + ','; - VTYPE_INT : TempResult := TempResult + IntToStr(aValue.GetInt) + ','; - VTYPE_DOUBLE : TempResult := TempResult + FloatToStr(aValue.GetDouble) + ','; - VTYPE_STRING : TempResult := TempResult + aValue.GetString + ','; - VTYPE_BINARY : TempResult := TempResult + '-binary-,'; - VTYPE_DICTIONARY : - begin - TempSL.Clear; - HandleDictionary(TempValue.GetDictionary, TempSL, ''); - TempResult := TempResult + TempSL.CommaText + ','; - end; - - VTYPE_LIST : - begin - TempSL.Clear; - HandleList(TempValue, TempSL, '', ''); - TempResult := TempResult + TempSL.CommaText + ','; - end; - - else TempResult := TempResult + '-invalid-,'; - end; - - inc(i); - end; - - i := length(TempResult); - if (i > 0) and (TempResult[i] = ',') then TempResult := copy(TempResult, 1, pred(i)); - TempResult := TempResult + '}'; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : ' + TempResult) - else - aResultSL.Add(TempResult); - - TempSL.Free; -end; - -procedure TFMXChromium.HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string); -var - TempKey : string; -begin - if (aRoot <> '') then - TempKey := aRoot + '.' + aKey - else - TempKey := aKey; - - if (length(TempKey) > 0) then - aResultSL.Add(TempKey + ' : -invalid-') - else - aResultSL.Add('-invalid-'); -end; - -procedure TFMXChromium.HandleDictionary(const aDict : ICefDictionaryValue; var aResultSL : TStringList; const aRoot : string); -var - TempKeys : TStringList; - i, j : integer; - TempValue : ICefValue; - TempNewKey : string; -begin - TempKeys := nil; - - try - try - if (aDict <> nil) then - begin - TempKeys := TStringList.Create; - aDict.GetKeys(TempKeys); - - i := 0; - j := TempKeys.Count; - - while (i < j) do - begin - TempValue := aDict.GetValue(TempKeys[i]); - - case TempValue.GetType of - VTYPE_NULL : HandleNull(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_BOOL : HandleBool(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_INT : HandleInteger(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_DOUBLE : HandleDouble(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_STRING : HandleString(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_BINARY : HandleBinary(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_LIST : HandleList(TempValue, aResultSL, aRoot, TempKeys[i]); - VTYPE_DICTIONARY : - begin - if (length(aRoot) > 0) then - TempNewKey := aRoot + '.' + TempKeys[i] - else - TempNewKey := TempKeys[i]; - - HandleDictionary(TempValue.GetDictionary, aResultSL, TempNewKey); - end; - - else - HandleInvalid(TempValue, aResultSL, aRoot, TempKeys[i]); - end; - - inc(i); - end; - - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.HandleDictionary', e) then raise; - end; - finally - if (TempKeys <> nil) then TempKeys.Free; - end; -end; - -function TFMXChromium.doSavePreferences : boolean; -var - TempDict : ICefDictionaryValue; - TempPrefs : TStringList; -begin - Result := False; - TempPrefs := nil; - - try - try - if Initialized then - begin - TempPrefs := TStringList.Create; - TempDict := FBrowser.Host.RequestContext.GetAllPreferences(True); - HandleDictionary(TempDict, TempPrefs, ''); - TempPrefs.SaveToFile(FPrefsFileName); - Result := True; - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.Internal_SavePreferences', e) then raise; - end; - finally - if (TempPrefs <> nil) then FreeAndNil(TempPrefs); - end; -end; - -procedure TFMXChromium.doResolvedHostAvailable(result: TCefErrorCode; const resolvedIps: TStrings); -begin - if assigned(FOnResolvedHostAvailable) then FOnResolvedHostAvailable(self, result, resolvedIps); -end; - -function TFMXChromium.MustCreateLoadHandler : boolean; -begin - Result := assigned(FOnLoadStart) or - assigned(FOnLoadEnd) or - assigned(FOnLoadError) or - assigned(FOnLoadingStateChange); -end; - -function TFMXChromium.MustCreateFocusHandler : boolean; -begin - Result := assigned(FOnTakeFocus) or - assigned(FOnSetFocus) or - assigned(FOnGotFocus); -end; - -function TFMXChromium.MustCreateContextMenuHandler : boolean; -begin - Result := assigned(FOnBeforeContextMenu) or - assigned(FOnRunContextMenu) or - assigned(FOnContextMenuCommand) or - assigned(FOnContextMenuDismissed); -end; - -function TFMXChromium.MustCreateDialogHandler : boolean; -begin - Result := assigned(FOnFileDialog); -end; - -function TFMXChromium.MustCreateKeyboardHandler : boolean; -begin - Result := assigned(FOnPreKeyEvent) or - assigned(FOnKeyEvent); -end; - -function TFMXChromium.MustCreateDisplayHandler : boolean; -begin - Result := assigned(FOnAddressChange) or - assigned(FOnTitleChange) or - assigned(FOnFavIconUrlChange) or - assigned(FOnFullScreenModeChange) or - assigned(FOnTooltip) or - assigned(FOnStatusMessage) or - assigned(FOnConsoleMessage) or - assigned(FOnAutoResize) or - assigned(FOnLoadingProgressChange); -end; - -function TFMXChromium.MustCreateDownloadHandler : boolean; -begin - Result := assigned(FOnBeforeDownload) or - assigned(FOnDownloadUpdated); -end; - -function TFMXChromium.MustCreateJsDialogHandler : boolean; -begin - Result := assigned(FOnJsdialog) or - assigned(FOnBeforeUnloadDialog) or - assigned(FOnResetDialogState) or - assigned(FOnDialogClosed); -end; - -function TFMXChromium.MustCreateDragHandler : boolean; -begin - Result := assigned(FOnDragEnter) or - assigned(FOnDraggableRegionsChanged); -end; - -function TFMXChromium.MustCreateFindHandler : boolean; -begin - Result := assigned(FOnFindResult); -end; - -procedure TFMXChromium.doTextResultAvailable(const aText : ustring); -begin - if assigned(FOnTextResultAvailable) then FOnTextResultAvailable(self, aText); -end; - -procedure TFMXChromium.ExecuteJavaScript(const aCode, aScriptURL, aFrameName : ustring; aStartLine : integer); -var - TempFrame : ICefFrame; -begin - try - if Initialized then - begin - if (length(aFrameName) > 0) then - TempFrame := FBrowser.GetFrame(aFrameName) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - TempFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.ExecuteJavaScript', e) then raise; - end; -end; - -procedure TFMXChromium.ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrame : ICefFrame; aStartLine : integer); -begin - try - if Initialized and (aFrame <> nil) then - aFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.ExecuteJavaScript', e) then raise; - end; -end; - -procedure TFMXChromium.ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameIdentifier : int64; aStartLine : integer = 0); -var - TempFrame : ICefFrame; -begin - try - if Initialized then - begin - if (aFrameIdentifier <> 0) then - TempFrame := FBrowser.GetFrameByident(aFrameIdentifier) - else - TempFrame := FBrowser.MainFrame; - - if (TempFrame <> nil) then - TempFrame.ExecuteJavaScript(aCode, aScriptURL, aStartLine); - end; - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.ExecuteJavaScript', e) then raise; - end; -end; - -procedure TFMXChromium.doCookiesDeleted(numDeleted : integer); -begin - if assigned(FOnCookiesDeleted) then FOnCookiesDeleted(self, numDeleted); -end; - -procedure TFMXChromium.doPdfPrintFinished(aResultOK : boolean); -begin - if assigned(FOnPdfPrintFinished) then FOnPdfPrintFinished(self, aResultOK); -end; - -function TFMXChromium.doOnClose(const browser: ICefBrowser): Boolean; -begin - Result := False; - - if (browser <> nil) and (FBrowserId = browser.Identifier) then FClosing := True; - - if Assigned(FOnClose) then FOnClose(Self, browser, Result); -end; - -procedure TFMXChromium.doOnBeforeClose(const browser: ICefBrowser); -begin - if (browser <> nil) and (FBrowserId = browser.Identifier) then - begin - FInitialized := False; - ClearBrowserReference; - DestroyClientHandler; - end; - - if Assigned(FOnBeforeClose) then FOnBeforeClose(Self, browser); -end; - -procedure TFMXChromium.doOnAddressChange(const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); -begin - if Assigned(FOnAddressChange) then FOnAddressChange(Self, browser, frame, url); -end; - -procedure TFMXChromium.doOnAfterCreated(const browser: ICefBrowser); -begin - if MultithreadApp and (FBrowser = nil) and (browser <> nil) then - begin - FBrowser := browser; - FBrowserId := browser.Identifier; - FInitialized := (FBrowserId <> 0); - end; - - doUpdatePreferences(browser); - - if Assigned(FOnAfterCreated) then FOnAfterCreated(Self, browser); -end; - -function TFMXChromium.doOnBeforeBrowse(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - user_gesture : Boolean; - isRedirect : Boolean): Boolean; -begin - Result := False; - - if FUpdatePreferences then doUpdatePreferences(browser); - - if Assigned(FOnBeforeBrowse) then FOnBeforeBrowse(Self, browser, frame, request, user_gesture, isRedirect, Result); -end; - -procedure TFMXChromium.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 TFMXChromium.doRunContextMenu(const browser : ICefBrowser; - const frame : ICefFrame; - const params : ICefContextMenuParams; - const model : ICefMenuModel; - const callback : ICefRunContextMenuCallback): Boolean; -begin - Result := False; - - if Assigned(FOnRunContextMenu) then FOnRunContextMenu(Self, browser, frame, params, model, callback, Result); -end; - -procedure TFMXChromium.doOnBeforeDownload(const browser : ICefBrowser; - const downloadItem : ICefDownloadItem; - const suggestedName : ustring; - const callback : ICefBeforeDownloadCallback); -begin - if Assigned(FOnBeforeDownload) then FOnBeforeDownload(Self, browser, downloadItem, suggestedName, callback); -end; - -function TFMXChromium.doOnBeforePopup(const browser : ICefBrowser; - const frame : ICefFrame; - const targetUrl : ustring; - const targetFrameName : ustring; - targetDisposition : TCefWindowOpenDisposition; - userGesture : Boolean; - const 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, - targetDisposition, userGesture, popupFeatures, windowInfo, client, - settings, noJavascriptAccess, Result); -end; - -function TFMXChromium.doOnBeforeResourceLoad(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const callback : ICefRequestCallback): TCefReturnValue; -var - TempHeaderMap : ICefStringMultimap; -begin - if FAddCustomHeader then - try - TempHeaderMap := TCefStringMultimapOwn.Create; - request.GetHeaderMap(TempHeaderMap); - TempHeaderMap.Append(FCustomHeaderName, FCustomHeaderValue); - request.SetHeaderMap(TempHeaderMap); - finally - TempHeaderMap := nil; - end; - - if not(FSendReferrer) then request.SetReferrer('', REFERRER_POLICY_NO_REFERRER); - - Result := RV_CONTINUE; - - if Assigned(FOnBeforeResourceLoad) then FOnBeforeResourceLoad(Self, browser, frame, request, callback, Result); -end; - -function TFMXChromium.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; - -function TFMXChromium.doOnCertificateError(const browser : ICefBrowser; - certError : TCefErrorcode; - const requestUrl : ustring; - const sslInfo : ICefSslInfo; - const callback : ICefRequestCallback): Boolean; -begin - Result := False; - - if Assigned(FOnCertificateError) then - FOnCertificateError(Self, browser, certError, requestUrl, sslInfo, callback, Result); -end; - -function TFMXChromium.doOnConsoleMessage(const browser : ICefBrowser; - level : TCefLogSeverity; - const aMessage : ustring; - const source : ustring; - line : Integer): Boolean; -begin - Result := False; - - if Assigned(FOnConsoleMessage) then FOnConsoleMessage(Self, browser, level, aMessage, source, line, Result); -end; - -function TFMXChromium.doOnAutoResize(const browser : ICefBrowser; - const new_size : PCefSize): Boolean; -begin - Result := False; - - if Assigned(FOnAutoResize) then FOnAutoResize(Self, browser, new_size, Result); -end; - -procedure TFMXChromium.doOnLoadingProgressChange(const browser: ICefBrowser; const progress: double); -begin - if assigned(FOnLoadingProgressChange) then FOnLoadingProgressChange(self, browser, progress); -end; - -function TFMXChromium.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 TFMXChromium.doOnContextMenuDismissed(const browser: ICefBrowser; const frame: ICefFrame); -begin - if Assigned(FOnContextMenuDismissed) then FOnContextMenuDismissed(Self, browser, frame); -end; - -procedure TFMXChromium.doOnCursorChange(const browser : ICefBrowser; - cursor : TCefCursorHandle; - cursorType : TCefCursorType; - const customCursorInfo : PCefCursorInfo); -begin - if assigned(FOnCursorChange) then FOnCursorChange(self, browser, cursor, cursorType, customCursorInfo); -end; - -procedure TFMXChromium.doOnDialogClosed(const browser: ICefBrowser); -begin - if Assigned(FOnDialogClosed) then FOnDialogClosed(Self, browser); -end; - -procedure TFMXChromium.doOnDownloadUpdated(const browser : ICefBrowser; - const downloadItem : ICefDownloadItem; - const callback : ICefDownloadItemCallback); -begin - if Assigned(FOnDownloadUpdated) then FOnDownloadUpdated(Self, browser, downloadItem, callback); -end; - -function TFMXChromium.doOnDragEnter(const browser : ICefBrowser; - const dragData : ICefDragData; - mask : TCefDragOperations): Boolean; -begin - Result := False; - - if Assigned(FOnDragEnter) then FOnDragEnter(Self, browser, dragData, mask, Result); -end; - -procedure TFMXChromium.doOnDraggableRegionsChanged(const browser : ICefBrowser; - regionsCount : NativeUInt; - regions : PCefDraggableRegionArray); -begin - if Assigned(FOnDraggableRegionsChanged) then FOnDraggableRegionsChanged(Self, browser, regionsCount, regions); -end; - -procedure TFMXChromium.doOnFaviconUrlChange(const browser: ICefBrowser; const iconUrls: TStrings); -begin - if Assigned(FOnFavIconUrlChange) then FOnFavIconUrlChange(Self, browser, iconUrls); -end; - -function TFMXChromium.doOnFileDialog(const browser : ICefBrowser; - mode : TCefFileDialogMode; - const title : ustring; - const defaultFilePath : ustring; - const acceptFilters : TStrings; - selectedAcceptFilter : Integer; - const callback : ICefFileDialogCallback): Boolean; -begin - Result := False; - - if Assigned(FOnFileDialog) then - FOnFileDialog(Self, browser, mode, title, defaultFilePath, acceptFilters, - selectedAcceptFilter, callback, Result); -end; - -procedure TFMXChromium.doOnFindResult(const browser : ICefBrowser; - identifier : integer; - count : Integer; - const selectionRect : PCefRect; - activeMatchOrdinal : Integer; - finalUpdate : Boolean); -begin - if Assigned(FOnFindResult) then - FOnFindResult(Self, browser, identifier, count, selectionRect, activeMatchOrdinal, finalUpdate); -end; - -procedure TFMXChromium.doOnFullScreenModeChange(const browser: ICefBrowser; fullscreen: Boolean); -begin - if Assigned(FOnFullScreenModeChange) then FOnFullScreenModeChange(Self, browser, fullscreen); -end; - -function TFMXChromium.doOnGetAuthCredentials(const browser : ICefBrowser; - const frame : ICefFrame; - isProxy : Boolean; - const host : ustring; - port : Integer; - const realm : ustring; - const scheme : ustring; - const callback : ICefAuthCallback): Boolean; -begin - Result := False; - - if isProxy then - begin - if (FProxyType = CEF_PROXYTYPE_FIXED_SERVERS) and (callback <> nil) then - begin - Result := True; - callback.cont(FProxyUsername, FProxyPassword); - end; - end - else - if (frame <> nil) and frame.IsMain and Assigned(FOnGetAuthCredentials) then - FOnGetAuthCredentials(Self, browser, frame, isProxy, host, port, realm, scheme, callback, Result); -end; - -function TFMXChromium.doCanGetCookies(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest): boolean; -begin - Result := True; - - if assigned(FOnCanGetCookies) then FOnCanGetCookies(self, browser, frame, request, Result); -end; - -function TFMXChromium.doCanSetCookie(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const cookie : PCefCookie): boolean; -begin - Result := True; - - if assigned(FOnCanSetCookie) then FOnCanSetCookie(self, browser, frame, request, cookie, Result); -end; - -function TFMXChromium.doOnGetResourceHandler(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest): ICefResourceHandler; -begin - Result := nil; - - if Assigned(FOnGetResourceHandler) then - FOnGetResourceHandler(Self, browser, frame, request, Result); -end; - -procedure TFMXChromium.doOnGetAccessibilityHandler(var aAccessibilityHandler : ICefAccessibilityHandler); -begin - if assigned(FOnGetAccessibilityHandler) then FOnGetAccessibilityHandler(Self, aAccessibilityHandler); -end; - -function TFMXChromium.doOnGetRootScreenRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; -begin - Result := False; - - if Assigned(FOnGetRootScreenRect) then FOnGetRootScreenRect(Self, browser, rect, Result); -end; - -function TFMXChromium.doOnGetScreenInfo(const browser: ICefBrowser; var screenInfo: TCefScreenInfo): Boolean; -begin - Result := False; - - if Assigned(FOnGetScreenInfo) then FOnGetScreenInfo(Self, browser, screenInfo, Result); -end; - -function TFMXChromium.doOnGetScreenPoint(const browser: ICefBrowser; viewX, viewY: Integer; var screenX, screenY: Integer): Boolean; -begin - Result := False; - - if Assigned(FOnGetScreenPoint) then FOnGetScreenPoint(Self, browser, viewX, viewY, screenX, screenY, Result); -end; - -function TFMXChromium.doOnGetViewRect(const browser: ICefBrowser; var rect: TCefRect): Boolean; -begin - Result := False; - - if Assigned(FOnGetViewRect) then FOnGetViewRect(Self, browser, rect, Result); -end; - -procedure TFMXChromium.doOnGotFocus(const browser: ICefBrowser); -begin - if Assigned(FOnGotFocus) then FOnGotFocus(Self, browser) -end; - -function TFMXChromium.doOnJsdialog(const browser : ICefBrowser; - const originUrl : ustring; - dialogType : TCefJsDialogType; - const messageText : ustring; - const defaultPromptText : ustring; - const callback : ICefJsDialogCallback; - out suppressMessage : Boolean): Boolean; -begin - Result := False; - - if not(Initialized) then - suppressMessage := True - else - begin - suppressMessage := False; - - if Assigned(FOnJsdialog) then - FOnJsdialog(Self, browser, originUrl, dialogType, messageText, - defaultPromptText, callback, suppressMessage, Result); - end; -end; - -function TFMXChromium.doOnKeyEvent(const browser : ICefBrowser; - const event : PCefKeyEvent; - osEvent : TCefEventHandle): Boolean; -begin - Result := False; - - if Assigned(FOnKeyEvent) then FOnKeyEvent(Self, browser, event, osEvent, Result); -end; - -procedure TFMXChromium.doOnLoadEnd(const browser : ICefBrowser; - const frame : ICefFrame; - httpStatusCode : Integer); -begin - if Assigned(FOnLoadEnd) then FOnLoadEnd(Self, browser, frame, httpStatusCode); -end; - -procedure TFMXChromium.doOnLoadError(const browser : ICefBrowser; - const frame : ICefFrame; - errorCode : TCefErrorCode; - const errorText : ustring; - const failedUrl : ustring); -begin - if Assigned(FOnLoadError) then FOnLoadError(Self, browser, frame, errorCode, errorText, failedUrl); -end; - -procedure TFMXChromium.doOnLoadingStateChange(const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); -begin - if Assigned(FOnLoadingStateChange) then FOnLoadingStateChange(Self, browser, isLoading, canGoBack, canGoForward); -end; - -procedure TFMXChromium.doOnLoadStart(const browser: ICefBrowser; const frame: ICefFrame; transitionType: TCefTransitionType); -begin - if Assigned(FOnLoadStart) then FOnLoadStart(Self, browser, frame, transitionType); -end; - -function TFMXChromium.doOnOpenUrlFromTab(const browser : ICefBrowser; - const frame : ICefFrame; - const targetUrl : ustring; - targetDisposition : TCefWindowOpenDisposition; - userGesture : Boolean): Boolean; -begin - Result := False; - - if Assigned(FOnOpenUrlFromTab) then - FOnOpenUrlFromTab(Self, browser, frame, targetUrl, targetDisposition, userGesture, Result); -end; - -procedure TFMXChromium.doOnPaint(const browser : ICefBrowser; - kind : TCefPaintElementType; - dirtyRectsCount : NativeUInt; - const dirtyRects : PCefRectArray; - const buffer : Pointer; - width : Integer; - height : Integer); -begin - if Assigned(FOnPaint) then FOnPaint(Self, browser, kind, dirtyRectsCount, dirtyRects, buffer, width, height); -end; - -function TFMXChromium.doOnSelectClientCertificate(const browser : ICefBrowser; - isProxy : boolean; - const host : ustring; - port : integer; - certificatesCount : NativeUInt; - const certificates : TCefX509CertificateArray; - const callback : ICefSelectClientCertificateCallback): boolean; -begin - Result := False; - - if assigned(FOnSelectClientCertificate) then - FOnSelectClientCertificate(self, browser, isProxy, host, port, certificatesCount, certificates, callback, Result); -end; - -procedure TFMXChromium.doOnPluginCrashed(const browser: ICefBrowser; const pluginPath: ustring); -begin - if Assigned(FOnPluginCrashed) then FOnPluginCrashed(Self, browser, pluginPath); -end; - -procedure TFMXChromium.doOnPopupShow(const browser: ICefBrowser; show: Boolean); -begin - if assigned(FOnPopupShow) then FOnPopupShow(self, browser, show); -end; - -procedure TFMXChromium.doOnPopupSize(const browser: ICefBrowser; const rect: PCefRect); -begin - if assigned(FOnPopupSize) then FOnPopupSize(self, browser, rect); -end; - -function TFMXChromium.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 TFMXChromium.doOnProcessMessageReceived(const browser : ICefBrowser; - sourceProcess : TCefProcessId; - const aMessage : ICefProcessMessage): Boolean; -begin - Result := False; - - if Assigned(FOnProcessMessageReceived) then - FOnProcessMessageReceived(Self, browser, sourceProcess, aMessage, Result); -end; - -procedure TFMXChromium.doOnProtocolExecution(const browser : ICefBrowser; - const url : ustring; - out allowOsExecution : Boolean); -begin - if Assigned(FOnProtocolExecution) then FOnProtocolExecution(Self, browser, url, allowOsExecution); -end; - -function TFMXChromium.doOnQuotaRequest(const browser : ICefBrowser; - const originUrl : ustring; - newSize : Int64; - const callback : ICefRequestCallback): Boolean; -begin - Result := False; - - if Assigned(FOnQuotaRequest) then FOnQuotaRequest(Self, browser, originUrl, newSize, callback, Result); -end; - -procedure TFMXChromium.doOnRenderProcessTerminated(const browser: ICefBrowser; status: TCefTerminationStatus); -begin - if Assigned(FOnRenderProcessTerminated) then FOnRenderProcessTerminated(Self, browser, status); -end; - -procedure TFMXChromium.doOnRenderViewReady(const browser: ICefBrowser); -begin - {$IFDEF MSWINDOWS} - if (browser <> nil) and - (browser.Host <> nil) and - (browser.Identifier = FBrowserId) then - begin - FBrowserCompHWND := browser.Host.WindowHandle; - - if (FBrowserCompHWND <> 0) then - FWidgetCompHWND := FindWindowEx(FBrowserCompHWND, 0, 'Chrome_WidgetWin_0', ''); - - if (FWidgetCompHWND <> 0) then - FRenderCompHWND := FindWindowEx(FWidgetCompHWND, 0, 'Chrome_RenderWidgetHostHWND', 'Chrome Legacy Window'); - - if assigned(FOnBrowserCompMsg) and (FBrowserCompHWND <> 0) and (FOldBrowserCompWndPrc = nil) then - begin - CreateStub(BrowserCompWndProc, FBrowserCompStub); - FOldBrowserCompWndPrc := TFNWndProc(SetWindowLongPtr(FBrowserCompHWND, - GWL_WNDPROC, - NativeInt(FBrowserCompStub))); - end; - - if assigned(FOnWidgetCompMsg) and (FWidgetCompHWND <> 0) and (FOldWidgetCompWndPrc = nil) then - begin - CreateStub(WidgetCompWndProc, FWidgetCompStub); - FOldWidgetCompWndPrc := TFNWndProc(SetWindowLongPtr(FWidgetCompHWND, - GWL_WNDPROC, - NativeInt(FWidgetCompStub))); - end; - - if assigned(FOnRenderCompMsg) and (FRenderCompHWND <> 0) and (FOldRenderCompWndPrc = nil) then - begin - CreateStub(RenderCompWndProc, FRenderCompStub); - FOldRenderCompWndPrc := TFNWndProc(SetWindowLongPtr(FRenderCompHWND, - GWL_WNDPROC, - NativeInt(FRenderCompStub))); - end; - end; - {$ENDIF} - - if Assigned(FOnRenderViewReady) then FOnRenderViewReady(Self, browser); -end; - -procedure TFMXChromium.doOnResetDialogState(const browser: ICefBrowser); -begin - if Assigned(FOnResetDialogState) then FOnResetDialogState(Self, browser); -end; - -procedure TFMXChromium.doOnResourceRedirect(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - var newUrl : ustring); -begin - if Assigned(FOnResourceRedirect) then FOnResourceRedirect(Self, browser, frame, request, response, newUrl); -end; - -function TFMXChromium.doOnResourceResponse(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse): Boolean; -begin - Result := False; - - if Assigned(FOnResourceResponse) then FOnResourceResponse(Self, browser, frame, request, response, Result); -end; -function TFMXChromium.doOnGetResourceResponseFilter(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse) : ICefResponseFilter; -begin - Result := nil; - - if Assigned(FOnGetResourceResponseFilter) then - FOnGetResourceResponseFilter(self, browser, frame, request, response, Result); -end; - -procedure TFMXChromium.doOnResourceLoadComplete(const browser : ICefBrowser; - const frame : ICefFrame; - const request : ICefRequest; - const response : ICefResponse; - status : TCefUrlRequestStatus; - receivedContentLength : Int64); -begin - if Assigned(FOnResourceLoadComplete) then - FOnResourceLoadComplete(self, browser, frame, request, response, status, receivedContentLength); -end; - -procedure TFMXChromium.doOnScrollOffsetChanged(const browser: ICefBrowser; x, y: Double); -begin - if Assigned(FOnScrollOffsetChanged) then FOnScrollOffsetChanged(Self, browser, x, y); -end; - -procedure TFMXChromium.doOnIMECompositionRangeChanged(const browser : ICefBrowser; - const selected_range : PCefRange; - character_boundsCount : NativeUInt; - const character_bounds : PCefRect); -begin - if assigned(FOnIMECompositionRangeChanged) then - FOnIMECompositionRangeChanged(self, browser, selected_range, character_boundsCount, character_bounds); -end; - -procedure TFMXChromium.doOnTextSelectionChanged(const browser : ICefBrowser; - const selected_text : ustring; - const selected_range : PCefRange); -begin - if assigned(FOnTextSelectionChanged) then - FOnTextSelectionChanged(self, browser, selected_text, selected_range); -end; - -function TFMXChromium.doOnSetFocus(const browser: ICefBrowser; source: TCefFocusSource): Boolean; -begin - Result := False; - - if Assigned(FOnSetFocus) then FOnSetFocus(Self, browser, source, Result); -end; - -function TFMXChromium.doOnStartDragging(const browser : ICefBrowser; - const dragData : ICefDragData; - allowedOps : TCefDragOperations; - x : integer; - y : Integer): Boolean; -begin - Result := False; -end; - -procedure TFMXChromium.doOnStatusMessage(const browser: ICefBrowser; const value: ustring); -begin - if Assigned(FOnStatusMessage) then FOnStatusMessage(Self, browser, value); -end; - -procedure TFMXChromium.doOnTakeFocus(const browser: ICefBrowser; next: Boolean); -begin - if Assigned(FOnTakeFocus) then FOnTakeFocus(Self, browser, next); -end; - -procedure TFMXChromium.doOnTitleChange(const browser: ICefBrowser; const title: ustring); -begin - if Assigned(FOnTitleChange) then FOnTitleChange(Self, browser, title); -end; - -function TFMXChromium.doOnTooltip(const browser: ICefBrowser; var text: ustring): Boolean; -begin - Result := False; - - if Assigned(FOnTooltip) then FOnTooltip(Self, browser, text, Result); -end; - -procedure TFMXChromium.doOnUpdateDragCursor(const browser: ICefBrowser; operation: TCefDragOperation); -begin - // -end; - -function TFMXChromium.GetParentForm : TCustomForm; -var - TempComp : TComponent; -begin - Result := nil; - TempComp := Owner; - - while (TempComp <> nil) do - if (TempComp is TCustomForm) then - begin - Result := TCustomForm(TempComp); - exit; - end - else - TempComp := TempComp.owner; -end; - -{$IFDEF MSWINDOWS} -procedure TFMXChromium.CreateStub(const aMethod : TWndMethod; var aStub : Pointer); -begin - if (aStub = nil) then aStub := MakeObjectInstance(aMethod); -end; - -procedure TFMXChromium.FreeAndNilStub(var aStub : pointer); -begin - if (aStub <> nil) then - begin - FreeObjectInstance(aStub); - aStub := nil; - end; -end; - -procedure TFMXChromium.BrowserCompWndProc(var aMessage: TMessage); -var - TempHandled : boolean; -begin - try - TempHandled := False; - - if assigned(FOnBrowserCompMsg) then - FOnBrowserCompMsg(aMessage, TempHandled); - - if not(TempHandled) and - (FOldBrowserCompWndPrc <> nil) and - (FBrowserCompHWND <> 0) then - aMessage.Result := CallWindowProc(FOldBrowserCompWndPrc, - FBrowserCompHWND, - aMessage.Msg, - aMessage.wParam, - aMessage.lParam); - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.BrowserCompWndProc', e) then raise; - end; -end; - -procedure TFMXChromium.WidgetCompWndProc(var aMessage: TMessage); -var - TempHandled : boolean; -begin - try - TempHandled := False; - - if assigned(FOnWidgetCompMsg) then - FOnWidgetCompMsg(aMessage, TempHandled); - - if not(TempHandled) and - (FOldWidgetCompWndPrc <> nil) and - (FWidgetCompHWND <> 0) then - aMessage.Result := CallWindowProc(FOldWidgetCompWndPrc, - FWidgetCompHWND, - aMessage.Msg, - aMessage.wParam, - aMessage.lParam); - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.WidgetCompWndProc', e) then raise; - end; -end; - -procedure TFMXChromium.RenderCompWndProc(var aMessage: TMessage); -var - TempHandled : boolean; -begin - try - TempHandled := False; - - if assigned(FOnRenderCompMsg) then - FOnRenderCompMsg(aMessage, TempHandled); - - if not(TempHandled) and - (FOldRenderCompWndPrc <> nil) and - (FRenderCompHWND <> 0) then - aMessage.Result := CallWindowProc(FOldRenderCompWndPrc, - FRenderCompHWND, - aMessage.Msg, - aMessage.wParam, - aMessage.lParam); - except - on e : exception do - if CustomExceptionHandler('TFMXChromium.RenderCompWndProc', e) then raise; - end; -end; -{$ENDIF} - -procedure TFMXChromium.MoveFormTo(const x, y: Integer); -var - TempForm : TCustomForm; - {$IFDEF DELPHI17_UP} - TempRect : TRect; - {$ENDIF} -begin - TempForm := GetParentForm; - {$IFDEF DELPHI17_UP} - if (TempForm <> nil) then - begin - TempRect.Left := min(max(x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); - TempRect.Top := min(max(y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); - TempRect.Right := TempRect.Left + TempForm.Width - 1; - TempRect.Bottom := TempRect.Top + TempForm.Height - 1; - - TempForm.SetBounds(TempRect.Left, TempRect.Top, TempRect.Right - TempRect.Left + 1, TempRect.Bottom - TempRect.Top + 1); - end; - {$ELSE} - TempForm.SetBounds(x, y, TempForm.Width, TempForm.Height); - {$ENDIF} -end; - -procedure TFMXChromium.MoveFormBy(const x, y: Integer); -var - TempForm : TCustomForm; - {$IFDEF DELPHI17_UP} - TempRect : TRect; - {$ENDIF} -begin - TempForm := GetParentForm; - {$IFDEF DELPHI17_UP} - if (TempForm <> nil) then - begin - TempRect.Left := min(max(TempForm.Left + x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); - TempRect.Top := min(max(TempForm.Top + y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); - TempRect.Right := TempRect.Left + TempForm.Width - 1; - TempRect.Bottom := TempRect.Top + TempForm.Height - 1; - - TempForm.SetBounds(TempRect.Left, TempRect.Top, TempRect.Right - TempRect.Left + 1, TempRect.Bottom - TempRect.Top + 1); - end; - {$ELSE} - TempForm.SetBounds(TempForm.Left + x, TempForm.Top + y, TempForm.Width, TempForm.Height); - {$ENDIF} -end; - -procedure TFMXChromium.ResizeFormWidthTo(const x : Integer); -var - TempForm : TCustomForm; - TempX, TempDeltaX : integer; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - begin - TempX := max(x, 100); - TempDeltaX := TempForm.Width - TempForm.ClientWidth; - TempForm.Width := TempX + TempDeltaX; - end; -end; - -procedure TFMXChromium.ResizeFormHeightTo(const y : Integer); -var - TempForm : TCustomForm; - TempY, TempDeltaY : integer; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - begin - TempY := max(y, 100); - TempDeltaY := TempForm.Height - TempForm.ClientHeight; - TempForm.Height := TempY + TempDeltaY; - end; -end; - -procedure TFMXChromium.SetFormLeftTo(const x : Integer); -var - TempForm : TCustomForm; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - {$IFDEF DELPHI17_UP} - TempForm.Left := min(max(x, max(screen.DesktopLeft, 0)), screen.DesktopWidth - TempForm.Width); - {$ELSE} - TempForm.Left := x; - {$ENDIF} -end; - -procedure TFMXChromium.SetFormTopTo(const y : Integer); -var - TempForm : TCustomForm; -begin - TempForm := GetParentForm; - - if (TempForm <> nil) then - {$IFDEF DELPHI17_UP} - TempForm.Top := min(max(y, max(screen.DesktopTop, 0)), screen.DesktopHeight - TempForm.Height); - {$ELSE} - TempForm.Top := y; - {$ENDIF} -end; - -procedure TFMXChromium.WasResized; -begin - if Initialized then FBrowser.Host.WasResized; -end; - -procedure TFMXChromium.WasHidden(hidden: Boolean); -begin - if Initialized then FBrowser.Host.WasHidden(hidden); -end; - -procedure TFMXChromium.NotifyScreenInfoChanged; -begin - if Initialized then FBrowser.Host.NotifyScreenInfoChanged; -end; - -procedure TFMXChromium.NotifyMoveOrResizeStarted; -begin - if Initialized then FBrowser.Host.NotifyMoveOrResizeStarted; -end; - -procedure TFMXChromium.Invalidate(kind: TCefPaintElementType); -begin - if Initialized then - begin - if FIsOSR then - FBrowser.Host.Invalidate(kind) - else - if (RenderHandle <> 0) then - InvalidateRect(RenderHandle, nil, False) - else - InvalidateRect(WindowHandle, nil, False); - end; -end; - -procedure TFMXChromium.SendKeyEvent(const event: PCefKeyEvent); -begin - if Initialized then FBrowser.Host.SendKeyEvent(event); -end; - -procedure TFMXChromium.SendMouseClickEvent(const event : PCefMouseEvent; - kind : TCefMouseButtonType; - mouseUp : Boolean; - clickCount : Integer); -begin - if Initialized then FBrowser.Host.SendMouseClickEvent(event, kind, mouseUp, clickCount); -end; - -procedure TFMXChromium.SendMouseMoveEvent(const event: PCefMouseEvent; mouseLeave: Boolean); -begin - if Initialized then FBrowser.Host.SendMouseMoveEvent(event, mouseLeave); -end; - -procedure TFMXChromium.SendMouseWheelEvent(const event: PCefMouseEvent; deltaX, deltaY: Integer); -begin - if Initialized then FBrowser.Host.SendMouseWheelEvent(event, deltaX, deltaY); -end; - -procedure TFMXChromium.SendFocusEvent(setFocus: Boolean); -begin - if Initialized then FBrowser.Host.SendFocusEvent(setFocus); -end; - -procedure TFMXChromium.SendCaptureLostEvent; -begin - if Initialized then FBrowser.Host.SendCaptureLostEvent; -end; - -procedure TFMXChromium.SetFocus(focus: Boolean); -begin - if Initialized then FBrowser.Host.SetFocus(focus); -end; - -procedure TFMXChromium.SetAccessibilityState(accessibilityState: TCefState); -begin - if Initialized then FBrowser.Host.SetAccessibilityState(accessibilityState); -end; - -function TFMXChromium.SendProcessMessage(targetProcess: TCefProcessId; const ProcMessage: ICefProcessMessage): Boolean; -begin - Result := Initialized and FBrowser.SendProcessMessage(targetProcess, ProcMessage); -end; - -procedure TFMXChromium.DragTargetDragEnter(const dragData: ICefDragData; const event: PCefMouseEvent; allowedOps: TCefDragOperations); -begin - if Initialized then FBrowser.Host.DragTargetDragEnter(dragData, event, allowedOps); -end; - -procedure TFMXChromium.DragTargetDragOver(const event: PCefMouseEvent; allowedOps: TCefDragOperations); -begin - if Initialized then FBrowser.Host.DragTargetDragOver(event, allowedOps); -end; - -procedure TFMXChromium.DragTargetDragLeave; -begin - if Initialized then FBrowser.Host.DragTargetDragLeave; -end; - -procedure TFMXChromium.DragTargetDrop(event: PCefMouseEvent); -begin - if Initialized then FBrowser.Host.DragTargetDrop(event); -end; - -procedure TFMXChromium.DragSourceEndedAt(x, y: Integer; op: TCefDragOperation); -begin - if Initialized then FBrowser.Host.DragSourceEndedAt(x, y, op); -end; - -procedure TFMXChromium.DragSourceSystemDragEnded; -begin - if Initialized then FBrowser.Host.DragSourceSystemDragEnded; -end; - -end. diff --git a/windows/src/ext/cef4delphi/source/uceflazaruscocoa.pas b/windows/src/ext/cef4delphi/source/uceflazaruscocoa.pas new file mode 100644 index 0000000000000000000000000000000000000000..a5f88fb2c77d7f7fb54fae6f9fb4639b98f7eec9 --- /dev/null +++ b/windows/src/ext/cef4delphi/source/uceflazaruscocoa.pas @@ -0,0 +1,180 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2021 Salvador Diaz Fau. All rights reserved. +// +// Unit Author: Jonas Maebe +// + +unit uCEFLazarusCocoa; + + +{$mode objfpc}{$H+} +{$I cef.inc} + +{$IFDEF DARWIN} // $IFDEF MACOSX +{$ModeSwitch objectivec2} +{$ENDIF} + +interface + +uses +{$IFDEF DARWIN} // $IFDEF MACOSX + CocoaAll, CocoaInt, Cocoa_Extra, +{$ENDIF} + Classes, SysUtils, ctypes; + +{$IFDEF DARWIN} // $IFDEF MACOSX +type + CrAppProtocol = objcprotocol + function isHandlingSendEvent: LCLObjCBoolean; message 'isHandlingSendEvent'; + end; + + CrAppControlProtocol = objcprotocol(CrAppProtocol) + procedure setHandlingSendEvent(handlingSendEvent: LCLObjCBoolean); message 'setHandlingSendEvent:'; + end; + + TCrCocoaApplication = objcclass(TCocoaApplication, CrAppControlProtocol) + public + function isHandlingSendEvent: LCLObjCBoolean; + procedure setHandlingSendEvent(handlingSendEvent: LCLObjCBoolean); + procedure sendEvent(theEvent: NSEvent); override; + + procedure terminate(sender: id); override; + private + fHandlingSendEvent: LCLObjCBoolean; + end; + + procedure AddCrDelegate; + +var LastMacOsKeyDownCode: cushort; +{$ENDIF} + +implementation + +{$IFDEF DARWIN} // $IFDEF MACOSX +uses + Forms; + +type + TChromeAppDelegateIntercept = objcclass(NSProxy) + procedure tryToTerminateApplication(app: NSApplication); message 'tryToTerminateApplication:'; + function initWithDelegate(delegate: id): id; message 'initWithDelegate:'; + procedure dealloc; override; + function respondsToSelector(aSelector: SEL): LCLObjCBoolean; override; + procedure forwardInvocation (invocation: NSInvocation); override; + function methodSignatureForSelector (sel_: SEL): NSMethodSignature; override; + + private + fLCLDelegate: id; + end; + +procedure TChromeAppDelegateIntercept.tryToTerminateApplication(app: NSApplication); + begin + Application.MainForm.Close; + end; + + +function TChromeAppDelegateIntercept.initWithDelegate(delegate: id): id; + begin + fLCLDelegate:=delegate; + fLCLDelegate.retain; + result:=self; + end; + + +procedure TChromeAppDelegateIntercept.dealloc; +begin + fLCLDelegate.release; + fLCLDelegate:=nil; + inherited dealloc; +end; + + +function TChromeAppDelegateIntercept.respondsToSelector(aSelector: SEL): LCLObjCBoolean; +begin + if aSelector = objcselector('tryToTerminateApplication:') then + result:=true + else if assigned(fLCLDelegate) then + result:=fLCLDelegate.respondsToSelector(aSelector) + else + result:=false; +end; + + +procedure TChromeAppDelegateIntercept.forwardInvocation(invocation: NSInvocation); +begin + { this only gets called in case we can't handle the invocation } + if assigned(fLCLDelegate) then + begin + invocation.setTarget(fLCLDelegate); + invocation.invoke; + end; +end; + + +function TChromeAppDelegateIntercept.methodSignatureForSelector(sel_: SEL): NSMethodSignature; +begin + { if the original delegate can handle it, send it there. Otherwise we try to handle it } + if assigned(fLCLDelegate) then + result:=fLCLDelegate.methodSignatureForSelector(sel_); + if not assigned(result) then + result:=inherited; +end; + + +procedure AddCrDelegate; +var + delegate: id; +begin + delegate := TChromeAppDelegateIntercept.alloc.initWithDelegate(NSApp.delegate); + NSApp.setDelegate(delegate); +end; + + +function TCrCocoaApplication.isHandlingSendEvent: LCLObjCBoolean; +begin + result:=fHandlingSendEvent; +end; + +procedure TCrCocoaApplication.setHandlingSendEvent(handlingSendEvent: LCLObjCBoolean); +begin + fHandlingSendEvent:=handlingSendEvent; +end; + +procedure TCrCocoaApplication.sendEvent(theEvent: NSEvent); +var + CurrentHandling: LCLObjCBoolean; +begin + CurrentHandling:=isHandlingSendEvent; + setHandlingSendEvent(true); + if (theEvent.type_ = NSKeyDown) + then begin + LastMacOsKeyDownCode := theEvent.keyCode; + end; + inherited; + LastMacOsKeyDownCode:=0; + setHandlingSendEvent(CurrentHandling); +end; + +procedure TCrCocoaApplication.terminate(sender: id); +var + AppDelegate: TChromeAppDelegateIntercept; +begin + AppDelegate:=TChromeAppDelegateIntercept(NSApp.delegate); + AppDelegate.tryToTerminateApplication(CocoaWidgetSet.NSApp); +end; + +{$ENDIF} + +end. + diff --git a/windows/src/global/delphi/chromium/Keyman.System.CEFManager.pas b/windows/src/global/delphi/chromium/Keyman.System.CEFManager.pas index ff7567ad4a93a37512bd18ce3ddc1c3dae556e65..0d13f885a03aaccddff1596e956a9b26f592478f 100644 --- a/windows/src/global/delphi/chromium/Keyman.System.CEFManager.pas +++ b/windows/src/global/delphi/chromium/Keyman.System.CEFManager.pas @@ -67,6 +67,7 @@ uses uCEFTypes; procedure GlobalCEFApp_ProcessMessageReceived(const browser : ICefBrowser; + const frame : ICefFrame; sourceProcess : TCefProcessId; const message : ICefProcessMessage; var aHandled : boolean); forward; @@ -110,9 +111,8 @@ begin GlobalCEFApp.LocalesDirPath := GlobalCEFApp.FrameworkDirPath + '\locales'; GlobalCEFApp.EnableGPU := True; // Enable hardware acceleration GlobalCEFApp.cache := TKeymanPaths.CEFDataPath('cache'); - GlobalCEFApp.cookies := TKeymanPaths.CEFDataPath('cookies'); GlobalCEFApp.UserDataPath := TKeymanPaths.CEFDataPath('userdata'); - GlobalCEFApp.UserAgent := 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36 (TIKE/'+SKeymanVersion+')'; + GlobalCEFApp.UserAgent := 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36 (Keyman/'+SKeymanVersion+')'; GlobalCEFApp.OnProcessMessageReceived := GlobalCEFApp_ProcessMessageReceived; @@ -245,7 +245,7 @@ begin FWindows.Remove(cef); end; -procedure DOMVisitor_GetWindowSize(const browser: ICefBrowser; const document: ICefDomDocument); +procedure DOMVisitor_GetWindowSize(const browser : ICefBrowser; const frame: ICefFrame; const document: ICefDomDocument); const NODE_ID = 'size'; var @@ -265,12 +265,13 @@ begin msg.ArgumentList.SetInt(0, node.ElementBounds.width); msg.ArgumentList.SetInt(1, node.ElementBounds.height); CefLog('CEFManager', 1, CEF_LOG_SEVERITY_ERROR, 'Sending message '+msg.Name+', '+IntToStr(node.ElementBounds.width)+', '+IntToStr(node.ElementBounds.height)); - browser.SendProcessMessage(PID_BROWSER, msg); + browser.MainFrame.SendProcessMessage(PID_BROWSER, msg); end; end; end; procedure GlobalCEFApp_ProcessMessageReceived(const browser : ICefBrowser; + const frame : ICefFrame; sourceProcess : TCefProcessId; const message : ICefProcessMessage; var aHandled : boolean); @@ -290,7 +291,7 @@ begin if (TempFrame <> nil) then begin - TempVisitor := TCefFastDomVisitor2.Create(browser, DOMVisitor_GetWindowSize); + TempVisitor := TCefFastDomVisitor2.Create(browser, browser.MainFrame, DOMVisitor_GetWindowSize); TempFrame.VisitDom(TempVisitor); end;