TCEFApplication and TCEFApplicationCore

TCEFApplicationCore is used to simplify the CEF initialization and finalization.

TCEFApplication inherits from TCEFApplicationCore and it was created to avoid an issue with the CEF subprocesses and MS Office.

Most demos initializate a global variable called GlobalCEFApp using TCEFApplication but the demos using a different executable for the subprocesses will use TCEFApplicationCore in the subprocesses.

GlobalCEFApp is usually created before the main application form and destroyed when all the forms are already closed. When an application uses a different executable for the subprocesses the GlobalCEFApp can be created at any moment.

Most of the properties, events and methods in TCEFApplicationCore correspond to methods and callbacks in these CEF classes : CefApp, CefBrowserProcessHandler, CefRenderProcessHandler, CefResourceBundleHandler and CefLoadHandler.

Some properties are used to assign values to the CEF settings and to enable some CEF command line switches when it's initialized. This means that those properties must be set before initializing CEF and all the changes made to those properties after initialization are ignored.

The command line switches can be used to enable or disable many Chromium features available as configuration flags in the that browser.

Procedures and functions in TCEFApplicationCore

procedure TCEFApplicationCore.AddCustomCommandLine(const aCommandLine : string; const aValue : string = '');

Used to add any command line switch that is not available as a TCEFApplicationCore property.

function TCEFApplicationCore.StartMainProcess : boolean;

Used to initialize CEF in the main browser process. In case CEF is configured to used the same executable for all processes then all processes must call this function.

CEF can only be initialized once per process. This is a CEF feature and there's no workaround.

function TCEFApplicationCore.StartSubProcess : boolean;

Used to initialize CEF in the subprocesses. This function can only be used when CEF is configured to use a different executable for the subprocesses.

procedure TCEFApplicationCore.InitLibLocationFromArgs;

This procedure is only available in MacOS to read some configuration settings from the command line arguments.

procedure TCEFApplicationCore.DoMessageLoopWork;

This procedure is used to perform a single iteration of CEF message loop processing when the multithreaded message loop is disabled and the external message pump is enabled.

Read the code comments about cef_do_message_loop_work for more details.

procedure TCEFApplicationCore.RunMessageLoop;

This procedure is a replacement for the main application message loop when the multithreaded message loop and the external message pump are disabled.

Read the code comments about cef_run_message_loop for more details.

procedure TCEFApplicationCore.QuitMessageLoop;

Procedure used to stop the message loop started by RunMessageLoop when the multithreaded message loop and the external message pump are disabled.

Read the code comments about cef_quit_message_loop for more details.

procedure TCEFApplicationCore.UpdateDeviceScaleFactor;

This procedure is used to update the device scale factor property value in this class. That value is only used in OSR mode.

procedure TCEFApplicationCore.Internal_*

All the procedures and function that start with Internal_ are meant to be used by the CEF handlers and they should never be used by applications.

Properties used to populate TCEFSettings in TCEFApplicationCore

The following properties are used to populate the TCefSettings record when CEF is initialized and they should be set before the StartMainProcess/StartSubProcess calls.

Read the code comments about cef_settings_t for more information about each of them.

  • AcceptLanguageList
  • ApplicationClientID
  • BackgroundColor
  • BrowserSubprocessPath
  • Cache
  • ChromeRuntime
  • CommandLineArgsDisabled
  • CookieableSchemesList
  • CookieableSchemesExcludeDefaults
  • ExternalMessagePump
  • FrameworkDirPath
  • IgnoreCertificateErrors
  • JavaScriptFlags
  • Locale
  • LocalesDirPath
  • LogFile
  • LogSeverity
  • MainBundlePath
  • MultiThreadedMessageLoop
  • NoSandbox
  • PackLoadingDisabled
  • PersistSessionCookies
  • PersistUserPreferences
  • RemoteDebuggingPort
  • ResourcesDirPath
  • RootCache
  • UncaughtExceptionStackSize
  • UserAgent
  • UserAgentProduct
  • UserDataPath
  • WindowlessRenderingEnabled

Properties used to add CEF command line switches in TCEFApplicationCore

The following properties add some of the most popular command line switches to CEF when it's initialized and they should be set before the StartMainProcess/StartSubProcess calls.

The command line switches may change with every Chromium version.

These links have the updated list of switches :

These are the the equivalent switches for the properties :

