Chromium Code Reviews| Index: ui/views/win/hwnd_message_handler.cc |
| diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc |
| index 7d4857d309c9f5d6215929aeacaa35a42450ed7b..fa2b1f9857e1764af45b975ea4e9878301b88501 100644 |
| --- a/ui/views/win/hwnd_message_handler.cc |
| +++ b/ui/views/win/hwnd_message_handler.cc |
| @@ -808,23 +808,14 @@ void HWNDMessageHandler::FrameTypeChanged() { |
| void HWNDMessageHandler::SetWindowIcons(const gfx::ImageSkia& window_icon, |
| const gfx::ImageSkia& app_icon) { |
| if (!window_icon.isNull()) { |
| - HICON windows_icon = IconUtil::CreateHICONFromSkBitmap( |
| - *window_icon.bitmap()); |
| - // We need to make sure to destroy the previous icon, otherwise we'll leak |
| - // these GDI objects until we crash! |
| - HICON old_icon = reinterpret_cast<HICON>( |
| - SendMessage(hwnd(), WM_SETICON, ICON_SMALL, |
| - reinterpret_cast<LPARAM>(windows_icon))); |
| - if (old_icon) |
| - DestroyIcon(old_icon); |
| + window_icon_.Set(IconUtil::CreateHICONFromSkBitmap(*window_icon.bitmap())); |
|
sky
2015/11/03 17:23:16
Seems risky to destroy the old icon (as Set destro
|
| + SendMessage(hwnd(), WM_SETICON, ICON_SMALL, |
| + reinterpret_cast<LPARAM>(window_icon_.Get())); |
| } |
| if (!app_icon.isNull()) { |
| - HICON windows_icon = IconUtil::CreateHICONFromSkBitmap(*app_icon.bitmap()); |
| - HICON old_icon = reinterpret_cast<HICON>( |
| - SendMessage(hwnd(), WM_SETICON, ICON_BIG, |
| - reinterpret_cast<LPARAM>(windows_icon))); |
| - if (old_icon) |
| - DestroyIcon(old_icon); |
| + app_icon_.Set(IconUtil::CreateHICONFromSkBitmap(*app_icon.bitmap())); |
| + SendMessage(hwnd(), WM_SETICON, ICON_BIG, |
| + reinterpret_cast<LPARAM>(app_icon_.Get())); |
| } |
| } |