Skip to content

Commit f3b6304

Browse files
authored
Fixed some win32 feedback and an issue with leaving experiment in
1 parent 47e2a12 commit f3b6304

File tree

1 file changed

+40
-35
lines changed

1 file changed

+40
-35
lines changed

specs/GetFavicon.md

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,45 @@ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
1212
// Initialize GDI+.
1313
Gdiplus::GdiplusStartup(&gdiplusToken_, &gdiplusStartupInput, NULL);
1414
CHECK_FAILURE(m_webView2->add_FaviconChanged(
15-
Callback<ICoreWebView2ExperimentalFaviconChangedEventHandler>(
15+
Callback<ICoreWebView2FaviconChangedEventHandler>(
1616
[this](ICoreWebView2* sender, IUnknown* args) -> HRESULT {
17-
if (m_faviconChanged)
18-
{
19-
wil::unique_cotaskmem_string url;
20-
Microsoft::WRL::ComPtr<ICoreWebView2>
21-
webview2Experimental;
22-
CHECK_FAILURE(
23-
sender->QueryInterface(IID_PPV_ARGS(&webview2)));
24-
25-
CHECK_FAILURE(webview2Experimental->get_FaviconUri(&url));
26-
std::wstring strUrl(url.get());
27-
28-
webview2->GetFavicon(
29-
COREWEBVIEW2_FAVICON_IMAGE_FORMAT_PNG,
30-
Callback<ICoreWebView2ExperimentalGetFaviconCompletedHandler>(
31-
[this, strUrl](HRESULT errorCode, IStream* iconStream) -> HRESULT
17+
wil::unique_cotaskmem_string url;
18+
Microsoft::WRL::ComPtr<ICoreWebView2>
19+
webview2;
20+
CHECK_FAILURE(
21+
sender->QueryInterface(IID_PPV_ARGS(&webview2)));
22+
23+
CHECK_FAILURE(webview2->get_FaviconUri(&url));
24+
std::wstring strUrl(url.get());
25+
26+
webview2->GetFavicon(
27+
COREWEBVIEW2_FAVICON_IMAGE_FORMAT_PNG,
28+
Callback<ICoreWebView2GetFaviconCompletedHandler>(
29+
[this, strUrl](HRESULT errorCode, IStream* iconStream) -> HRESULT
30+
{
31+
CHECK_FAILURE(errorCode);
32+
Gdiplus::Bitmap iconBitmap(iconStream);
33+
wil::unique_hicon icon;
34+
if (iconBitmap.GetHICON(&icon) == Gdiplus::Status::Ok)
3235
{
33-
CHECK_FAILURE(errorCode);
34-
Gdiplus::Bitmap iconBitmap(iconStream);
35-
wil::unique_hicon icon;
36-
if (!iconBitmap.GetHICON(&icon))
37-
{
38-
m_favicon = std::move(icon);
39-
SendMessage(
40-
m_appWindow->GetMainWindow(), WM_SETICON,
41-
ICON_SMALL, (LPARAM)m_favicon.get());
42-
m_statusBar.Show(strUrl);
43-
}
44-
45-
return S_OK;
46-
})
47-
.Get());
48-
}
36+
m_favicon = std::move(icon);
37+
SendMessage(
38+
m_appWindow->GetMainWindow(), WM_SETICON,
39+
ICON_SMALL, (LPARAM)m_favicon.get());
40+
m_statusBar.Show(strUrl);
41+
}
42+
else
43+
{
44+
SendMessage(
45+
m_appWindow->GetMainWindow(), WM_SETICON,
46+
ICON_SMALL, (LPARAM)IDC_NO);
47+
m_statusBar.Show(L"No Icon");
48+
}
49+
50+
return S_OK;
51+
})
52+
.Get());
53+
4954
return S_OK;
5055
}).Get(), &m_faviconChangedToken));
5156
}
@@ -92,14 +97,14 @@ interface ICoreWebView2FaviconChangedEventHandler : IUnknown {
9297
/// then no data would be copied into the imageStream.
9398
/// For more details, see the `GetFavicon` API.
9499
[uuid(A2508329-7DA8-49D7-8C05-FA125E4AEE8D), object, pointer_default(unique)]
95-
interface ICoreWebView2ExperimentalGetFaviconCompletedHandler : IUnknown {
100+
interface ICoreWebView2GetFaviconCompletedHandler : IUnknown {
96101
/// Called to notify the favicon has been retrieved.
97102
HRESULT Invoke(
98103
[in] HRESULT errorCode,
99104
[in] IStream* faviconStream);
100105
}
101106

102-
/// This is the ICoreWebView2 Experimental Favicon interface.
107+
/// This is the ICoreWebView2 Favicon interface.
103108
[uuid(DC838C64-F64B-4DC7-98EC-0992108E2157), object, pointer_default(unique)]
104109
interface ICoreWebView2_10 : ICoreWebView2_9 {
105110
/// Add an event handler for the `FaviconChanged` event.
@@ -113,7 +118,7 @@ interface ICoreWebView2_10 : ICoreWebView2_9 {
113118
/// to set its favicon. The favicon information can then be retrieved with
114119
/// `GetFavicon` and `FaviconUri`.
115120
HRESULT add_FaviconChanged(
116-
[in] ICoreWebViewFaviconChangedEventHandler* eventHandler,
121+
[in] ICoreWebView2FaviconChangedEventHandler* eventHandler,
117122
[out] EventRegistrationToken* token);
118123

119124
/// Remove the event handler for `FaviconChanged` event.

0 commit comments

Comments
 (0)