interface ICoreWebView2Experimental32

Note

This reference is no longer being maintained. For the latest API reference, see WebView2 API Reference.

Note

This an experimental API that is shipped with our prerelease SDK. See WebView2 release notes.

interface ICoreWebView2Experimental32
  : public IUnknown

Extension of the ICoreWebView2 interface that provides sensitivity classification of a web page.

Summary

Members Descriptions
add_SensitivityInfoChanged Adds an event handler for the SensitivityInfoChanged event.
get_SensitivityInfo Gets the current state of sensitivity label detection for the content loaded in the WebView2 control.
remove_SensitivityInfoChanged Removes an event handler previously added with add_SensitivityInfoChanged.

This interface enables applications to monitor and respond to changes in the sensitivity classification of web content loaded in the WebView2 control. When sensitivity labels are detected, updated, or removed from web pages, the SensitivityInfoChanged event is raised.

Applies to

Product Introduced
WebView2 Win32 N/A
WebView2 Win32 Prerelease

Members

add_SensitivityInfoChanged

Adds an event handler for the SensitivityInfoChanged event.

public HRESULT add_SensitivityInfoChanged(ICoreWebView2ExperimentalSensitivityInfoChangedEventHandler * eventHandler, EventRegistrationToken * token)

Event raised when the sensitivity label classification of web page changes. Web page may report sensitivity labels via Page Interaction Restriction Manager. This event is triggered when the WebView2 control detects a change in the sensitivity labels associated with the currently loaded web page. Changes can occur when navigating to a new page in the main frame, when the existing page updates its sensitivity label information. On navigation to a new page SensitivityInfoChanged event is raised just after the NavigationStarting event. Applications can subscribe to this event to receive notifications about sensitivity changes. The event handler can then query the SensitivityInfo property to get the latest sensitivity label information and take appropriate actions based on the updated sensitivity classification.

    CHECK_FAILURE(webView32->add_SensitivityInfoChanged(
        Callback<ICoreWebView2ExperimentalSensitivityInfoChangedEventHandler>(
            [this](ICoreWebView2* sender, IUnknown* args) -> HRESULT
            {
                auto webView32 = this->m_webView.try_query<ICoreWebView2Experimental32>();
                Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalSensitivityInfo>
                    sensitivityInfo;
                webView32->get_SensitivityInfo(&sensitivityInfo);

                OnSensitivityChanged(sensitivityInfo.Get());

                return S_OK;
            })
            .Get(),
        &m_sensitivityInfoChangedToken));

get_SensitivityInfo

Gets the current state of sensitivity label detection for the content loaded in the WebView2 control.

public HRESULT get_SensitivityInfo(ICoreWebView2ExperimentalSensitivityInfo ** value)

See ICoreWebView2SensitivityInfo for more details.

    COREWEBVIEW2_SENSITIVITY_LABELS_STATE sensitivityLabelsState;
    CHECK_FAILURE(sensitivityInfo->get_SensitivityLabelsState(&sensitivityLabelsState));
    Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalSensitivityLabelCollectionView>
        sensitivityLabelsCollection;
    if (sensitivityLabelsState == COREWEBVIEW2_SENSITIVITY_LABELS_STATE_AVAILABLE)
    {
        CHECK_FAILURE(sensitivityInfo->get_SensitivityLabels(&sensitivityLabelsCollection));
    }

remove_SensitivityInfoChanged

Removes an event handler previously added with add_SensitivityInfoChanged.

public HRESULT remove_SensitivityInfoChanged(EventRegistrationToken token)