| 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/new_user_view.h" | 5 #include "chrome/browser/chromeos/login/new_user_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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 splitter_down1_(NULL), | 91 splitter_down1_(NULL), |
| 92 splitter_down2_(NULL), | 92 splitter_down2_(NULL), |
| 93 sign_in_button_(NULL), | 93 sign_in_button_(NULL), |
| 94 create_account_link_(NULL), | 94 create_account_link_(NULL), |
| 95 guest_link_(NULL), | 95 guest_link_(NULL), |
| 96 languages_menubutton_(NULL), | 96 languages_menubutton_(NULL), |
| 97 accel_focus_pass_(views::Accelerator(app::VKEY_P, false, false, true)), | 97 accel_focus_pass_(views::Accelerator(app::VKEY_P, false, false, true)), |
| 98 accel_focus_user_(views::Accelerator(app::VKEY_U, false, false, true)), | 98 accel_focus_user_(views::Accelerator(app::VKEY_U, false, false, true)), |
| 99 accel_login_off_the_record_( | 99 accel_login_off_the_record_( |
| 100 views::Accelerator(app::VKEY_B, false, false, true)), | 100 views::Accelerator(app::VKEY_B, false, false, true)), |
| 101 accel_enable_accessibility_(WizardAccessibilityHelper::GetAccelerator()), | 101 accel_toggle_accessibility_(WizardAccessibilityHelper::GetAccelerator()), |
| 102 delegate_(delegate), | 102 delegate_(delegate), |
| 103 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)), | 103 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)), |
| 104 focus_delayed_(false), | 104 focus_delayed_(false), |
| 105 login_in_process_(false), | 105 login_in_process_(false), |
| 106 need_border_(need_border), | 106 need_border_(need_border), |
| 107 need_guest_link_(false), | 107 need_guest_link_(false), |
| 108 need_create_account_(false), | 108 need_create_account_(false), |
| 109 languages_menubutton_order_(-1), | 109 languages_menubutton_order_(-1), |
| 110 sign_in_button_order_(-1) { | 110 sign_in_button_order_(-1) { |
| 111 if (need_guest_link && UserCrosSettingsProvider::cached_allow_guest()) | 111 if (need_guest_link && UserCrosSettingsProvider::cached_allow_guest()) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 title_hint_label_->SetMultiLine(true); | 143 title_hint_label_->SetMultiLine(true); |
| 144 AddChildView(title_hint_label_); | 144 AddChildView(title_hint_label_); |
| 145 | 145 |
| 146 splitter_up1_ = CreateSplitter(kSplitterUp1Color); | 146 splitter_up1_ = CreateSplitter(kSplitterUp1Color); |
| 147 splitter_up2_ = CreateSplitter(kSplitterUp2Color); | 147 splitter_up2_ = CreateSplitter(kSplitterUp2Color); |
| 148 splitter_down1_ = CreateSplitter(kSplitterDown1Color); | 148 splitter_down1_ = CreateSplitter(kSplitterDown1Color); |
| 149 splitter_down2_ = CreateSplitter(kSplitterDown2Color); | 149 splitter_down2_ = CreateSplitter(kSplitterDown2Color); |
| 150 | 150 |
| 151 username_field_ = new UsernameField(); | 151 username_field_ = new UsernameField(); |
| 152 username_field_->set_background(new CopyBackground(this)); | 152 username_field_->set_background(new CopyBackground(this)); |
| 153 username_field_->SetAccessibleName( |
| 154 ASCIIToWide(l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_USERNAME_LABEL))); |
| 153 AddChildView(username_field_); | 155 AddChildView(username_field_); |
| 154 | 156 |
| 155 password_field_ = new TextfieldWithMargin(views::Textfield::STYLE_PASSWORD); | 157 password_field_ = new TextfieldWithMargin(views::Textfield::STYLE_PASSWORD); |
| 156 password_field_->set_background(new CopyBackground(this)); | 158 password_field_->set_background(new CopyBackground(this)); |
| 157 AddChildView(password_field_); | 159 AddChildView(password_field_); |
| 158 | 160 |
| 159 language_switch_menu_.InitLanguageMenu(); | 161 language_switch_menu_.InitLanguageMenu(); |
| 160 | 162 |
| 161 RecreatePeculiarControls(); | 163 RecreatePeculiarControls(); |
| 162 | 164 |
| 163 AddChildView(sign_in_button_); | 165 AddChildView(sign_in_button_); |
| 164 if (need_create_account_) { | 166 if (need_create_account_) { |
| 165 InitLink(&create_account_link_); | 167 InitLink(&create_account_link_); |
| 166 } | 168 } |
| 167 if (need_guest_link_) { | 169 if (need_guest_link_) { |
| 168 InitLink(&guest_link_); | 170 InitLink(&guest_link_); |
| 169 } | 171 } |
| 170 AddChildView(languages_menubutton_); | 172 AddChildView(languages_menubutton_); |
| 171 | 173 |
| 172 // Set up accelerators. | 174 // Set up accelerators. |
| 173 AddAccelerator(accel_focus_user_); | 175 AddAccelerator(accel_focus_user_); |
| 174 AddAccelerator(accel_focus_pass_); | 176 AddAccelerator(accel_focus_pass_); |
| 175 AddAccelerator(accel_login_off_the_record_); | 177 AddAccelerator(accel_login_off_the_record_); |
| 176 AddAccelerator(accel_enable_accessibility_); | 178 AddAccelerator(accel_toggle_accessibility_); |
| 177 | 179 |
| 178 OnLocaleChanged(); | 180 OnLocaleChanged(); |
| 179 | 181 |
| 180 // Controller to handle events from textfields | 182 // Controller to handle events from textfields |
| 181 username_field_->SetController(this); | 183 username_field_->SetController(this); |
| 182 password_field_->SetController(this); | 184 password_field_->SetController(this); |
| 183 if (!CrosLibrary::Get()->EnsureLoaded()) { | 185 if (!CrosLibrary::Get()->EnsureLoaded()) { |
| 184 EnableInputControls(false); | 186 EnableInputControls(false); |
| 185 } | 187 } |
| 186 | 188 |
| 187 // The 'Sign in' button should be disabled when there is no text in the | 189 // The 'Sign in' button should be disabled when there is no text in the |
| 188 // username and password fields. | 190 // username and password fields. |
| 189 sign_in_button_->SetEnabled(false); | 191 sign_in_button_->SetEnabled(false); |
| 190 } | 192 } |
| 191 | 193 |
| 192 bool NewUserView::AcceleratorPressed(const views::Accelerator& accelerator) { | 194 bool NewUserView::AcceleratorPressed(const views::Accelerator& accelerator) { |
| 193 if (accelerator == accel_focus_user_) { | 195 if (accelerator == accel_focus_user_) { |
| 194 username_field_->RequestFocus(); | 196 username_field_->RequestFocus(); |
| 195 } else if (accelerator == accel_focus_pass_) { | 197 } else if (accelerator == accel_focus_pass_) { |
| 196 password_field_->RequestFocus(); | 198 password_field_->RequestFocus(); |
| 197 } else if (accelerator == accel_login_off_the_record_) { | 199 } else if (accelerator == accel_login_off_the_record_) { |
| 198 delegate_->OnLoginOffTheRecord(); | 200 delegate_->OnLoginOffTheRecord(); |
| 199 } else if (accelerator == accel_enable_accessibility_) { | 201 } else if (accelerator == accel_toggle_accessibility_) { |
| 200 WizardAccessibilityHelper::GetInstance()->EnableAccessibility(this); | 202 WizardAccessibilityHelper::GetInstance()->ToggleAccessibility(this); |
| 201 } else { | 203 } else { |
| 202 return false; | 204 return false; |
| 203 } | 205 } |
| 204 return true; | 206 return true; |
| 205 } | 207 } |
| 206 | 208 |
| 207 void NewUserView::RecreatePeculiarControls() { | 209 void NewUserView::RecreatePeculiarControls() { |
| 208 // PreferredSize reported by MenuButton (and TextField) is not able | 210 // PreferredSize reported by MenuButton (and TextField) is not able |
| 209 // to shrink, only grow; so recreate on text change. | 211 // to shrink, only grow; so recreate on text change. |
| 210 delete languages_menubutton_; | 212 delete languages_menubutton_; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 546 |
| 545 void NewUserView::InitLink(views::Link** link) { | 547 void NewUserView::InitLink(views::Link** link) { |
| 546 *link = new views::Link(std::wstring()); | 548 *link = new views::Link(std::wstring()); |
| 547 (*link)->SetController(this); | 549 (*link)->SetController(this); |
| 548 (*link)->SetNormalColor(login::kLinkColor); | 550 (*link)->SetNormalColor(login::kLinkColor); |
| 549 (*link)->SetHighlightedColor(login::kLinkColor); | 551 (*link)->SetHighlightedColor(login::kLinkColor); |
| 550 AddChildView(*link); | 552 AddChildView(*link); |
| 551 } | 553 } |
| 552 | 554 |
| 553 } // namespace chromeos | 555 } // namespace chromeos |
| OLD | NEW |