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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_helper.h" | 11 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
13 #include "grit/browser_resources.h" | 13 #include "grit/browser_resources.h" |
14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
17 #include "ui/views/controls/label.h" | 17 #include "ui/views/controls/label.h" |
18 #include "ui/views/layout/grid_layout.h" | 18 #include "ui/views/layout/grid_layout.h" |
19 #include "ui/views/layout/layout_constants.h" | 19 #include "ui/views/layout/layout_constants.h" |
20 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
21 | 21 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // closed by any other way than CloseIdleLogoutDialog, we check if our | 73 // closed by any other way than CloseIdleLogoutDialog, we check if our |
74 // 'closed' state is set - if not, then we set it and set g_instance to null, | 74 // 'closed' state is set - if not, then we set it and set g_instance to null, |
75 // since that means that CloseIdleLogoutDialog was never called. | 75 // since that means that CloseIdleLogoutDialog was never called. |
76 if (!this->is_closed()) { | 76 if (!this->is_closed()) { |
77 g_instance->set_closed(); | 77 g_instance->set_closed(); |
78 g_instance = NULL; | 78 g_instance = NULL; |
79 } | 79 } |
80 | 80 |
81 // CallInit succeeded (or was never called) hence it didn't free | 81 // CallInit succeeded (or was never called) hence it didn't free |
82 // this pointer, free it here. | 82 // this pointer, free it here. |
83 if (chromeos::KioskModeHelper::Get()->is_initialized()) | 83 if (chromeos::KioskModeSettings::Get()->is_initialized()) |
84 delete instance_holder_; | 84 delete instance_holder_; |
85 | 85 |
86 delete this; | 86 delete this; |
87 } | 87 } |
88 | 88 |
89 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
90 // IdleLogoutDialog private methods | 90 // IdleLogoutDialog private methods |
91 IdleLogoutDialogView::IdleLogoutDialogView() : restart_label_(NULL), | 91 IdleLogoutDialogView::IdleLogoutDialogView() : restart_label_(NULL), |
92 warning_label_(NULL) { | 92 warning_label_(NULL) { |
93 instance_holder_ = new IdleLogoutDialogView*(this); | 93 instance_holder_ = new IdleLogoutDialogView*(this); |
94 } | 94 } |
95 | 95 |
96 IdleLogoutDialogView::~IdleLogoutDialogView() { | 96 IdleLogoutDialogView::~IdleLogoutDialogView() { |
97 } | 97 } |
98 | 98 |
99 // static | 99 // static |
100 void IdleLogoutDialogView::CallInit(IdleLogoutDialogView** instance_holder) { | 100 void IdleLogoutDialogView::CallInit(IdleLogoutDialogView** instance_holder) { |
101 if (*instance_holder) | 101 if (*instance_holder) |
102 (*instance_holder)->Init(); | 102 (*instance_holder)->Init(); |
103 else | 103 else |
104 // Our class is gone, free the holder memory. | 104 // Our class is gone, free the holder memory. |
105 delete instance_holder; | 105 delete instance_holder; |
106 } | 106 } |
107 | 107 |
108 void IdleLogoutDialogView::Init() { | 108 void IdleLogoutDialogView::Init() { |
109 if (!chromeos::KioskModeHelper::Get()->is_initialized()) { | 109 if (!chromeos::KioskModeSettings::Get()->is_initialized()) { |
110 chromeos::KioskModeHelper::Get()->Initialize( | 110 chromeos::KioskModeSettings::Get()->Initialize( |
111 base::Bind(&IdleLogoutDialogView::CallInit, instance_holder_)); | 111 base::Bind(&IdleLogoutDialogView::CallInit, instance_holder_)); |
112 return; | 112 return; |
113 } | 113 } |
114 | 114 |
115 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 115 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
116 | 116 |
117 warning_label_ = new views::Label( | 117 warning_label_ = new views::Label( |
118 l10n_util::GetStringUTF16(IDS_IDLE_LOGOUT_WARNING)); | 118 l10n_util::GetStringUTF16(IDS_IDLE_LOGOUT_WARNING)); |
119 warning_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 119 warning_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
120 warning_label_->SetMultiLine(true); | 120 warning_label_->SetMultiLine(true); |
(...skipping 12 matching lines...) Expand all Loading... |
133 views::GridLayout::USE_PREF, 0, 0); | 133 views::GridLayout::USE_PREF, 0, 0); |
134 layout->StartRow(0, 0); | 134 layout->StartRow(0, 0); |
135 layout->AddView(warning_label_); | 135 layout->AddView(warning_label_); |
136 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 136 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
137 layout->StartRow(0, 0); | 137 layout->StartRow(0, 0); |
138 layout->AddView(restart_label_); | 138 layout->AddView(restart_label_); |
139 } | 139 } |
140 | 140 |
141 void IdleLogoutDialogView::Show() { | 141 void IdleLogoutDialogView::Show() { |
142 // Setup the countdown label before showing. | 142 // Setup the countdown label before showing. |
143 countdown_end_time_ = base::Time::Now() + base::TimeDelta::FromSeconds( | 143 countdown_end_time_ = base::Time::Now() + |
144 chromeos::KioskModeHelper::Get()->GetIdleLogoutWarningTimeout()); | 144 chromeos::KioskModeSettings::Get()->GetIdleLogoutWarningDuration(); |
145 UpdateCountdownTimer(); | 145 UpdateCountdownTimer(); |
146 | 146 |
147 views::Widget::CreateWindow(this); | 147 views::Widget::CreateWindow(this); |
148 GetWidget()->SetAlwaysOnTop(true); | 148 GetWidget()->SetAlwaysOnTop(true); |
149 GetWidget()->Show(); | 149 GetWidget()->Show(); |
150 | 150 |
151 // Update countdown every 1 second. | 151 // Update countdown every 1 second. |
152 timer_.Start(FROM_HERE, | 152 timer_.Start(FROM_HERE, |
153 base::TimeDelta::FromSeconds(kCountdownUpdateInterval), | 153 base::TimeDelta::FromSeconds(kCountdownUpdateInterval), |
154 this, | 154 this, |
(...skipping 22 matching lines...) Expand all Loading... |
177 IDS_IDLE_LOGOUT_WARNING_RESTART_1S)); | 177 IDS_IDLE_LOGOUT_WARNING_RESTART_1S)); |
178 } else { | 178 } else { |
179 // Set the label - the logout probably won't be instant. | 179 // Set the label - the logout probably won't be instant. |
180 restart_label_->SetText(l10n_util::GetStringUTF16( | 180 restart_label_->SetText(l10n_util::GetStringUTF16( |
181 IDS_IDLE_LOGOUT_WARNING_RESTART_NOW)); | 181 IDS_IDLE_LOGOUT_WARNING_RESTART_NOW)); |
182 | 182 |
183 // Logout the current user. | 183 // Logout the current user. |
184 BrowserList::AttemptUserExit(); | 184 BrowserList::AttemptUserExit(); |
185 } | 185 } |
186 } | 186 } |
OLD | NEW |