Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: chrome/browser/ui/views/status_icons/status_icon_win.cc

Issue 8379003: Implementing custom notification icons for the DisplayBalloon method on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing uninitialized NOTIFIYICONDATA. HideBalloon not required anymore. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/status_icons/status_icon_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" 5 #include "chrome/browser/ui/views/status_icons/status_icon_win.h"
6 6
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "base/win/windows_version.h"
8 #include "third_party/skia/include/core/SkBitmap.h" 9 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "ui/gfx/icon_util.h" 10 #include "ui/gfx/icon_util.h"
10 #include "ui/gfx/point.h" 11 #include "ui/gfx/point.h"
11 #if !defined(USE_AURA) 12 #if !defined(USE_AURA)
12 #include "views/controls/menu/menu_2.h" 13 #include "views/controls/menu/menu_2.h"
13 #endif 14 #endif
14 15
15 StatusIconWin::StatusIconWin(UINT id, HWND window, UINT message) 16 StatusIconWin::StatusIconWin(UINT id, HWND window, UINT message)
16 : icon_id_(id), 17 : icon_id_(id),
17 window_(window), 18 window_(window),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 icon_data.uFlags = NIF_TIP; 78 icon_data.uFlags = NIF_TIP;
78 wcscpy_s(icon_data.szTip, tool_tip.c_str()); 79 wcscpy_s(icon_data.szTip, tool_tip.c_str());
79 BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data); 80 BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
80 if (!result) 81 if (!result)
81 LOG(WARNING) << "Unable to set tooltip for status tray icon"; 82 LOG(WARNING) << "Unable to set tooltip for status tray icon";
82 } 83 }
83 84
84 void StatusIconWin::DisplayBalloon(const SkBitmap& icon, 85 void StatusIconWin::DisplayBalloon(const SkBitmap& icon,
85 const string16& title, 86 const string16& title,
86 const string16& contents) { 87 const string16& contents) {
87 // TODO(leandrogracia): implement custom icons for notification balloons.
88
89 NOTIFYICONDATA icon_data; 88 NOTIFYICONDATA icon_data;
90 InitIconData(&icon_data); 89 InitIconData(&icon_data);
91 icon_data.uFlags = NIF_INFO; 90 icon_data.uFlags = NIF_INFO;
92 icon_data.dwInfoFlags = NIIF_INFO; 91 icon_data.dwInfoFlags = NIIF_INFO;
93 wcscpy_s(icon_data.szInfoTitle, title.c_str()); 92 wcscpy_s(icon_data.szInfoTitle, title.c_str());
94 wcscpy_s(icon_data.szInfo, contents.c_str()); 93 wcscpy_s(icon_data.szInfo, contents.c_str());
95 icon_data.uTimeout = 0; 94 icon_data.uTimeout = 0;
95
96 base::win::Version win_version = base::win::OSInfo::GetInstance()->version();
97 if (!icon.empty() && win_version != base::win::VERSION_PRE_XP) {
98 balloon_icon_.Set(IconUtil::CreateHICONFromSkBitmap(icon));
99 if (win_version >= base::win::VERSION_VISTA) {
100 icon_data.hBalloonIcon = balloon_icon_.Get();
101 icon_data.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON;
102 } else {
103 icon_data.hIcon = balloon_icon_.Get();
104 icon_data.uFlags |= NIF_ICON;
105 icon_data.dwInfoFlags = NIIF_USER;
106 }
107 }
108
96 BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data); 109 BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data);
97 if (!result) 110 if (!result)
98 LOG(WARNING) << "Unable to create status tray balloon."; 111 LOG(WARNING) << "Unable to create status tray balloon.";
99 } 112 }
100 113
101 void StatusIconWin::UpdatePlatformContextMenu(ui::MenuModel* menu) { 114 void StatusIconWin::UpdatePlatformContextMenu(ui::MenuModel* menu) {
102 #if defined(USE_AURA) 115 #if defined(USE_AURA)
103 // crbug.com/99489. 116 // crbug.com/99489.
104 NOTIMPLEMENTED(); 117 NOTIMPLEMENTED();
105 #else 118 #else
(...skipping 21 matching lines...) Expand all
127 if (context_menu_.get()) { 140 if (context_menu_.get()) {
128 // Set our window as the foreground window, so the context menu closes when 141 // Set our window as the foreground window, so the context menu closes when
129 // we click away from it. 142 // we click away from it.
130 SetForegroundWindow(window_); 143 SetForegroundWindow(window_);
131 context_menu_->RunContextMenuAt(gfx::Point(x, y)); 144 context_menu_->RunContextMenuAt(gfx::Point(x, y));
132 } 145 }
133 #endif 146 #endif
134 } 147 }
135 148
136 void StatusIconWin::InitIconData(NOTIFYICONDATA* icon_data) { 149 void StatusIconWin::InitIconData(NOTIFYICONDATA* icon_data) {
137 icon_data->cbSize = sizeof(NOTIFYICONDATA); 150 if (base::win::OSInfo::GetInstance()->version() >=
151 base::win::VERSION_VISTA) {
152 memset(icon_data, 0, sizeof(NOTIFYICONDATA));
153 icon_data->cbSize = sizeof(NOTIFYICONDATA);
154 } else {
155 memset(icon_data, 0, NOTIFYICONDATA_V3_SIZE);
156 icon_data->cbSize = NOTIFYICONDATA_V3_SIZE;
157 }
158
138 icon_data->hWnd = window_; 159 icon_data->hWnd = window_;
139 icon_data->uID = icon_id_; 160 icon_data->uID = icon_id_;
140 } 161 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/status_icons/status_icon_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698