Skip to content

Commit 85f82c0

Browse files
authored
Refactor SensitivityLabel.md for clarity and updates
1 parent ac2bf9b commit 85f82c0

File tree

1 file changed

+75
-77
lines changed

1 file changed

+75
-77
lines changed

specs/SensitivityLabel.md

Lines changed: 75 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,39 @@ Sensitivity label support for Webview2
22
===
33

44
# Background
5-
Web pages may contain content with sensitive information. Such information can be identified using data loss protection (DLP) methods. The purpose of this API is to provide sensitivity label information, communicated by web pages through the [PageInteractionRestrictionManager](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/PageInteractionRestrictionManager/explainer.md), to the host application. This enables the host application to be informed of the presence of sensitive content.
5+
Web pages may contain content with sensitive information. Such information can
6+
be identified using data loss protection (DLP) methods. The purpose of this API
7+
is to provide sensitivity label information, communicated by web pages through
8+
the [PageInteractionRestrictionManager](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/PageInteractionRestrictionManager/explainer.md),
9+
to the host application. This enables the host application to be informed of the
10+
presence of sensitive content.
611

712
# Description
813

9-
This API introduces a SensitivityLabelChanged event to the CoreWebView2 object, enabling applications to monitor changes in sensitivity labels within hosted content. This functionality is restricted to domains explicitly included in an allow list configured by the application. The allow list can be set at the profile level, thereby enabling the Page Interaction Restriction Manager for content within specified domains. By default, the allow list is empty, preventing hosted content from transmitting sensitivity label information.
14+
This API introduces a SensitivityLabelChanged event to the CoreWebView2 object,
15+
enabling applications to monitor changes in sensitivity labels within hosted
16+
content. This functionality is restricted to domains explicitly included in an
17+
allow list configured by the application. The allow list can be set at the
18+
profile level, thereby enabling the Page Interaction Restriction Manager for
19+
content within specified domains. By default, the allow list is empty,
20+
preventing hosted content from transmitting sensitivity label information.
1021

1122
The core features of this proposal are as follows:
12-
* Configure the allow list filter for Page Interaction Restriction Manager at the profile level.
13-
* After the setup, the `Page Interaction Restriction Manager` is available on pages in the allow list. Content can send sensitivity labels to the platform via the API.
14-
* When a label changes, an event is raised by WebView2 to hosted app with all the labels on that page.
23+
* Configure the allow list filter for Page Interaction Restriction Manager at
24+
the profile level.
25+
* After the setup, the `Page Interaction Restriction Manager` is available on
26+
pages in the allow list. Content can send sensitivity labels to the platform
27+
via the API.
28+
* When a label changes, an event is raised by WebView2 to hosted app with all
29+
the labels on that page.
1530
* Sensitivity labels are cleared when navigating away from the current WebView.
1631

1732
# Examples
1833

1934
## Setting up an allow list
2035

21-
Configure the PageInteractionRestrictionManager allow list to enable Sensitivity label functionality on trusted domains.
36+
Configure the PageInteractionRestrictionManager allow list to enable Sensitivity
37+
label functionality on trusted domains.
2238

