Trait webview2_sys::ICoreWebView2_3[][src]

pub trait ICoreWebView2_3: ICoreWebView2_2 {
    unsafe fn try_suspend(
        &self,
        handler: *mut *mut ICoreWebView2TrySuspendCompletedHandlerVTable
    ) -> HRESULT;
unsafe fn resume(&self) -> HRESULT;
unsafe fn get_is_suspended(&self, is_suspended: *mut BOOL) -> HRESULT;
unsafe fn set_virtual_host_name_to_folder_mapping(
        &self,
        host_name: LPCWSTR,
        folder_path: LPCWSTR,
        access_kind: HostResourceAccessKind
    ) -> HRESULT;
unsafe fn clear_virtual_host_name_to_folder_mapping(
        &self,
        host_name: LPCWSTR
    ) -> HRESULT; }

A continuation of ICoreWebView2 interface.

Required methods

unsafe fn try_suspend(
    &self,
    handler: *mut *mut ICoreWebView2TrySuspendCompletedHandlerVTable
) -> HRESULT
[src]

An app may call the TrySuspend API to have the WebView2 consume less memory. This is useful when a Win32 app becomes invisible, or when a Universal Windows Platform app is being suspended, during the suspended event handler before completing the suspended event. The CoreWebView2Controller’s IsVisible property must be false when the API is called. Otherwise, the API fails with HRESULT_FROM_WIN32(ERROR_INVALID_STATE). Suspending is similar to putting a tab to sleep in the Edge browser. Suspending pauses WebView script timers and animations, minimizes CPU usage for the associated browser renderer process and allows the operating system to reuse the memory that was used by the renderer process for other processes. Note that Suspend is best effort and considered completed successfully once the request is sent to browser renderer process. If there is a running script, the script will continue to run and the renderer process will be suspended after that script is done. See Sleeping Tabs FAQ for conditions that might prevent WebView from being suspended. In those situations, the completed handler will be invoked with isSuccessful as false and errorCode as S_OK. The WebView will be automatically resumed when it becomes visible. Therefore, the app normally does not have to call Resume explicilty. The app can call Resume and then TrySuspend periodically for an invisible WebView so that the invisible WebView can sync up with latest data and the page ready to show fresh content when it becomes visible. All WebView APIs can still be accessed when a WebView is suspended. Some APIs like Navigate will auto resume the WebView. To avoid unexpected auto resume, check IsSuspended property before calling APIs that might change WebView state.

\snippet ViewComponent.cpp ToggleIsVisibleOnMinimize

\snippet ViewComponent.cpp Suspend

unsafe fn resume(&self) -> HRESULT[src]

Resumes the WebView so that it resumes activities on the web page. This API can be called while the WebView2 controller is invisible. The app can interact with the WebView immediately after Resume. WebView will be automatically resumed when it becomes visible.

\snippet ViewComponent.cpp ToggleIsVisibleOnMinimize

\snippet ViewComponent.cpp Resume

unsafe fn get_is_suspended(&self, is_suspended: *mut BOOL) -> HRESULT[src]

Whether WebView is suspended. TRUE when WebView is suspended, from the time when TrySuspend has completed successfully until WebView is resumed.

unsafe fn set_virtual_host_name_to_folder_mapping(
    &self,
    host_name: LPCWSTR,
    folder_path: LPCWSTR,
    access_kind: HostResourceAccessKind
) -> HRESULT
[src]

Set a mapping between a virtual host name and a folder path to make available to web sites via that host name.

After setting the mapping, documents loaded in the WebView can use HTTP or HTTPS URLs at the specified host name specified by hostName to access files in the local folder specified by folderPath.

This mapping applies to both top-level document and iframe navigations as well as subresource references from a document. This also applies to dedicated and shared worker scripts but does not apply to service worker scripts.

Both absolute and relative paths are supported for folderPath. Relative paths are interpreted as relative to the folder where the exe of the app is in.

accessKind specifies the level of access to resources under the virtual host from other sites.

For example, after calling

   SetVirtualHostNameToFolderMapping(
       L"appassets.example", L"assets",
       COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY);

navigating to https://appassets.example/my-local-file.html will show content from my-local-file.html in the assets subfolder located on disk under the same path as the app’s executable file.

You should typically choose virtual host names that are never used by real sites. If you own a domain such as example.com, another option is to use a subdomain reserved for the app (like my-app.example.com).

RFC 6761 has reserved several special-use domain names that are guaranteed to not be used by real sites (for example, .example, .test, and .invalid.)

Apps should use distinct domain names when mapping folder from different sources that should be isolated from each other. For instance, the app might use app-file.example for files that ship as part of the app, and book1.example might be used for files containing books from a less trusted source that were previously downloaded and saved to the disk by the app.

The host name used in the APIs is canonicalized using Chromium’s host name parsing logic before being used internally.

All host names that are canonicalized to the same string are considered identical. For example, EXAMPLE.COM and example.com are treated as the same host name. An international host name and its Punycode-encoded host name are considered the same host name. There is no DNS resolution for host name and the trailing ‘.’ is not normalized as part of canonicalization.

Therefore example.com and example.com. are treated as different host names. Similarly, virtual-host-name and virtual-host-name.example.com are treated as different host names even if the machine has a DNS suffix of example.com.

Specify the minimal cross-origin access necessary to run the app. If there is not a need to access local resources from other origins, use COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY.

\snippet AppWindow.cpp AddVirtualHostNameToFolderMapping

\snippet AppWindow.cpp LocalUrlUsage

unsafe fn clear_virtual_host_name_to_folder_mapping(
    &self,
    host_name: LPCWSTR
) -> HRESULT
[src]

Clear a host name mapping for local folder that was added by SetVirtualHostNameToFolderMapping.

Loading content...

Trait Implementations

impl ComInterface for dyn ICoreWebView2_3[src]

type VTable = ICoreWebView2_3VTable

A COM compatible V-Table

type Super = dyn ICoreWebView2_2

The interface that this interface inherits from

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

Implementations on Foreign Types

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

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

Loading content...

Implementors

Loading content...