| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/login_manager_view.h" | 5 #include "chrome/browser/chromeos/login/login_manager_view.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 LoginManagerView::LoginManagerView(ScreenObserver* observer) | 64 LoginManagerView::LoginManagerView(ScreenObserver* observer) |
| 65 : username_field_(NULL), | 65 : username_field_(NULL), |
| 66 password_field_(NULL), | 66 password_field_(NULL), |
| 67 os_version_label_(NULL), | 67 os_version_label_(NULL), |
| 68 title_label_(NULL), | 68 title_label_(NULL), |
| 69 username_label_(NULL), | 69 username_label_(NULL), |
| 70 password_label_(NULL), | 70 password_label_(NULL), |
| 71 error_label_(NULL), | 71 error_label_(NULL), |
| 72 sign_in_button_(NULL), | 72 sign_in_button_(NULL), |
| 73 create_account_button_(NULL), | 73 create_account_button_(NULL), |
| 74 accel_focus_user_(views::Accelerator(base::VKEY_U, false, false, true)), |
| 75 accel_focus_pass_(views::Accelerator(base::VKEY_P, false, false, true)), |
| 74 observer_(observer), | 76 observer_(observer), |
| 75 error_id_(-1), | 77 error_id_(-1), |
| 76 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)), | 78 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)), |
| 77 focus_delayed_(false) { | 79 focus_delayed_(false) { |
| 78 if (kStubOutLogin) | 80 if (kStubOutLogin) |
| 79 authenticator_.reset(new StubAuthenticator(this)); | 81 authenticator_.reset(new StubAuthenticator(this)); |
| 80 else | 82 else |
| 81 authenticator_.reset(LoginUtils::Get()->CreateAuthenticator(this)); | 83 authenticator_.reset(LoginUtils::Get()->CreateAuthenticator(this)); |
| 82 } | 84 } |
| 83 | 85 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 os_version_label_->SetColor(kVersionColor); | 139 os_version_label_->SetColor(kVersionColor); |
| 138 os_version_label_->SetFont(version_font); | 140 os_version_label_->SetFont(version_font); |
| 139 AddChildView(os_version_label_); | 141 AddChildView(os_version_label_); |
| 140 | 142 |
| 141 error_label_ = new views::Label(); | 143 error_label_ = new views::Label(); |
| 142 error_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 144 error_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 143 error_label_->SetColor(kErrorColor); | 145 error_label_->SetColor(kErrorColor); |
| 144 error_label_->SetFont(label_font); | 146 error_label_->SetFont(label_font); |
| 145 AddChildView(error_label_); | 147 AddChildView(error_label_); |
| 146 | 148 |
| 149 AddAccelerator(accel_focus_user_); |
| 150 AddAccelerator(accel_focus_pass_); |
| 151 |
| 147 UpdateLocalizedStrings(); | 152 UpdateLocalizedStrings(); |
| 148 | 153 |
| 149 // Restore previously logged in user. | 154 // Restore previously logged in user. |
| 150 std::vector<UserManager::User> users = UserManager::Get()->GetUsers(); | 155 std::vector<UserManager::User> users = UserManager::Get()->GetUsers(); |
| 151 if (users.size() > 0) { | 156 if (users.size() > 0) { |
| 152 username_field_->SetText(UTF8ToUTF16(users[0].email())); | 157 username_field_->SetText(UTF8ToUTF16(users[0].email())); |
| 153 } | 158 } |
| 154 RequestFocus(); | 159 RequestFocus(); |
| 155 | 160 |
| 156 // Controller to handle events from textfields | 161 // Controller to handle events from textfields |
| 157 username_field_->SetController(this); | 162 username_field_->SetController(this); |
| 158 password_field_->SetController(this); | 163 password_field_->SetController(this); |
| 159 if (CrosLibrary::Get()->EnsureLoaded()) { | 164 if (CrosLibrary::Get()->EnsureLoaded()) { |
| 160 loader_.GetVersion( | 165 loader_.GetVersion( |
| 161 &consumer_, NewCallback(this, &LoginManagerView::OnOSVersion)); | 166 &consumer_, NewCallback(this, &LoginManagerView::OnOSVersion)); |
| 162 } else if (!kStubOutLogin) { | 167 } else if (!kStubOutLogin) { |
| 163 error_label_->SetText( | 168 error_label_->SetText( |
| 164 ASCIIToWide(CrosLibrary::Get()->load_error_string())); | 169 ASCIIToWide(CrosLibrary::Get()->load_error_string())); |
| 165 username_field_->SetReadOnly(true); | 170 username_field_->SetReadOnly(true); |
| 166 password_field_->SetReadOnly(true); | 171 password_field_->SetReadOnly(true); |
| 167 } | 172 } |
| 168 } | 173 } |
| 169 | 174 |
| 175 bool LoginManagerView::AcceleratorPressed( |
| 176 const views::Accelerator& accelerator) { |
| 177 if (accelerator == accel_focus_user_) { |
| 178 username_field_->RequestFocus(); |
| 179 return true; |
| 180 } |
| 181 |
| 182 if (accelerator == accel_focus_pass_) { |
| 183 password_field_->RequestFocus(); |
| 184 return true; |
| 185 } |
| 186 |
| 187 return false; |
| 188 } |
| 189 |
| 170 void LoginManagerView::UpdateLocalizedStrings() { | 190 void LoginManagerView::UpdateLocalizedStrings() { |
| 171 title_label_->SetText(l10n_util::GetString(IDS_LOGIN_TITLE)); | 191 title_label_->SetText(l10n_util::GetString(IDS_LOGIN_TITLE)); |
| 172 username_label_->SetText(l10n_util::GetString(IDS_LOGIN_USERNAME)); | 192 username_label_->SetText(l10n_util::GetString(IDS_LOGIN_USERNAME)); |
| 173 password_label_->SetText(l10n_util::GetString(IDS_LOGIN_PASSWORD)); | 193 password_label_->SetText(l10n_util::GetString(IDS_LOGIN_PASSWORD)); |
| 174 sign_in_button_->SetLabel(l10n_util::GetString(IDS_LOGIN_BUTTON)); | 194 sign_in_button_->SetLabel(l10n_util::GetString(IDS_LOGIN_BUTTON)); |
| 175 create_account_button_->SetLabel( | 195 create_account_button_->SetLabel( |
| 176 l10n_util::GetString(IDS_CREATE_ACCOUNT_BUTTON)); | 196 l10n_util::GetString(IDS_CREATE_ACCOUNT_BUTTON)); |
| 177 ShowError(error_id_); | 197 ShowError(error_id_); |
| 178 } | 198 } |
| 179 | 199 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 return false; | 400 return false; |
| 381 } | 401 } |
| 382 | 402 |
| 383 void LoginManagerView::OnOSVersion( | 403 void LoginManagerView::OnOSVersion( |
| 384 VersionLoader::Handle handle, | 404 VersionLoader::Handle handle, |
| 385 std::string version) { | 405 std::string version) { |
| 386 os_version_label_->SetText(ASCIIToWide(version)); | 406 os_version_label_->SetText(ASCIIToWide(version)); |
| 387 } | 407 } |
| 388 | 408 |
| 389 } // namespace chromeos | 409 } // namespace chromeos |
| OLD | NEW |