2339
### C++ Sample
2440
```cpp
@@ -28,8 +44,8 @@ void ConfigureAllowlist()
2844
wil::com_ptr<ICoreWebView2Profile> profile;
2945
CHECK_FAILURE(m_webView->get_Profile(&profile));
3046

31-
auto stagingProfile3 = profile.try_query<ICoreWebView2StagingProfile3>();
32-
if (stagingProfile3) {
47+
auto profile9 = profile.try_query<ICoreWebView2Profile9>();
48+
if (profile9) {
3349
// Create allow list with trusted URLs
3450
std::vector<std::wstring> allowlist = {
3551
L"https://intranet.company.com/*",
@@ -47,16 +63,16 @@ void ConfigureAllowlist()
4763
wil::com_ptr<ICoreWebView2Environment> environment;
4864
CHECK_FAILURE(m_webView->get_Environment(&environment));
4965

50-
auto stagingEnvironment15 = environment.try_query<ICoreWebView2StagingEnvironment15>();
51-
if (stagingEnvironment15) {
66+
auto environment16 = environment.try_query<ICoreWebView2Environment16>();
67+
if (environment16) {
5268
wil::com_ptr<ICoreWebView2StringCollection> stringCollection;
53-
CHECK_FAILURE(stagingEnvironment15->CreateStringCollection(
69+
CHECK_FAILURE(environment16->CreateStringCollection(
5470
static_cast<UINT32>(items.size()),
5571
items.data(),
5672
&stringCollection));
5773

5874
// Apply the allow list
59-
CHECK_FAILURE(stagingProfile3->put_PageInteractionRestrictionManagerAllowlist(
75+
CHECK_FAILURE(profile9->put_PageInteractionRestrictionManagerAllowlist(
6076
stringCollection.get()));
6177
}
6278
}
@@ -74,47 +90,9 @@ var allowlist = new List<string>
7490
};
7591

7692
// Set the allowlist on the profile
77-
webView2Control.CoreWebView2.Profile.PageInteractionRestrictionManagerAllowlist = allowlist;
93+
webView2Control.CoreWebView2.Profile.PageInteractionRestrictionManagerAllowlist =
94+
allowlist;
7895

79-
MessageBox.Show($"Allowlist configured with {allowlist.Count} URLs");
80-
```
81-
82-
83-
## Retrieving current allow list
84-
### C++ Sample
85-
```cpp
86-
void GetCurrentAllowlist()
87-
{
88-
auto stagingProfile3 = m_profile.try_query<ICoreWebView2StagingProfile3>();
89-
if (stagingProfile3) {
90-
wil::com_ptr<ICoreWebView2StringCollection> allowlist;
91-
HRESULT hr = stagingProfile3->get_PageInteractionRestrictionManagerAllowlist(&allowlist);
92-
93-
if (SUCCEEDED(hr) && allowlist) {
94-
UINT count = 0;
95-
CHECK_FAILURE(allowlist->get_Count(&count));
96-
97-
wprintf(L"Current allowlist contains %u entries:\n", count);
98-
for (UINT i = 0; i < count; ++i) {
99-
wil::unique_cotaskmem_string item;
100-
CHECK_FAILURE(allowlist->GetValueAtIndex(i, &item));
101-
wprintf(L" • %s\n", item.get());
102-
}
103-
}
104-
}
105-
}
106-
```
107-
108-
### .NET/WinRT
109-
```c#
110-
// Get current allowlist
111-
var currentAllowlist = webView2Control.CoreWebView2.Profile.PageInteractionRestrictionManagerAllowlist;
112-
113-
Console.WriteLine($"Current allowlist contains {currentAllowlist.Count} entries:");
114-
foreach (var url in currentAllowlist)
115-
{
116-
Console.WriteLine($" • {url}");
117-
}
11896
```
11997

12098

@@ -156,8 +134,10 @@ void RegisterForSensitivityLabelChange()
156134

