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

Side by Side Diff: ash/common/system/chromeos/session/logout_confirmation_controller.h

Issue 2108793002: mash: Convert system tray logout button to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more review comments, fix mash_unittests Created 4 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef ASH_SYSTEM_CHROMEOS_SESSION_LOGOUT_CONFIRMATION_CONTROLLER_H_ 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_SESSION_LOGOUT_CONFIRMATION_CONTROLLER_H_
6 #define ASH_SYSTEM_CHROMEOS_SESSION_LOGOUT_CONFIRMATION_CONTROLLER_H_ 6 #define ASH_COMMON_SYSTEM_CHROMEOS_SESSION_LOGOUT_CONFIRMATION_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/common/shell_observer.h" 11 #include "ash/common/shell_observer.h"
12 #include "ash/common/system/chromeos/session/last_window_closed_observer.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 17
17 namespace base { 18 namespace base {
18 class TickClock; 19 class TickClock;
19 } 20 }
20 21
21 namespace ash { 22 namespace ash {
22 23
23 class LogoutConfirmationDialog; 24 class LogoutConfirmationDialog;
24 25
25 // This class shows a dialog asking the user to confirm or deny logout and 26 // 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 // terminates the session if the user either confirms or allows the countdown
27 // shown in the dialog to expire. 28 // shown in the dialog to expire.
29 //
28 // It is guaranteed that no more than one confirmation dialog will be visible at 30 // 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 31 // 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. 32 // at the same time, the dialog whose countdown expires first is shown.
31 class ASH_EXPORT LogoutConfirmationController : public ShellObserver { 33 //
34 // In public sessions, asks the user to end the session when the last window is
35 // closed.
36 class ASH_EXPORT LogoutConfirmationController
37 : public ShellObserver,
38 public LastWindowClosedObserver {
32 public: 39 public:
33 // The |logout_closure| must be safe to call as long as |this| is alive. 40 // The |logout_closure| must be safe to call as long as |this| is alive.
34 explicit LogoutConfirmationController(const base::Closure& logout_closure); 41 explicit LogoutConfirmationController(const base::Closure& logout_closure);
35 ~LogoutConfirmationController() override; 42 ~LogoutConfirmationController() override;
36 43
37 base::TickClock* clock() const { return clock_.get(); } 44 base::TickClock* clock() const { return clock_.get(); }
38 45
39 // Shows a LogoutConfirmationDialog. If a confirmation dialog is already being 46 // Shows a LogoutConfirmationDialog. If a confirmation dialog is already being
40 // shown, it is closed and a new one opened if |logout_time| is earlier than 47 // shown, it is closed and a new one opened if |logout_time| is earlier than
41 // the current dialog's |logout_time_|. 48 // the current dialog's |logout_time_|.
42 void ConfirmLogout(base::TimeTicks logout_time); 49 void ConfirmLogout(base::TimeTicks logout_time);
43 50
44 void SetClockForTesting(std::unique_ptr<base::TickClock> clock); 51 void SetClockForTesting(std::unique_ptr<base::TickClock> clock);
45 52
46 // ShellObserver: 53 // ShellObserver:
47 void OnLockStateChanged(bool locked) override; 54 void OnLockStateChanged(bool locked) override;
48 55
49 // Called by the |dialog_| when the user confirms logout. 56 // Called by the |dialog_| when the user confirms logout.
50 void OnLogoutConfirmed(); 57 void OnLogoutConfirmed();
51 58
52 // Called by the |dialog_| when it is closed. 59 // Called by the |dialog_| when it is closed.
53 void OnDialogClosed(); 60 void OnDialogClosed();
54 61
55 LogoutConfirmationDialog* dialog_for_testing() const { return dialog_; } 62 LogoutConfirmationDialog* dialog_for_testing() const { return dialog_; }
56 63
57 private: 64 private:
65 // LastWindowClosedObserver:
66 void OnLastWindowClosed() override;
67
58 std::unique_ptr<base::TickClock> clock_; 68 std::unique_ptr<base::TickClock> clock_;
59 base::Closure logout_closure_; 69 base::Closure logout_closure_;
60 70
61 base::TimeTicks logout_time_; 71 base::TimeTicks logout_time_;
62 LogoutConfirmationDialog* dialog_; // Owned by the Views hierarchy. 72 LogoutConfirmationDialog* dialog_; // Owned by the Views hierarchy.
63 base::Timer logout_timer_; 73 base::Timer logout_timer_;
64 74
65 DISALLOW_COPY_AND_ASSIGN(LogoutConfirmationController); 75 DISALLOW_COPY_AND_ASSIGN(LogoutConfirmationController);
66 }; 76 };
67 77
68 } // namespace ash 78 } // namespace ash
69 79
70 #endif // ASH_SYSTEM_CHROMEOS_SESSION_LOGOUT_CONFIRMATION_CONTROLLER_H_ 80 #endif // ASH_COMMON_SYSTEM_CHROMEOS_SESSION_LOGOUT_CONFIRMATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698