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

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

Issue 888693003: Process WM_ENDSESSION in the traybar icon window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Now new and improved - compiles, even. Created 5 years, 10 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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
11 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/win/wrapped_window_proc.h" 13 #include "base/win/wrapped_window_proc.h"
14 #include "chrome/browser/lifetime/application_lifetime.h"
14 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" 15 #include "chrome/browser/ui/views/status_icons/status_icon_win.h"
15 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" 16 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h"
16 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "components/browser_watcher/exit_funnel_win.h"
17 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
18 #include "ui/gfx/win/hwnd_util.h" 20 #include "ui/gfx/win/hwnd_util.h"
19 21
20 static const UINT kStatusIconMessage = WM_APP + 1; 22 static const UINT kStatusIconMessage = WM_APP + 1;
21 23
22 namespace { 24 namespace {
23 // |kBaseIconId| is 2 to avoid conflicts with plugins that hard-code id 1. 25 // |kBaseIconId| is 2 to avoid conflicts with plugins that hard-code id 1.
24 const UINT kBaseIconId = 2; 26 const UINT kBaseIconId = 2;
25 27
26 UINT ReservedIconId(StatusTray::StatusIconType type) { 28 UINT ReservedIconId(StatusTray::StatusIconType type) {
27 return kBaseIconId + static_cast<UINT>(type); 29 return kBaseIconId + static_cast<UINT>(type);
28 } 30 }
31
32 // See http://crbug.com/412384.
33 void TraceSessionEnding(LPARAM lparam) {
34 browser_watcher::ExitFunnel funnel;
35 if (!funnel.Init(chrome::kBrowserExitCodesRegistryPath,
36 base::GetCurrentProcessHandle())) {
37 return;
38 }
39
40 // This exit path is the prime suspect for most our unclean shutdowns.
41 // Trace all the possible options to WM_ENDSESSION. This may result in
42 // multiple events for a single shutdown, but that's fine.
43 funnel.RecordEvent(L"TraybarEndSession");
44
45 if (lparam & ENDSESSION_CLOSEAPP)
46 funnel.RecordEvent(L"ES_CloseApp");
47 if (lparam & ENDSESSION_CRITICAL)
48 funnel.RecordEvent(L"ES_Critical");
49 if (lparam & ENDSESSION_LOGOFF)
50 funnel.RecordEvent(L"ES_Logoff");
51 const LPARAM kKnownBits =
52 ENDSESSION_CLOSEAPP | ENDSESSION_CRITICAL | ENDSESSION_LOGOFF;
53 if (lparam & ~kKnownBits)
54 funnel.RecordEvent(L"ES_Other");
55 }
56
29 } // namespace 57 } // namespace
30 58
31 // Default implementation for StatusTrayStateChanger that communicates to 59 // Default implementation for StatusTrayStateChanger that communicates to
32 // Exporer.exe via COM. It spawns a background thread with a fresh COM 60 // Exporer.exe via COM. It spawns a background thread with a fresh COM
33 // apartment and requests that the visibility be increased unless the user 61 // apartment and requests that the visibility be increased unless the user
34 // has explicitly set the icon to be hidden. 62 // has explicitly set the icon to be hidden.
35 class StatusTrayStateChangerProxyImpl : public StatusTrayStateChangerProxy, 63 class StatusTrayStateChangerProxyImpl : public StatusTrayStateChangerProxy,
36 public base::NonThreadSafe { 64 public base::NonThreadSafe {
37 public: 65 public:
38 StatusTrayStateChangerProxyImpl() 66 StatusTrayStateChangerProxyImpl()
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 case WM_LBUTTONDOWN: 219 case WM_LBUTTONDOWN:
192 case WM_RBUTTONDOWN: 220 case WM_RBUTTONDOWN:
193 case WM_CONTEXTMENU: 221 case WM_CONTEXTMENU:
194 // Walk our icons, find which one was clicked on, and invoke its 222 // Walk our icons, find which one was clicked on, and invoke its
195 // HandleClickEvent() method. 223 // HandleClickEvent() method.
196 gfx::Point cursor_pos( 224 gfx::Point cursor_pos(
197 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint()); 225 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint());
198 win_icon->HandleClickEvent(cursor_pos, lparam == WM_LBUTTONDOWN); 226 win_icon->HandleClickEvent(cursor_pos, lparam == WM_LBUTTONDOWN);
199 return TRUE; 227 return TRUE;
200 } 228 }
229 } else if (message == WM_ENDSESSION) {
230 // If chrome is in background-only mode, this is the only notification
Will Harris 2015/01/29 21:56:02 nit: Chrome
Sigurður Ásgeirsson 2015/01/30 13:52:12 Done.
231 // it gets that Windows is exiting. Make sure we shutdown in an orderly
232 // fashion.
233 TraceSessionEnding(lparam);
234 chrome::SessionEnding();
201 } 235 }
202 return ::DefWindowProc(hwnd, message, wparam, lparam); 236 return ::DefWindowProc(hwnd, message, wparam, lparam);
203 } 237 }
204 238
205 StatusIcon* StatusTrayWin::CreatePlatformStatusIcon( 239 StatusIcon* StatusTrayWin::CreatePlatformStatusIcon(
206 StatusTray::StatusIconType type, 240 StatusTray::StatusIconType type,
207 const gfx::ImageSkia& image, 241 const gfx::ImageSkia& image,
208 const base::string16& tool_tip) { 242 const base::string16& tool_tip) {
209 UINT next_icon_id; 243 UINT next_icon_id;
210 if (type == StatusTray::OTHER_ICON) 244 if (type == StatusTray::OTHER_ICON)
(...skipping 15 matching lines...) Expand all
226 } 260 }
227 261
228 void StatusTrayWin::SetStatusTrayStateChangerProxyForTest( 262 void StatusTrayWin::SetStatusTrayStateChangerProxyForTest(
229 scoped_ptr<StatusTrayStateChangerProxy> proxy) { 263 scoped_ptr<StatusTrayStateChangerProxy> proxy) {
230 state_changer_proxy_ = proxy.Pass(); 264 state_changer_proxy_ = proxy.Pass();
231 } 265 }
232 266
233 StatusTray* StatusTray::Create() { 267 StatusTray* StatusTray::Create() {
234 return new StatusTrayWin(); 268 return new StatusTrayWin();
235 } 269 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698