Skip to content

Commit 710afd2

Browse files
author
Denghui Yu
committed
add add_ProfileDeleted/remove_ProfileDeleted SPEC
1 parent 3b46d95 commit 710afd2

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

specs/MultiProfile.md

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,22 @@ HRESULT AppWindow::DeleteProfile(ICoreWebView2* webView2)
175175
CHECK_FAILURE(webView2->get_Profile(&profile));
176176
CHECK_FAILURE(profile2->Delete());
177177
}
178+
179+
EventRegistrationToken m_profileDeletedEventToken = {};
180+
void AppWindow::AddProfileDeleted(ICoreWebView2* webView2)
181+
{
182+
CHECK_FAILURE(webView2->add_ProfileDeleted(
183+
Microsoft::WRL::Callback<ICoreWebView2StagingProfileDeletedEventHandler>(
184+
[this](ICoreWebView2Staging9* sender, IUnknown* args) {
185+
CloseAppWindow();
186+
return S_OK;
187+
}).Get(), &m_profileDeletedEventToken));
188+
}
189+
190+
void AppWindow::RemoveProfileDeleted(ICoreWebView2* webView2)
191+
{
192+
CHECK_FAILURE(webView2->remove_ProfileDeleted(m_profileDeletedEventToken));
193+
}
178194
```
179195
180196
## .NET and WinRT
@@ -247,6 +263,21 @@ public DeleteProfile(CoreWebView2Controller controller)
247263
// Delete current profile.
248264
profile.Delete();
249265
}
266+
267+
private void AddProfileDeleted(object sender, object e)
268+
{
269+
webView.CoreWebView2.ProfileDeleted += CoreWebView2_ProfileDeleted;
270+
}
271+
272+
private void RemoveProfileDeleted(object sender, object e)
273+
{
274+
webView.CoreWebView2.ProfileDeleted -= CoreWebView2_ProfileDeleted;
275+
}
276+
277+
private void CoreWebView2_ProfileDeleted(object sender, object e)
278+
{
279+
Close();
280+
}
250281
```
251282

252283
# API Details
@@ -353,8 +384,8 @@ interface ICoreWebView2Profile2 : ICoreWebView2Profile {
353384
[propget] HRESULT CookieManager([out, retval] ICoreWebView2CookieManager** cookieManager);
354385
}
355386
356-
[uuid(1c1ae2cc-d5c2-ffe3-d3e7-7857035d23b7), object, pointer_default(unique)]
357-
interface ICoreWebView2Profile3 : ICoreWebView2Profile2 {
387+
[uuid(2765B8BD-7C57-4B76-B8AA-1EC940FE92CC), object, pointer_default(unique)]
388+
interface ICoreWebView2StagingProfile4 : IUnknown {
358389
/// After the API is called, the profile will be marked for deletion. The
359390
/// local profile’s directory will be tried to delete at browser process
360391
/// exit, if fail to delete, it will recursively try to delete at next
@@ -370,6 +401,20 @@ interface ICoreWebView2Profile3 : ICoreWebView2Profile2 {
370401
/// (0x8007139FL).
371402
HRESULT Delete();
372403
}
404+
405+
[uuid(cc39bea3-f6f8-471b-919f-fa253e2fff03), object, pointer_default(unique)]
406+
interface ICoreWebView2Staging9 : IUnknown {
407+
/// The `ProfileDeleted` event is raised when its corresponding Profile's
408+
/// Delete API is called. When this event has been raised, continue to use
409+
/// the profile or its corresponding webviews is an undefined behavior.
410+
HRESULT add_ProfileDeleted(
411+
[in] ICoreWebView2StagingProfileDeletedEventHandler* eventHandler,
412+
[out] EventRegistrationToken* token);
413+
414+
/// Remove an event handler previously added with `add_ProfileDeleted`.
415+
HRESULT remove_ProfileDeleted(
416+
[in] EventRegistrationToken token);
417+
}
373418
```
374419

375420
## .NET and WinRT
@@ -410,6 +455,11 @@ namespace Microsoft.Web.WebView2.Core
410455
{
411456
// ...
412457
CoreWebView2Profile Profile { get; };
458+
459+
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2Staging9")]
460+
{
461+
event Windows.Foundation.TypedEventHandler<CoreWebView2, Object> ProfileDeleted;
462+
}
413463
}
414464

415465
runtimeclass CoreWebView2Profile
@@ -422,9 +472,9 @@ namespace Microsoft.Web.WebView2.Core
422472

423473
CoreWebView2CookieManager CookieManager { get; };
424474

425-
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2Profile3")]
475+
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2StagingProfile4")]
426476
{
427-
// ICoreWebView2Profile3 members
477+
// ICoreWebView2StagingProfile4 members
428478
void Delete();
429479
}
430480
}

0 commit comments

Comments
 (0)