interface ICoreWebView2ExperimentalSensitivityInfo

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 ICoreWebView2ExperimentalSensitivityInfo
  : public IUnknown

This interface provides information about sensitivity of a web page loaded in the WebView2 control.

Summary

Members Descriptions
get_SensitivityLabels Gets a read-only collection of all sensitivity labels detected in the current web document.
get_SensitivityLabelsState Gets the current state of sensitivity label detection.

It contains the current state of sensitivity label detection and a collection of all sensitivity labels that have been reported by the web page via Page Interaction Restriction Manager.

Applies to

Product Introduced
WebView2 Win32 N/A
WebView2 Win32 Prerelease 1.0.3590

Members

get_SensitivityLabels

Gets a read-only collection of all sensitivity labels detected in the current web document.

public HRESULT get_SensitivityLabels(ICoreWebView2ExperimentalSensitivityLabelCollectionView ** value)

This collection contains list of sensitivity labels that have been reported by the web content. SensitivityLabels are valid only if SensitivityLabelsState is COREWEBVIEW2_SENSITIVITY_LABELS_STATE_AVAILABLE. In case SensitivityLabelsState is COREWEBVIEW2_SENSITIVITY_LABELS_STATE_NOT_APPLICABLE this collection will be empty. In case SensitivityLabelsState is COREWEBVIEW2_SENSITIVITY_LABELS_STATE_PENDING this will return nullptr.

std::vector<std::pair<std::wstring, std::wstring>> ScenarioSensitivityLabel::
    ExtractSensitivityLabelInfo(
        ICoreWebView2ExperimentalSensitivityLabelCollectionView* labelCollection)
{
    std::vector<std::pair<std::wstring, std::wstring>> labelInfos;

    if (!labelCollection)
    {
        return labelInfos;
    }

    UINT32 labelCount = 0;
    CHECK_FAILURE(labelCollection->get_Count(&labelCount));

    for (UINT32 i = 0; i < labelCount; ++i)
    {
        Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalSensitivityLabel> sensitivityLabel;
        CHECK_FAILURE(labelCollection->GetValueAtIndex(i, &sensitivityLabel));

        COREWEBVIEW2_SENSITIVITY_LABEL_KIND labelKind;
        CHECK_FAILURE(sensitivityLabel->get_LabelKind(&labelKind));
        if (labelKind == COREWEBVIEW2_SENSITIVITY_LABEL_KIND_MIP)
        {
            Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalMipSensitivityLabel> mipLabel;
            if (SUCCEEDED(sensitivityLabel.As(&mipLabel)))
            {
                wil::unique_cotaskmem_string labelId;
                wil::unique_cotaskmem_string organizationId;
                CHECK_FAILURE(mipLabel->get_LabelId(&labelId));
                CHECK_FAILURE(mipLabel->get_OrganizationId(&organizationId));

                // Store the label id and organization id as a pair. Can be used
                // to query Purview for the allowed rights on the document
                labelInfos.emplace_back(
                    std::wstring(labelId.get()), std::wstring(organizationId.get()));
            }
        }
    }
    return labelInfos;
}

get_SensitivityLabelsState

Gets the current state of sensitivity label detection.

public HRESULT get_SensitivityLabelsState(COREWEBVIEW2_SENSITIVITY_LABELS_STATE * value)

Refer COREWEBVIEW2_SENSITIVITY_LABELS_STATE for different states.