ICoreWebView2_3

Undocumented in source.

Members

Functions

ClearVirtualHostNameToFolderMapping
HRESULT ClearVirtualHostNameToFolderMapping(LPCWSTR hostName)

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

Resume
HRESULT Resume()

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.

SetVirtualHostNameToFolderMapping
HRESULT SetVirtualHostNameToFolderMapping(LPCWSTR hostName, LPCWSTR folderPath, COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND accessKind)

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

TrySuspend
HRESULT TrySuspend(ICoreWebView2TrySuspendCompletedHandler handler)

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 explicitly. 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.

get_IsSuspended
HRESULT get_IsSuspended(BOOL* isSuspended)

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

Inherited Members

From ICoreWebView2_2

add_WebResourceResponseReceived
HRESULT add_WebResourceResponseReceived(ICoreWebView2WebResourceResponseReceivedEventHandler eventHandler, EventRegistrationToken* token)

Add an event handler for the WebResourceResponseReceived event. WebResourceResponseReceived is raised when the WebView receives the response for a request for a web resource (any URI resolution performed by the WebView; such as HTTP/HTTPS, file and data requests from redirects, navigations, declarations in HTML, implicit favicon lookups, and fetch API usage in the document). The host app can use this event to view the actual request and response for a web resource. There is no guarantee about the order in which the WebView processes the response and the host app's handler runs. The app's handler will not block the WebView from processing the response. \snippet ScenarioAuthentication.cpp WebResourceResponseReceived

remove_WebResourceResponseReceived
HRESULT remove_WebResourceResponseReceived(EventRegistrationToken token)

Remove an event handler previously added with add_WebResourceResponseReceived.

NavigateWithWebResourceRequest
HRESULT NavigateWithWebResourceRequest(ICoreWebView2WebResourceRequest request)

Navigates using a constructed WebResourceRequest object. This lets you provide post data or additional request headers during navigation. The headers in the WebResourceRequest override headers added by WebView2 runtime except for Cookie headers. Method can only be either "GET" or "POST". Provided post data will only be sent only if the method is "POST" and the uri scheme is HTTP(S). \snippet ScenarioNavigateWithWebResourceRequest.cpp NavigateWithWebResourceRequest

add_DOMContentLoaded
HRESULT add_DOMContentLoaded(ICoreWebView2DOMContentLoadedEventHandler eventHandler, EventRegistrationToken* token)

Add an event handler for the DOMContentLoaded event. DOMContentLoaded is raised when the initial html document has been parsed. This aligns with the document's DOMContentLoaded event in html.

remove_DOMContentLoaded
HRESULT remove_DOMContentLoaded(EventRegistrationToken token)

Remove an event handler previously added with add_DOMContentLoaded.

get_CookieManager
HRESULT get_CookieManager(ICoreWebView2CookieManager* cookieManager)

Gets the cookie manager object associated with this ICoreWebView2. See ICoreWebView2CookieManager.

get_Environment
HRESULT get_Environment(ICoreWebView2Environment* environment)

Exposes the CoreWebView2Environment used to create this CoreWebView2.

Meta