(Cleanup) Remove .Times(1) from the VideoCaptureManagerTest unit tests EXPECT_CALLs.
[chromium-blink-merge.git] / ash / system / session / logout_confirmation_controller.h
blob1b91d4d81ceba84ed15f87c4e3aa805ad36eb4ea
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.
5 #ifndef ASH_SYSTEM_SESSION_LOGOUT_CONFIRMATION_CONTROLLER_H_
6 #define ASH_SYSTEM_SESSION_LOGOUT_CONFIRMATION_CONTROLLER_H_
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"
16 namespace base {
17 class TickClock;
20 namespace ash {
21 namespace internal {
23 class LogoutConfirmationDialog;
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 // The |logout_closure| must be safe to call as long as |this| is alive.
34 explicit LogoutConfirmationController(const base::Closure& logout_closure);
35 virtual ~LogoutConfirmationController();
37 base::TickClock* clock() const { return clock_.get(); }
39 // 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
41 // the current dialog's |logout_time_|.
42 void ConfirmLogout(base::TimeTicks logout_time);
44 void SetClockForTesting(scoped_ptr<base::TickClock> clock);
46 // ShellObserver:
47 virtual void OnLockStateChanged(bool locked) OVERRIDE;
49 // Called by the |dialog_| when the user confirms logout.
50 void OnLogoutConfirmed();
52 // Called by the |dialog_| when it is closed.
53 void OnDialogClosed();
55 private:
56 scoped_ptr<base::TickClock> clock_;
57 base::Closure logout_closure_;
59 base::TimeTicks logout_time_;
60 LogoutConfirmationDialog* dialog_; // Owned by the Views hierarchy.
61 base::Timer logout_timer_;
63 DISALLOW_COPY_AND_ASSIGN(LogoutConfirmationController);
66 } // namespace internal
67 } // namespace ash
69 #endif // ASH_SYSTEM_SESSION_LOGOUT_CONFIRMATION_CONTROLLER_H_