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