Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/ui/views/status_icons/status_tray_win.cc

Issue 2767893002: Remove ScopedVector from chrome/browser/. (Closed)
Patch Set: Address comments from zea@ Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory/ptr_util.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
16 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
17 #include "base/win/wrapped_window_proc.h" 18 #include "base/win/wrapped_window_proc.h"
18 #include "chrome/browser/lifetime/application_lifetime.h" 19 #include "chrome/browser/lifetime/application_lifetime.h"
19 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" 20 #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" 21 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h"
21 #include "chrome/common/chrome_constants.h" 22 #include "chrome/common/chrome_constants.h"
22 #include "ui/display/screen.h" 23 #include "ui/display/screen.h"
23 #include "ui/gfx/geometry/point.h" 24 #include "ui/gfx/geometry/point.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 155 }
155 156
156 LRESULT CALLBACK StatusTrayWin::WndProc(HWND hwnd, 157 LRESULT CALLBACK StatusTrayWin::WndProc(HWND hwnd,
157 UINT message, 158 UINT message,
158 WPARAM wparam, 159 WPARAM wparam,
159 LPARAM lparam) { 160 LPARAM lparam) {
160 if (message == taskbar_created_message_) { 161 if (message == taskbar_created_message_) {
161 // We need to reset all of our icons because the taskbar went away. 162 // We need to reset all of our icons because the taskbar went away.
162 for (StatusIcons::const_iterator i(status_icons().begin()); 163 for (StatusIcons::const_iterator i(status_icons().begin());
163 i != status_icons().end(); ++i) { 164 i != status_icons().end(); ++i) {
164 StatusIconWin* win_icon = static_cast<StatusIconWin*>(*i); 165 StatusIconWin* win_icon = static_cast<StatusIconWin*>(i->get());
165 win_icon->ResetIcon(); 166 win_icon->ResetIcon();
166 } 167 }
167 return TRUE; 168 return TRUE;
168 } else if (message == kStatusIconMessage) { 169 } else if (message == kStatusIconMessage) {
169 StatusIconWin* win_icon = NULL; 170 StatusIconWin* win_icon = nullptr;
170 171
171 // Find the selected status icon. 172 // Find the selected status icon.
172 for (StatusIcons::const_iterator i(status_icons().begin()); 173 for (StatusIcons::const_iterator i(status_icons().begin());
173 i != status_icons().end(); 174 i != status_icons().end();
174 ++i) { 175 ++i) {
175 StatusIconWin* current_win_icon = static_cast<StatusIconWin*>(*i); 176 StatusIconWin* current_win_icon = static_cast<StatusIconWin*>(i->get());
176 if (current_win_icon->icon_id() == wparam) { 177 if (current_win_icon->icon_id() == wparam) {
177 win_icon = current_win_icon; 178 win_icon = current_win_icon;
178 break; 179 break;
179 } 180 }
180 } 181 }
181 182
182 // It is possible for this procedure to be called with an obsolete icon 183 // It is possible for this procedure to be called with an obsolete icon
183 // id. In that case we should just return early before handling any 184 // id. In that case we should just return early before handling any
184 // actions. 185 // actions.
185 if (!win_icon) 186 if (!win_icon)
(...skipping 16 matching lines...) Expand all
202 } 203 }
203 } else if (message == WM_ENDSESSION) { 204 } else if (message == WM_ENDSESSION) {
204 // If Chrome is in background-only mode, this is the only notification 205 // If Chrome is in background-only mode, this is the only notification
205 // it gets that Windows is exiting. Make sure we shutdown in an orderly 206 // it gets that Windows is exiting. Make sure we shutdown in an orderly
206 // fashion. 207 // fashion.
207 chrome::SessionEnding(); 208 chrome::SessionEnding();
208 } 209 }
209 return ::DefWindowProc(hwnd, message, wparam, lparam); 210 return ::DefWindowProc(hwnd, message, wparam, lparam);
210 } 211 }
211 212
212 StatusIcon* StatusTrayWin::CreatePlatformStatusIcon( 213 std::unique_ptr<StatusIcon> StatusTrayWin::CreatePlatformStatusIcon(
213 StatusTray::StatusIconType type, 214 StatusTray::StatusIconType type,
214 const gfx::ImageSkia& image, 215 const gfx::ImageSkia& image,
215 const base::string16& tool_tip) { 216 const base::string16& tool_tip) {
216 UINT next_icon_id; 217 UINT next_icon_id;
217 if (type == StatusTray::OTHER_ICON) 218 if (type == StatusTray::OTHER_ICON)
218 next_icon_id = NextIconId(); 219 next_icon_id = NextIconId();
219 else 220 else
220 next_icon_id = ReservedIconId(type); 221 next_icon_id = ReservedIconId(type);
221 222
222 StatusIcon* icon = 223 auto icon = base::MakeUnique<StatusIconWin>(this, next_icon_id, window_,
223 new StatusIconWin(this, next_icon_id, window_, kStatusIconMessage); 224 kStatusIconMessage);
224 225
225 icon->SetImage(image); 226 icon->SetImage(image);
226 icon->SetToolTip(tool_tip); 227 icon->SetToolTip(tool_tip);
227 return icon; 228 return std::move(icon);
228 } 229 }
229 230
230 UINT StatusTrayWin::NextIconId() { 231 UINT StatusTrayWin::NextIconId() {
231 UINT icon_id = next_icon_id_++; 232 UINT icon_id = next_icon_id_++;
232 return kBaseIconId + static_cast<UINT>(NAMED_STATUS_ICON_COUNT) + icon_id; 233 return kBaseIconId + static_cast<UINT>(NAMED_STATUS_ICON_COUNT) + icon_id;
233 } 234 }
234 235
235 void StatusTrayWin::SetStatusTrayStateChangerProxyForTest( 236 void StatusTrayWin::SetStatusTrayStateChangerProxyForTest(
236 std::unique_ptr<StatusTrayStateChangerProxy> proxy) { 237 std::unique_ptr<StatusTrayStateChangerProxy> proxy) {
237 state_changer_proxy_ = std::move(proxy); 238 state_changer_proxy_ = std::move(proxy);
238 } 239 }
239 240
240 StatusTray* StatusTray::Create() { 241 StatusTray* StatusTray::Create() {
241 return new StatusTrayWin(); 242 return new StatusTrayWin();
242 } 243 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/status_icons/status_tray_win.h ('k') | chrome/browser/ui/webui/settings/certificates_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698