Skip to content

Commit

Permalink
multiple profile Delete API's review spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Denghui Yu committed Jul 26, 2022
1 parent 6698039 commit 470a1af
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions specs/ExtendedProcessFailed.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ std::wstring ProcessComponent::ProcessFailedReasonToString(
REASON_ENTRY(COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED);
REASON_ENTRY(COREWEBVIEW2_PROCESS_FAILED_REASON_LAUNCH_FAILED);
REASON_ENTRY(COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY);
REASON_ENTRY(COREWEBVIEW2_PROCESS_FAILED_REASON_PROFILE_DELETED);

#undef REASON_ENTRY
}
Expand Down Expand Up @@ -544,6 +545,9 @@ typedef enum COREWEBVIEW2_PROCESS_FAILED_REASON {

/// The process died due to running out of memory.
COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY,

/// The process exited due to the related profile is deleted.
COREWEBVIEW2_PROCESS_FAILED_REASON_PROFILE_DELETED,
} COREWEBVIEW2_PROCESS_FAILED_REASON;

/// A continuation of `ICoreWebView2ProcessFailedEventArgs` interface.
Expand Down
49 changes: 49 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,15 @@ 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 {
/// All webviews on this profile will be closed, and the profile will be marked for deletion.
/// 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.
/// The profile directory on disk will be actually deleted when the browser process exits.
/// It will be failure to create a new profile with the name of the deleting profile.
HRESULT Delete();
}
```

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

CoreWebView2CookieManager CookieManager { get; };

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

0 comments on commit 470a1af

Please sign in to comment.