| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 24 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 25 #include "chrome/browser/chromeos/views/copy_background.h" | 25 #include "chrome/browser/chromeos/views/copy_background.h" |
| 26 #include "chrome/browser/prefs/pref_service.h" | 26 #include "chrome/browser/prefs/pref_service.h" |
| 27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 28 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 30 #include "grit/ui_resources.h" | 30 #include "grit/ui_resources.h" |
| 31 #include "ui/base/keycodes/keyboard_codes.h" | 31 #include "ui/base/keycodes/keyboard_codes.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/gfx/color_utils.h" |
| 34 #include "ui/gfx/font.h" | 35 #include "ui/gfx/font.h" |
| 35 #include "views/controls/button/menu_button.h" | 36 #include "views/controls/button/menu_button.h" |
| 36 #include "views/controls/button/text_button.h" | 37 #include "views/controls/button/text_button.h" |
| 37 #include "views/controls/label.h" | 38 #include "views/controls/label.h" |
| 38 #include "views/controls/link.h" | 39 #include "views/controls/link.h" |
| 39 #include "views/controls/textfield/textfield.h" | 40 #include "views/controls/textfield/textfield.h" |
| 40 #include "views/controls/throbber.h" | 41 #include "views/controls/throbber.h" |
| 41 | 42 |
| 42 using views::View; | 43 using views::View; |
| 43 | 44 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 need_create_account_ = true; | 135 need_create_account_ = true; |
| 135 if (need_guest_link) | 136 if (need_guest_link) |
| 136 need_guest_link_ = true; | 137 need_guest_link_ = true; |
| 137 } | 138 } |
| 138 } | 139 } |
| 139 | 140 |
| 140 NewUserView::~NewUserView() { | 141 NewUserView::~NewUserView() { |
| 141 } | 142 } |
| 142 | 143 |
| 143 void NewUserView::Init() { | 144 void NewUserView::Init() { |
| 144 if (need_border_) { | |
| 145 // Use rounded rect background. | |
| 146 set_border(CreateWizardBorder(&BorderDefinition::kUserBorder)); | |
| 147 views::Painter* painter = CreateWizardPainter( | |
| 148 &BorderDefinition::kUserBorder); | |
| 149 set_background(views::Background::CreateBackgroundPainter(true, painter)); | |
| 150 } | |
| 151 | |
| 152 title_label_ = new views::Label(); | 145 title_label_ = new views::Label(); |
| 153 title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 146 title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 154 title_label_->SetMultiLine(true); | 147 title_label_->SetMultiLine(true); |
| 155 AddChildView(title_label_); | 148 AddChildView(title_label_); |
| 156 | 149 |
| 157 title_hint_label_ = new views::Label(); | 150 title_hint_label_ = new views::Label(); |
| 158 title_hint_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 151 title_hint_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 159 title_hint_label_->SetColor(SK_ColorGRAY); | 152 title_hint_label_->SetEnabledColor(SK_ColorGRAY); |
| 160 title_hint_label_->SetMultiLine(true); | 153 title_hint_label_->SetMultiLine(true); |
| 161 AddChildView(title_hint_label_); | 154 AddChildView(title_hint_label_); |
| 162 | 155 |
| 163 splitter_up1_ = CreateSplitter(kSplitterUp1Color); | 156 splitter_up1_ = CreateSplitter(kSplitterUp1Color); |
| 164 splitter_up2_ = CreateSplitter(kSplitterUp2Color); | 157 splitter_up2_ = CreateSplitter(kSplitterUp2Color); |
| 165 splitter_down1_ = CreateSplitter(kSplitterDown1Color); | 158 splitter_down1_ = CreateSplitter(kSplitterDown1Color); |
| 166 splitter_down2_ = CreateSplitter(kSplitterDown2Color); | 159 splitter_down2_ = CreateSplitter(kSplitterDown2Color); |
| 167 | 160 |
| 168 username_field_ = new UsernameField(this); | 161 username_field_ = new UsernameField(this); |
| 169 username_field_->set_background(new CopyBackground(this)); | 162 username_field_->set_background(new CopyBackground(this)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 181 | 174 |
| 182 AddChildView(sign_in_button_); | 175 AddChildView(sign_in_button_); |
| 183 if (need_guest_link_) { | 176 if (need_guest_link_) { |
| 184 InitLink(&guest_link_); | 177 InitLink(&guest_link_); |
| 185 } | 178 } |
| 186 if (need_create_account_) { | 179 if (need_create_account_) { |
| 187 InitLink(&create_account_link_); | 180 InitLink(&create_account_link_); |
| 188 } | 181 } |
| 189 AddChildView(languages_menubutton_); | 182 AddChildView(languages_menubutton_); |
| 190 | 183 |
| 184 if (need_border_) { |
| 185 // Use rounded rect background. |
| 186 set_border(CreateWizardBorder(&BorderDefinition::kUserBorder)); |
| 187 views::Painter* painter = CreateWizardPainter( |
| 188 &BorderDefinition::kUserBorder); |
| 189 set_background(views::Background::CreateBackgroundPainter(true, painter)); |
| 190 SkColor background_color = color_utils::AlphaBlend( |
| 191 BorderDefinition::kUserBorder.top_color, |
| 192 BorderDefinition::kUserBorder.bottom_color, 128); |
| 193 title_label_->SetBackgroundColor(background_color); |
| 194 title_hint_label_->SetBackgroundColor(background_color); |
| 195 if (guest_link_) |
| 196 guest_link_->SetBackgroundColor(background_color); |
| 197 if (create_account_link_) |
| 198 guest_link_->SetBackgroundColor(background_color); |
| 199 } else { |
| 200 // In theory, we should actually set the real background color for all the |
| 201 // labels and links whether or not |need_border_| is set, but since without |
| 202 // it the background color is non-obvious, just disable auto color |
| 203 // readability. |
| 204 title_label_->SetAutoColorReadabilityEnabled(false); |
| 205 title_hint_label_->SetAutoColorReadabilityEnabled(false); |
| 206 if (guest_link_) |
| 207 guest_link_->SetAutoColorReadabilityEnabled(false); |
| 208 if (create_account_link_) |
| 209 create_account_link_->SetAutoColorReadabilityEnabled(false); |
| 210 } |
| 211 |
| 191 // Set up accelerators. | 212 // Set up accelerators. |
| 192 AddAccelerator(accel_focus_user_); | 213 AddAccelerator(accel_focus_user_); |
| 193 AddAccelerator(accel_focus_pass_); | 214 AddAccelerator(accel_focus_pass_); |
| 194 AddAccelerator(accel_enterprise_enrollment_); | 215 AddAccelerator(accel_enterprise_enrollment_); |
| 195 AddAccelerator(accel_login_off_the_record_); | 216 AddAccelerator(accel_login_off_the_record_); |
| 196 AddAccelerator(accel_toggle_accessibility_); | 217 AddAccelerator(accel_toggle_accessibility_); |
| 197 | 218 |
| 198 OnLocaleChanged(); | 219 OnLocaleChanged(); |
| 199 | 220 |
| 200 // Controller to handle events from textfields | 221 // Controller to handle events from textfields |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 if (need_guest_link_) { | 574 if (need_guest_link_) { |
| 554 guest_link_->SetEnabled(enabled); | 575 guest_link_->SetEnabled(enabled); |
| 555 } | 576 } |
| 556 if (need_create_account_) { | 577 if (need_create_account_) { |
| 557 create_account_link_->SetEnabled(enabled); | 578 create_account_link_->SetEnabled(enabled); |
| 558 } | 579 } |
| 559 UpdateSignInButtonState(); | 580 UpdateSignInButtonState(); |
| 560 } | 581 } |
| 561 | 582 |
| 562 bool NewUserView::NavigateAway() { | 583 bool NewUserView::NavigateAway() { |
| 563 if (username_field_->text().empty() && | 584 if (!username_field_->text().empty() || |
| 564 password_field_->text().empty()) { | 585 !password_field_->text().empty()) |
| 565 delegate_->NavigateAway(); | |
| 566 return true; | |
| 567 } else { | |
| 568 return false; | 586 return false; |
| 569 } | 587 delegate_->NavigateAway(); |
| 588 return true; |
| 570 } | 589 } |
| 571 | 590 |
| 572 void NewUserView::InitLink(views::Link** link) { | 591 void NewUserView::InitLink(views::Link** link) { |
| 573 *link = new views::Link(string16()); | 592 *link = new views::Link(string16()); |
| 574 (*link)->set_listener(this); | 593 (*link)->set_listener(this); |
| 575 (*link)->SetNormalColor(login::kLinkColor); | 594 (*link)->SetEnabledColor(login::kLinkColor); |
| 576 (*link)->SetHighlightedColor(login::kLinkColor); | 595 (*link)->SetPressedColor(login::kLinkColor); |
| 577 AddChildView(*link); | 596 AddChildView(*link); |
| 578 } | 597 } |
| 579 | 598 |
| 580 } // namespace chromeos | 599 } // namespace chromeos |
| OLD | NEW |