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/gfx/screen.h" | 12 #include "ui/gfx/screen.h" |
13 #include "ui/gfx/win/hwnd_util.h" | 13 #include "ui/gfx/win/hwnd_util.h" |
14 #include "win8/util/win8_util.h" | |
15 | 14 |
16 static const UINT kStatusIconMessage = WM_APP + 1; | 15 static const UINT kStatusIconMessage = WM_APP + 1; |
17 | 16 |
18 namespace { | 17 namespace { |
19 // |kBaseIconId| is 2 to avoid conflicts with plugins that hard-code id 1. | 18 // |kBaseIconId| is 2 to avoid conflicts with plugins that hard-code id 1. |
20 const UINT kBaseIconId = 2; | 19 const UINT kBaseIconId = 2; |
21 | 20 |
22 UINT ReservedIconId(StatusTray::StatusIconType type) { | 21 UINT ReservedIconId(StatusTray::StatusIconType type) { |
23 return kBaseIconId + static_cast<UINT>(type); | 22 return kBaseIconId + static_cast<UINT>(type); |
24 } | 23 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 StatusIcon* StatusTrayWin::CreatePlatformStatusIcon( | 127 StatusIcon* StatusTrayWin::CreatePlatformStatusIcon( |
129 StatusTray::StatusIconType type, | 128 StatusTray::StatusIconType type, |
130 const gfx::ImageSkia& image, | 129 const gfx::ImageSkia& image, |
131 const base::string16& tool_tip) { | 130 const base::string16& tool_tip) { |
132 UINT next_icon_id; | 131 UINT next_icon_id; |
133 if (type == StatusTray::OTHER_ICON) | 132 if (type == StatusTray::OTHER_ICON) |
134 next_icon_id = NextIconId(); | 133 next_icon_id = NextIconId(); |
135 else | 134 else |
136 next_icon_id = ReservedIconId(type); | 135 next_icon_id = ReservedIconId(type); |
137 | 136 |
138 StatusIcon* icon = NULL; | 137 StatusIcon* icon = |
139 if (win8::IsSingleWindowMetroMode()) | 138 new StatusIconWin(next_icon_id, window_, kStatusIconMessage); |
140 icon = new StatusIconMetro(next_icon_id); | |
141 else | |
142 icon = new StatusIconWin(next_icon_id, window_, kStatusIconMessage); | |
143 | 139 |
144 icon->SetImage(image); | 140 icon->SetImage(image); |
145 icon->SetToolTip(tool_tip); | 141 icon->SetToolTip(tool_tip); |
146 return icon; | 142 return icon; |
147 } | 143 } |
148 | 144 |
149 UINT StatusTrayWin::NextIconId() { | 145 UINT StatusTrayWin::NextIconId() { |
150 UINT icon_id = next_icon_id_++; | 146 UINT icon_id = next_icon_id_++; |
151 return kBaseIconId + static_cast<UINT>(NAMED_STATUS_ICON_COUNT) + icon_id; | 147 return kBaseIconId + static_cast<UINT>(NAMED_STATUS_ICON_COUNT) + icon_id; |
152 } | 148 } |
153 | 149 |
154 StatusTray* StatusTray::Create() { | 150 StatusTray* StatusTray::Create() { |
155 return new StatusTrayWin(); | 151 return new StatusTrayWin(); |
156 } | 152 } |
OLD | NEW |