Skip to content

Commit 83b642d

Browse files
authored
Refactor PageInteractionRestrictionManager allowlist methods
1 parent f767dde commit 83b642d

1 file changed

Lines changed: 26 additions & 47 deletions

File tree

specs/SensitivityLabel.md

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ var allowlist = new List<string>
113113
};
114114

115115
// Set the allowlist on the profile
116-
webView2Control.CoreWebView2.Profile.SetPageInteractionRestrictionManagerAllowlist(allowlist);
116+
webView2Control.CoreWebView2.Profile.PageInteractionRestrictionManagerAllowlist = allowlist;
117117

118118
MessageBox.Show($"Allowlist configured with {allowlist.Count} URLs");
119119
```
@@ -153,7 +153,7 @@ void ConfigureAllowlist()
153153
&stringCollection));
154154

155155
// Apply the allowlist
156-
CHECK_FAILURE(stagingProfile3->SetPageInteractionRestrictionManagerAllowlist(
156+
CHECK_FAILURE(stagingProfile3->put_PageInteractionRestrictionManagerAllowlist(
157157
stringCollection.get()));
158158
}
159159
}
@@ -164,7 +164,7 @@ void ConfigureAllowlist()
164164

165165
```c#
166166
// Get current allowlist
167-
var currentAllowlist = await webView2Control.CoreWebView2.Profile.GetPageInteractionRestrictionManagerAllowlist();
167+
var currentAllowlist = webView2Control.CoreWebView2.Profile.PageInteractionRestrictionManagerAllowlist;
168168

169169
Console.WriteLine($"Current allowlist contains {currentAllowlist.Count} entries:");
170170
foreach (var url in currentAllowlist)
@@ -178,22 +178,20 @@ void GetCurrentAllowlist()
178178
{
179179
auto stagingProfile3 = m_profile.try_query<ICoreWebView2StagingProfile3>();
180180
if (stagingProfile3) {
181-
CHECK_FAILURE(stagingProfile3->GetPageInteractionRestrictionManagerAllowlist(
182-
Callback<ICoreWebView2StagingGetPageInteractionRestrictionManagerAllowlistCompletedHandler>(
183-
[](HRESULT result, ICoreWebView2StringCollection* allowlist) -> HRESULT {
184-
if (SUCCEEDED(result) && allowlist) {
185-
UINT count = 0;
186-
CHECK_FAILURE(allowlist->get_Count(&count));
187-
188-
wprintf(L"Current allowlist contains %u entries:\n", count);
189-
for (UINT i = 0; i < count; ++i) {
190-
wil::unique_cotaskmem_string item;
191-
CHECK_FAILURE(allowlist->GetValueAtIndex(i, &item));
192-
wprintf(L" • %s\n", item.get());
193-
}
194-
}
195-
return S_OK;
196-
}).Get()));
181+
wil::com_ptr<ICoreWebView2StringCollection> allowlist;
182+
HRESULT hr = stagingProfile3->get_PageInteractionRestrictionManagerAllowlist(&allowlist);
183+
184+
if (SUCCEEDED(hr) && allowlist) {
185+
UINT count = 0;
186+
CHECK_FAILURE(allowlist->get_Count(&count));
187+
188+
wprintf(L"Current allowlist contains %u entries:\n", count);
189+
for (UINT i = 0; i < count; ++i) {
190+
wil::unique_cotaskmem_string item;
191+
CHECK_FAILURE(allowlist->GetValueAtIndex(i, &item));
192+
wprintf(L" • %s\n", item.get());
193+
}
194+
}
197195
}
198196
}
199197
```
@@ -285,26 +283,13 @@ interface ICoreWebView2StagingEnvironment15 : IUnknown {
285283
```
286284

287285
```
288-
[uuid(25b0fd91-f2e8-5c54-92f4-f74751b1fa0e), object, pointer_default(unique)]
286+
[uuid(7b0ade48-e6a9-5038-b7f7-496ad426d907), object, pointer_default(unique)]
289287
interface ICoreWebView2StagingProfile3 : IUnknown {
290-
/// Get the current PageInteractionRestrictionManager allowlist.
291-
/// The allowlist contains URL patterns that are exempt from page interaction restrictions.
292-
HRESULT GetPageInteractionRestrictionManagerAllowlist(
293-
[in] ICoreWebView2StagingGetPageInteractionRestrictionManagerAllowlistCompletedHandler* handler);
294-
295-
/// Set the PageInteractionRestrictionManager allowlist.
296-
/// URL patterns in this allowlist will be exempt from page interaction restrictions
297-
/// imposed by DLP policies. Pass an empty collection to clear the allowlist.
298-
HRESULT SetPageInteractionRestrictionManagerAllowlist(
299-
[in] ICoreWebView2StringCollection* allow_list);
300-
}
301-
```
288+
/// Gets the `PageInteractionRestrictionManagerAllowlist` property.
289+
[propget] HRESULT PageInteractionRestrictionManagerAllowlist([out, retval] ICoreWebView2StringCollection** value);
302290
303-
```
304-
[uuid(ac924e9c-1639-586b-a402-1b81e6309d8a), object, pointer_default(unique)]
305-
interface ICoreWebView2StagingGetPageInteractionRestrictionManagerAllowlistCompletedHandler : IUnknown {
306-
/// Provides the result of the GetPageInteractionRestrictionManagerAllowlist operation.
307-
HRESULT Invoke([in] HRESULT errorCode, [in] ICoreWebView2StringCollection* result);
291+
/// Sets the `PageInteractionRestrictionManagerAllowlist` property.
292+
[propput] HRESULT PageInteractionRestrictionManagerAllowlist([in] ICoreWebView2StringCollection* value);
308293
}
309294
```
310295

@@ -314,17 +299,11 @@ namespace Microsoft.Web.WebView2.Core
314299
public partial class CoreWebView2Profile
315300
{
316301
/// <summary>
317-
/// Get the current PageInteractionRestrictionManager allowlist.
318-
/// </summary>
319-
/// <returns>A collection of URL patterns that are exempt from page interaction restrictions.</returns>
320-
public async Task<IReadOnlyList<string>> GetPageInteractionRestrictionManagerAllowlist();
321-
322-
/// <summary>
323-
/// Set the PageInteractionRestrictionManager allowlist.
302+
/// Gets or sets the PageInteractionRestrictionManager allowlist.
324303
/// </summary>
325-
/// <param name="allowList">Collection of URL patterns to exempt from page interaction restrictions.
326-
/// Pass an empty collection to clear the allowlist.</param>
327-
public void SetPageInteractionRestrictionManagerAllowlist(IReadOnlyList<string> allowList);
304+
/// <value>A collection of URL patterns that are exempt from page interaction restrictions.
305+
/// Pass an empty collection to clear the allowlist.</value>
306+
public IReadOnlyList<string> PageInteractionRestrictionManagerAllowlist { get; set; }
328307
}
329308
}
330309
```

0 commit comments

Comments
 (0)