Click or drag to resize

IRequestContextLoadExtension Method

Version 75.1.140
Load an extension. If extension resources will be read from disk using the default load implementation then rootDirectoy should be the absolute path to the extension resources directory and manifestJson should be null. If extension resources will be provided by the client (e.g. via IRequestHandler and/or IExtensionHandler) then rootDirectory should be a path component unique to the extension (if not absolute this will be internally prefixed with the PK_DIR_RESOURCES path) and manifestJson should contain the contents that would otherwise be read from the "manifest.json" file on disk. The loaded extension will be accessible in all contexts sharing the same storage (HasExtension returns true). However, only the context on which this method was called is considered the loader (DidLoadExtension returns true) and only the loader will receive IRequestContextHandler callbacks for the extension. OnExtensionLoaded(IExtension) will be called on load success or OnExtensionLoadFailed(CefErrorCode) will be called on load failure. If the extension specifies a background script via the "background" manifest key then OnBeforeBackgroundBrowser(IExtension, String, IBrowserSettings) will be called to create the background browser. See that method for additional information about background scripts. For visible extension views the client application should evaluate the manifest to determine the correct extension URL to load and then load the extension URL in a ChromiumWebBrowser instance after the extension has loaded. For example, the client can look for the "browser_action" manifest key as documented at https://developer.chrome.com/extensions/browserAction. Extension URLs take the form "chrome-extension://<extension_id>/<path>" Browsers that host extensions differ from normal browsers as follows: - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit chrome://extensions-support for the list of extension APIs currently supported by CEF. - Main frame navigation to non-extension content is blocked. - Pinch-zooming is disabled. - Extension returns the hosted extension. - CefBrowserHost::IsBackgroundHost returns true for background hosts. See https://developer.chrome.com/extensions for extension implementation and usage documentation.

Namespace:  CefSharp
Assembly:  CefSharp (in CefSharp.dll) Version: 75.1.140.0 (75.1.140.0)
Syntax
void LoadExtension(
	string rootDirectory,
	string manifestJson,
	IExtensionHandler handler
)

Parameters

rootDirectory
Type: SystemString
If extension resources will be read from disk using the default load implementation then rootDirectoy should be the absolute path to the extension resources directory and manifestJson should be null
manifestJson
Type: SystemString
If extension resources will be provided by the client then rootDirectory should be a path component unique to the extension and manifestJson should contain the contents that would otherwise be read from the manifest.json file on disk
handler
Type: CefSharpIExtensionHandler
handle events related to browser extensions
Remarks
For extensions that load a popup you are required to query the Manifest, build a Url in the format chrome-extension://{extension.Identifier}/{default_popup} with default_popup url coming from the mainfest. With the extension url you then need to open a new Form/Window/Tab and create a new ChromiumWebBrowser instance to host the extension popup. To load a crx file you must first unzip them to a folder and pass the path containing the extension as rootDirectory. It in theory should be possible to load a crx file in memory, passing it's manifest.json file content as manifestJson then fulfilling the resource rquests made to GetExtensionResource(IExtension, IBrowser, String, IGetExtensionResourceCallback).
See Also