| 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 "base/win/wrapped_window_proc.h" | 9 #include "base/win/wrapped_window_proc.h" |
| 10 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" | 10 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" |
| 11 #include "chrome/common/chrome_constants.h" | 11 #include "chrome/common/chrome_constants.h" |
| 12 #include "ui/base/win/hwnd_util.h" | |
| 13 #include "ui/gfx/screen.h" | 12 #include "ui/gfx/screen.h" |
| 13 #include "ui/gfx/win/hwnd_util.h" |
| 14 #include "win8/util/win8_util.h" | 14 #include "win8/util/win8_util.h" |
| 15 | 15 |
| 16 static const UINT kStatusIconMessage = WM_APP + 1; | 16 static const UINT kStatusIconMessage = WM_APP + 1; |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 // |kBaseIconId| is 2 to avoid conflicts with plugins that hard-code id 1. | 19 // |kBaseIconId| is 2 to avoid conflicts with plugins that hard-code id 1. |
| 20 const UINT kBaseIconId = 2; | 20 const UINT kBaseIconId = 2; |
| 21 | 21 |
| 22 UINT ReservedIconId(StatusTray::StatusIconType type) { | 22 UINT ReservedIconId(StatusTray::StatusIconType type) { |
| 23 return kBaseIconId + static_cast<UINT>(type); | 23 return kBaseIconId + static_cast<UINT>(type); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 43 // If the taskbar is re-created after we start up, we have to rebuild all of | 43 // If the taskbar is re-created after we start up, we have to rebuild all of |
| 44 // our icons. | 44 // our icons. |
| 45 taskbar_created_message_ = RegisterWindowMessage(TEXT("TaskbarCreated")); | 45 taskbar_created_message_ = RegisterWindowMessage(TEXT("TaskbarCreated")); |
| 46 | 46 |
| 47 // Create an offscreen window for handling messages for the status icons. We | 47 // Create an offscreen window for handling messages for the status icons. We |
| 48 // create a hidden WS_POPUP window instead of an HWND_MESSAGE window, because | 48 // create a hidden WS_POPUP window instead of an HWND_MESSAGE window, because |
| 49 // only top-level windows such as popups can receive broadcast messages like | 49 // only top-level windows such as popups can receive broadcast messages like |
| 50 // "TaskbarCreated". | 50 // "TaskbarCreated". |
| 51 window_ = CreateWindow(MAKEINTATOM(atom_), | 51 window_ = CreateWindow(MAKEINTATOM(atom_), |
| 52 0, WS_POPUP, 0, 0, 0, 0, 0, 0, instance_, 0); | 52 0, WS_POPUP, 0, 0, 0, 0, 0, 0, instance_, 0); |
| 53 ui::CheckWindowCreated(window_); | 53 gfx::CheckWindowCreated(window_); |
| 54 ui::SetWindowUserData(window_, this); | 54 gfx::SetWindowUserData(window_, this); |
| 55 } | 55 } |
| 56 | 56 |
| 57 LRESULT CALLBACK StatusTrayWin::WndProcStatic(HWND hwnd, | 57 LRESULT CALLBACK StatusTrayWin::WndProcStatic(HWND hwnd, |
| 58 UINT message, | 58 UINT message, |
| 59 WPARAM wparam, | 59 WPARAM wparam, |
| 60 LPARAM lparam) { | 60 LPARAM lparam) { |
| 61 StatusTrayWin* msg_wnd = reinterpret_cast<StatusTrayWin*>( | 61 StatusTrayWin* msg_wnd = reinterpret_cast<StatusTrayWin*>( |
| 62 GetWindowLongPtr(hwnd, GWLP_USERDATA)); | 62 GetWindowLongPtr(hwnd, GWLP_USERDATA)); |
| 63 if (msg_wnd) | 63 if (msg_wnd) |
| 64 return msg_wnd->WndProc(hwnd, message, wparam, lparam); | 64 return msg_wnd->WndProc(hwnd, message, wparam, lparam); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 | 148 |
| 149 UINT StatusTrayWin::NextIconId() { | 149 UINT StatusTrayWin::NextIconId() { |
| 150 UINT icon_id = next_icon_id_++; | 150 UINT icon_id = next_icon_id_++; |
| 151 return kBaseIconId + static_cast<UINT>(NAMED_STATUS_ICON_COUNT) + icon_id; | 151 return kBaseIconId + static_cast<UINT>(NAMED_STATUS_ICON_COUNT) + icon_id; |
| 152 } | 152 } |
| 153 | 153 |
| 154 StatusTray* StatusTray::Create() { | 154 StatusTray* StatusTray::Create() { |
| 155 return new StatusTrayWin(); | 155 return new StatusTrayWin(); |
| 156 } | 156 } |
| OLD | NEW |