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 "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/win/windows_version.h" | 8 #include "base/win/windows_version.h" |
| 9 #include "chrome/browser/ui/views/status_icons/status_tray_win.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
10 #include "ui/gfx/icon_util.h" | 11 #include "ui/gfx/icon_util.h" |
11 #include "ui/gfx/point.h" | 12 #include "ui/gfx/point.h" |
12 #include "ui/views/controls/menu/menu_item_view.h" | 13 #include "ui/views/controls/menu/menu_item_view.h" |
13 #include "ui/views/controls/menu/menu_runner.h" | 14 #include "ui/views/controls/menu/menu_runner.h" |
14 | 15 |
15 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
16 // StatusIconWin, public: | 17 // StatusIconWin, public: |
17 | 18 |
18 StatusIconWin::StatusIconWin(UINT id, HWND window, UINT message) | 19 StatusIconWin::StatusIconWin(StatusTrayWin* tray, |
19 : icon_id_(id), | 20 UINT id, |
| 21 HWND window, |
| 22 UINT message) |
| 23 : tray_(tray), |
| 24 icon_id_(id), |
20 window_(window), | 25 window_(window), |
21 message_id_(message), | 26 message_id_(message), |
22 menu_model_(NULL) { | 27 menu_model_(NULL) { |
23 NOTIFYICONDATA icon_data; | 28 NOTIFYICONDATA icon_data; |
24 InitIconData(&icon_data); | 29 InitIconData(&icon_data); |
25 icon_data.uFlags = NIF_MESSAGE; | 30 icon_data.uFlags = NIF_MESSAGE; |
26 icon_data.uCallbackMessage = message_id_; | 31 icon_data.uCallbackMessage = message_id_; |
27 BOOL result = Shell_NotifyIcon(NIM_ADD, &icon_data); | 32 BOOL result = Shell_NotifyIcon(NIM_ADD, &icon_data); |
28 // This can happen if the explorer process isn't running when we try to | 33 // This can happen if the explorer process isn't running when we try to |
29 // create the icon for some reason (for example, at startup). | 34 // create the icon for some reason (for example, at startup). |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 icon_data.uFlags |= NIF_ICON; | 140 icon_data.uFlags |= NIF_ICON; |
136 icon_data.dwInfoFlags = NIIF_USER; | 141 icon_data.dwInfoFlags = NIIF_USER; |
137 } | 142 } |
138 } | 143 } |
139 | 144 |
140 BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data); | 145 BOOL result = Shell_NotifyIcon(NIM_MODIFY, &icon_data); |
141 if (!result) | 146 if (!result) |
142 LOG(WARNING) << "Unable to create status tray balloon."; | 147 LOG(WARNING) << "Unable to create status tray balloon."; |
143 } | 148 } |
144 | 149 |
| 150 void StatusIconWin::ForceVisible() { |
| 151 tray_->UpdateIconVisibilityInBackground(this); |
| 152 } |
| 153 |
145 //////////////////////////////////////////////////////////////////////////////// | 154 //////////////////////////////////////////////////////////////////////////////// |
146 // StatusIconWin, private: | 155 // StatusIconWin, private: |
147 | 156 |
148 void StatusIconWin::UpdatePlatformContextMenu(StatusIconMenuModel* menu) { | 157 void StatusIconWin::UpdatePlatformContextMenu(StatusIconMenuModel* menu) { |
149 // |menu_model_| is about to be destroyed. Destroy the menu (which closes it) | 158 // |menu_model_| is about to be destroyed. Destroy the menu (which closes it) |
150 // so that it doesn't attempt to continue using |menu_model_|. | 159 // so that it doesn't attempt to continue using |menu_model_|. |
151 menu_runner_.reset(); | 160 menu_runner_.reset(); |
152 DCHECK(menu); | 161 DCHECK(menu); |
153 menu_model_ = menu; | 162 menu_model_ = menu; |
154 } | 163 } |
155 | 164 |
156 void StatusIconWin::InitIconData(NOTIFYICONDATA* icon_data) { | 165 void StatusIconWin::InitIconData(NOTIFYICONDATA* icon_data) { |
157 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 166 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
158 memset(icon_data, 0, sizeof(NOTIFYICONDATA)); | 167 memset(icon_data, 0, sizeof(NOTIFYICONDATA)); |
159 icon_data->cbSize = sizeof(NOTIFYICONDATA); | 168 icon_data->cbSize = sizeof(NOTIFYICONDATA); |
160 } else { | 169 } else { |
161 memset(icon_data, 0, NOTIFYICONDATA_V3_SIZE); | 170 memset(icon_data, 0, NOTIFYICONDATA_V3_SIZE); |
162 icon_data->cbSize = NOTIFYICONDATA_V3_SIZE; | 171 icon_data->cbSize = NOTIFYICONDATA_V3_SIZE; |
163 } | 172 } |
164 | 173 |
165 icon_data->hWnd = window_; | 174 icon_data->hWnd = window_; |
166 icon_data->uID = icon_id_; | 175 icon_data->uID = icon_id_; |
167 } | 176 } |
OLD | NEW |