Skip to content

Commit

Permalink
Add API:CoreWebView2Profile.Erase
Browse files Browse the repository at this point in the history
  • Loading branch information
Denghui Yu committed Jul 4, 2022
1 parent 6698039 commit 6ce6795
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions specs/MultiProfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,28 @@ void ScenarioCookieManagement::DeleteAllCookies()
CHECK_FAILURE(m_cookieManager->DeleteAllCookies();
}
```

### Delete profile

```cpp
HRESULT AppWindow::DeleteProfile(ICoreWebView2Controller* controller)
{
wil::com_ptr<ICoreWebView2> coreWebView2;
CHECK_FAILURE(controller->get_CoreWebView2(&coreWebView2));
auto webview7 = coreWebView2.try_query<ICoreWebView2_7>();
if (webview7)
{
wil::com_ptr<ICoreWebView2Profile> profile;
CHECK_FAILURE(webview7->get_Profile(&profile));
auto profile2 = profile.try_query<ICoreWebView2StagingProfile4>;
if (profile2)
{
CHECK_FAILURE(profile2->Delete());
}
}
}
```
## .NET and WinRT
### Create WebView2 with a specific profile, then access the profile property of WebView2
Expand Down Expand Up @@ -226,6 +248,17 @@ void DeleteAllCookies()
}
```

```csharp
public DeleteProfile(CoreWebView2Controller controller)
{
// Get the profile object.
CoreWebView2Profile profile = controller.CoreWebView2.Profile;

// Delete current profile.
profile.Delete();
}
```

# API Details

## Win32 C++
Expand All @@ -236,6 +269,7 @@ interface ICoreWebView2Environment5;
interface ICoreWebView2_7;
interface ICoreWebView2Profile;
interface ICoreWebView2Profile2;
interface ICoreWebView2Profile3;
/// This interface is used to manage profile options that created by 'CreateCoreWebView2ControllerOptions'.
[uuid(C2669A3A-03A9-45E9-97EA-03CD55E5DC03), object, pointer_default(unique)]
Expand Down Expand Up @@ -328,6 +362,13 @@ interface ICoreWebView2Profile2 : ICoreWebView2Profile {
/// See ICoreWebView2CookieManager.
[propget] HRESULT CookieManager([out, retval] ICoreWebView2CookieManager** cookieManager);
}
[uuid(1c1ae2cc-d5c2-ffe3-d3e7-7857035d23b7), object, pointer_default(unique)]
interface ICoreWebView2Profile3 : ICoreWebView2Profile2 {
/// Delete the profile completely. All webviews on this profile will be closed and
/// the profile directory on disk will be deleted.
HRESULT Delete();
}
```

## .NET and WinRT
Expand Down Expand Up @@ -379,6 +420,12 @@ namespace Microsoft.Web.WebView2.Core
String ProfilePath { get; };

CoreWebView2CookieManager CookieManager { get; };

[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2Profile4")]
{
// ICoreWebView2Profile4 members
void Delete();
}
}
}
```
Expand Down

0 comments on commit 6ce6795

Please sign in to comment.