Chromium Code Reviews| Index: ash/accelerators/exit_warning_handler.h |
| diff --git a/ash/accelerators/exit_warning_handler.h b/ash/accelerators/exit_warning_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..033b2d0bb7f7ba586ced955a16d4635e568f766f |
| --- /dev/null |
| +++ b/ash/accelerators/exit_warning_handler.h |
| @@ -0,0 +1,106 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#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.
|
| +#define ASH_EXIT_WARNING_HANDLER_H_ |
| + |
| +#include "base/timer.h" |
| + |
| +namespace views { |
| +class Widget; |
| +} |
| + |
| +namespace ash { |
| + |
| +// In order to avoid accidental exits when the user presses the exit |
| +// shortcut by mistake, we require the user to hold the shortcut for |
| +// a period of time. During that time we show a popup informing the |
| +// user of this. We exit only if the user holds the shortcut longer |
| +// than this time limit. |
| +// An expert user may quickly release and then press again (double press) |
| +// 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.
|
| +// the double press time limit. |
| +// If the user releases (without double press) before the required hold |
| +// time, we will cancel the exit, but show the ui until the hold time limit |
| +// has expired to avoid a short popup flash. |
| +// |
| +// State Transition Diagrams: |
| +// |
| +// T1 - double press time limit (short) |
| +// T2 - hold to exit time limit (long) |
| +// |
| +// IDLE |
| +// | Press |
| +// WAIT_FOR_QUICK_RELEASE action: show ui & start timers |
| +// | Release (DT < T1) |
| +// WAIT_FOR_DOUBLE_PRESS |
| +// | Press (DT < T1) |
| +// EXITING action: hide ui, stop timers, exit |
| +// |
| +// IDLE |
| +// | Press |
| +// WAIT_FOR_QUICK_RELEASE action: show ui & start timers |
| +// | T1 timer expires |
| +// WAIT_FOR_LONG_HOLD |
| +// | T2 Timer exipres |
| +// EXITING action: hide ui, exit |
| +// |
| +// IDLE |
| +// | Press |
| +// WAIT_FOR_QUICK_RELEASE action: show ui & start timers |
| +// | T1 timer expiers |
| +// WAIT_FOR_LONG_HOLD |
| +// | Release |
| +// CANCELED |
| +// | T2 timer expires |
| +// IDLE action: hide ui |
| +// |
| +// IDLE |
| +// | Press |
| +// WAIT_FOR_QUICK_RELEASE action: show ui & start timers |
| +// | Release (DT < T1) |
| +// WAIT_FOR_DOUBLE_PRESS |
| +// | T1 timer expires |
| +// CANCELED |
| +// | T2 timer expires |
| +// IDLE action: hide ui |
| +// |
| + |
| +class ExitWarningHandler { |
| + public: |
| + |
|
sky
2013/05/13 15:40:32
nit: no newline here.
sschmitz
2013/05/14 16:49:11
Done.
|
| + ExitWarningHandler(); |
| + |
| + ~ExitWarningHandler(); |
| + |
| + 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
|
| + |
| + private: |
| + void Timer1Action(); |
|
sky
2013/05/13 15:40:32
These need a description.
sschmitz
2013/05/14 16:49:11
Done.
|
| + void Timer2Action(); |
| + |
| + void StartTimers(); |
| + void CancelTimers(); |
| + |
| + void Show(); |
| + void Hide(); |
| + |
| + enum State { |
|
sky
2013/05/13 15:40:32
enums should be first in section.
sschmitz
2013/05/14 16:49:11
Done.
|
| + IDLE, |
| + WAIT_FOR_QUICK_RELEASE, |
| + WAIT_FOR_DOUBLE_PRESS, |
| + WAIT_FOR_LONG_HOLD, |
| + CANCELED, |
| + EXITING |
| + }; |
| + |
| + State state_; |
| + views::Widget* widget_; |
|
sky
2013/05/13 15:40:32
Document ownership.
sschmitz
2013/05/14 16:49:11
Done.
|
| + base::OneShotTimer<ExitWarningHandler> timer1_; // short; double press |
| + base::OneShotTimer<ExitWarningHandler> timer2_; // long; hold to exit |
| +}; |
|
sky
2013/05/13 15:40:32
DISALLOW_...
sschmitz
2013/05/14 16:49:11
Done.
|
| + |
| +} |
| + |
| +#endif |