Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1510)

Unified Diff: ash/system/logout_confirmation/logout_confirmation_controller.cc

Issue 178183005: Add LogoutConfirmationController to show LogoutConfirmationDialogs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/system/logout_confirmation/logout_confirmation_controller.cc
diff --git a/ash/system/logout_confirmation/logout_confirmation_controller.cc b/ash/system/logout_confirmation/logout_confirmation_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..86aefceab0c1ecb273db3164eb51093b16ee78a5
--- /dev/null
+++ b/ash/system/logout_confirmation/logout_confirmation_controller.cc
@@ -0,0 +1,66 @@
+// Copyright 2014 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.
+
+#include "ash/system/logout_confirmation/logout_confirmation_controller.h"
+
+#include "ash/shell.h"
+#include "ash/system/logout_confirmation/logout_confirmation_dialog.h"
+#include "base/location.h"
+#include "base/time/tick_clock.h"
+
+namespace ash {
+namespace internal {
+
+LogoutConfirmationController::LogoutConfirmationController(
+ scoped_ptr<base::TickClock> clock,
+ const base::Closure& logout_closure)
+ : clock_(clock.Pass()),
+ logout_closure_(logout_closure),
+ dialog_(NULL),
+ logout_timer_(false, false) {
+}
+
+LogoutConfirmationController::~LogoutConfirmationController() {
+}
+
+base::TickClock* LogoutConfirmationController::Clock() const {
+ return clock_.get();
+}
+
+void LogoutConfirmationController::ConfirmLogout(
+ base::TimeTicks logout_time) {
+ if (!logout_time_.is_null() && logout_time >= logout_time_) {
+ // If a confirmation dialog is already being shown and its countdown expires
+ // no later than the |logout_time| requested now, keep the current dialog
+ // open.
+ return;
+ }
+ logout_time_ = logout_time;
+
+ if (!dialog_) {
+ // Show confirmation dialog unless this is a unit test without a Shell.
+ if (Shell::HasInstance())
+ dialog_ = new LogoutConfirmationDialog(this, logout_time_);
+ }
+ else
stevenjb 2014/02/27 17:58:44 } else {
bartfab (slow) 2014/02/28 12:13:49 Done.
+ dialog_->Update(logout_time_);
+
+ logout_timer_.Start(FROM_HERE,
+ logout_time_ - clock_->NowTicks(),
+ logout_closure_);
+}
+
+void LogoutConfirmationController::OnLogoutConfirmed() {
+ logout_timer_.Stop();
+ logout_closure_.Run();
+}
+
+void LogoutConfirmationController::OnDialogClosed() {
+ logout_time_ = base::TimeTicks();
+ dialog_ = NULL;
+ logout_timer_.Stop();
+}
+
+} // namespace internal
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698