Skip to content

Commit d35d4f6

Browse files
renamed file and updated to profile
1 parent c307c32 commit d35d4f6

1 file changed

Lines changed: 24 additions & 15 deletions

File tree

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ For reference, in the screenshot below, this API is meant to expose the Overall
1414
## C++
1515

1616
```cpp
17-
wil::com_ptr<ICoreWebView2Profile> m_profile;
17+
wil::com_ptr<ICoreWebView2> m_webView;
1818

1919
void ViewComponent::SetTheme(COREWEBVIEW2_THEME_KIND value)
2020
{
21-
wil::com_ptr<ICoreWebView2Profile> webViewProfile;
21+
wil::com_ptr<ICoreWebView2_7> webView7;
22+
webView7 = m_webView.try_query<ICoreWebView2_7>();
2223

23-
CHECK_FAILURE(m_profile->QueryInterface(IID_PPV_ARGS(&webViewProfile)));
24-
if (webViewProfile)
24+
if (ICoreWebView2_7)
2525
{
26-
CHECK_FAILURE(webViewProfile->put_Theme(value));
26+
wil::com_ptr<ICoreWebView2Profile> profile;
27+
CHECK_FAILURE(ICoreWebView2_7->get_Profile(&profile));
28+
29+
auto profile2 = profile.try_query<ICoreWebView2Profile2>();
30+
if (profile2)
31+
{
32+
profile2->put_Theme(value);
33+
}
2734
}
2835
}
2936
```
@@ -32,14 +39,14 @@ void ViewComponent::SetTheme(COREWEBVIEW2_THEME_KIND value)
3239
3340
```c#
3441
35-
private CoreWebView2Profile m_profile;
42+
private CoreWebView2 m_webView;
3643
3744
void SetTheme(CoreWebView2ThemeKind value)
3845
{
3946
// Check for runtime support
4047
try
4148
{
42-
m_profile.Theme = value;
49+
m_webView.Profile.Theme = value;
4350
}
4451
catch (NotImplementedException exception)
4552
{
@@ -54,15 +61,16 @@ void SetTheme(CoreWebView2ThemeKind value)
5461
## C++
5562
```cpp
5663
[uuid(5f817cce-5d36-4cd0-a1d5-aaaf95c8685f), object, pointer_default(unique)]
57-
interface ICoreWebView2Controller4 : ICoreWebView2Controller3 {
64+
interface ICoreWebView2Profile2 : ICoreWebView2Profile {
5865
/// The Theme property sets the overall theme of the WebView2 instance.
5966
/// The input parameter is either COREWEBVIEW2_THEME_KIND_SYSTEM,
6067
/// COREWEBVIEW2_THEME_KIND_LIGHT, or COREWEBVIEW2_THEME_KIND_DARK.
61-
/// Note that this API applies theme to WebView2 pages, dialogs, menus,
62-
/// and sets the media feature `prefers-color-scheme` for websites to respond to.
68+
/// Note that this API applies theme to WebView2 pages, dialogs, and menus
69+
/// by setting the media feature `prefers-color-scheme` for websites to
70+
/// respond to.
6371
///
64-
/// \snippet ViewComponents.cpp SetAppearance
65-
/// Returns the value of the `Appearance` property.
72+
/// \snippet ViewComponent.cpp SetTheme
73+
/// Returns the value of the `Theme` property.
6674
[propget] HRESULT Theme(
6775
[out, retval] COREWEBVIEW2_THEME_KIND* value);
6876

@@ -100,14 +108,15 @@ namespace Microsoft.Web.WebView2.Core
100108
Dark = 2,
101109
};
102110

111+
[doc_string("Multiple profiles can be created under a single user data directory but with separated cookies, user preference settings, and various data storage etc..")]
103112
runtimeclass CoreWebView2Profile
104113
{
105114
// ...
106115
107-
[interface_name("Microsoft.Web.WebView2.Core.CoreWebView2Profile")]
116+
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2Profile2")]
108117
{
109-
// CoreWebView2Profile members
110-
CoreWebView2ThemeKind Theme { get; set; };
118+
[doc_string("The Theme property sets the overall theme of the WebView2 instance.")]
119+
CoreWebView2ThemeKind Theme { get; set };
111120
}
112121
}
113122
}

0 commit comments

Comments
 (0)