[][src]Trait webview2_sys::ICoreWebView2Environment

pub trait ICoreWebView2Environment: IUnknown {
    unsafe fn create_core_web_view2_controller(
        &self,
        parent_window: HWND,
        handler: *mut *mut ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerVTable
    ) -> HRESULT;
unsafe fn create_web_resource_response(
        &self,
        content: *mut *mut IStreamVTable,
        status_code: i32,
        reason_phrase: LPCWSTR,
        headers: LPCWSTR,
        response: *mut *mut *mut ICoreWebView2WebResourceResponseVTable
    ) -> HRESULT;
unsafe fn get_browser_version_string(
        &self,
        version_info: *mut LPWSTR
    ) -> HRESULT;
unsafe fn add_new_browser_version_available(
        &self,
        event_handler: *mut *mut ICoreWebView2NewBrowserVersionAvailableEventHandlerVTable,
        token: *mut EventRegistrationToken
    ) -> HRESULT;
unsafe fn remove_new_browser_version_available(
        &self,
        token: EventRegistrationToken
    ) -> HRESULT; }

This represents the WebView2 Environment. WebViews created from an environment run on the browser process specified with environment parameters and objects created from an environment should be used in the same environment. Using it in different environments are not guaranteed to be compatible and may fail.

Required methods

unsafe fn create_core_web_view2_controller(
    &self,
    parent_window: HWND,
    handler: *mut *mut ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerVTable
) -> HRESULT

Asynchronously create a new WebView.

parentWindow is the HWND in which the WebView should be displayed and from which receive input. The WebView will add a child window to the provided window during WebView creation. Z-order and other things impacted by sibling window order will be affected accordingly.

It is recommended that the application set Application User Model ID for the process or the application window. If none is set, during WebView creation a generated Application User Model ID is set to root window of parentWindow. \snippet AppWindow.cpp CreateCoreWebView2Controller

It is recommended that the application handles restart manager messages so that it can be restarted gracefully in the case when the app is using Edge for WebView from a certain installation and that installation is being uninstalled. For example, if a user installs Edge from Dev channel and opts to use Edge from that channel for testing the app, and then uninstalls Edge from that channel without closing the app, the app will be restarted to allow uninstallation of the dev channel to succeed. \snippet AppWindow.cpp RestartManager

When the application retries CreateCoreWebView2Controller upon failure, it is recommended that the application restarts from creating a new WebView2 Environment. If an Edge update happens, the version associated with a WebView2 Environment could have been removed and causing the object to no longer work. Creating a new WebView2 Environment will work as it uses the latest version.

WebView creation will fail if there is already a running instance using the same user data folder, and the Environment objects have different EnvironmentOptions. For example, if there is already a WebView created with one language, trying to create a WebView with a different language using the same user data folder will fail.

unsafe fn create_web_resource_response(
    &self,
    content: *mut *mut IStreamVTable,
    status_code: i32,
    reason_phrase: LPCWSTR,
    headers: LPCWSTR,
    response: *mut *mut *mut ICoreWebView2WebResourceResponseVTable
) -> HRESULT

Create a new web resource response object. The headers is the raw response header string delimited by newline. It's also possible to create this object with empty headers string and then use the ICoreWebView2HttpResponseHeaders to construct the headers line by line. For information on other parameters see ICoreWebView2WebResourceResponse.

\snippet SettingsComponent.cpp WebResourceRequested

unsafe fn get_browser_version_string(
    &self,
    version_info: *mut LPWSTR
) -> HRESULT

The browser version info of the current ICoreWebView2Environment, including channel name if it is not the stable channel. This matches the format of the GetAvailableCoreWebView2BrowserVersionString API. Channel names are 'beta', 'dev', and 'canary'.

\snippet AppWindow.cpp GetBrowserVersionString

unsafe fn add_new_browser_version_available(
    &self,
    event_handler: *mut *mut ICoreWebView2NewBrowserVersionAvailableEventHandlerVTable,
    token: *mut EventRegistrationToken
) -> HRESULT

Add an event handler for the NewBrowserVersionAvailable event. NewBrowserVersionAvailable fires when a newer version of the Edge browser is installed and available for use via WebView2. To use the newer version of the browser you must create a new environment and WebView. This event will only be fired for new version from the same Edge channel that the code is running from. When not running with installed Edge, no event will be fired.

Because a user data folder can only be used by one browser process at a time, if you want to use the same user data folder in the WebViews using the new version of the browser, you must close the environment and WebViews that are using the older version of the browser first. Or simply prompt the user to restart the app.

\snippet AppWindow.cpp NewBrowserVersionAvailable

unsafe fn remove_new_browser_version_available(
    &self,
    token: EventRegistrationToken
) -> HRESULT

Remove an event handler previously added with add_NewBrowserVersionAvailable.

Loading content...

Trait Implementations

impl ComInterface for dyn ICoreWebView2Environment[src]

type VTable = ICoreWebView2EnvironmentVTable

A COM compatible V-Table

type Super = dyn IUnknown

The interface that this interface inherits from

impl<C: ICoreWebView2Environment> ProductionComInterface<C> for dyn ICoreWebView2Environment[src]

Implementations on Foreign Types

impl<T: ICoreWebView2Environment + ComInterface + ?Sized> ICoreWebView2Environment for ComRc<T>[src]

impl<T: ICoreWebView2Environment + ComInterface + ?Sized> ICoreWebView2Environment for ComPtr<T>[src]

Loading content...

Implementors

Loading content...