@@ -171,12 +171,13 @@ void ScenarioCookieManagement::DeleteAllCookies()
171171``` cpp
172172HRESULT AppWindow::DeleteProfile (ICoreWebView2* webView2)
173173{
174+ DCHECK(webView2);
174175 wil::com_ptr<ICoreWebView2Profile > profile;
175176 CHECK_FAILURE(webView2->get_Profile(&profile));
176177 CHECK_FAILURE(profile2->Delete());
177178}
178179
179- void AppWindow::RegisterEventHandlers (ICoreWebView2* webView2)
180+ void AppWindow::RegisterProfileDeletedEventHandlers (ICoreWebView2* webView2)
180181{
181182 wil::com_ptr<ICoreWebView2Profile > profile;
182183 CHECK_FAILURE(webView2->get_Profile(&profile));
@@ -265,10 +266,10 @@ void DeleteAllCookies()
265266```
266267
267268``` csharp
268- public DeleteProfile (CoreWebView2Controller controller )
269+ public DeleteProfile (CoreWebView2 coreWebView2 )
269270{
270271 // Delete current profile.
271- controller . CoreWebView2 .Profile .Delete ();
272+ CoreWebView2 .Profile .Delete ();
272273}
273274
274275void WebView_CoreWebView2InitializationCompleted (object sender , CoreWebView2InitializationCompletedEventArgs e )
@@ -396,20 +397,22 @@ interface ICoreWebView2Profile2 : ICoreWebView2Profile {
396397[uuid(2765B8BD-7C57-4B76-B8CC-1EC940FF92CC), object, pointer_default(unique)]
397398interface ICoreWebView2StagingProfile7 : IUnknown {
398399 /// After the API is called, the profile will be marked for deletion. The
399- /// local profile's directory will be tried to delete at browser process
400- /// exit, if fail to delete, it will recursively try to delete at next
401- /// browser process start until successful.
402- /// The corresponding webview2s will be auto closed and profile's Deleted
403- /// event will be raised. See `Profile.Deleted` for more information.
404- /// If create a new profile with the same name as the profile that has been
405- /// marked as deleted will be failure with the HRESULT:ERROR_INVALID_STATE
406- /// (0x8007139FL).
400+ /// local profile's directory will be deleted at browser process exit. If it
401+ /// fails to delete, because something else is holding the files open,
402+ /// WebView2 will try to delete again during all future at next browser
403+ /// process starts until successful.
404+ /// The corresponding CoreWebView2s will be closed and the
405+ /// CoreWebView2Profile.Deleted event will be raised. See
406+ /// `CoreWebView2Profile.Deleted` for more information.
407+ /// If you try to create a new profile with the same name as an existing
408+ /// profile that has been marked as deleted but hasn't yet been deleted,
409+ /// profile creation will fail with HRESULT_FROM_WIN32(ERROR_INVALID_STATE).
407410 HRESULT Delete();
408411
409- /// Add an event handler for the `Deleted` event. `Deleted` event handle runs
410- /// when the profile's Delete API is called . When this event is raised, the
411- /// profile and its corresponding webview2 moves to the Closed state, and
412- /// cannot be used anymore.
412+ /// Add an event handler for the `Deleted` event. The `Deleted` event is
413+ /// raised when the profile is marked for deletion . When this event is
414+ /// raised, the CoreWebView2Profile and its corresponding CoreWebView2s are
415+ /// closed, and cannot be used anymore.
413416 HRESULT add_Deleted(
414417 [in] ICoreWebView2StagingProfileDeletedEventHandler* eventHandler,
415418 [out] EventRegistrationToken* token);
0 commit comments