Click or drag to resize

CefRuntime Methods

The CefRuntime type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAddCrossOriginWhitelistEntry
Add an entry to the cross-origin access whitelist. The same-origin policy restricts how scripts hosted from different origins (scheme + domain + port) can communicate. By default, scripts can only access resources with the same origin. Scripts hosted on the HTTP and HTTPS schemes (but no other schemes) can use the "Access-Control-Allow-Origin" header to allow cross-origin requests. For example, https://source.example.com can make XMLHttpRequest requests on http://target.example.com if the http://target.example.com request returns an "Access-Control-Allow-Origin: https://source.example.com" response header. Scripts in separate frames or iframes and hosted from the same protocol and domain suffix can execute cross-origin JavaScript if both pages set the document.domain value to the same domain suffix. For example, scheme://foo.example.com and scheme://bar.example.com can communicate using JavaScript if both domains set document.domain="example.com". This method is used to allow access to origins that would otherwise violate the same-origin policy. Scripts hosted underneath the fully qualified |source_origin| URL (like http://www.example.com) will be allowed access to all resources hosted on the specified |target_protocol| and |target_domain|. If |target_domain| is non-empty and |allow_target_subdomains| if false only exact domain matches will be allowed. If |target_domain| contains a top- level domain component (like "example.com") and |allow_target_subdomains| is true sub-domain matches will be allowed. If |target_domain| is empty and |allow_target_subdomains| if true all domains and IP addresses will be allowed. This method cannot be used to bypass the restrictions on local or display isolated schemes. See the comments on CefRegisterCustomScheme for more information. This function may be called on any thread. Returns false if |source_origin| is invalid or the whitelist cannot be accessed.
Public methodStatic memberBase64Decode
Decodes the base64 encoded string |data|. The returned value will be NULL if the decoding fails.
Public methodStatic memberBase64Encode(Byte)
Public methodStatic memberBase64Encode(Void*, Int32)
Encodes |data| as a base64 string.
Public methodStatic memberBase64Encode(Byte, Int32, Int32)
Public methodStatic memberCefRegisterWidevineCdm
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 CefBrowserHost::StartDownload method and CefZipArchive class can be used to implement this functionality in CEF. 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 on Windows, libwidevinecdm.dylib on OS X, libwidevinecdm.so on Linux). 3. widevidecdmadapter file from the CEF binary distribution (e.g. widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X, libwidevinecdmadapter.so on Linux). If any of these files are missing or if the manifest file has incorrect contents the registration will fail and |callback| will receive a |result| value of CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS. 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 a |result| value of CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE. |callback| will be executed asynchronously once registration is complete. On Linux this function must be called before CefInitialize() and the registration cannot be changed during runtime. If registration is not supported at the time that CefRegisterWidevineCdm() is called then |callback| will receive a |result| value of CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED.
Public methodStatic memberClearCrossOriginWhitelist
Remove all entries from the cross-origin access whitelist. Returns false if the whitelist cannot be accessed.
Public methodStatic memberClearSchemeHandlerFactories
Clear all registered scheme handler factories. Returns false on error. This function may be called on any thread in the browser process.
Public methodStatic memberCreateUrl
Public methodStatic memberCurrentlyOn
CEF maintains multiple internal threads that are used for handling different types of tasks in different processes. See the cef_thread_id_t definitions in cef_types.h for more information. This function will return true if called on the specified thread. It is an error to request a thread from the wrong process.
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 either the CefRunMessageLoop() function or CefSettings.multi_threaded_message_loop if possible. When using this function care must be taken to balance performance against excessive CPU usage. It is recommended to enable the CefSettings.external_message_pump option when using this function so that CefBrowserProcessHandler::OnScheduleMessagePumpWork() callbacks can facilitate the scheduling process. This function should only be called on the main application thread and only if CefInitialize() is called with a CefSettings.multi_threaded_message_loop 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 memberExecuteProcess(CefMainArgs, CefApp) Obsolete.
Public methodStatic memberExecuteProcess(CefMainArgs, CefApp, IntPtr)
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 memberGetExtensionsForMimeType
Get the extensions associated with the given mime type. This should be passed in lower case. There could be multiple extensions for a given mime type, like "html,htm" for "text/html", or "txt,text,html,..." for "text/*". Any existing elements in the provided vector will not be erased.
Public methodStatic memberGetGeolocation
Request a one-time geolocation update. This function bypasses any user permission checks so should only be used by code that is allowed to access location information.
Public methodStatic memberGetMimeType
Returns the mime type for the specified file extension or an empty string if unknown.
Public methodStatic memberGetPath
Retrieve the path associated with the specified |key|. Returns true on success. Can be called on any thread in the browser process.
Public methodStatic memberInitialize(CefMainArgs, CefSettings, CefApp) Obsolete.
Public methodStatic memberInitialize(CefMainArgs, CefSettings, CefApp, IntPtr)
This function should be called on the main application thread to initialize the CEF browser process. The |application| parameter may be empty. A return value of true indicates that it succeeded and false indicates that it failed. The |windows_sandbox_info| parameter is only used on Windows and may be NULL (see cef_sandbox_win.h for details).
Public methodStatic memberIsWebPluginUnstable
Query if a plugin is unstable. Can be called on any thread in the browser process.
Public methodStatic memberLaunchProcess
Launches the process specified via |command_line|. Returns true upon success. Must be called on the browser process TID_PROCESS_LAUNCHER thread. Unix-specific notes: - All file descriptors open in the parent process will be closed in the child process except for stdin, stdout, and stderr. - If the first argument on the command line does not contain a slash, PATH will be searched. (See man execvp.)
Public methodStatic memberLoad
Loads CEF runtime.
Public methodStatic memberLoad(String)
Loads CEF runtime from specified path.
Public methodStatic memberParseJson
Parses the specified |json_string| and returns a dictionary or list representation. If JSON parsing fails this method returns NULL.
Public methodStatic memberParseJsonAndReturnError
Parses the specified |json_string| and returns a dictionary or list representation. If JSON parsing fails this method returns NULL and populates |error_code_out| and |error_msg_out| with an error code and a formatted error message respectively.
Public methodStatic memberParseUrl
Parse the specified |url| into its component parts. Returns false if the URL is empty or invalid.
Public methodStatic memberPostTask(CefThreadId, CefTask)
Post a task for execution on the specified thread. This function may be called on any thread. It is an error to request a thread from the wrong process.
Public methodStatic memberPostTask(CefThreadId, CefTask, Int64)
Post a task for delayed execution on the specified thread. This function may be called on any thread. It is an error to request a thread from the wrong process.
Public methodStatic memberQuitMessageLoop
Quit the CEF message loop that was started by calling CefRunMessageLoop(). This function should only be called on the main application thread and only if CefRunMessageLoop() 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. Can be called on any thread in the browser process.
Public methodStatic memberRegisterExtension
Register a new V8 extension with the specified JavaScript extension code and handler. Functions implemented by the handler are prototyped using the keyword 'native'. The calling of a native function is restricted to the scope in which the prototype of the native function is defined. This function may only be called on the render process main thread. Example JavaScript extension code:
// create the 'example' global object if it doesn't already exist.
if (!example)
  example = {};
