Click or drag to resize

Cef Class

Version 83.4.2
Global CEF methods are exposed through this class. e.g. CefInitalize maps to Cef.Initialize CEF API Doc https://magpcss.org/ceforum/apidocs3/projects/(default)/(_globals).html This class cannot be inherited.
Inheritance Hierarchy
SystemObject
  CefSharpCef

Namespace:  CefSharp
Assembly:  CefSharp.Core (in CefSharp.Core.dll) Version: 83.4.2.0
Syntax
public sealed class Cef

The Cef type exposes the following members.

Constructors
  NameDescription
Public methodCef
Initializes a new instance of the Cef class
Top
Properties
  NameDescription
Public propertyStatic memberCefCommitHash
Gets a value that indicates the Git Hash for CEF version currently being used.
Public propertyStatic memberCefSharpVersion
Gets a value that indicates the version of CefSharp currently being used.
Public propertyStatic memberCefVersion
Gets a value that indicates the CEF version currently being used.
Public propertyStatic memberChromiumVersion
Gets a value that indicates the Chromium version currently being used.
Public propertyStatic memberCrashReportingEnabled
Crash reporting is configured using an INI-style config file named crash_reporter.cfg. This file must be placed next to the main application executable. File contents are as follows: # Comments start with a hash character and must be on their own line. [Config] ProductName=<Value of the "prod" crash key; defaults to "cef"> ProductVersion=<Value of the "ver" crash key; defaults to the CEF version> AppName=<Windows only; App-specific folder name component for storing crash information; default to "CEF"> ExternalHandler=<Windows only; Name of the external handler exe to use instead of re-launching the main exe; default to empty> ServerURL=<crash server URL; default to empty> RateLimitEnabled=<True if uploads should be rate limited; default to true> MaxUploadsPerDay=<Max uploads per 24 hours, used if rate limit is enabled; default to 5> MaxDatabaseSizeInMb=<Total crash report disk usage greater than this value will cause older reports to be deleted; default to 20> MaxDatabaseAgeInDays=<Crash reports older than this value will be deleted; default to 5> [CrashKeys] my_key1=<small|medium|large> my_key2=<small|medium|large> Config section: If "ProductName" and/or "ProductVersion" are set then the specified values will be included in the crash dump metadata. If "AppName" is set on Windows then crash report information (metrics, database and dumps) will be stored locally on disk under the "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. If "ExternalHandler" is set on Windows then the specified exe will be launched as the crashpad-handler instead of re-launching the main process exe. The value can be an absolute path or a path relative to the main exe directory. If "ServerURL" is set then crashes will be uploaded as a multi-part POST request to the specified URL. Otherwise, reports will only be stored locally on disk. If "RateLimitEnabled" is set to true then crash report uploads will be rate limited as follows: 1. If "MaxUploadsPerDay" is set to a positive value then at most the specified number of crashes will be uploaded in each 24 hour period. 2. If crash upload fails due to a network or server error then an incremental backoff delay up to a maximum of 24 hours will be applied for retries. 3. If a backoff delay is applied and "MaxUploadsPerDay" is > 1 then the "MaxUploadsPerDay" value will be reduced to 1 until the client is restarted. This helps to avoid an upload flood when the network or server error is resolved. If "MaxDatabaseSizeInMb" is set to a positive value then crash report storage on disk will be limited to that size in megabytes. For example, on Windows each dump is about 600KB so a "MaxDatabaseSizeInMb" value of 20 equates to about 34 crash reports stored on disk. If "MaxDatabaseAgeInDays" is set to a positive value then crash reports older than the specified age in days will be deleted. CrashKeys section: Any number of crash keys can be specified for use by the application. Crash key values will be truncated based on the specified size (small = 63 bytes, medium = 252 bytes, large = 1008 bytes). The value of crash keys can be set from any thread or process using the Cef.SetCrashKeyValue function. These key/value pairs will be sent to the crash server along with the crash dump file. Medium and large values will be chunked for submission. For example, if your key is named "mykey" then the value will be broken into ordered chunks and submitted using keys named "mykey-1", "mykey-2", etc.
Public propertyStatic memberFileThreadTaskFactory
Public propertyStatic memberIOThreadTaskFactory
Public propertyStatic memberIsInitialized
Gets a value that indicates whether CefSharp is initialized.
Public propertyStatic memberUIThreadTaskFactory
Top
Methods
  NameDescription
