| 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/metro.h" | 8 #include "base/win/metro.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "chrome/browser/ui/views/status_icons/status_tray_win.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 11 #include "ui/gfx/icon_util.h" | 12 #include "ui/gfx/icon_util.h" |
| 12 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
| 13 #include "ui/views/controls/menu/menu_item_view.h" | 14 #include "ui/views/controls/menu/menu_item_view.h" |
| 14 #include "ui/views/controls/menu/menu_runner.h" | 15 #include "ui/views/controls/menu/menu_runner.h" |
| 15 #include "win8/util/win8_util.h" | 16 |
| 17 // Implements AsStatusIconWin. This is only implemented on Windows and will |
| 18 // cause a link error if the function is declared on any other platform. |
| 19 StatusIconWin* StatusIcon::AsStatusIconWin() { |
| 20 if (StatusTrayWin::DisabledForMetroMode()) |
| 21 return NULL; |
| 22 return (StatusIconWin*)this; |
| 23 } |
| 16 | 24 |
| 17 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 18 // StatusIconWin, public: | 26 // StatusIconWin, public: |
| 19 | 27 |
| 20 StatusIconWin::StatusIconWin(UINT id, HWND window, UINT message) | 28 StatusIconWin::StatusIconWin(UINT id, HWND window, UINT message) |
| 21 : icon_id_(id), | 29 : icon_id_(id), |
| 22 window_(window), | 30 window_(window), |
| 23 message_id_(message), | 31 message_id_(message), |
| 24 menu_model_(NULL) { | 32 menu_model_(NULL) { |
| 33 DCHECK(!StatusTrayWin::DisabledForMetroMode()); |
| 25 NOTIFYICONDATA icon_data; | 34 NOTIFYICONDATA icon_data; |
| 26 InitIconData(&icon_data); | 35 InitIconData(&icon_data); |
| 27 icon_data.uFlags = NIF_MESSAGE; | 36 icon_data.uFlags = NIF_MESSAGE; |
| 28 icon_data.uCallbackMessage = message_id_; | 37 icon_data.uCallbackMessage = message_id_; |
| 29 BOOL result = Shell_NotifyIcon(NIM_ADD, &icon_data); | 38 BOOL result = Shell_NotifyIcon(NIM_ADD, &icon_data); |
| 30 // This can happen if the explorer process isn't running when we try to | 39 // This can happen if the explorer process isn't running when we try to |
| 31 // create the icon for some reason (for example, at startup). | 40 // create the icon for some reason (for example, at startup). |
| 32 if (!result) | 41 if (!result) |
| 33 LOG(WARNING) << "Unable to create status tray icon."; | 42 LOG(WARNING) << "Unable to create status tray icon."; |
| 34 } | 43 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 175 |
| 167 icon_data->hWnd = window_; | 176 icon_data->hWnd = window_; |
| 168 icon_data->uID = icon_id_; | 177 icon_data->uID = icon_id_; |
| 169 } | 178 } |
| 170 | 179 |
| 171 //////////////////////////////////////////////////////////////////////////////// | 180 //////////////////////////////////////////////////////////////////////////////// |
| 172 // StatusIconMetro | 181 // StatusIconMetro |
| 173 | 182 |
| 174 StatusIconMetro::StatusIconMetro(UINT id) | 183 StatusIconMetro::StatusIconMetro(UINT id) |
| 175 : id_(id) { | 184 : id_(id) { |
| 176 DCHECK(win8::IsSingleWindowMetroMode()); | 185 DCHECK(StatusTrayWin::DisabledForMetroMode()); |
| 177 } | 186 } |
| 178 | 187 |
| 179 StatusIconMetro::~StatusIconMetro() { | 188 StatusIconMetro::~StatusIconMetro() { |
| 180 } | 189 } |
| 181 | 190 |
| 182 void StatusIconMetro::SetImage(const gfx::ImageSkia& image) { | 191 void StatusIconMetro::SetImage(const gfx::ImageSkia& image) { |
| 183 DVLOG(1) << __FUNCTION__; | 192 DVLOG(1) << __FUNCTION__; |
| 184 } | 193 } |
| 185 | 194 |
| 186 void StatusIconMetro::SetPressedImage(const gfx::ImageSkia& image) { | 195 void StatusIconMetro::SetPressedImage(const gfx::ImageSkia& image) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 208 notification("", "", title.c_str(), contents.c_str(), L"", | 217 notification("", "", title.c_str(), contents.c_str(), L"", |
| 209 base::IntToString(id_).c_str(), NULL, NULL); | 218 base::IntToString(id_).c_str(), NULL, NULL); |
| 210 } | 219 } |
| 211 } | 220 } |
| 212 | 221 |
| 213 void StatusIconMetro::UpdatePlatformContextMenu(StatusIconMenuModel* menu) { | 222 void StatusIconMetro::UpdatePlatformContextMenu(StatusIconMenuModel* menu) { |
| 214 DVLOG(1) << __FUNCTION__ | 223 DVLOG(1) << __FUNCTION__ |
| 215 << " This functionality is not supported in Windows 8 metro"; | 224 << " This functionality is not supported in Windows 8 metro"; |
| 216 } | 225 } |
| 217 | 226 |
| OLD | NEW |