| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 e// 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/screen_lock_view.h" | 5 #include "chrome/browser/chromeos/login/screen_lock_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/login/helper.h" | 10 #include "chrome/browser/chromeos/login/helper.h" |
| 11 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 11 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 main_(NULL), | 65 main_(NULL), |
| 66 username_(NULL) { | 66 username_(NULL) { |
| 67 DCHECK(screen_locker_); | 67 DCHECK(screen_locker_); |
| 68 } | 68 } |
| 69 | 69 |
| 70 gfx::Size ScreenLockView::GetPreferredSize() { | 70 gfx::Size ScreenLockView::GetPreferredSize() { |
| 71 return main_->GetPreferredSize(); | 71 return main_->GetPreferredSize(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void ScreenLockView::Layout() { | 74 void ScreenLockView::Layout() { |
| 75 int username_height = username_->GetPreferredSize().height(); | 75 int username_height = login::kSelectedLabelHeight; |
| 76 main_->SetBounds(0, 0, width(), height()); | 76 main_->SetBounds(0, 0, width(), height()); |
| 77 username_->SetBounds( | 77 username_->SetBounds( |
| 78 kBorderSize, | 78 kBorderSize, |
| 79 login::kUserImageSize - username_height + kBorderSize, | 79 login::kUserImageSize - username_height + kBorderSize, |
| 80 login::kUserImageSize, | 80 login::kUserImageSize, |
| 81 username_height); | 81 username_height); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void ScreenLockView::Init() { | 84 void ScreenLockView::Init() { |
| 85 registrar_.Add(this, | 85 registrar_.Add(this, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 104 password_field_->set_background(new CopyBackground(main_)); | 104 password_field_->set_background(new CopyBackground(main_)); |
| 105 | 105 |
| 106 // User icon. | 106 // User icon. |
| 107 UserManager::User user = screen_locker_->user(); | 107 UserManager::User user = screen_locker_->user(); |
| 108 user_view_->SetImage(user.image()); | 108 user_view_->SetImage(user.image()); |
| 109 | 109 |
| 110 // User name. | 110 // User name. |
| 111 std::wstring text = UTF8ToWide(user.GetDisplayName()); | 111 std::wstring text = UTF8ToWide(user.GetDisplayName()); |
| 112 | 112 |
| 113 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 113 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 114 const gfx::Font& font = | 114 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumBoldFont); |
| 115 rb.GetFont(ResourceBundle::LargeFont).DeriveFont(0, gfx::Font::BOLD); | |
| 116 | 115 |
| 117 // Layouts image, textfield and button components. | 116 // Layouts image, textfield and button components. |
| 118 GridLayout* layout = new GridLayout(main_); | 117 GridLayout* layout = new GridLayout(main_); |
| 119 main_->SetLayoutManager(layout); | 118 main_->SetLayoutManager(layout); |
| 120 views::ColumnSet* column_set = layout->AddColumnSet(0); | 119 views::ColumnSet* column_set = layout->AddColumnSet(0); |
| 121 column_set->AddPaddingColumn(0, kBorderSize); | 120 column_set->AddPaddingColumn(0, kBorderSize); |
| 122 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 121 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
| 123 GridLayout::USE_PREF, 0, 0); | 122 GridLayout::USE_PREF, 0, 0); |
| 124 column_set->AddPaddingColumn(0, kBorderSize); | 123 column_set->AddPaddingColumn(0, kBorderSize); |
| 125 | 124 |
| 126 column_set = layout->AddColumnSet(1); | 125 column_set = layout->AddColumnSet(1); |
| 127 column_set->AddPaddingColumn(0, 5); | 126 column_set->AddPaddingColumn(0, 5); |
| 128 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 127 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
| 129 GridLayout::USE_PREF, 0, 0); | 128 GridLayout::USE_PREF, 0, 0); |
| 130 column_set->AddPaddingColumn(0, 5); | 129 column_set->AddPaddingColumn(0, 5); |
| 131 | 130 |
| 132 layout->AddPaddingRow(0, kBorderSize); | 131 layout->AddPaddingRow(0, kBorderSize); |
| 133 layout->StartRow(0, 0); | 132 layout->StartRow(0, 0); |
| 134 layout->AddView(user_view_); | 133 layout->AddView(user_view_); |
| 135 layout->AddPaddingRow(0, kBorderSize); | 134 layout->AddPaddingRow(0, kBorderSize); |
| 136 layout->StartRow(0, 1); | 135 layout->StartRow(0, 1); |
| 137 layout->AddView(password_field_); | 136 layout->AddView(password_field_); |
| 138 layout->AddPaddingRow(0, kBorderSize); | 137 layout->AddPaddingRow(0, kBorderSize); |
| 139 | 138 |
| 140 AddChildView(main_); | 139 AddChildView(main_); |
| 141 | 140 |
| 142 UsernameView* username = new UsernameView(text); | 141 UsernameView* username = new UsernameView(text); |
| 143 username_ = username; | 142 username_ = username; |
| 143 username->SetColor(login::kTextColor); |
| 144 username->SetFont(font); | 144 username->SetFont(font); |
| 145 AddChildView(username); | 145 AddChildView(username); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void ScreenLockView::ClearAndSetFocusToPassword() { | 148 void ScreenLockView::ClearAndSetFocusToPassword() { |
| 149 password_field_->RequestFocus(); | 149 password_field_->RequestFocus(); |
| 150 password_field_->SetText(string16()); | 150 password_field_->SetText(string16()); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void ScreenLockView::SetSignoutEnabled(bool enabled) { | 153 void ScreenLockView::SetSignoutEnabled(bool enabled) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 user_view_->SetImage(user->image()); | 207 user_view_->SetImage(user->image()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void ScreenLockView::ViewHierarchyChanged(bool is_add, | 210 void ScreenLockView::ViewHierarchyChanged(bool is_add, |
| 211 views::View* parent, | 211 views::View* parent, |
| 212 views::View* child) { | 212 views::View* child) { |
| 213 if (is_add && this == child) | 213 if (is_add && this == child) |
| 214 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this); | 214 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this); |
| 215 } | 215 } |
| 216 } // namespace chromeos | 216 } // namespace chromeos |
| OLD | NEW |