| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "app/keyboard_codes.h" | 13 #include "app/keyboard_codes.h" |
| 14 #include "app/l10n_util.h" | 14 #include "app/l10n_util.h" |
| 15 #include "app/resource_bundle.h" | 15 #include "app/resource_bundle.h" |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
| 20 #include "base/process_util.h" | 20 #include "base/process_util.h" |
| 21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
| 23 #include "chrome/browser/chromeos/cros/cros_library.h" | 23 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 24 #include "chrome/browser/chromeos/login/helper.h" | 24 #include "chrome/browser/chromeos/login/helper.h" |
| 25 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 25 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| 26 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" |
| 26 #include "grit/app_resources.h" | 27 #include "grit/app_resources.h" |
| 27 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 29 #include "views/controls/button/native_button.h" | 30 #include "views/controls/button/native_button.h" |
| 30 #include "views/controls/label.h" | 31 #include "views/controls/label.h" |
| 31 #include "views/controls/throbber.h" | 32 #include "views/controls/throbber.h" |
| 32 #include "views/widget/widget_gtk.h" | 33 #include "views/widget/widget_gtk.h" |
| 33 | 34 |
| 34 using views::Label; | 35 using views::Label; |
| 35 using views::Textfield; | 36 using views::Textfield; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 splitter_(NULL), | 83 splitter_(NULL), |
| 83 sign_in_button_(NULL), | 84 sign_in_button_(NULL), |
| 84 create_account_link_(NULL), | 85 create_account_link_(NULL), |
| 85 browse_without_signin_link_(NULL), | 86 browse_without_signin_link_(NULL), |
| 86 languages_menubutton_(NULL), | 87 languages_menubutton_(NULL), |
| 87 throbber_(NULL), | 88 throbber_(NULL), |
| 88 accel_focus_pass_(views::Accelerator(app::VKEY_P, false, false, true)), | 89 accel_focus_pass_(views::Accelerator(app::VKEY_P, false, false, true)), |
| 89 accel_focus_user_(views::Accelerator(app::VKEY_U, false, false, true)), | 90 accel_focus_user_(views::Accelerator(app::VKEY_U, false, false, true)), |
| 90 accel_login_off_the_record_( | 91 accel_login_off_the_record_( |
| 91 views::Accelerator(app::VKEY_B, false, false, true)), | 92 views::Accelerator(app::VKEY_B, false, false, true)), |
| 93 accel_enable_accessibility_(WizardAccessibilityHelper::GetAccelerator()), |
| 92 delegate_(delegate), | 94 delegate_(delegate), |
| 93 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)), | 95 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)), |
| 94 focus_delayed_(false), | 96 focus_delayed_(false), |
| 95 login_in_process_(false), | 97 login_in_process_(false), |
| 96 need_border_(need_border), | 98 need_border_(need_border), |
| 97 need_browse_without_signin_(need_browse_without_signin), | 99 need_browse_without_signin_(need_browse_without_signin), |
| 98 need_create_account_(false), | 100 need_create_account_(false), |
| 99 languages_menubutton_order_(-1), | 101 languages_menubutton_order_(-1), |
| 100 sign_in_button_order_(-1) { | 102 sign_in_button_order_(-1) { |
| 101 } | 103 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 language_switch_menu_.InitLanguageMenu(); | 156 language_switch_menu_.InitLanguageMenu(); |
| 155 | 157 |
| 156 RecreatePeculiarControls(); | 158 RecreatePeculiarControls(); |
| 157 AddChildView(sign_in_button_); | 159 AddChildView(sign_in_button_); |
| 158 AddChildView(languages_menubutton_); | 160 AddChildView(languages_menubutton_); |
| 159 | 161 |
| 160 // Set up accelerators. | 162 // Set up accelerators. |
| 161 AddAccelerator(accel_focus_user_); | 163 AddAccelerator(accel_focus_user_); |
| 162 AddAccelerator(accel_focus_pass_); | 164 AddAccelerator(accel_focus_pass_); |
| 163 AddAccelerator(accel_login_off_the_record_); | 165 AddAccelerator(accel_login_off_the_record_); |
| 166 AddAccelerator(accel_enable_accessibility_); |
| 164 | 167 |
| 165 UpdateLocalizedStrings(); | 168 UpdateLocalizedStrings(); |
| 166 RequestFocus(); | 169 RequestFocus(); |
| 167 | 170 |
| 168 // Controller to handle events from textfields | 171 // Controller to handle events from textfields |
| 169 username_field_->SetController(this); | 172 username_field_->SetController(this); |
| 170 password_field_->SetController(this); | 173 password_field_->SetController(this); |
| 171 if (!CrosLibrary::Get()->EnsureLoaded()) { | 174 if (!CrosLibrary::Get()->EnsureLoaded()) { |
| 172 EnableInputControls(false); | 175 EnableInputControls(false); |
| 173 } | 176 } |
| 174 } | 177 } |
| 175 | 178 |
| 176 bool NewUserView::AcceleratorPressed(const views::Accelerator& accelerator) { | 179 bool NewUserView::AcceleratorPressed(const views::Accelerator& accelerator) { |
| 177 if (accelerator == accel_focus_user_) { | 180 if (accelerator == accel_focus_user_) { |
| 178 username_field_->RequestFocus(); | 181 username_field_->RequestFocus(); |
| 179 } else if (accelerator == accel_focus_pass_) { | 182 } else if (accelerator == accel_focus_pass_) { |
| 180 password_field_->RequestFocus(); | 183 password_field_->RequestFocus(); |
| 181 } else if (accelerator == accel_login_off_the_record_) { | 184 } else if (accelerator == accel_login_off_the_record_) { |
| 182 delegate_->OnLoginOffTheRecord(); | 185 delegate_->OnLoginOffTheRecord(); |
| 186 } else if (accelerator == accel_enable_accessibility_) { |
| 187 WizardAccessibilityHelper::GetInstance()->EnableAccessibility(this); |
| 183 } else { | 188 } else { |
| 184 return false; | 189 return false; |
| 185 } | 190 } |
| 186 return true; | 191 return true; |
| 187 } | 192 } |
| 188 | 193 |
| 189 void NewUserView::RecreatePeculiarControls() { | 194 void NewUserView::RecreatePeculiarControls() { |
| 190 // PreferredSize reported by MenuButton (and TextField) is not able | 195 // PreferredSize reported by MenuButton (and TextField) is not able |
| 191 // to shrink, only grow; so recreate on text change. | 196 // to shrink, only grow; so recreate on text change. |
| 192 delete languages_menubutton_; | 197 delete languages_menubutton_; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 &NewUserView::FocusFirstField)); | 266 &NewUserView::FocusFirstField)); |
| 262 } | 267 } |
| 263 | 268 |
| 264 void NewUserView::ViewHierarchyChanged(bool is_add, | 269 void NewUserView::ViewHierarchyChanged(bool is_add, |
| 265 View *parent, | 270 View *parent, |
| 266 View *child) { | 271 View *child) { |
| 267 if (is_add && child == this) { | 272 if (is_add && child == this) { |
| 268 MessageLoop::current()->PostTask(FROM_HERE, | 273 MessageLoop::current()->PostTask(FROM_HERE, |
| 269 focus_grabber_factory_.NewRunnableMethod( | 274 focus_grabber_factory_.NewRunnableMethod( |
| 270 &NewUserView::FocusFirstField)); | 275 &NewUserView::FocusFirstField)); |
| 276 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this); |
| 271 } | 277 } |
| 272 } | 278 } |
| 273 | 279 |
| 274 void NewUserView::NativeViewHierarchyChanged(bool attached, | 280 void NewUserView::NativeViewHierarchyChanged(bool attached, |
| 275 gfx::NativeView native_view, | 281 gfx::NativeView native_view, |
| 276 views::RootView* root_view) { | 282 views::RootView* root_view) { |
| 277 if (focus_delayed_ && attached) { | 283 if (focus_delayed_ && attached) { |
| 278 focus_delayed_ = false; | 284 focus_delayed_ = false; |
| 279 MessageLoop::current()->PostTask(FROM_HERE, | 285 MessageLoop::current()->PostTask(FROM_HERE, |
| 280 focus_grabber_factory_.NewRunnableMethod( | 286 focus_grabber_factory_.NewRunnableMethod( |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 } | 493 } |
| 488 } | 494 } |
| 489 | 495 |
| 490 void NewUserView::InitLink(views::Link** link) { | 496 void NewUserView::InitLink(views::Link** link) { |
| 491 *link = new views::Link(std::wstring()); | 497 *link = new views::Link(std::wstring()); |
| 492 (*link)->SetController(this); | 498 (*link)->SetController(this); |
| 493 AddChildView(*link); | 499 AddChildView(*link); |
| 494 } | 500 } |
| 495 | 501 |
| 496 } // namespace chromeos | 502 } // namespace chromeos |
| OLD | NEW |