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.
5 #ifndef ASH_ACCELERATORS_EXIT_WARNING_HANDLER_H_
6 #define ASH_ACCELERATORS_EXIT_WARNING_HANDLER_H_
8 #include "ash/ash_export.h"
9 #include "base/timer/timer.h"
10 #include "ui/base/accelerators/accelerator.h"
18 // In order to avoid accidental exits when the user presses the exit
19 // shortcut by mistake, we require the user press it twice within a
20 // period of time. During that time we show a popup informing the
25 // The corresponding accelerator must be non-repeatable (see
26 // kNonrepeatableActions in accelerator_table.cc). Otherwise the "Double Press
27 // Exit" will be activated just by holding it down, i.e. probably every time.
29 // State Transition Diagrams:
33 // WAIT_FOR_DOUBLE_PRESS action: show ui & start timers
34 // | Press (before time limit )
35 // EXITING action: hide ui, stop timer, exit
39 // WAIT_FOR_DOUBLE_PRESS action: show ui & start timers
41 // IDLE action: hide ui
44 class AcceleratorControllerTest
;
46 class ASH_EXPORT ExitWarningHandler
{
50 ~ExitWarningHandler();
52 // Handles accelerator for exit (Ctrl-Shift-Q).
53 void HandleAccelerator();
56 friend class AcceleratorControllerTest
;
60 WAIT_FOR_DOUBLE_PRESS
,
64 // Performs actions when the time limit is exceeded.
74 views::Widget
* widget_
; // owned by |this|.
75 base::OneShotTimer
<ExitWarningHandler
> timer_
;
77 // Flag to suppress starting the timer for testing. For test we call
78 // TimerAction() directly to simulate the expiration of the timer.
79 bool stub_timer_for_test_
;
81 DISALLOW_COPY_AND_ASSIGN(ExitWarningHandler
);
86 #endif // ASH_ACCELERATORS_EXIT_WARNING_HANDLER_H_