Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/chromeos/login/screen_lock_view.cc

Issue 5709001: Place the spinner in the right corner of the controls window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos/login
Patch Set: cpplist + remove debug Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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"
11 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" 10 #include "chrome/browser/chromeos/login/rounded_rect_painter.h"
12 #include "chrome/browser/chromeos/login/screen_locker.h" 11 #include "chrome/browser/chromeos/login/screen_locker.h"
13 #include "chrome/browser/chromeos/login/user_manager.h" 12 #include "chrome/browser/chromeos/login/user_manager.h"
14 #include "chrome/browser/chromeos/login/user_view.h" 13 #include "chrome/browser/chromeos/login/user_view.h"
15 #include "chrome/browser/chromeos/login/username_view.h" 14 #include "chrome/browser/chromeos/login/username_view.h"
16 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" 15 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h"
17 #include "chrome/browser/chromeos/login/textfield_with_margin.h" 16 #include "chrome/browser/chromeos/login/textfield_with_margin.h"
18 #include "chrome/browser/chromeos/views/copy_background.h" 17 #include "chrome/browser/chromeos/views/copy_background.h"
19 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/common/notification_service.h" 19 #include "chrome/common/notification_service.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 private: 51 private:
53 DISALLOW_COPY_AND_ASSIGN(PasswordField); 52 DISALLOW_COPY_AND_ASSIGN(PasswordField);
54 }; 53 };
55 54
56 } // namespace 55 } // namespace
57 56
58 using views::GridLayout; 57 using views::GridLayout;
59 using login::kBorderSize; 58 using login::kBorderSize;
60 59
61 ScreenLockView::ScreenLockView(ScreenLocker* screen_locker) 60 ScreenLockView::ScreenLockView(ScreenLocker* screen_locker)
62 : user_view_(NULL), 61 : ThrobberHost(this),
62 user_view_(NULL),
63 password_field_(NULL), 63 password_field_(NULL),
64 screen_locker_(screen_locker), 64 screen_locker_(screen_locker),
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 ScreenLockView::~ScreenLockView() {
71 }
72
70 gfx::Size ScreenLockView::GetPreferredSize() { 73 gfx::Size ScreenLockView::GetPreferredSize() {
71 return main_->GetPreferredSize(); 74 return main_->GetPreferredSize();
72 } 75 }
73 76
74 void ScreenLockView::Layout() { 77 void ScreenLockView::Layout() {
75 int username_height = login::kSelectedLabelHeight; 78 int username_height = login::kSelectedLabelHeight;
76 main_->SetBounds(0, 0, width(), height()); 79 main_->SetBounds(0, 0, width(), height());
77 username_->SetBounds( 80 username_->SetBounds(
78 kBorderSize, 81 kBorderSize,
79 login::kUserImageSize - username_height + kBorderSize, 82 login::kUserImageSize - username_height + kBorderSize,
(...skipping 13 matching lines...) Expand all
93 // Use rounded rect background. 96 // Use rounded rect background.
94 views::Painter* painter = 97 views::Painter* painter =
95 CreateWizardPainter(&BorderDefinition::kUserBorder); 98 CreateWizardPainter(&BorderDefinition::kUserBorder);
96 99
97 main_->set_background( 100 main_->set_background(
98 views::Background::CreateBackgroundPainter(true, painter)); 101 views::Background::CreateBackgroundPainter(true, painter));
99 main_->set_border(CreateWizardBorder(&BorderDefinition::kUserBorder)); 102 main_->set_border(CreateWizardBorder(&BorderDefinition::kUserBorder));
100 103
101 // Password field. 104 // Password field.
102 password_field_ = new PasswordField(); 105 password_field_ = new PasswordField();
106
103 password_field_->SetController(this); 107 password_field_->SetController(this);
104 password_field_->set_background(new CopyBackground(main_)); 108 password_field_->set_background(new CopyBackground(main_));
105 109
110 // Setup ThrobberView's host view.
111 set_host_view(password_field_);
112
106 // User icon. 113 // User icon.
107 UserManager::User user = screen_locker_->user(); 114 UserManager::User user = screen_locker_->user();
108 user_view_->SetImage(user.image(), user.image()); 115 user_view_->SetImage(user.image(), user.image());
109 116
110 // User name. 117 // User name.
111 std::wstring text = UTF8ToWide(user.GetDisplayName()); 118 std::wstring text = UTF8ToWide(user.GetDisplayName());
112 119
113 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 120 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
114 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumBoldFont); 121 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumBoldFont);
115 122
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void ScreenLockView::SetSignoutEnabled(bool enabled) { 160 void ScreenLockView::SetSignoutEnabled(bool enabled) {
154 user_view_->SetSignoutEnabled(enabled); 161 user_view_->SetSignoutEnabled(enabled);
155 } 162 }
156 163
157 gfx::Rect ScreenLockView::GetPasswordBoundsRelativeTo(const views::View* view) { 164 gfx::Rect ScreenLockView::GetPasswordBoundsRelativeTo(const views::View* view) {
158 gfx::Point p; 165 gfx::Point p;
159 views::View::ConvertPointToView(password_field_, view, &p); 166 views::View::ConvertPointToView(password_field_, view, &p);
160 return gfx::Rect(p, size()); 167 return gfx::Rect(p, size());
161 } 168 }
162 169
170
163 void ScreenLockView::SetEnabled(bool enabled) { 171 void ScreenLockView::SetEnabled(bool enabled) {
164 views::View::SetEnabled(enabled); 172 views::View::SetEnabled(enabled);
165 173
166 if (!enabled) { 174 if (!enabled) {
167 user_view_->StartThrobber();
168 // TODO(oshima): Re-enabling does not move the focus to the view 175 // TODO(oshima): Re-enabling does not move the focus to the view
169 // that had a focus (issue http://crbug.com/43131). 176 // that had a focus (issue http://crbug.com/43131).
170 // Clear focus on the textfield so that re-enabling can set focus 177 // Clear focus on the textfield so that re-enabling can set focus
171 // back to the text field. 178 // back to the text field.
172 // FocusManager may be null if the view does not have 179 // FocusManager may be null if the view does not have
173 // associated Widget yet. 180 // associated Widget yet.
174 if (password_field_->GetFocusManager()) 181 if (password_field_->GetFocusManager())
175 password_field_->GetFocusManager()->ClearFocus(); 182 password_field_->GetFocusManager()->ClearFocus();
176 } else {
177 user_view_->StopThrobber();
178 } 183 }
179 password_field_->SetEnabled(enabled); 184 password_field_->SetEnabled(enabled);
180 } 185 }
181 186
182 void ScreenLockView::OnSignout() { 187 void ScreenLockView::OnSignout() {
183 screen_locker_->Signout(); 188 screen_locker_->Signout();
184 } 189 }
185 190
186 bool ScreenLockView::HandleKeystroke( 191 bool ScreenLockView::HandleKeystroke(
187 views::Textfield* sender, 192 views::Textfield* sender,
(...skipping 18 matching lines...) Expand all
206 return; 211 return;
207 user_view_->SetImage(user->image(), user->image()); 212 user_view_->SetImage(user->image(), user->image());
208 } 213 }
209 214
210 void ScreenLockView::ViewHierarchyChanged(bool is_add, 215 void ScreenLockView::ViewHierarchyChanged(bool is_add,
211 views::View* parent, 216 views::View* parent,
212 views::View* child) { 217 views::View* child) {
213 if (is_add && this == child) 218 if (is_add && this == child)
214 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this); 219 WizardAccessibilityHelper::GetInstance()->MaybeEnableAccessibility(this);
215 } 220 }
221
216 } // namespace chromeos 222 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698