OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 BOOL result = Shell_NotifyIcon(NIM_ADD, &icon_data); | 93 BOOL result = Shell_NotifyIcon(NIM_ADD, &icon_data); |
94 if (!result) | 94 if (!result) |
95 LOG(WARNING) << "Unable to re-create status tray icon."; | 95 LOG(WARNING) << "Unable to re-create status tray icon."; |
96 } | 96 } |
97 | 97 |
98 void StatusIconWin::SetImage(const gfx::ImageSkia& image) { | 98 void StatusIconWin::SetImage(const gfx::ImageSkia& image) { |
99 // Create the icon. | 99 // Create the icon. |
100 NOTIFYICONDATA icon_data; | 100 NOTIFYICONDATA icon_data; |
101 InitIconData(&icon_data); | 101 InitIconData(&icon_data); |
102 icon_data.uFlags = NIF_ICON; | 102 icon_data.uFlags = NIF_ICON; |
103 icon_ = IconUtil::CreateHICONFromSkBitmap(*image.bitmap()).Pass(); | 103 icon_ = IconUtil::CreateHICONFromSkBitmap(*image.bitmap()); |
104 icon_data.hIcon = icon_.get(); | 104 icon_data.hIcon = icon_.get(); |
105 BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data); | 105 BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data); |
106 if (!result) | 106 if (!result) |
107 LOG(WARNING) << "Error setting status tray icon image"; | 107 LOG(WARNING) << "Error setting status tray icon image"; |
108 } | 108 } |
109 | 109 |
110 void StatusIconWin::SetToolTip(const base::string16& tool_tip) { | 110 void StatusIconWin::SetToolTip(const base::string16& tool_tip) { |
111 // Create the icon. | 111 // Create the icon. |
112 NOTIFYICONDATA icon_data; | 112 NOTIFYICONDATA icon_data; |
113 InitIconData(&icon_data); | 113 InitIconData(&icon_data); |
(...skipping 12 matching lines...) Expand all Loading... |
126 NOTIFYICONDATA icon_data; | 126 NOTIFYICONDATA icon_data; |
127 InitIconData(&icon_data); | 127 InitIconData(&icon_data); |
128 icon_data.uFlags = NIF_INFO; | 128 icon_data.uFlags = NIF_INFO; |
129 icon_data.dwInfoFlags = NIIF_INFO; | 129 icon_data.dwInfoFlags = NIIF_INFO; |
130 wcscpy_s(icon_data.szInfoTitle, title.c_str()); | 130 wcscpy_s(icon_data.szInfoTitle, title.c_str()); |
131 wcscpy_s(icon_data.szInfo, contents.c_str()); | 131 wcscpy_s(icon_data.szInfo, contents.c_str()); |
132 icon_data.uTimeout = 0; | 132 icon_data.uTimeout = 0; |
133 | 133 |
134 base::win::Version win_version = base::win::GetVersion(); | 134 base::win::Version win_version = base::win::GetVersion(); |
135 if (!icon.isNull() && win_version != base::win::VERSION_PRE_XP) { | 135 if (!icon.isNull() && win_version != base::win::VERSION_PRE_XP) { |
136 balloon_icon_ = IconUtil::CreateHICONFromSkBitmap(*icon.bitmap()).Pass(); | 136 balloon_icon_ = IconUtil::CreateHICONFromSkBitmap(*icon.bitmap()); |
137 if (win_version >= base::win::VERSION_VISTA) { | 137 if (win_version >= base::win::VERSION_VISTA) { |
138 icon_data.hBalloonIcon = balloon_icon_.get(); | 138 icon_data.hBalloonIcon = balloon_icon_.get(); |
139 icon_data.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON; | 139 icon_data.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON; |
140 } else { | 140 } else { |
141 icon_data.hIcon = balloon_icon_.get(); | 141 icon_data.hIcon = balloon_icon_.get(); |
142 icon_data.uFlags |= NIF_ICON; | 142 icon_data.uFlags |= NIF_ICON; |
143 icon_data.dwInfoFlags = NIIF_USER; | 143 icon_data.dwInfoFlags = NIIF_USER; |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
(...skipping 22 matching lines...) Expand all Loading... |
169 memset(icon_data, 0, sizeof(NOTIFYICONDATA)); | 169 memset(icon_data, 0, sizeof(NOTIFYICONDATA)); |
170 icon_data->cbSize = sizeof(NOTIFYICONDATA); | 170 icon_data->cbSize = sizeof(NOTIFYICONDATA); |
171 } else { | 171 } else { |
172 memset(icon_data, 0, NOTIFYICONDATA_V3_SIZE); | 172 memset(icon_data, 0, NOTIFYICONDATA_V3_SIZE); |
173 icon_data->cbSize = NOTIFYICONDATA_V3_SIZE; | 173 icon_data->cbSize = NOTIFYICONDATA_V3_SIZE; |
174 } | 174 } |
175 | 175 |
176 icon_data->hWnd = window_; | 176 icon_data->hWnd = window_; |
177 icon_data->uID = icon_id_; | 177 icon_data->uID = icon_id_; |
178 } | 178 } |
OLD | NEW |