Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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 #include "ash/system/logout_confirmation/logout_confirmation_controller.h" | |
| 6 | |
| 7 #include "ash/shell.h" | |
| 8 #include "ash/system/logout_confirmation/logout_confirmation_dialog.h" | |
| 9 #include "base/location.h" | |
| 10 #include "base/time/tick_clock.h" | |
| 11 | |
| 12 namespace ash { | |
| 13 namespace internal { | |
| 14 | |
| 15 LogoutConfirmationController::LogoutConfirmationController( | |
| 16 scoped_ptr<base::TickClock> clock, | |
| 17 const base::Closure& logout_closure) | |
| 18 : clock_(clock.Pass()), | |
| 19 logout_closure_(logout_closure), | |
| 20 dialog_(NULL), | |
| 21 logout_timer_(false, false) { | |
| 22 } | |
| 23 | |
| 24 LogoutConfirmationController::~LogoutConfirmationController() { | |
| 25 } | |
| 26 | |
| 27 base::TickClock* LogoutConfirmationController::Clock() const { | |
| 28 return clock_.get(); | |
| 29 } | |
| 30 | |
| 31 void LogoutConfirmationController::ConfirmLogout( | |
| 32 base::TimeTicks logout_time) { | |
| 33 if (!logout_time_.is_null() && logout_time >= logout_time_) { | |
| 34 // If a confirmation dialog is already being shown and its countdown expires | |
| 35 // no later than the |logout_time| requested now, keep the current dialog | |
| 36 // open. | |
| 37 return; | |
| 38 } | |
| 39 logout_time_ = logout_time; | |
| 40 | |
| 41 if (!dialog_) { | |
| 42 // Show confirmation dialog unless this is a unit test without a Shell. | |
| 43 if (Shell::HasInstance()) | |
| 44 dialog_ = new LogoutConfirmationDialog(this, logout_time_); | |
| 45 } | |
| 46 else | |
|
stevenjb
2014/02/27 17:58:44
} else {
bartfab (slow)
2014/02/28 12:13:49
Done.
| |
| 47 dialog_->Update(logout_time_); | |
| 48 | |
| 49 logout_timer_.Start(FROM_HERE, | |
| 50 logout_time_ - clock_->NowTicks(), | |
| 51 logout_closure_); | |
| 52 } | |
| 53 | |
| 54 void LogoutConfirmationController::OnLogoutConfirmed() { | |
| 55 logout_timer_.Stop(); | |
| 56 logout_closure_.Run(); | |
| 57 } | |
| 58 | |
| 59 void LogoutConfirmationController::OnDialogClosed() { | |
| 60 logout_time_ = base::TimeTicks(); | |
| 61 dialog_ = NULL; | |
| 62 logout_timer_.Stop(); | |
| 63 } | |
| 64 | |
| 65 } // namespace internal | |
| 66 } // namespace ash | |
| OLD | NEW |