AllowFileAccessFromFiles--allow-file-access-from-files
AllowRunningInsecureContent--allow-running-insecure-content
AllowUniversalAccessFromFileUrls--allow-universal-access-from-files
AutoplayPolicy--autoplay-policy
BlinkSettings--blink-settings
DefaultEncoding--default-encoding
DevToolsProtocolLogFile--devtools-protocol-log-file
DisableBackgroundNetworking--disable-background-networking
DisableBlinkFeatures--disable-blink-features
DisableChromeLoginPrompt--disable-chrome-login-prompt
DisableExtensions--disable-extensions
DisableFeatures--disable-features
DisableImageLoading--disable-image-loading
DisableJavascript--disable-javascript
DisableJavascriptAccessClipboard--disable-javascript-access-clipboard
DisableJavascriptCloseWindows--disable-javascript-close-windows
DisableJavascriptDomPaste--disable-javascript-dom-paste
DisableNewBrowserInfoTimeout--disable-new-browser-info-timeout
DisablePDFExtension--disable-pdf-extension
DisablePlugins--disable-plugins
DisableReadingFromCanvas--disable-reading-from-canvas
DisableSafeBrowsing--safebrowsing-disable-auto-update
DisableSiteIsolationTrials--disable-site-isolation-trials
DisableSpellChecking--disable-spell-checking
DisableTabToLinks--disable-tab-to-links
DisableTextAreaResize--disable-text-area-resize
DisableWebSecurity--disable-web-security
DisableZygote--no-zygote
EnableBlinkFeatures--enable-blink-features
EnableFeatures--enable-features
EnableGPU--enable-gpu-plugin
EnableMediaStream--enable-media-stream
EnablePrintPreview--enable-print-preview
EnableProfanityFilter--enable-profanity-filter
EnableSpeechInput--enable-speech-input
EnableUsermediaScreenCapturing--enable-usermedia-screen-capturing
FastUnload--enable-fast-unload
ForcedDeviceScaleFactor--device-scale-factor
ForceFieldTrialParams--force-fieldtrial-params
ForceFieldTrials--force-fieldtrials
HyperlinkAuditing--no-pings
ImageShrinkStandaloneToFit--image-shrink-standalone-to-fit
MetricsRecordingOnly--metrics-recording-only
MuteAudio--mute-audio
OverrideSpellCheckLang--override-spell-check-lang
PluginPolicy--plugin-policy
SingleProcess--single-process
SitePerProcess--site-per-process
SmoothScrolling--enable-smooth-scrolling
TouchEvents--touch-events
UseFakeUIForMediaStream--use-fake-ui-for-media-stream
UseMockKeyChain--use-mock-keychain

See the code in TcefApplicationCore.AddCustomCommandLineSwitches to know how each property is translated into one or more switches.

Custom properties in TCEFApplicationCore

ApiHashCommitCalls cef_api_hash to get the commit hash.
ApiHashPlatformCalls cef_api_hash to get the platform hash.
ApiHashUniversalCalls cef_api_hash to get the universal hash.
AvailableSystemMemoryCalculates the available memory in Windows.
CheckCEFFilesChecks if the CEF binaries are present and the DLL version.
ChildProcessesCountReturns the number of CEF subprocesses running at that moment.
ChromeBuildReturns the build version information from Chromium.
ChromeElfPathReturns the path to chrome_elf.dll.
ChromeMajorVerReturns the major version information from Chromium.
ChromeMinorVerReturns the minor version information from Chromium.
ChromeReleaseReturns the release version information from Chromium.
ChromeVersionReturns the full version information from Chromium.
DeleteCacheUsed to delete all the cache files before CEF is initialized.
DeleteCookiesUsed to delete all the cookies before CEF is initialized.
DeviceScaleFactorReturns the device scale factor used in OSR mode.
DisableRequestHandlingForTestingUsed to bypass request handling in CEF to facilitate debugging of network-related issues.
EnableHighDPISupportUsed to support high DPI monitors. Calls cef_enable_highdpi_support when CEF is initialized.
GlobalContextInitializedSet to True when the global context is initialized and the application can start creating web browsers.
LastErrorMessageLast error message that is usually shown when CEF finds a problem at initialization.
LibCefPathPath to libcef.dll or libcef.so
LibCefVersionComplete libcef version information.
LibLoadedSet to true when TCEFApplicationCore has loaded the CEF libraries.
LocalesRequiredList of locale files that will be checked with CheckCEFFiles.
LogProcessInfoAdd a debug log information line when the CEF libraries are loaded.
MissingBinariesExceptionRaise an exception when the CEF binaries check fails.
MissingLibFilesList of missing CEF library files.
MustCreateBrowserProcessHandlerForce the creation of ICefBrowserProcessHandler.
MustCreateLoadHandlerForce the creation of ICefLoadHandler.
MustCreateRenderProcessHandlerForce the creation of ICefRenderProcessHandler.
MustCreateResourceBundleHandlerForce the creation of ICefResourceBundleHandler.
MustFreeLibrarySet to true to free the library handle when TCEFApplicationCore is destroyed.
OsmodalLoopSet to true when the application receives WM_ENTERMENULOOP and set to false when the application receives WM_EXITMENULOOP.
ProcessTypeCEF process type currently running.
ReRaiseExceptionsSet to true to raise all exceptions.
SetCurrentDirUsed to set the current directory when the CEF libraries are loaded. This is required if the application is launched from a different application.
ShowMessageDlgSet to true when you need to use a showmessage dialog to show the error messages.
StatusReturns the TCEFApplicationCore initialization status.
SystemMemoryLoadMemory load in Windows.
TotalSystemMemoryTotal system memory in Windows.
UsedMemoryTotal used memory by all CEF processes.
WidevinePathPath to the Widevine CDM plugin.
WindowsSandboxInfoPointer to the sandbox info. Currently unused in Delphi and Lazarus.
XDisplayPointer to XDisplay in Linux.

