| Index: chrome/browser/ui/views/status_icons/status_icon_win.cc
|
| diff --git a/chrome/browser/ui/views/status_icons/status_icon_win.cc b/chrome/browser/ui/views/status_icons/status_icon_win.cc
|
| index 9e16e0fdf69a25f4e3b4d6fb598daf0a67195998..1d1026c43f7588eedb3845234874202a2c848eb6 100644
|
| --- a/chrome/browser/ui/views/status_icons/status_icon_win.cc
|
| +++ b/chrome/browser/ui/views/status_icons/status_icon_win.cc
|
| @@ -5,6 +5,7 @@
|
| #include "chrome/browser/ui/views/status_icons/status_icon_win.h"
|
|
|
| #include "base/sys_string_conversions.h"
|
| +#include "base/win/windows_version.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| #include "ui/gfx/icon_util.h"
|
| #include "ui/gfx/point.h"
|
| @@ -28,6 +29,10 @@ StatusIconWin::StatusIconWin(UINT id, HWND window, UINT message)
|
| }
|
|
|
| StatusIconWin::~StatusIconWin() {
|
| + // Force to hide the balloon if any. Otherwise it might keep the icon in
|
| + // the tray until the balloon goes away.
|
| + HideBalloon();
|
| +
|
| // Remove our icon.
|
| NOTIFYICONDATA icon_data;
|
| InitIconData(&icon_data);
|
| @@ -84,8 +89,6 @@ void StatusIconWin::SetToolTip(const string16& tool_tip) {
|
| void StatusIconWin::DisplayBalloon(const SkBitmap& icon,
|
| const string16& title,
|
| const string16& contents) {
|
| - // TODO(leandrogracia): implement custom icons for notification balloons.
|
| -
|
| NOTIFYICONDATA icon_data;
|
| InitIconData(&icon_data);
|
| icon_data.uFlags = NIF_INFO;
|
| @@ -93,11 +96,34 @@ void StatusIconWin::DisplayBalloon(const SkBitmap& icon,
|
| wcscpy_s(icon_data.szInfoTitle, title.c_str());
|
| wcscpy_s(icon_data.szInfo, contents.c_str());
|
| icon_data.uTimeout = 0;
|
| +
|
| + base::win::Version win_version = base::win::OSInfo::GetInstance()->version();
|
| + if (!icon.empty() && win_version != base::win::VERSION_PRE_XP) {
|
| + balloon_icon_.Set(IconUtil::CreateHICONFromSkBitmap(icon));
|
| + if (win_version >= base::win::VERSION_VISTA) {
|
| + icon_data.hBalloonIcon = balloon_icon_.Get();
|
| + icon_data.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON;
|
| + } else {
|
| + icon_data.hIcon = balloon_icon_.Get();
|
| + icon_data.uFlags |= NIF_ICON;
|
| + icon_data.dwInfoFlags = NIIF_USER;
|
| + }
|
| + }
|
| +
|
| BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
|
| if (!result)
|
| LOG(WARNING) << "Unable to create status tray balloon.";
|
| }
|
|
|
| +void StatusIconWin::HideBalloon() {
|
| + NOTIFYICONDATA icon_data;
|
| + InitIconData(&icon_data);
|
| + icon_data.szInfo[0] = '\0';
|
| + BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
|
| + if (!result)
|
| + LOG(WARNING) << "Unable to hide status tray balloon.";
|
| +}
|
| +
|
| void StatusIconWin::UpdatePlatformContextMenu(ui::MenuModel* menu) {
|
| #if defined(USE_AURA)
|
| // crbug.com/99489.
|
| @@ -134,7 +160,11 @@ void StatusIconWin::HandleClickEvent(int x, int y, bool left_mouse_click) {
|
| }
|
|
|
| void StatusIconWin::InitIconData(NOTIFYICONDATA* icon_data) {
|
| - icon_data->cbSize = sizeof(NOTIFYICONDATA);
|
| + if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA)
|
| + icon_data->cbSize = sizeof(NOTIFYICONDATA);
|
| + else
|
| + icon_data->cbSize = NOTIFYICONDATA_V3_SIZE;
|
| +
|
| icon_data->hWnd = window_;
|
| icon_data->uID = icon_id_;
|
| }
|
|
|