@@ -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. 
255245CoreWebView2Profile  profile  =  controller .CoreWebView2 .Profile ;
256-      
246+ 
257247    //  Delete current profile. 
258248profile .Delete ();
259249}
@@ -365,13 +355,19 @@ interface ICoreWebView2Profile2 : ICoreWebView2Profile {
365355
366356[uuid(1c1ae2cc-d5c2-ffe3-d3e7-7857035d23b7), object, pointer_default(unique)] 
367357interface 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. 
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+   /// All corresponding webviews of this profile (include on InPrivate mode 
366+   /// profile) will be auto closed after user's `ProfileDeleted` event handle 
367+   /// function return. 
368+   /// If create a new profile with the same name as the profile that has been 
369+   /// marked as deleted will be failure with the HRESULT:ERROR_INVALID_STATE 
370+   /// (0x8007139FL). 
375371  HRESULT Delete();  
376372} 
377373``` 
0 commit comments