From d40cfb073d4ae6ec8bb7b7c7668424894e8b7595 Mon Sep 17 00:00:00 2001 From: Denghui Yu Date: Thu, 15 Dec 2022 16:13:02 +0800 Subject: [PATCH] Multiprofile's Delete API modify --- specs/MultiProfile.md | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/specs/MultiProfile.md b/specs/MultiProfile.md index 14ae95c32..5dfc573d2 100644 --- a/specs/MultiProfile.md +++ b/specs/MultiProfile.md @@ -169,21 +169,11 @@ void ScenarioCookieManagement::DeleteAllCookies() ### Delete profile ```cpp -HRESULT AppWindow::DeleteProfile(ICoreWebView2Controller* controller) +HRESULT AppWindow::DeleteProfile(ICoreWebView2* webView2) { - wil::com_ptr coreWebView2; - CHECK_FAILURE(controller->get_CoreWebView2(&coreWebView2)); - auto webview7 = coreWebView2.try_query(); - if (webview7) - { - wil::com_ptr profile; - CHECK_FAILURE(webview7->get_Profile(&profile)); - auto profile2 = profile.try_query(); - if (profile2) - { - CHECK_FAILURE(profile2->Delete()); - } - } + wil::com_ptr profile; + CHECK_FAILURE(webView2->get_Profile(&profile)); + CHECK_FAILURE(profile2->Delete()); } ``` @@ -253,7 +243,7 @@ public DeleteProfile(CoreWebView2Controller controller) { // Get the profile object. CoreWebView2Profile profile = controller.CoreWebView2.Profile; - + // Delete current profile. profile.Delete(); } @@ -365,13 +355,19 @@ 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. + /// 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. + /// All corresponding webviews of this profile (include on InPrivate mode + /// profile) will be auto closed after user's `ProfileDeleted` event handle + /// function return. + /// 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(); } ```