void TrayIcon::SetHighlightMode(bool highlight) {
}
+void TrayIcon::DisplayBalloon(const gfx::ImageSkia& icon,
+ const base::string16& title,
+ const base::string16& contents) {
+}
+
void TrayIcon::NotifyClicked() {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked());
}
// works on OS X.
virtual void SetHighlightMode(bool highlight);
+ // Displays a notification balloon with the specified contents.
+ // Depending on the platform it might not appear by the icon tray.
+ virtual void DisplayBalloon(const gfx::ImageSkia& icon,
+ const base::string16& title,
+ const base::string16& contents);
+
// Set the context menu for this icon.
virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) = 0;
LOG(WARNING) << "Unable to set tooltip for status tray icon";
}
+void NotifyIcon::DisplayBalloon(const gfx::ImageSkia& icon,
+ const base::string16& title,
+ const base::string16& contents) {
+ NOTIFYICONDATA icon_data;
+ InitIconData(&icon_data);
+ icon_data.uFlags = NIF_INFO;
+ icon_data.dwInfoFlags = NIIF_INFO;
+ 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::GetVersion();
+ if (!icon.isNull() && win_version != base::win::VERSION_PRE_XP) {
+ balloon_icon_.Set(IconUtil::CreateHICONFromSkBitmap(*icon.bitmap()));
+ 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 NotifyIcon::SetContextMenu(ui::SimpleMenuModel* menu_model) {
menu_model_ = menu_model;
}
void SetImage(const gfx::ImageSkia& image) override;
void SetPressedImage(const gfx::ImageSkia& image) override;
void SetToolTip(const std::string& tool_tip) override;
+ void DisplayBalloon(const gfx::ImageSkia& icon,
+ const base::string16& title,
+ const base::string16& contents) override;
void SetContextMenu(ui::SimpleMenuModel* menu_model) override;
private:
// The currently-displayed icon for the window.
base::win::ScopedHICON icon_;
+ // The currently-displayed icon for the notification balloon.
+ base::win::ScopedHICON balloon_icon_;
+
// The context menu.
ui::SimpleMenuModel* menu_model_;