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

Side by Side Diff: ash/system/logout_confirmation/logout_confirmation_controller.h

Issue 178183005: Add LogoutConfirmationController to show LogoutConfirmationDialogs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Rebased. Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #ifndef ASH_SYSTEM_LOGOUT_CONFIRMATION_LOGOUT_CONFIRMATION_CONTROLLER_H_
6 #define ASH_SYSTEM_LOGOUT_CONFIRMATION_LOGOUT_CONFIRMATION_CONTROLLER_H_
7
8 #include "ash/ash_export.h"
9 #include "ash/shell_observer.h"
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/time/time.h"
14 #include "base/timer/timer.h"
15
16 namespace base {
17 class TickClock;
18 }
19
20 namespace ash {
21 namespace internal {
22
23 class LogoutConfirmationDialog;
24
25 // This class shows a dialog asking the user to confirm or deny logout and
26 // terminates the session if the user either confirms or allows the countdown
27 // shown in the dialog to expire.
28 // It is guaranteed that no more than one confirmation dialog will be visible at
29 // any given time. If there are multiple requests to show a confirmation dialog
30 // at the same time, the dialog whose countdown expires first is shown.
31 class ASH_EXPORT LogoutConfirmationController : public ShellObserver {
32 public:
33 explicit LogoutConfirmationController(const base::Closure& logout_closure);
34 virtual ~LogoutConfirmationController();
35
36 base::TickClock* clock() const { return clock_.get(); }
37
38 // Shows a LogoutConfirmationDialog. If a confirmation dialog is already being
39 // shown, it is closed and a new one opened if |logout_time| is earlier than
40 // the current dialog's |logout_time_|.
41 void ConfirmLogout(base::TimeTicks logout_time);
42
43 void SetClockForTesting(scoped_ptr<base::TickClock> clock);
44
45 // ShellObserver:
46 virtual void OnLockStateChanged(bool locked) OVERRIDE;
47
48 // Called by the |dialog_| when the user confirms logout.
49 void OnLogoutConfirmed();
50
51 // Called by the |dialog_| when it is closed.
52 void OnDialogClosed();
53
54 private:
55 scoped_ptr<base::TickClock> clock_;
56 base::Closure logout_closure_;
57
58 base::TimeTicks logout_time_;
59 LogoutConfirmationDialog* dialog_; // Owned by the Views hierarchy.
60 base::Timer logout_timer_;
61
62 DISALLOW_COPY_AND_ASSIGN(LogoutConfirmationController);
63 };
64
65 } // namespace internal
66 } // namespace ash
67
68 #endif // ASH_SYSTEM_LOGOUT_CONFIRMATION_LOGOUT_CONFIRMATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698