| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "ash/accelerators/exit_warning_handler.h" | 5 #include "ash/accelerators/exit_warning_handler.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 widget_(NULL), | 98 widget_(NULL), |
| 99 stub_timer_for_test_(false) { | 99 stub_timer_for_test_(false) { |
| 100 } | 100 } |
| 101 | 101 |
| 102 ExitWarningHandler::~ExitWarningHandler() { | 102 ExitWarningHandler::~ExitWarningHandler() { |
| 103 // Note: If a timer is outstanding, it is stopped in its destructor. | 103 // Note: If a timer is outstanding, it is stopped in its destructor. |
| 104 Hide(); | 104 Hide(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ExitWarningHandler::HandleAccelerator() { | 107 void ExitWarningHandler::HandleAccelerator() { |
| 108 ShellDelegate* shell_delegate = Shell::GetInstance()->delegate(); |
| 108 switch (state_) { | 109 switch (state_) { |
| 109 case IDLE: | 110 case IDLE: |
| 110 state_ = WAIT_FOR_DOUBLE_PRESS; | 111 state_ = WAIT_FOR_DOUBLE_PRESS; |
| 111 Show(); | 112 Show(); |
| 112 StartTimer(); | 113 StartTimer(); |
| 114 shell_delegate->RecordUserMetricsAction(UMA_ACCEL_EXIT_FIRST_Q); |
| 113 break; | 115 break; |
| 114 case WAIT_FOR_DOUBLE_PRESS: | 116 case WAIT_FOR_DOUBLE_PRESS: |
| 115 state_ = EXITING; | 117 state_ = EXITING; |
| 116 CancelTimer(); | 118 CancelTimer(); |
| 117 Hide(); | 119 Hide(); |
| 118 Shell::GetInstance()->delegate()->Exit(); | 120 shell_delegate->RecordUserMetricsAction(UMA_ACCEL_EXIT_SECOND_Q); |
| 121 shell_delegate->Exit(); |
| 119 break; | 122 break; |
| 120 case EXITING: | 123 case EXITING: |
| 121 break; | 124 break; |
| 122 default: | 125 default: |
| 123 NOTREACHED(); | 126 NOTREACHED(); |
| 124 break; | 127 break; |
| 125 } | 128 } |
| 126 } | 129 } |
| 127 | 130 |
| 128 void ExitWarningHandler::TimerAction() { | 131 void ExitWarningHandler::TimerAction() { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 178 } |
| 176 | 179 |
| 177 void ExitWarningHandler::Hide() { | 180 void ExitWarningHandler::Hide() { |
| 178 if (!widget_) | 181 if (!widget_) |
| 179 return; | 182 return; |
| 180 widget_->Close(); | 183 widget_->Close(); |
| 181 widget_ = NULL; | 184 widget_ = NULL; |
| 182 } | 185 } |
| 183 | 186 |
| 184 } // namespace ash | 187 } // namespace ash |
| OLD | NEW |