OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_UI_IDLE_LOGOUT_DIALOG_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_UI_IDLE_LOGOUT_DIALOG_H_ | |
7 #pragma once | |
8 | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/string16.h" | |
11 #include "base/timer.h" | |
12 #include "ui/views/controls/label.h" | |
13 #include "ui/views/window/dialog_delegate.h" | |
14 | |
15 namespace base { | |
16 class TimeDelta; | |
17 } | |
18 | |
19 // A class to show the logout on idle dialog if the machine is in retail mode. | |
20 class IdleLogoutDialog : public views::DialogDelegateView { | |
21 public: | |
22 static void ShowIdleLogoutDialog(); | |
23 static void CloseIdleLogoutDialog(); | |
24 | |
25 // views::DialogDelegateView: | |
26 virtual int GetDialogButtons() const OVERRIDE; | |
27 virtual ui::ModalType GetModalType() const OVERRIDE; | |
28 virtual string16 GetWindowTitle() const OVERRIDE; | |
29 virtual views::View* GetContentsView() OVERRIDE; | |
30 virtual void DeleteDelegate() OVERRIDE; | |
31 | |
32 // views::View | |
33 virtual void Layout() OVERRIDE; | |
34 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
35 | |
36 // Indicate that this instance has been 'closed' and should not be used. | |
37 void set_closed() { *instance_holder_ = NULL; } | |
sky
2012/03/12 23:33:38
Don't expose this in the public section.
rkc
2012/03/12 23:57:51
Done.
| |
38 // If our instance holder holds NULL, means we've been closed already. | |
39 bool is_closed() { return NULL == *instance_holder_; } | |
40 | |
41 private: | |
42 IdleLogoutDialog(); | |
43 | |
44 // Closure that calls init after checking if the class is still alive. | |
45 friend void CallInit(IdleLogoutDialog** dialog); | |
46 // Adds the labels and adds them to the layout. | |
47 void Init(); | |
48 | |
49 void Show(); | |
50 void Close(); | |
51 | |
52 void UpdateCountdownTimer(); | |
53 | |
54 views::Label* restart_label_; | |
55 views::Label* warning_label_; | |
56 | |
57 // Time at which the countdown is over and we should close the dialog. | |
58 base::Time countdown_end_time_; | |
59 | |
60 base::RepeatingTimer<IdleLogoutDialog> timer_; | |
61 | |
62 // Holds a pointer to our instance; if we are closed, we set this to hold | |
63 // a NULL value, indicating that our instance is been 'closed' and should | |
64 // not be used further. The delete will happen async to the closing. | |
65 IdleLogoutDialog** instance_holder_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(IdleLogoutDialog); | |
68 }; | |
69 | |
70 #endif // CHROME_BROWSER_CHROMEOS_UI_IDLE_LOGOUT_DIALOG_H_ | |
OLD | NEW |