@@ -165,6 +165,28 @@ void ScenarioCookieManagement::DeleteAllCookies()
165
165
CHECK_FAILURE(m_cookieManager->DeleteAllCookies();
166
166
}
167
167
```
168
+
169
+ ### Delete profile
170
+
171
+ ``` cpp
172
+ HRESULT AppWindow::DeleteProfile (ICoreWebView2Controller* controller)
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
+ }
187
+ }
188
+ ```
189
+
168
190
## .NET and WinRT
169
191
170
192
### Create WebView2 with a specific profile, then access the profile property of WebView2
@@ -226,6 +248,17 @@ void DeleteAllCookies()
226
248
}
227
249
```
228
250
251
+ ``` csharp
252
+ public DeleteProfile (CoreWebView2Controller controller )
253
+ {
254
+ // Get the profile object.
255
+ CoreWebView2Profile profile = controller .CoreWebView2 .Profile ;
256
+
257
+ // Delete current profile.
258
+ profile .Delete ();
259
+ }
260
+ ```
261
+
229
262
# API Details
230
263
231
264
## Win32 C++
@@ -236,6 +269,7 @@ interface ICoreWebView2Environment5;
236
269
interface ICoreWebView2_7;
237
270
interface ICoreWebView2Profile;
238
271
interface ICoreWebView2Profile2;
272
+ interface ICoreWebView2Profile3;
239
273
240
274
/// This interface is used to manage profile options that created by 'CreateCoreWebView2ControllerOptions'.
241
275
[uuid(C2669A3A-03A9-45E9-97EA-03CD55E5DC03), object, pointer_default(unique)]
@@ -328,6 +362,15 @@ interface ICoreWebView2Profile2 : ICoreWebView2Profile {
328
362
/// See ICoreWebView2CookieManager.
329
363
[propget] HRESULT CookieManager([out, retval] ICoreWebView2CookieManager** cookieManager);
330
364
}
365
+
366
+ [uuid(1c1ae2cc-d5c2-ffe3-d3e7-7857035d23b7), object, pointer_default(unique)]
367
+ interface ICoreWebView2Profile3 : ICoreWebView2Profile2 {
368
+ /// All webviews on this profile will be closed, and the profile will be marked for deletion.
369
+ /// The render process of webviews on this profile will async exit with reason. See 'COREWEBVIEW2_PROCESS_FAILED_REASON::COREWEBVIEW2_PROCESS_FAILED_REASON_PROFILE_DELETED' for more details.
370
+ /// The profile directory on disk will be actually deleted when the browser process exits.
371
+ /// It will be failure to create a new profile with the name of the deleting profile.
372
+ HRESULT Delete();
373
+ }
331
374
```
332
375
333
376
## .NET and WinRT
@@ -379,6 +422,12 @@ namespace Microsoft.Web.WebView2.Core
379
422
String ProfilePath { get ; };
380
423
381
424
CoreWebView2CookieManager CookieManager { get ; };
425
+
426
+ [interface_name (" Microsoft.Web.WebView2.Core.ICoreWebView2Profile3" )]
427
+ {
428
+ // ICoreWebView2Profile3 members
429
+ void Delete ();
430
+ }
382
431
}
383
432
}
384
433
```
0 commit comments