Update GPU benchmarking extension to not copy Persistent handles.
[chromium-blink-merge.git] / ash / accelerators / exit_warning_handler.h
blob832a3ed94426c34d12770fa3d94eb09c266c9196
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.h"
10 #include "ui/base/accelerators/accelerator.h"
12 namespace views {
13 class Widget;
16 namespace ash {
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
21 // user of this.
23 // Notes:
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:
31 // IDLE
32 // | Press
33 // WAIT_FOR_DOUBLE_PRESS action: show ui & start timers
34 // | Press (before time limit )
35 // EXITING action: hide ui, stop timer, exit
37 // IDLE
38 // | Press
39 // WAIT_FOR_DOUBLE_PRESS action: show ui & start timers
40 // | T timer expires
41 // IDLE action: hide ui
44 class AcceleratorControllerTest;
46 class ASH_EXPORT ExitWarningHandler {
47 public:
48 ExitWarningHandler();
50 ~ExitWarningHandler();
52 // Handles accelerator for exit (Ctrl-Shift-Q).
53 void HandleAccelerator();
55 private:
56 friend class AcceleratorControllerTest;
58 enum State {
59 IDLE,
60 WAIT_FOR_DOUBLE_PRESS,
61 EXITING
64 // Performs actions when the time limit is exceeded.
65 void TimerAction();
67 void StartTimer();
68 void CancelTimer();
70 void Show();
71 void Hide();
73 State state_;
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);
84 } // namespace ash
86 #endif // ASH_ACCELERATORS_EXIT_WARNING_HANDLER_H_