| 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" | |
| 14 #include "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
| 15 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
| 16 #include "base/callback.h" | 15 #include "base/callback.h" |
| 17 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 18 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
| 19 #include "base/process_util.h" | 18 #include "base/process_util.h" |
| 20 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 21 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 22 #include "chrome/browser/chromeos/cros/cros_library.h" | 21 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 23 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 22 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| 24 #include "chrome/browser/chromeos/login/textfield_with_margin.h" | 23 #include "chrome/browser/chromeos/login/textfield_with_margin.h" |
| 25 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" | 24 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" |
| 26 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 25 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 27 #include "chrome/browser/chromeos/views/copy_background.h" | 26 #include "chrome/browser/chromeos/views/copy_background.h" |
| 28 #include "gfx/font.h" | 27 #include "gfx/font.h" |
| 29 #include "grit/app_resources.h" | 28 #include "grit/app_resources.h" |
| 30 #include "grit/chromium_strings.h" | 29 #include "grit/chromium_strings.h" |
| 31 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 31 #include "ui/base/keycodes/keyboard_codes.h" |
| 32 #include "views/controls/label.h" | 32 #include "views/controls/label.h" |
| 33 #include "views/controls/throbber.h" | 33 #include "views/controls/throbber.h" |
| 34 #include "views/widget/widget_gtk.h" | 34 #include "views/widget/widget_gtk.h" |
| 35 | 35 |
| 36 using views::View; | 36 using views::View; |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 const int kTextfieldWidth = 230; | 40 const int kTextfieldWidth = 230; |
| 41 const int kSplitterHeight = 1; | 41 const int kSplitterHeight = 1; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 was_trim = false; | 74 was_trim = false; |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 if (was_trim) | 78 if (was_trim) |
| 79 SetText(user_input); | 79 SetText(user_input); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Overridden from views::View: | 82 // Overridden from views::View: |
| 83 virtual bool OnKeyPressed(const views::KeyEvent& e) { | 83 virtual bool OnKeyPressed(const views::KeyEvent& e) { |
| 84 if (e.GetKeyCode() == app::VKEY_LEFT) { | 84 if (e.GetKeyCode() == ui::VKEY_LEFT) { |
| 85 return controller_->NavigateAway(); | 85 return controller_->NavigateAway(); |
| 86 } | 86 } |
| 87 return false; | 87 return false; |
| 88 } | 88 } |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 chromeos::NewUserView* controller_; | 91 chromeos::NewUserView* controller_; |
| 92 DISALLOW_COPY_AND_ASSIGN(UsernameField); | 92 DISALLOW_COPY_AND_ASSIGN(UsernameField); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace | 95 } // namespace |
| 96 | 96 |
| 97 namespace chromeos { | 97 namespace chromeos { |
| 98 | 98 |
| 99 NewUserView::NewUserView(Delegate* delegate, | 99 NewUserView::NewUserView(Delegate* delegate, |
| 100 bool need_border, | 100 bool need_border, |
| 101 bool need_guest_link) | 101 bool need_guest_link) |
| 102 : username_field_(NULL), | 102 : username_field_(NULL), |
| 103 password_field_(NULL), | 103 password_field_(NULL), |
| 104 title_label_(NULL), | 104 title_label_(NULL), |
| 105 title_hint_label_(NULL), | 105 title_hint_label_(NULL), |
| 106 splitter_up1_(NULL), | 106 splitter_up1_(NULL), |
| 107 splitter_up2_(NULL), | 107 splitter_up2_(NULL), |
| 108 splitter_down1_(NULL), | 108 splitter_down1_(NULL), |
| 109 splitter_down2_(NULL), | 109 splitter_down2_(NULL), |
| 110 sign_in_button_(NULL), | 110 sign_in_button_(NULL), |
| 111 create_account_link_(NULL), | 111 create_account_link_(NULL), |
| 112 guest_link_(NULL), | 112 guest_link_(NULL), |
| 113 languages_menubutton_(NULL), | 113 languages_menubutton_(NULL), |
| 114 accel_focus_pass_(views::Accelerator(app::VKEY_P, false, false, true)), | 114 accel_focus_pass_(views::Accelerator(ui::VKEY_P, false, false, true)), |
| 115 accel_focus_user_(views::Accelerator(app::VKEY_U, false, false, true)), | 115 accel_focus_user_(views::Accelerator(ui::VKEY_U, false, false, true)), |
| 116 accel_login_off_the_record_( | 116 accel_login_off_the_record_( |
| 117 views::Accelerator(app::VKEY_B, false, false, true)), | 117 views::Accelerator(ui::VKEY_B, false, false, true)), |
| 118 accel_toggle_accessibility_(WizardAccessibilityHelper::GetAccelerator()), | 118 accel_toggle_accessibility_(WizardAccessibilityHelper::GetAccelerator()), |
| 119 delegate_(delegate), | 119 delegate_(delegate), |
| 120 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)), | 120 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)), |
| 121 focus_delayed_(false), | 121 focus_delayed_(false), |
| 122 login_in_process_(false), | 122 login_in_process_(false), |
| 123 need_border_(need_border), | 123 need_border_(need_border), |
| 124 need_guest_link_(false), | 124 need_guest_link_(false), |
| 125 need_create_account_(false), | 125 need_create_account_(false), |
| 126 languages_menubutton_order_(-1), | 126 languages_menubutton_order_(-1), |
| 127 sign_in_button_order_(-1) { | 127 sign_in_button_order_(-1) { |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 523 |
| 524 gfx::Rect NewUserView::GetUsernameBounds() const { | 524 gfx::Rect NewUserView::GetUsernameBounds() const { |
| 525 return username_field_->GetScreenBounds(); | 525 return username_field_->GetScreenBounds(); |
| 526 } | 526 } |
| 527 | 527 |
| 528 bool NewUserView::HandleKeyEvent(views::Textfield* sender, | 528 bool NewUserView::HandleKeyEvent(views::Textfield* sender, |
| 529 const views::KeyEvent& key_event) { | 529 const views::KeyEvent& key_event) { |
| 530 if (!CrosLibrary::Get()->EnsureLoaded() || login_in_process_) | 530 if (!CrosLibrary::Get()->EnsureLoaded() || login_in_process_) |
| 531 return false; | 531 return false; |
| 532 | 532 |
| 533 if (key_event.GetKeyCode() == app::VKEY_RETURN) { | 533 if (key_event.GetKeyCode() == ui::VKEY_RETURN) { |
| 534 if (!username_field_->text().empty() && !password_field_->text().empty()) | 534 if (!username_field_->text().empty() && !password_field_->text().empty()) |
| 535 Login(); | 535 Login(); |
| 536 // Return true so that processing ends | 536 // Return true so that processing ends |
| 537 return true; | 537 return true; |
| 538 } | 538 } |
| 539 delegate_->ClearErrors(); | 539 delegate_->ClearErrors(); |
| 540 // Return false so that processing does not end | 540 // Return false so that processing does not end |
| 541 return false; | 541 return false; |
| 542 } | 542 } |
| 543 | 543 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 571 | 571 |
| 572 void NewUserView::InitLink(views::Link** link) { | 572 void NewUserView::InitLink(views::Link** link) { |
| 573 *link = new views::Link(std::wstring()); | 573 *link = new views::Link(std::wstring()); |
| 574 (*link)->SetController(this); | 574 (*link)->SetController(this); |
| 575 (*link)->SetNormalColor(login::kLinkColor); | 575 (*link)->SetNormalColor(login::kLinkColor); |
| 576 (*link)->SetHighlightedColor(login::kLinkColor); | 576 (*link)->SetHighlightedColor(login::kLinkColor); |
| 577 AddChildView(*link); | 577 AddChildView(*link); |
| 578 } | 578 } |
| 579 | 579 |
| 580 } // namespace chromeos | 580 } // namespace chromeos |
| OLD | NEW |