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

Side by Side Diff: ash/accelerators/exit_warning_handler.h

Issue 14587007: Unify and change logout/sleep/lock shortcuts (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: exit warning Created 7 years, 7 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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ASH_EXIT_WARNING_HANDLER_H_
sky 2013/05/13 15:40:32 You missed the accelerators here, eg ASH_ACCELERAT
sschmitz 2013/05/14 16:49:11 Done.
6 #define ASH_EXIT_WARNING_HANDLER_H_
7
8 #include "base/timer.h"
9
10 namespace views {
11 class Widget;
12 }
13
14 namespace ash {
15
16 // In order to avoid accidental exits when the user presses the exit
17 // shortcut by mistake, we require the user to hold the shortcut for
18 // a period of time. During that time we show a popup informing the
19 // user of this. We exit only if the user holds the shortcut longer
20 // than this time limit.
21 // An expert user may quickly release and then press again (double press)
22 // for immediate exit. The press, release and press must happend within
sky 2013/05/13 15:40:32 happend -> happen
sschmitz 2013/05/14 16:49:11 Done.
23 // the double press time limit.
24 // If the user releases (without double press) before the required hold
25 // time, we will cancel the exit, but show the ui until the hold time limit
26 // has expired to avoid a short popup flash.
27 //
28 // State Transition Diagrams:
29 //
30 // T1 - double press time limit (short)
31 // T2 - hold to exit time limit (long)
32 //
33 // IDLE
34 // | Press
35 // WAIT_FOR_QUICK_RELEASE action: show ui & start timers
36 // | Release (DT < T1)
37 // WAIT_FOR_DOUBLE_PRESS
38 // | Press (DT < T1)
39 // EXITING action: hide ui, stop timers, exit
40 //
41 // IDLE
42 // | Press
43 // WAIT_FOR_QUICK_RELEASE action: show ui & start timers
44 // | T1 timer expires
45 // WAIT_FOR_LONG_HOLD
46 // | T2 Timer exipres
47 // EXITING action: hide ui, exit
48 //
49 // IDLE
50 // | Press
51 // WAIT_FOR_QUICK_RELEASE action: show ui & start timers
52 // | T1 timer expiers
53 // WAIT_FOR_LONG_HOLD
54 // | Release
55 // CANCELED
56 // | T2 timer expires
57 // IDLE action: hide ui
58 //
59 // IDLE
60 // | Press
61 // WAIT_FOR_QUICK_RELEASE action: show ui & start timers
62 // | Release (DT < T1)
63 // WAIT_FOR_DOUBLE_PRESS
64 // | T1 timer expires
65 // CANCELED
66 // | T2 timer expires
67 // IDLE action: hide ui
68 //
69
70 class ExitWarningHandler {
71 public:
72
sky 2013/05/13 15:40:32 nit: no newline here.
sschmitz 2013/05/14 16:49:11 Done.
73 ExitWarningHandler();
74
75 ~ExitWarningHandler();
76
77 void HandleExitKey(bool press);
sky 2013/05/13 15:40:32 Document what press is.
sschmitz 2013/05/14 16:49:11 Done.
sky 2013/05/14 17:10:05 It still isn't clear that |press| is true on a pre
78
79 private:
80 void Timer1Action();
sky 2013/05/13 15:40:32 These need a description.
sschmitz 2013/05/14 16:49:11 Done.
81 void Timer2Action();
82
83 void StartTimers();
84 void CancelTimers();
85
86 void Show();
87 void Hide();
88
89 enum State {
sky 2013/05/13 15:40:32 enums should be first in section.
sschmitz 2013/05/14 16:49:11 Done.
90 IDLE,
91 WAIT_FOR_QUICK_RELEASE,
92 WAIT_FOR_DOUBLE_PRESS,
93 WAIT_FOR_LONG_HOLD,
94 CANCELED,
95 EXITING
96 };
97
98 State state_;
99 views::Widget* widget_;
sky 2013/05/13 15:40:32 Document ownership.
sschmitz 2013/05/14 16:49:11 Done.
100 base::OneShotTimer<ExitWarningHandler> timer1_; // short; double press
101 base::OneShotTimer<ExitWarningHandler> timer2_; // long; hold to exit
102 };
sky 2013/05/13 15:40:32 DISALLOW_...
sschmitz 2013/05/14 16:49:11 Done.
103
104 }
105
106 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698