CoreWebView2Profile Class
Multiple profiles can be created under a single user data directory but with separated cookies, user preference settings, and various data storage etc.. If the CoreWebView2 was created with a CoreWebView2ControllerOptions, the CoreWebView2Profile will match those specified options. Otherwise if this CoreWebView2 was created without a CoreWebView2ControllerOptions, then this will be the default CoreWebView2Profile for the corresponding CoreWebView2Environment.
Summary
Members | Description |
---|---|
DefaultDownloadFolderPath | The default download folder path. |
IsInPrivateModeEnabled | InPrivate mode is enabled or not. |
PreferredColorScheme | The PreferredColorScheme property sets the overall color scheme of the WebView2s associated with this profile. |
ProfileName | The name of the profile. |
ProfilePath | Full path of the profile directory. |
ClearBrowsingDataAsync | Clears browsing data for dataKinds between startTime and endTime. |
ClearBrowsingDataAsync | Clears all browsing data associated with the profile this method is called on regardless of timestamp. |
ClearBrowsingDataAsync | Clear the browsing data of the associated profile. |
Properties
DefaultDownloadFolderPath
string DefaultDownloadFolderPath
The default download folder path. The default value is the system default download folder path for the user. The default download folder path is persisted in the user data folder across sessions. The value should be an absolute path to a folder that the user and application can write to. Throws an exception if the value is invalid, and the default download path is not changed. Otherwise the path is changed immediately. If the directory does not yet exist, it is created at the time of the next download. If the host application does not have permission to create the directory, then the user is prompted to provide a new path through the Save As dialog. The user can override the default download folder path for a given download by choosing a different path in the Save As dialog.
IsInPrivateModeEnabled
readonly bool IsInPrivateModeEnabled
InPrivate mode is enabled or not.
PreferredColorScheme
CoreWebView2PreferredColorScheme PreferredColorScheme
The PreferredColorScheme property sets the overall color scheme of the WebView2s associated with this profile.
This sets the color scheme for WebView2 UI like dialogs, prompts, and menus by setting the media feature prefers-color-scheme
.
The default value for this is CoreWebView2PreferredColorScheme.Auto, which will follow whatever color scheme the OS is currently set to.
ProfileName
readonly string ProfileName
The name of the profile.
ProfilePath
readonly string ProfilePath
Full path of the profile directory.
Methods
ClearBrowsingDataAsync
IAsyncAction ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds dataKinds, DateTime startTime, DateTime endTime)
Clears browsing data for dataKinds between startTime and endTime.
ClearBrowsingDataAsync
IAsyncAction ClearBrowsingDataAsync()
Clears all browsing data associated with the profile this method is called on regardless of timestamp.
ClearBrowsingDataAsync
IAsyncAction ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds dataKinds)
Clear the browsing data of the associated profile. Clears browsing data on the profile the method is called on. Additional optional parameters include the start time and end time to clear the browsing data between as well as the data specific data kinds to clear on the profile. The method may be overloaded to take:
- No parameters - in which the entirety of the data on the profile will be cleared.
- The data kind(s) - in which the data kind(s) will be cleared for their entirety.
- The data kind(s), start time, and end time - in which the data kind(s) will be cleared between the start and end time. The start time will be offset by -1.0 and the end time will be offset by +1.0 to include the last fractional second on each respective end. The start time is inclusive in the time period while the end time is exclusive.
The exposed methods are as follows:
ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds dataKinds);
ClearBrowsingDataAsync(CoreWebView2BrowsingDataKinds dataKinds, DateTime startTime, DateTime endTime);
ClearBrowsingDataAsync();