// create the 'example.test' global object if it doesn't already exist.
if (!example.test)
  example.test = {};
(function() {
  // Define the function 'example.test.myfunction'.
  example.test.myfunction = function() {
    // Call CefV8Handler::Execute() with the function name 'MyFunction'
    // and no arguments.
    native function MyFunction();
    return MyFunction();
  };
  // Define the getter function for parameter 'example.test.myparam'.
  example.test.__defineGetter__('myparam', function() {
    // Call CefV8Handler::Execute() with the function name 'GetMyParam'
    // and no arguments.
    native function GetMyParam();
    return GetMyParam();
  });
  // Define the setter function for parameter 'example.test.myparam'.
  example.test.__defineSetter__('myparam', function(b) {
    // Call CefV8Handler::Execute() with the function name 'SetMyParam'
    // and a single argument.
    native function SetMyParam();
    if(b) SetMyParam(b);
  });

  // Extension definitions can also contain normal JavaScript variables
  // and functions.
  var myint = 0;
  example.test.increment = function() {
    myint += 1;
    return myint;
  };
})();
Example usage in the page:
// Call the function.
example.test.myfunction();
// Set the parameter.
example.test.myparam = value;
// Get the parameter.
value = example.test.myparam;
// Call another function.
example.test.increment();
Public methodStatic memberRegisterSchemeHandlerFactory
Register a scheme handler factory for the specified |scheme_name| and optional |domain_name|. An empty |domain_name| value for a standard scheme will cause the factory to match all domain names. The |domain_name| value will be ignored for non-standard schemes. If |scheme_name| is a built-in scheme and no handler is returned by |factory| then the built-in scheme handler factory will be called. If |scheme_name| is a custom scheme then also implement the CefApp::OnRegisterCustomSchemes() method in all processes. This function may be called multiple times to change or remove the factory that matches the specified |scheme_name| and optional |domain_name|. Returns false if an error occurs. This function may be called on any thread in the browser process.
Public methodStatic memberRegisterWebPluginCrash
Register a plugin crash. Can be called on any thread in the browser process but will be executed on the IO thread.
Public methodStatic memberRemoveCrossOriginWhitelistEntry
Remove an entry from the cross-origin access whitelist. Returns false if |source_origin| is invalid or the whitelist cannot be accessed.
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 CefInitialize() is called with a CefSettings.multi_threaded_message_loop value of false. This function will block until a quit message is received by the system.
Public methodStatic memberSetOSModalLoop
Set to true before calling Windows APIs like TrackPopupMenu that enter a modal message loop. Set to false after exiting the modal message loop.
Public methodStatic memberShutdown
This function should be called on the main application thread to shut down the CEF browser process before the application exits.
Public methodStatic memberUnregisterInternalWebPlugin
Unregister an internal plugin. This may be undone the next time CefRefreshWebPlugins() is called. Can be called on any thread in the browser process.
Public methodStatic memberUriDecode
Unescapes |text| and returns the result. Unescaping consists of looking for the exact pattern "%XX" where each X is a hex digit and converting to the character with the numerical value of those digits (e.g. "i%20=%203%3b" unescapes to "i = 3;"). If |convert_to_utf8| is true this function will attempt to interpret the initial decoded result as UTF-8. If the result is convertable into UTF-8 it will be returned as converted. Otherwise the initial decoded result will be returned. The |unescape_rule| parameter supports further customization the decoding process.
Public methodStatic memberUriEncode
Escapes characters in |text| which are unsuitable for use as a query parameter value. Everything except alphanumerics and -_.!~*'() will be converted to "%XX". If |use_plus| is true spaces will change to "+". The result is basically the same as encodeURIComponent in Javacript.
Public methodStatic memberVisitWebPluginInfo
Visit web plugin information. Can be called on any thread in the browser process.
Public methodStatic memberWriteJson
Generates a JSON string from the specified root |node| which should be a dictionary or list value. Returns an empty string on failure. This method requires exclusive access to |node| including any underlying data.
Top
See Also