OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/chromeos/ui/idle_logout_dialog_view.h" | 5 #include "chrome/browser/chromeos/ui/idle_logout_dialog_view.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 // called, in which case we reset g_instance there if not already reset. | 69 // called, in which case we reset g_instance there if not already reset. |
70 if (!g_instance) { | 70 if (!g_instance) { |
71 g_instance = new IdleLogoutDialogView(); | 71 g_instance = new IdleLogoutDialogView(); |
72 g_instance->InitAndShow(); | 72 g_instance->InitAndShow(); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 // static | 76 // static |
77 void IdleLogoutDialogView::CloseDialog() { | 77 void IdleLogoutDialogView::CloseDialog() { |
78 if (g_instance) | 78 if (g_instance) |
79 g_instance->Close(); | 79 g_instance->GetWidget()->Close(); |
achuithb
2013/07/29 17:56:38
Shouldn't you be calling g_instance->Close() here?
fdoray
2013/07/29 18:38:38
No. Calling g_instance->Close() wouldn't close the
| |
80 } | 80 } |
81 | 81 |
82 //////////////////////////////////////////////////////////////////////////////// | 82 //////////////////////////////////////////////////////////////////////////////// |
83 // Overridden from views::DialogDelegateView | 83 // Overridden from views::DialogDelegateView |
84 int IdleLogoutDialogView::GetDialogButtons() const { | 84 int IdleLogoutDialogView::GetDialogButtons() const { |
85 return ui::DIALOG_BUTTON_NONE; | 85 return ui::DIALOG_BUTTON_NONE; |
86 } | 86 } |
87 | 87 |
88 ui::ModalType IdleLogoutDialogView::GetModalType() const { | 88 ui::ModalType IdleLogoutDialogView::GetModalType() const { |
89 return ui::MODAL_TYPE_WINDOW; | 89 return ui::MODAL_TYPE_WINDOW; |
90 } | 90 } |
91 | 91 |
92 string16 IdleLogoutDialogView::GetWindowTitle() const { | 92 string16 IdleLogoutDialogView::GetWindowTitle() const { |
93 return l10n_util::GetStringUTF16(IDS_IDLE_LOGOUT_TITLE); | 93 return l10n_util::GetStringUTF16(IDS_IDLE_LOGOUT_TITLE); |
94 } | 94 } |
95 | 95 |
96 bool IdleLogoutDialogView::Close() { | |
97 if (timer_.IsRunning()) | |
98 timer_.Stop(); | |
99 | |
100 // We just closed our dialog. The global | |
101 // instance is invalid now, set it to null. | |
102 g_instance = NULL; | |
103 | |
104 return true; | |
105 } | |
106 | |
96 //////////////////////////////////////////////////////////////////////////////// | 107 //////////////////////////////////////////////////////////////////////////////// |
97 // IdleLogoutDialog private methods | 108 // IdleLogoutDialog private methods |
98 IdleLogoutDialogView::IdleLogoutDialogView() | 109 IdleLogoutDialogView::IdleLogoutDialogView() |
99 : restart_label_(NULL), | 110 : restart_label_(NULL), |
100 weak_ptr_factory_(this) { | 111 weak_ptr_factory_(this) { |
101 if (!IdleLogoutDialogView::provider_) | 112 if (!IdleLogoutDialogView::provider_) |
102 IdleLogoutDialogView::provider_ = new IdleLogoutSettingsProvider(); | 113 IdleLogoutDialogView::provider_ = new IdleLogoutSettingsProvider(); |
103 } | 114 } |
104 | 115 |
105 IdleLogoutDialogView::~IdleLogoutDialogView() { | 116 IdleLogoutDialogView::~IdleLogoutDialogView() { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 GetWidget()->SetAlwaysOnTop(true); | 165 GetWidget()->SetAlwaysOnTop(true); |
155 GetWidget()->Show(); | 166 GetWidget()->Show(); |
156 | 167 |
157 // Update countdown every 1 second. | 168 // Update countdown every 1 second. |
158 timer_.Start(FROM_HERE, | 169 timer_.Start(FROM_HERE, |
159 IdleLogoutDialogView::provider_->GetCountdownUpdateInterval(), | 170 IdleLogoutDialogView::provider_->GetCountdownUpdateInterval(), |
160 this, | 171 this, |
161 &IdleLogoutDialogView::UpdateCountdown); | 172 &IdleLogoutDialogView::UpdateCountdown); |
162 } | 173 } |
163 | 174 |
164 void IdleLogoutDialogView::Close() { | |
165 DCHECK(GetWidget()); | |
166 | |
167 if (timer_.IsRunning()) | |
168 timer_.Stop(); | |
169 GetWidget()->Close(); | |
170 | |
171 // We just closed our dialog. The global | |
172 // instance is invalid now, set it to null. | |
173 g_instance = NULL; | |
174 } | |
175 | |
176 void IdleLogoutDialogView::UpdateCountdown() { | 175 void IdleLogoutDialogView::UpdateCountdown() { |
177 base::TimeDelta logout_warning_time = countdown_end_time_ - | 176 base::TimeDelta logout_warning_time = countdown_end_time_ - |
178 base::Time::Now(); | 177 base::Time::Now(); |
179 int64 seconds_left = (logout_warning_time.InMillisecondsF() / | 178 int64 seconds_left = (logout_warning_time.InMillisecondsF() / |
180 base::Time::kMillisecondsPerSecond) + 0.5; | 179 base::Time::kMillisecondsPerSecond) + 0.5; |
181 | 180 |
182 if (seconds_left > 1) { | 181 if (seconds_left > 1) { |
183 restart_label_->SetText(l10n_util::GetStringFUTF16( | 182 restart_label_->SetText(l10n_util::GetStringFUTF16( |
184 IDS_IDLE_LOGOUT_WARNING_RESTART, | 183 IDS_IDLE_LOGOUT_WARNING_RESTART, |
185 base::Int64ToString16(seconds_left))); | 184 base::Int64ToString16(seconds_left))); |
(...skipping 16 matching lines...) Expand all Loading... | |
202 return g_instance; | 201 return g_instance; |
203 } | 202 } |
204 | 203 |
205 // static | 204 // static |
206 void IdleLogoutDialogView::set_settings_provider( | 205 void IdleLogoutDialogView::set_settings_provider( |
207 IdleLogoutSettingsProvider* provider) { | 206 IdleLogoutSettingsProvider* provider) { |
208 provider_ = provider; | 207 provider_ = provider; |
209 } | 208 } |
210 | 209 |
211 } // namespace chromeos | 210 } // namespace chromeos |
OLD | NEW |