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_tray_win.h" | 5 #include "chrome/browser/ui/views/status_icons/status_tray_win.h" |
6 | 6 |
7 #include <commctrl.h> | 7 #include <commctrl.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "base/win/wrapped_window_proc.h" | 17 #include "base/win/wrapped_window_proc.h" |
18 #include "chrome/browser/lifetime/application_lifetime.h" | 18 #include "chrome/browser/lifetime/application_lifetime.h" |
19 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" | 19 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" |
20 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" | 20 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" |
21 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
22 #include "ui/gfx/screen.h" | 22 #include "ui/display/screen.h" |
23 #include "ui/gfx/win/hwnd_util.h" | 23 #include "ui/gfx/win/hwnd_util.h" |
24 | 24 |
25 static const UINT kStatusIconMessage = WM_APP + 1; | 25 static const UINT kStatusIconMessage = WM_APP + 1; |
26 | 26 |
27 namespace { | 27 namespace { |
28 // |kBaseIconId| is 2 to avoid conflicts with plugins that hard-code id 1. | 28 // |kBaseIconId| is 2 to avoid conflicts with plugins that hard-code id 1. |
29 const UINT kBaseIconId = 2; | 29 const UINT kBaseIconId = 2; |
30 | 30 |
31 UINT ReservedIconId(StatusTray::StatusIconType type) { | 31 UINT ReservedIconId(StatusTray::StatusIconType type) { |
32 return kBaseIconId + static_cast<UINT>(type); | 32 return kBaseIconId + static_cast<UINT>(type); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 switch (lparam) { | 187 switch (lparam) { |
188 case TB_INDETERMINATE: | 188 case TB_INDETERMINATE: |
189 win_icon->HandleBalloonClickEvent(); | 189 win_icon->HandleBalloonClickEvent(); |
190 return TRUE; | 190 return TRUE; |
191 | 191 |
192 case WM_LBUTTONDOWN: | 192 case WM_LBUTTONDOWN: |
193 case WM_RBUTTONDOWN: | 193 case WM_RBUTTONDOWN: |
194 case WM_CONTEXTMENU: | 194 case WM_CONTEXTMENU: |
195 // Walk our icons, find which one was clicked on, and invoke its | 195 // Walk our icons, find which one was clicked on, and invoke its |
196 // HandleClickEvent() method. | 196 // HandleClickEvent() method. |
197 gfx::Point cursor_pos(gfx::Screen::GetScreen()->GetCursorScreenPoint()); | 197 gfx::Point cursor_pos( |
| 198 display::Screen::GetScreen()->GetCursorScreenPoint()); |
198 win_icon->HandleClickEvent(cursor_pos, lparam == WM_LBUTTONDOWN); | 199 win_icon->HandleClickEvent(cursor_pos, lparam == WM_LBUTTONDOWN); |
199 return TRUE; | 200 return TRUE; |
200 } | 201 } |
201 } else if (message == WM_ENDSESSION) { | 202 } else if (message == WM_ENDSESSION) { |
202 // If Chrome is in background-only mode, this is the only notification | 203 // If Chrome is in background-only mode, this is the only notification |
203 // it gets that Windows is exiting. Make sure we shutdown in an orderly | 204 // it gets that Windows is exiting. Make sure we shutdown in an orderly |
204 // fashion. | 205 // fashion. |
205 chrome::SessionEnding(); | 206 chrome::SessionEnding(); |
206 } | 207 } |
207 return ::DefWindowProc(hwnd, message, wparam, lparam); | 208 return ::DefWindowProc(hwnd, message, wparam, lparam); |
(...skipping 23 matching lines...) Expand all Loading... |
231 } | 232 } |
232 | 233 |
233 void StatusTrayWin::SetStatusTrayStateChangerProxyForTest( | 234 void StatusTrayWin::SetStatusTrayStateChangerProxyForTest( |
234 std::unique_ptr<StatusTrayStateChangerProxy> proxy) { | 235 std::unique_ptr<StatusTrayStateChangerProxy> proxy) { |
235 state_changer_proxy_ = std::move(proxy); | 236 state_changer_proxy_ = std::move(proxy); |
236 } | 237 } |
237 | 238 |
238 StatusTray* StatusTray::Create() { | 239 StatusTray* StatusTray::Create() { |
239 return new StatusTrayWin(); | 240 return new StatusTrayWin(); |
240 } | 241 } |
OLD | NEW |