Compartir a través de


interface ICoreWebView2Profile

interface ICoreWebView2Profile
  : public IUnknown

Provides a set of properties to configure a Profile object.

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.
        CHECK_FAILURE(webViewEnvironment10->CreateCoreWebView2CompositionControllerWithOptions(
            m_mainWindow, options.get(),
            Callback<ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler>(
                [this](
                    HRESULT result,
                    ICoreWebView2CompositionController* compositionController) -> HRESULT
                {
                    auto controller =
                        wil::com_ptr<ICoreWebView2CompositionController>(compositionController)
                            .query<ICoreWebView2Controller>();
                    return OnCreateCoreWebView2ControllerCompleted(result, controller.get());
                })
                .Get()));

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.

The caller must free the returned string with CoTaskMemFree. See API Conventions.

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_13> webView2_13;
    webView2_13 = m_webView.try_query<ICoreWebView2_13>();

    if (webView2_13)
    {
        wil::com_ptr<ICoreWebView2Profile> profile;
        CHECK_FAILURE(webView2_13->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)

The caller must free the returned string with CoTaskMemFree. See API Conventions.

get_ProfilePath

Full path of the profile directory.

public HRESULT get_ProfilePath(LPWSTR * value)

The caller must free the returned string with CoTaskMemFree. See API Conventions.

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)