RequestContextLoadExtension Method |
Version 71.0.0
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. [!:IExtensionHandler.OnExtensionLoaded] will be
called on load success or [!:IExtensionHandler.OnExtensionLoadFailed] will be called on load failure.
If the extension specifies a background script via the "background" manifest key then [!:IExtensionHandler.OnBeforeBackgroundBrowser]
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 pass
that URL to the IBrowserHost.CreateBrowser* function 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:///".
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.
- [!:IBrowserHost.GetExtension] returns the hosted extension.
- CefBrowserHost::IsBackgroundHost returns true for background hosts. See https://developer.chrome.com/extensions for extension implementation and usage documentation.
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. [!:IExtensionHandler.OnExtensionLoaded] will be
called on load success or [!:IExtensionHandler.OnExtensionLoadFailed] will be called on load failure.
If the extension specifies a background script via the "background" manifest key then [!:IExtensionHandler.OnBeforeBackgroundBrowser]
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 pass
that URL to the IBrowserHost.CreateBrowser* function 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:///".
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.
- [!:IBrowserHost.GetExtension] 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.Core (in CefSharp.Core.dll) Version: 71.0.0.0
Syntax public virtual void LoadExtension(
string rootDirectory,
string manifestJson,
IExtensionHandler handler
)
public:
virtual 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 nullIf 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 diskIf 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 extensionshandle events related to browser extensions
Implements
IRequestContextLoadExtension(String, String, IExtensionHandler)See Also