Skip to content

Commit 71ec5f8

Browse files
author
Denghui Yu
committed
Multiprofile's Delete API modify
1 parent a1a7553 commit 71ec5f8

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

specs/MultiProfile.md

+20-23
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,11 @@ void ScenarioCookieManagement::DeleteAllCookies()
169169
### Delete profile
170170

171171
```cpp
172-
HRESULT AppWindow::DeleteProfile(ICoreWebView2Controller* controller)
172+
HRESULT AppWindow::DeleteProfile(ICoreWebView2* webView2)
173173
{
174-
wil::com_ptr<ICoreWebView2> coreWebView2;
175-
CHECK_FAILURE(controller->get_CoreWebView2(&coreWebView2));
176-
auto webview7 = coreWebView2.try_query<ICoreWebView2_7>();
177-
if (webview7)
178-
{
179-
wil::com_ptr<ICoreWebView2Profile> profile;
180-
CHECK_FAILURE(webview7->get_Profile(&profile));
181-
auto profile2 = profile.try_query<ICoreWebView2StagingProfile4>();
182-
if (profile2)
183-
{
184-
CHECK_FAILURE(profile2->Delete());
185-
}
186-
}
174+
wil::com_ptr<ICoreWebView2Profile> profile;
175+
CHECK_FAILURE(webView2->get_Profile(&profile));
176+
CHECK_FAILURE(profile2->Delete());
187177
}
188178
```
189179
@@ -253,7 +243,7 @@ public DeleteProfile(CoreWebView2Controller controller)
253243
{
254244
// Get the profile object.
255245
CoreWebView2Profile profile = controller.CoreWebView2.Profile;
256-
246+
257247
// Delete current profile.
258248
profile.Delete();
259249
}
@@ -365,14 +355,21 @@ interface ICoreWebView2Profile2 : ICoreWebView2Profile {
365355
366356
[uuid(1c1ae2cc-d5c2-ffe3-d3e7-7857035d23b7), object, pointer_default(unique)]
367357
interface ICoreWebView2Profile3 : ICoreWebView2Profile2 {
368-
/// All webviews on this profile will be closed, and the profile will be marked for deletion.
369-
/// After the Delete() call completes, The render process of webviews on this profile will
370-
/// asynchronously exit with the reason:`COREWEBVIEW2_PROCESS_FAILED_REASON_PROFILE_DELETED`.
371-
/// See 'COREWEBVIEW2_PROCESS_FAILED_REASON::COREWEBVIEW2_PROCESS_FAILED_REASON_PROFILE_DELETED'
372-
/// for more details. The profile directory on disk will be actually deleted when the browser
373-
/// process exits. Webview2 creation will fail with the HRESULT is ERROR_INVALID_STATE(0x8007139FL)
374-
/// if you create it with the same name as a profile that is being deleted.
375-
HRESULT Delete();
358+
/// After the API is called, the profile will be marked for deletion. The
359+
/// local profile’s directory will be tried to deleted at browser process
360+
/// exit, if failure to delete, it will recursive try to delete at next
361+
/// browser process start until successful.
362+
/// The corresponding user's `ProfileDeleted` event handle function will
363+
/// be triggered. After the function is triggered, continuing to use the
364+
/// profile or its corresponding webviews is an undefined behavior.
365+
/// After user's `ProfileDeleted` event handle function return or the user
366+
/// does not registered `ProfileDeleted` event handle, all corresponding
367+
/// webviews of this profile (include on InPrivate mode profile) will be
368+
/// auto closed.
369+
/// If create a new profile with the same name as the profile that has been
370+
/// marked as deleted will be failure with the HRESULT:ERROR_INVALID_STATE
371+
/// (0x8007139FL).
372+
HRESULT Delete();
376373
}
377374
```
378375

0 commit comments

Comments
 (0)