Compartilhar via


interface ICoreWebView2Profile

Note

This reference is no longer being maintained. For the latest API reference, see WebView2 API Reference.

interface ICoreWebView2Profile
  : public IUnknown

Profile for ICoreWebView2_12 interface.

Summary

Members Descriptions
get_DefaultDownloadFolderPath Gets the DefaultDownloadFolderPath property.
get_IsInPrivateModeEnabled InPrivate mode is enabled or not.
get_PreferredColorScheme The PreferredColorScheme property sets the overall color scheme of the WebView2s associated with this profile.
get_ProfileName Name of the profile.
get_ProfilePath Full path of the profile directory.
put_DefaultDownloadFolderPath Sets the DefaultDownloadFolderPath property.
put_PreferredColorScheme Sets the PreferredColorScheme property.

Applies to

Product Introduced
WebView2 Win32 1.0.1210.39
WebView2 Win32 Prerelease 1.0.1222

Members

get_DefaultDownloadFolderPath

Gets the DefaultDownloadFolderPath property.

public HRESULT get_DefaultDownloadFolderPath(LPWSTR * value)

The default value is the system default download folder path for the user.

get_IsInPrivateModeEnabled

InPrivate mode is enabled or not.

public HRESULT get_IsInPrivateModeEnabled(BOOL * value)

get_PreferredColorScheme

The PreferredColorScheme property sets the overall color scheme of the WebView2s associated with this profile.

public HRESULT get_PreferredColorScheme(COREWEBVIEW2_PREFERRED_COLOR_SCHEME * value)

This sets the color scheme for WebView2 UI like dialogs, prompts, and context menus by setting the media feature prefers-color-scheme for websites to respond to.

The default value for this is COREWEBVIEW2_PREFERRED_COLOR_AUTO, which will follow whatever theme the OS is currently set to.

void ViewComponent::SetPreferredColorScheme(COREWEBVIEW2_PREFERRED_COLOR_SCHEME value)
{
    wil::com_ptr<ICoreWebView2_12> webView2_12;
    webView2_12 = m_webView.try_query<ICoreWebView2_12>();

    if (webView2_12)
    {
        wil::com_ptr<ICoreWebView2Profile> profile;
        CHECK_FAILURE(webView2_12->get_Profile(&profile));
        profile->put_PreferredColorScheme(value);
    }
}

Returns the value of the PreferredColorScheme property.

get_ProfileName

Name of the profile.

public HRESULT get_ProfileName(LPWSTR * value)

get_ProfilePath

Full path of the profile directory.

public HRESULT get_ProfilePath(LPWSTR * value)

put_DefaultDownloadFolderPath

Sets the DefaultDownloadFolderPath property.

public HRESULT put_DefaultDownloadFolderPath(LPCWSTR value)

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. Returns E_INVALIDARG if the value is invalid, and the default download folder 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.

put_PreferredColorScheme

Sets the PreferredColorScheme property.

public HRESULT put_PreferredColorScheme(COREWEBVIEW2_PREFERRED_COLOR_SCHEME value)