@@ -169,21 +169,11 @@ void ScenarioCookieManagement::DeleteAllCookies()
169
169
### Delete profile
170
170
171
171
``` cpp
172
- HRESULT AppWindow::DeleteProfile (ICoreWebView2Controller * controller )
172
+ HRESULT AppWindow::DeleteProfile (ICoreWebView2 * webView2 )
173
173
{
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());
187
177
}
188
178
```
189
179
@@ -253,7 +243,7 @@ public DeleteProfile(CoreWebView2Controller controller)
253
243
{
254
244
// Get the profile object.
255
245
CoreWebView2Profile profile = controller .CoreWebView2 .Profile ;
256
-
246
+
257
247
// Delete current profile.
258
248
profile .Delete ();
259
249
}
@@ -365,13 +355,19 @@ interface ICoreWebView2Profile2 : ICoreWebView2Profile {
365
355
366
356
[uuid(1c1ae2cc-d5c2-ffe3-d3e7-7857035d23b7), object, pointer_default(unique)]
367
357
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.
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).
375
371
HRESULT Delete();
376
372
}
377
373
```
0 commit comments