OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/login/screen_lock_view.h" | 5 #include "chrome/browser/chromeos/login/screen_lock_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/chromeos/login/helper.h" | 10 #include "chrome/browser/chromeos/login/helper.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 using views::GridLayout; | 58 using views::GridLayout; |
59 using login::kBorderSize; | 59 using login::kBorderSize; |
60 | 60 |
61 ScreenLockView::ScreenLockView(ScreenLocker* screen_locker) | 61 ScreenLockView::ScreenLockView(ScreenLocker* screen_locker) |
62 : user_view_(NULL), | 62 : user_view_(NULL), |
63 password_field_(NULL), | 63 password_field_(NULL), |
64 screen_locker_(screen_locker), | 64 screen_locker_(screen_locker), |
65 main_(NULL), | 65 main_(NULL), |
66 username_(NULL) { | 66 username_(NULL), |
| 67 throbber_manager_(new ThrobberManager()) { |
67 DCHECK(screen_locker_); | 68 DCHECK(screen_locker_); |
68 } | 69 } |
69 | 70 |
| 71 ScreenLockView::~ScreenLockView() { |
| 72 } |
| 73 |
70 gfx::Size ScreenLockView::GetPreferredSize() { | 74 gfx::Size ScreenLockView::GetPreferredSize() { |
71 return main_->GetPreferredSize(); | 75 return main_->GetPreferredSize(); |
72 } | 76 } |
73 | 77 |
74 void ScreenLockView::Layout() { | 78 void ScreenLockView::Layout() { |
75 int username_height = login::kSelectedLabelHeight; | 79 int username_height = login::kSelectedLabelHeight; |
76 main_->SetBounds(0, 0, width(), height()); | 80 main_->SetBounds(0, 0, width(), height()); |
77 username_->SetBounds( | 81 username_->SetBounds( |
78 kBorderSize, | 82 kBorderSize, |
79 login::kUserImageSize - username_height + kBorderSize, | 83 login::kUserImageSize - username_height + kBorderSize, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 void ScreenLockView::SetSignoutEnabled(bool enabled) { | 157 void ScreenLockView::SetSignoutEnabled(bool enabled) { |
154 user_view_->SetSignoutEnabled(enabled); | 158 user_view_->SetSignoutEnabled(enabled); |
155 } | 159 } |
156 | 160 |
157 gfx::Rect ScreenLockView::GetPasswordBoundsRelativeTo(const views::View* view) { | 161 gfx::Rect ScreenLockView::GetPasswordBoundsRelativeTo(const views::View* view) { |
158 gfx::Point p; | 162 gfx::Point p; |
159 views::View::ConvertPointToView(password_field_, view, &p); | 163 views::View::ConvertPointToView(password_field_, view, &p); |
160 return gfx::Rect(p, size()); | 164 return gfx::Rect(p, size()); |
161 } | 165 } |
162 | 166 |
| 167 void ScreenLockView::StartThrobber() { |
| 168 if (password_field_->GetWidget()) { |
| 169 throbber_manager_->CreateAndStart(password_field_->GetWidget(), |
| 170 CreateDefaultSmoothedThrobber(), |
| 171 login::kThrobberRightMargin); |
| 172 } |
| 173 } |
| 174 |
| 175 void ScreenLockView::StopThrobber() { |
| 176 throbber_manager_->StopAndClose(); |
| 177 } |
| 178 |
| 179 |
163 void ScreenLockView::SetEnabled(bool enabled) { | 180 void ScreenLockView::SetEnabled(bool enabled) { |
164 views::View::SetEnabled(enabled); | 181 views::View::SetEnabled(enabled); |
165 | 182 |
166 if (!enabled) { | 183 if (!enabled) { |
167 user_view_->StartThrobber(); | |
168 // TODO(oshima): Re-enabling does not move the focus to the view | 184 // TODO(oshima): Re-enabling does not move the focus to the view |
169 // that had a focus (issue http://crbug.com/43131). | 185 // that had a focus (issue http://crbug.com/43131). |
170 // Clear focus on the textfield so that re-enabling can set focus | 186 // Clear focus on the textfield so that re-enabling can set focus |
171 // back to the text field. | 187 // back to the text field. |
172 // FocusManager may be null if the view does not have | 188 // FocusManager may be null if the view does not have |
173 // associated Widget yet. | 189 // associated Widget yet. |
174 if (password_field_->GetFocusManager()) | 190 if (password_field_->GetFocusManager()) |
175 password_field_->GetFocusManager()->ClearFocus(); | 191 password_field_->GetFocusManager()->ClearFocus(); |
176 } else { | |
177 user_view_->StopThrobber(); | |
178 } | 192 } |
179 password_field_->SetEnabled(enabled); | 193 password_field_->SetEnabled(enabled); |
180 } | 194 } |
181 | 195 |
182 void ScreenLockView::OnSignout() { | 196 void ScreenLockView::OnSignout() { |
183 screen_locker_->Signout(); | 197 screen_locker_->Signout(); |
184 } | 198 } |
185 | 199 |
186 bool ScreenLockView::HandleKeystroke( | 200 bool ScreenLockView::HandleKeystroke( |
187 views::Textfield* sender, | 201 views::Textfield* sender, |
(...skipping 18 matching lines...) Expand all Loading... |
206 return; | 220 return; |
207 user_view_->SetImage(user->image(), user->image()); | 221 user_view_->SetImage(user->image(), user->image()); |
208 } | 222 } |
209 | 223 |
210 void ScreenLockView::ViewHierarchyChanged(bool is_add, | 224 void ScreenLockView::ViewHierarchyChanged(bool is_add, |
211 views::View* parent, | 225 views::View* parent, |
212 views::View* child) { | 226 views::View* child) { |
213 if (is_add && this == child) | 227 if (is_add && this == child) |
214 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this); | 228 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this); |
215 } | 229 } |
| 230 |
216 } // namespace chromeos | 231 } // namespace chromeos |
OLD | NEW |