Public methodStatic memberAddCrossOriginWhitelistEntry
Add an entry to the cross-origin whitelist.
Public methodStatic memberAddDisposable
Public methodStatic memberClearCrossOriginWhitelist
Remove all entries from the cross-origin access whitelist.
Public methodStatic memberClearSchemeHandlerFactories
Clear all scheme handler factories registered with the global request context. Returns false on error. This function may be called on any thread in the browser process. Using this function is equivalent to calling Cef.GetGlobalRequestContext().ClearSchemeHandlerFactories().
Public methodStatic memberColorSetARGB
Helper function (wrapper around the CefColorSetARGB macro) which combines the 4 color components into an uint32 for use with BackgroundColor property
Public methodStatic memberCurrentlyOnThread
Returns true if called on the specified CEF thread.
Public methodStatic memberDoMessageLoopWork
Perform a single iteration of CEF message loop processing.This function is provided for cases where the CEF message loop must be integrated into an existing application message loop. Use of this function is not recommended for most users; use CefSettings.MultiThreadedMessageLoop if possible (the deault). When using this function care must be taken to balance performance against excessive CPU usage. It is recommended to enable the CefSettings.ExternalMessagePump option when using this function so that IBrowserProcessHandler.OnScheduleMessagePumpWork() callbacks can facilitate the scheduling process. This function should only be called on the main application thread and only if Cef.Initialize() is called with a CefSettings.MultiThreadedMessageLoop value of false. This function will not block.
Public methodStatic memberEnableHighDPISupport
Call during process startup to enable High-DPI support on Windows 7 or newer. Older versions of Windows should be left DPI-unaware because they do not support DirectWrite and GDI fonts are kerned very badly.
Public methodStatic memberEnableWaitForBrowsersToClose
WaitForBrowsersToClose is not enabled by default, call this method before Cef.Initialize to enable. If you aren't calling Cef.Initialize explicitly then this should be called before creating your first ChromiumWebBrowser instance.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodStatic memberExecuteProcess
This function should be called from the application entry point function to execute a secondary process. It can be used to run secondary processes from the browser client executable (default behavior) or from a separate executable specified by the CefSettings.browser_subprocess_path value. If called for the browser process (identified by no "type" command-line value) it will return immediately with a value of -1. If called for a recognized secondary process it will block until the process should exit and then return the process exit code. The |application| parameter may be empty. The |windows_sandbox_info| parameter is only used on Windows and may be NULL (see cef_sandbox_win.h for details).
Public methodStatic memberGetGlobalCookieManager
Returns the global cookie manager. By default data will be stored at CefSettings.CachePath if specified or in memory otherwise. Using this method is equivalent to calling Cef.GetGlobalRequestContext().GetCookieManager() The cookie managers storage is created in an async fashion, whilst this method may return a cookie manager instance, there may be a short delay before you can Get/Write cookies. To be sure the cookie manager has been initialized use one of the following - Use the GetGlobalCookieManager(ICompletionCallback) overload and access the ICookieManager after ICompletionCallback.OnComplete has been called. - Access the ICookieManager instance in IBrowserProcessHandler.OnContextInitialized. - Use the ChromiumWebBrowser BrowserInitialized (OffScreen) or IsBrowserInitializedChanged (WinForms/WPF) events.
Public methodStatic memberGetGlobalCookieManager(ICompletionCallback)
Returns the global cookie manager. By default data will be stored at CefSettings.CachePath if specified or in memory otherwise. Using this method is equivalent to calling Cef.GetGlobalRequestContext().GetCookieManager() The cookie managers storage is created in an async fashion, whilst this method may return a cookie manager instance, there may be a short delay before you can Get/Write cookies. To be sure the cookie manager has been initialized use one of the following - Access the ICookieManager after ICompletionCallback.OnComplete has been called - Access the ICookieManager instance in IBrowserProcessHandler.OnContextInitialized. - Use the ChromiumWebBrowser BrowserInitialized (OffScreen) or IsBrowserInitializedChanged (WinForms/WPF) events.
Public methodStatic memberGetGlobalRequestContext
Gets the Global Request Context. Make sure to Dispose of this object when finished. The earlier possible place to access the IRequestContext is in IBrowserProcessHandler.OnContextInitialized. Alternative use the ChromiumWebBrowser BrowserInitialized (OffScreen) or IsBrowserInitializedChanged (WinForms/WPF) events.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodStatic memberGetMimeType
Returns the mime type for the specified file extension or an empty string if unknown.
Public methodStatic memberGetPlugins
Async returns a list containing Plugin Information (Wrapper around CefVisitWebPluginInfo)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberInitialize(CefSettingsBase)
Initializes CefSharp with user-provided settings. It's important to note that Initialize and Shutdown MUST be called on your main applicaiton thread (Typically the UI thead). If you call them on different threads, your application will hang. See the documentation for Cef.Shutdown() for more details.
Public methodStatic memberInitialize(CefSettingsBase, Boolean, IApp)
Initializes CefSharp with user-provided settings. It's important to note that Initialize/Shutdown MUST be called on your main applicaiton thread (Typically the UI thead). If you call them on different threads, your application will hang. See the documentation for Cef.Shutdown() for more details.
Public methodStatic memberInitialize(CefSettingsBase, Boolean, IBrowserProcessHandler)
Initializes CefSharp with user-provided settings. It's important to note that Initialize/Shutdown MUST be called on your main applicaiton thread (Typically the UI thead). If you call them on different threads, your application will hang. See the documentation for Cef.Shutdown() for more details.
Public methodStatic memberPreShutdown
Called prior to calling Cef.Shutdown, this diposes of any remaning ChromiumWebBrowser instances. In WPF this is used from Dispatcher.ShutdownStarted to release the unmanaged resources held by the ChromiumWebBrowser instances. Generally speaking you don't need to call this yourself.
Public methodStatic memberQuitMessageLoop
Quit the CEF message loop that was started by calling Cef.RunMessageLoop(). This function should only be called on the main application thread and only if Cef.RunMessageLoop() was used.
Public methodStatic memberRefreshWebPlugins
Cause the plugin list to refresh the next time it is accessed regardless of whether it has already been loaded.
Public methodStatic memberRegisterWidevineCdm
Register the Widevine CDM plugin. The client application is responsible for downloading an appropriate platform-specific CDM binary distribution from Google, extracting the contents, and building the required directory structure on the local machine. The StartDownload(String) method class can be used to implement this functionality in CefSharp. Contact Google via https://www.widevine.com/contact.html for details on CDM download. path is a directory that must contain the following files: 1. manifest.json file from the CDM binary distribution (see below). 2. widevinecdm file from the CDM binary distribution (e.g. widevinecdm.dll on Windows). 3. widevidecdmadapter file from the CEF binary distribution (e.g. widevinecdmadapter.dll on Windows). If any of these files are missing or if the manifest file has incorrect contents the registration will fail and callback will receive an ErrorCode value of IncorrectContents. The manifest.json file must contain the following keys: A. "os": Supported OS (e.g. "mac", "win" or "linux"). B. "arch": Supported architecture (e.g. "ia32" or "x64"). C. "x-cdm-module-versions": Module API version (e.g. "4"). D. "x-cdm-interface-versions": Interface API version (e.g. "8"). E. "x-cdm-host-versions": Host API version (e.g. "8"). F. "version": CDM version (e.g. "1.4.8.903"). G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1"). A through E are used to verify compatibility with the current Chromium version. If the CDM is not compatible the registration will fail and callback will receive an ErrorCode value of Incompatible. If registration is not supported at the time that Cef.RegisterWidevineCdm() is called then callback will receive an ErrorCode value of NotSupported.
Public methodStatic memberRegisterWidevineCdmAsync
Register the Widevine CDM plugin. See RegisterWidevineCdm(String, IRegisterCdmCallback) for more details.
Public methodStatic memberRemoveCrossOriginWhitelistEntry
Remove entry from cross-origin whitelist
Public methodStatic memberRemoveDisposable
Public methodStatic memberRunMessageLoop
Run the CEF message loop. Use this function instead of an application- provided message loop to get the best balance between performance and CPU usage. This function should only be called on the main application thread and only if Cef.Initialize() is called with a CefSettings.MultiThreadedMessageLoop value of false. This function will block until a quit message is received by the system.
Public methodStatic memberSetCrashKeyValue
Sets or clears a specific key-value pair from the crash metadata.
Public methodStatic memberShutdown
Shuts down CefSharp and the underlying CEF infrastructure. This method is safe to call multiple times; it will only shut down CEF on the first call (all subsequent calls will be ignored). This method should be called on the main application thread to shut down the CEF browser process before the application exits. If you are Using CefSharp.OffScreen then you must call this explicitly before your application exits or it will hang. This method must be called on the same thread as Initialize. If you don't call Shutdown explicitly then CefSharp.Wpf and CefSharp.WinForms versions will do their best to call Shutdown for you, if your application is having trouble closing then call thus explicitly.
Public methodStatic memberShutdownWithoutChecks
This method should only be used by advanced users, if you're unsure then use Cef.Shutdown(). This function should be called on the main application thread to shut down the CEF browser process before the application exits. This method simply obtains a lock and calls the native CefShutdown method, only IsInitialized is checked. All ChromiumWebBrowser instances MUST be Disposed of before calling this method. If calling this method results in a crash or hangs then you're likely hanging on to some unmanaged resources or haven't closed all of your browser instances
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberUnregisterInternalWebPlugin
Unregister an internal plugin. This may be undone the next time RefreshWebPlugins() is called.
Public methodStatic memberVisitWebPluginInfo
Visit web plugin information. Can be called on any thread in the browser process.
Public methodStatic memberWaitForBrowsersToClose
Helper method to ensure all ChromiumWebBrowser instances have been closed/disposed, should be called before Cef.Shutdown. Disposes all remaning ChromiumWebBrowser instances then waits for CEF to release it's remaning CefBrowser instances. Finally a small delay of 50ms to allow for CEF to finish it's cleanup. Should only be called when MultiThreadedMessageLoop = true; (Hasn't been tested when when CEF integrates into main message loop).
Top
See Also