157135
if(sensitivityState == COREWEBVIEW2_SENSITIVITY_LABEL_STATE_DETERMINED)
158136
{
159-
Microsoft::WRL::ComPtr<ICoreWebView2SensitivityLabelCollectionView> sensitivityLabelsCollection;
160-
CHECK_FAILURE(args->get_SensitivityLabels(&sensitivityLabelsCollection));
137+
Microsoft::WRL::ComPtr<ICoreWebView2SensitivityLabelCollectionView>
138+
sensitivityLabelsCollection;
139+
CHECK_FAILURE(args->get_SensitivityLabels(
140+
&sensitivityLabelsCollection));
161141

162142
// Get the count of labels
163143
UINT32 labelCount = 0;
@@ -172,8 +152,10 @@ void RegisterForSensitivityLabelChange()
172152
{
173153
for (UINT32 i = 0; i < labelCount; ++i)
174154
{
175-
Microsoft::WRL::ComPtr<ICoreWebView2SensitivityLabel> sensitivityLabel;
176-
CHECK_FAILURE(sensitivityLabelsCollection->GetValueAtIndex(i, &sensitivityLabel));
155+
Microsoft::WRL::ComPtr<ICoreWebView2SensitivityLabel>
156+
sensitivityLabel;
157+
CHECK_FAILURE(sensitivityLabelsCollection->GetValueAtIndex(
158+
i, &sensitivityLabel));
177159

178160
// Get the label type
179161
COREWEBVIEW2_SENSITIVITY_LABEL_KIND labelKind;
@@ -189,18 +171,23 @@ void RegisterForSensitivityLabelChange()
189171
{
190172
case COREWEBVIEW2_SENSITIVITY_LABEL_KIND_MIP:
191173
{
192-
Microsoft::WRL::ComPtr<ICoreWebView2SensitivityLabelMip> microsoftLabel;
174+
Microsoft::WRL::ComPtr<ICoreWebView2SensitivityLabelMip>
175+
microsoftLabel;
193176
if (SUCCEEDED(sensitivityLabel.As(&microsoftLabel)))
194177
{
195178
wil::unique_cotaskmem_string labelId;
196179
wil::unique_cotaskmem_string organizationId;
197-
CHECK_FAILURE(microsoftLabel->get_LabelId(&labelId));
198-
CHECK_FAILURE(microsoftLabel->get_OrganizationId(&organizationId));
180+
CHECK_FAILURE(microsoftLabel->get_LabelId(
181+
&labelId));
182+
CHECK_FAILURE(microsoftLabel->get_OrganizationId(
183+
&organizationId));
199184

200185
labelsString += L"Microsoft Label (ID: " +
201-
std::wstring(labelId.get() ? labelId.get() : L"<empty>") +
186+
std::wstring(labelId.get() ?
187+
labelId.get() : L"<empty>") +
202188
L", Org: " +
203-
std::wstring(organizationId.get() ? organizationId.get() : L"<empty>") +
189+
std::wstring(organizationId.get() ?
190+
organizationId.get() : L"<empty>") +
204191
L")";
205192
}
206193
break;
@@ -251,12 +238,14 @@ interface ICoreWebView2Environment16 : IUnknown {
251238

252239
```
253240
[uuid(7b0ade48-e6a9-5038-b7f7-496ad426d907), object, pointer_default(unique)]
254-
interface ICoreWebView2StagingProfile3 : IUnknown {
241+
interface ICoreWebView2Profile9 : IUnknown {
255242
/// Gets the `PageInteractionRestrictionManagerAllowlist` property.
256-
[propget] HRESULT PageInteractionRestrictionManagerAllowlist([out, retval] ICoreWebView2StringCollection** value);
243+
[propget] HRESULT PageInteractionRestrictionManagerAllowlist(
244+
[out, retval] ICoreWebView2StringCollection** value);
257245
258246
/// Sets the `PageInteractionRestrictionManagerAllowlist` property.
259-
[propput] HRESULT PageInteractionRestrictionManagerAllowlist([in] ICoreWebView2StringCollection* value);
247+
[propput] HRESULT PageInteractionRestrictionManagerAllowlist(
248+
[in] ICoreWebView2StringCollection* value);
260249
}
261250
```
262251
### .NET/WinRT
@@ -268,9 +257,11 @@ namespace Microsoft.Web.WebView2.Core
268257
/// <summary>
269258
/// Gets or sets the PageInteractionRestrictionManager allowlist.
270259
/// </summary>
271-
/// <value>A collection of URL patterns that are exempt from page interaction restrictions.
272-
/// Pass an empty collection to clear the allowlist.</value>
273-
public IReadOnlyList<string> PageInteractionRestrictionManagerAllowlist { get; set; }
260+
/// <value>A collection of URL patterns that are exempt from page
261+
/// interaction restrictions. Pass an empty collection to clear the
262+
/// allowlist.</value>
263+
public IReadOnlyList<string> PageInteractionRestrictionManagerAllowlist
264+
{ get; set; }
274265
}
275266
}
276267
```
@@ -288,7 +279,8 @@ typedef enum COREWEBVIEW2_SENSITIVITY_LABEL_STATE {
288279
/// none will report sensitivity labels.
289280
COREWEBVIEW2_SENSITIVITY_LABEL_STATE_NONE,
290281
/// Indicates that WebView2 has loaded pages from the allow list that can
291-
/// report sensitivity labels, but the label determination is not yet complete.
282+
/// report sensitivity labels, but the label determination is not yet
283+
/// complete.
292284
COREWEBVIEW2_SENSITIVITY_LABEL_STATE_UNDETERMINED,
293285
/// Indicates that WebView2 has loaded pages from the allow list,
294286
/// and those pages have provided label information.
@@ -320,7 +312,8 @@ interface ICoreWebView2SensitivityLabel : IUnknown {
320312
/// and handle the label data, as different label types may have different
321313
/// metadata formats, protection requirements, and policy enforcement
322314
/// mechanisms.
323-
[propget] HRESULT LabelKind([out, retval] COREWEBVIEW2_SENSITIVITY_LABEL_KIND* value);
315+
[propget] HRESULT LabelKind(
316+
[out, retval] COREWEBVIEW2_SENSITIVITY_LABEL_KIND* value);
324317
}
325318
326319
/// Interface for Microsoft Information Protection (MIP) sensitivity labels.
@@ -359,7 +352,9 @@ interface ICoreWebView2SensitivityLabelCollectionView : IUnknown {
359352
[propget] HRESULT Count([out, retval] UINT32* value);
360353
361354
/// Gets the element at the given index.
362-
HRESULT GetValueAtIndex([in] UINT32 index, [out, retval] ICoreWebView2SensitivityLabel** value);
355+
HRESULT GetValueAtIndex(
356+
[in] UINT32 index,
357+
[out, retval] ICoreWebView2SensitivityLabel** value);
363358
}
364359
365360
/// Event arguments for the `SensitivityLabelChanged` event.
@@ -374,11 +369,13 @@ interface ICoreWebView2SensitivityLabelEventArgs : IUnknown {
374369
/// Gets a read-only collection of all sensitivity labels detected in the
375370
/// current web document. This collection contains instances of sensitivity
376371
/// labels that have been reported by the web page.
377-
[propget] HRESULT SensitivityLabels([out, retval] ICoreWebView2SensitivityLabelCollectionView** value);
372+
[propget] HRESULT SensitivityLabels(
373+
[out, retval] ICoreWebView2SensitivityLabelCollectionView** value);
378374
379375
380376
/// Gets the current state of sensitivity label detection.
381-
[propget] HRESULT SensitivityState([out, retval] COREWEBVIEW2_SENSITIVITY_LABEL_STATE* value);
377+
[propget] HRESULT SensitivityState(
378+
[out, retval] COREWEBVIEW2_SENSITIVITY_LABEL_STATE* value);
382379
383380
}
384381
@@ -400,11 +397,11 @@ interface ICoreWebView2SensitivityLabelChangedEventHandler : IUnknown {
400397
[uuid(ac4543d5-f466-5622-8b3b-24d3b195525c), object, pointer_default(unique)]
401398
interface ICoreWebView2_32 : IUnknown {
402399
/// Adds an event handler for the `SensitivityLabelChanged` event.
403-
/// Event raised when the sensitivity label classification of web page changes.
404-
/// web pages may report sensitivity labels via
400+
/// Event raised when the sensitivity label classification of web page
401+
/// changes. web pages may report sensitivity labels via
405402
/// [`Page Interaction Restriction Manager`](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/PageInteractionRestrictionManager/explainer.md).
406-
/// This event is triggered when the WebView2 control detects a change in the
407-
/// sensitivity labels associated with the currently loaded web page.
403+
/// This event is triggered when the WebView2 control detects a change in
404+
/// the sensitivity labels associated with the currently loaded web page.
408405
/// Changes can occur when navigating to a new page in the main frame,
409406
/// when the existing page updates its sensitivity label information.
410407
/// On navigation to a new page `SensitivityLabelChanged` event is raised
@@ -417,7 +414,8 @@ interface ICoreWebView2_32 : IUnknown {
417414
[in] ICoreWebView2SensitivityLabelChangedEventHandler* eventHandler,
418415
[out] EventRegistrationToken* token);
419416
420-
/// Removes an event handler previously added with `add_SensitivityLabelChanged`.
417+
/// Removes an event handler previously added with
418+
/// `add_SensitivityLabelChanged`.
421419
HRESULT remove_SensitivityLabelChanged(
422420
[in] EventRegistrationToken token);
423421

0 commit comments

Comments
 (0)