| 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 "base/win/wrapped_window_proc.h" | 7 #include "base/win/wrapped_window_proc.h" |
| 8 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" | 8 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" |
| 9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
| 10 #include "ui/base/win/hwnd_util.h" | 10 #include "ui/base/win/hwnd_util.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 LPARAM lparam) { | 61 LPARAM lparam) { |
| 62 if (message == taskbar_created_message_) { | 62 if (message == taskbar_created_message_) { |
| 63 // We need to reset all of our icons because the taskbar went away. | 63 // We need to reset all of our icons because the taskbar went away. |
| 64 for (StatusIcons::const_iterator i(status_icons().begin()); | 64 for (StatusIcons::const_iterator i(status_icons().begin()); |
| 65 i != status_icons().end(); ++i) { | 65 i != status_icons().end(); ++i) { |
| 66 StatusIconWin* win_icon = static_cast<StatusIconWin*>(*i); | 66 StatusIconWin* win_icon = static_cast<StatusIconWin*>(*i); |
| 67 win_icon->ResetIcon(); | 67 win_icon->ResetIcon(); |
| 68 } | 68 } |
| 69 return TRUE; | 69 return TRUE; |
| 70 } else if (message == kStatusIconMessage) { | 70 } else if (message == kStatusIconMessage) { |
| 71 StatusIconWin* win_icon = NULL; |
| 72 gfx::Point cursor_pos( |
| 73 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint()); |
| 74 |
| 75 // Find the selected status icon. |
| 76 for (StatusIcons::const_iterator i(status_icons().begin()); |
| 77 i != status_icons().end(); |
| 78 ++i) { |
| 79 StatusIconWin* current_win_icon = static_cast<StatusIconWin*>(*i); |
| 80 if (current_win_icon->icon_id() == wparam) { |
| 81 win_icon = current_win_icon; |
| 82 break; |
| 83 } |
| 84 } |
| 85 |
| 71 switch (lparam) { | 86 switch (lparam) { |
| 87 case TB_INDETERMINATE: |
| 88 win_icon->HandleBalloonClickEvent(cursor_pos); |
| 89 return TRUE; |
| 90 |
| 72 case WM_LBUTTONDOWN: | 91 case WM_LBUTTONDOWN: |
| 73 case WM_RBUTTONDOWN: | 92 case WM_RBUTTONDOWN: |
| 74 case WM_CONTEXTMENU: | 93 case WM_CONTEXTMENU: |
| 75 // Walk our icons, find which one was clicked on, and invoke its | 94 // Walk our icons, find which one was clicked on, and invoke its |
| 76 // HandleClickEvent() method. | 95 // HandleClickEvent() method. |
| 77 for (StatusIcons::const_iterator i(status_icons().begin()); | 96 win_icon->HandleClickEvent(cursor_pos, lparam == WM_LBUTTONDOWN); |
| 78 i != status_icons().end(); ++i) { | |
| 79 StatusIconWin* win_icon = static_cast<StatusIconWin*>(*i); | |
| 80 if (win_icon->icon_id() == wparam) { | |
| 81 gfx::Point cursor_pos( | |
| 82 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint()); | |
| 83 win_icon->HandleClickEvent(cursor_pos, lparam == WM_LBUTTONDOWN); | |
| 84 break; | |
| 85 } | |
| 86 } | |
| 87 return TRUE; | 97 return TRUE; |
| 88 } | 98 } |
| 89 } | 99 } |
| 90 return ::DefWindowProc(hwnd, message, wparam, lparam); | 100 return ::DefWindowProc(hwnd, message, wparam, lparam); |
| 91 } | 101 } |
| 92 | 102 |
| 93 StatusTrayWin::~StatusTrayWin() { | 103 StatusTrayWin::~StatusTrayWin() { |
| 94 if (window_) | 104 if (window_) |
| 95 DestroyWindow(window_); | 105 DestroyWindow(window_); |
| 96 | 106 |
| 97 if (atom_) | 107 if (atom_) |
| 98 UnregisterClass(MAKEINTATOM(atom_), instance_); | 108 UnregisterClass(MAKEINTATOM(atom_), instance_); |
| 99 } | 109 } |
| 100 | 110 |
| 101 StatusIcon* StatusTrayWin::CreatePlatformStatusIcon() { | 111 StatusIcon* StatusTrayWin::CreatePlatformStatusIcon() { |
| 102 if (win8::IsSingleWindowMetroMode()) { | 112 if (win8::IsSingleWindowMetroMode()) { |
| 103 return new StatusIconMetro(next_icon_id_++); | 113 return new StatusIconMetro(next_icon_id_++); |
| 104 } else { | 114 } else { |
| 105 return new StatusIconWin(next_icon_id_++, window_, kStatusIconMessage); | 115 return new StatusIconWin(next_icon_id_++, window_, kStatusIconMessage); |
| 106 } | 116 } |
| 107 } | 117 } |
| 108 | 118 |
| 109 StatusTray* StatusTray::Create() { | 119 StatusTray* StatusTray::Create() { |
| 110 return new StatusTrayWin(); | 120 return new StatusTrayWin(); |
| 111 } | 121 } |
| OLD | NEW |