ICefApp events in TCEFApplicationCore

Read this page and the code comments in this file for all the details about ICefApp.

OnRegCustomSchemesCorresponds to CefApp.OnRegisterCustomSchemes. Provides an opportunity to register custom schemes.

ICefBrowserProcessHandler events in TCEFApplicationCore

Read this page and the code comments in this file for all the details about ICefBrowserProcessHandler.

OnContextInitializedTriggered on the browser process UI thread immediately after the CEF context has been initialized.
OnBeforeChildProcessLaunchTriggered before a child process is launched.
OnScheduleMessagePumpWorkTriggered when work has been scheduled for the browser process.
OnGetDefaultClientReturn the default client for use with a newly created browser window.

ICefBrowserProcessHandler events in TCEFApplicationCore

Read this page and the code comments in this file for all the details about ICefResourceBundleHandler.

OnGetLocalizedStringTriggered to retrieve a localized translation for the specified string_id.
OnGetDataResourceTriggered to retrieve data for the specified scale independent resource_id.
OnGetDataResourceForScaleTriggered to retrieve data for the specified resource_id nearest the scale factor scale_factor.

ICefRenderProcessHandler events in TCEFApplicationCore

Read this page and the code comments in this file for all the details about ICefRenderProcessHandler.

All these events are triggered on the render process only.

OnWebKitInitializedTriggered after WebKit has been initialized.
OnBrowserCreatedTriggered after a browser has been created.
OnBrowserDestroyedTriggered before a browser is destroyed.
OnContextCreatedTriggered immediately after the V8 context for a frame has been created.
OnContextReleasedTriggered immediately before the V8 context for a frame is released.
OnUncaughtExceptionTriggered for global uncaught exceptions in a frame.
OnFocusedNodeChangedTriggered when a new node in the the browser gets focus.
OnProcessMessageReceivedTriggered when a new message is received from a different process.

ICefRegisterCDMCallback events in TCEFApplicationCore

Read this page and the code comments in this file for all the details about ICefRegisterCDMCallback.

OnCDMRegistrationCompleteTriggered when CDM registration is complete.

ICefLoadHandler events in TCEFApplicationCore

Read this page and the code comments in this file for all the details about ICefLoadHandler.

All these events are triggered on the render process only.

OnLoadingStateChangeTriggered when the loading state has changed.
OnLoadStartTriggered after a navigation has been committed and before the browser begins loading contents in the frame.
OnLoadEndTriggered when the browser is done loading a frame.
OnLoadErrorTriggered when a navigation fails or is canceled.

TCEFApplication properties

DestroyApplicationObjectDestroy the Application object before initializing subprocesses.
DestroyAppWindowsDestroy the handles created by the Application object before initializing subprocesses.

TCEFApplication procedures

Procedure AddContextInitializedHandler(AHandler: TnotifyEvent)

Add a handler that will be alerted when the global context is initialized. Only available in Lazarus.

Procedure RemoveContextInitializedHandler(AHandler: TnotifyEvent)

Remove a handler from the handler list that will be alerted when the global context is initialized. Only available in Lazarus.

Cookie usage

By browsing our site you agree to our use of cookies. You will only see this message once.
Find out more
Ok