Skip to content

Commit

Permalink
Multiprofile's Delete API modify
Browse files Browse the repository at this point in the history
  • Loading branch information
Denghui Yu committed Dec 16, 2022
1 parent a1a7553 commit 71ec5f8
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions specs/MultiProfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,11 @@ void ScenarioCookieManagement::DeleteAllCookies()
### Delete profile

```cpp
HRESULT AppWindow::DeleteProfile(ICoreWebView2Controller* controller)
HRESULT AppWindow::DeleteProfile(ICoreWebView2* webView2)
{
wil::com_ptr<ICoreWebView2> coreWebView2;
CHECK_FAILURE(controller->get_CoreWebView2(&coreWebView2));
auto webview7 = coreWebView2.try_query<ICoreWebView2_7>();
if (webview7)
{
wil::com_ptr<ICoreWebView2Profile> profile;
CHECK_FAILURE(webview7->get_Profile(&profile));
auto profile2 = profile.try_query<ICoreWebView2StagingProfile4>();
if (profile2)
{
CHECK_FAILURE(profile2->Delete());
}
}
wil::com_ptr<ICoreWebView2Profile> profile;
CHECK_FAILURE(webView2->get_Profile(&profile));
CHECK_FAILURE(profile2->Delete());
}
```
Expand Down Expand Up @@ -253,7 +243,7 @@ public DeleteProfile(CoreWebView2Controller controller)
{
// Get the profile object.
CoreWebView2Profile profile = controller.CoreWebView2.Profile;

// Delete current profile.
profile.Delete();
}
Expand Down Expand Up @@ -365,14 +355,21 @@ interface ICoreWebView2Profile2 : ICoreWebView2Profile {
[uuid(1c1ae2cc-d5c2-ffe3-d3e7-7857035d23b7), object, pointer_default(unique)]
interface ICoreWebView2Profile3 : ICoreWebView2Profile2 {
/// All webviews on this profile will be closed, and the profile will be marked for deletion.
/// After the Delete() call completes, The render process of webviews on this profile will
/// asynchronously exit with the reason:`COREWEBVIEW2_PROCESS_FAILED_REASON_PROFILE_DELETED`.
/// See 'COREWEBVIEW2_PROCESS_FAILED_REASON::COREWEBVIEW2_PROCESS_FAILED_REASON_PROFILE_DELETED'
/// for more details. The profile directory on disk will be actually deleted when the browser
/// process exits. Webview2 creation will fail with the HRESULT is ERROR_INVALID_STATE(0x8007139FL)
/// if you create it with the same name as a profile that is being deleted.
HRESULT Delete();
/// After the API is called, the profile will be marked for deletion. The
/// local profile’s directory will be tried to deleted at browser process
/// exit, if failure to delete, it will recursive try to delete at next
/// browser process start until successful.
/// The corresponding user's `ProfileDeleted` event handle function will
/// be triggered. After the function is triggered, continuing to use the
/// profile or its corresponding webviews is an undefined behavior.
/// After user's `ProfileDeleted` event handle function return or the user
/// does not registered `ProfileDeleted` event handle, all corresponding
/// webviews of this profile (include on InPrivate mode profile) will be
/// auto closed.
/// If create a new profile with the same name as the profile that has been
/// marked as deleted will be failure with the HRESULT:ERROR_INVALID_STATE
/// (0x8007139FL).
HRESULT Delete();
}
```

Expand Down

0 comments on commit 71ec5f8

Please sign in to comment.