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

Side by Side Diff: ash/system/user/tray_user.cc

Issue 14756019: Adding new user menu section to the SystemTrayMenu & refactoring of user access (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 7 years, 7 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/system/user/tray_user.h" 5 #include "ash/system/user/tray_user.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <climits> 8 #include <climits>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/session_state_delegate.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/shell_delegate.h" 13 #include "ash/shell_delegate.h"
13 #include "ash/system/tray/system_tray.h" 14 #include "ash/system/tray/system_tray.h"
14 #include "ash/system/tray/system_tray_delegate.h" 15 #include "ash/system/tray/system_tray_delegate.h"
15 #include "ash/system/tray/system_tray_notifier.h" 16 #include "ash/system/tray/system_tray_notifier.h"
16 #include "ash/system/tray/tray_constants.h" 17 #include "ash/system/tray/tray_constants.h"
17 #include "ash/system/tray/tray_item_view.h" 18 #include "ash/system/tray/tray_item_view.h"
18 #include "ash/system/tray/tray_popup_label_button.h" 19 #include "ash/system/tray/tray_popup_label_button.h"
19 #include "ash/system/tray/tray_popup_label_button_border.h" 20 #include "ash/system/tray/tray_popup_label_button_border.h"
20 #include "ash/system/tray/tray_utils.h" 21 #include "ash/system/tray/tray_utils.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "ui/views/layout/box_layout.h" 55 #include "ui/views/layout/box_layout.h"
55 #include "ui/views/layout/fill_layout.h" 56 #include "ui/views/layout/fill_layout.h"
56 #include "ui/views/painter.h" 57 #include "ui/views/painter.h"
57 #include "ui/views/view.h" 58 #include "ui/views/view.h"
58 #include "ui/views/widget/widget.h" 59 #include "ui/views/widget/widget.h"
59 60
60 namespace { 61 namespace {
61 62
62 const int kUserDetailsVerticalPadding = 5; 63 const int kUserDetailsVerticalPadding = 5;
63 const int kUserCardVerticalPadding = 10; 64 const int kUserCardVerticalPadding = 10;
65 const int kInactiveUserCardVerticalPadding = 4;
64 const int kProfileRoundedCornerRadius = 2; 66 const int kProfileRoundedCornerRadius = 2;
65 const int kUserIconSize = 27; 67 const int kUserIconSize = 27;
66 const int kUserLabelToIconPadding = 5; 68 const int kUserLabelToIconPadding = 5;
67 69
70 // When a hover border is used, it is starting this many pixels before the icon
71 // position.
72 const int kTrayUserTileHoverBorderInset = 10;
73 // The border color of the user button.
Nikita (slow) 2013/05/17 17:00:32 nit: Insert empty line.
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Done.
74 const SkColor kBorderColor = 0xffdcdcdc;
75
68 // The invisible word joiner character, used as a marker to indicate the start 76 // The invisible word joiner character, used as a marker to indicate the start
69 // and end of the user's display name in the public account user card's text. 77 // and end of the user's display name in the public account user card's text.
70 const char16 kDisplayNameMark[] = { 0x2060, 0 }; 78 const char16 kDisplayNameMark[] = { 0x2060, 0 };
71 79
72 const int kPublicAccountLogoutButtonBorderImagesNormal[] = { 80 const int kPublicAccountLogoutButtonBorderImagesNormal[] = {
73 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, 81 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER,
74 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, 82 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND,
75 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, 83 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND,
76 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, 84 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER,
77 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, 85 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND,
(...skipping 19 matching lines...) Expand all
97 105
98 namespace ash { 106 namespace ash {
99 namespace internal { 107 namespace internal {
100 108
101 namespace tray { 109 namespace tray {
102 110
103 // A custom image view with rounded edges. 111 // A custom image view with rounded edges.
104 class RoundedImageView : public views::View { 112 class RoundedImageView : public views::View {
105 public: 113 public:
106 // Constructs a new rounded image view with rounded corners of radius 114 // Constructs a new rounded image view with rounded corners of radius
107 // |corner_radius|. 115 // |corner_radius|. If |active_user| is set, the icon will be drawn in
108 explicit RoundedImageView(int corner_radius); 116 // full colors - otherwise it will fade into the background.
117 RoundedImageView(int corner_radius, bool active_user);
109 virtual ~RoundedImageView(); 118 virtual ~RoundedImageView();
110 119
111 // Set the image that should be displayed. The image contents is copied to the 120 // Set the image that should be displayed. The image contents is copied to the
112 // receiver's image. 121 // receiver's image.
113 void SetImage(const gfx::ImageSkia& img, const gfx::Size& size); 122 void SetImage(const gfx::ImageSkia& img, const gfx::Size& size);
114 123
115 private: 124 private:
116 // Overridden from views::View. 125 // Overridden from views::View.
117 virtual gfx::Size GetPreferredSize() OVERRIDE; 126 virtual gfx::Size GetPreferredSize() OVERRIDE;
118 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 127 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
119 128
120 gfx::ImageSkia image_; 129 gfx::ImageSkia image_;
121 gfx::ImageSkia resized_; 130 gfx::ImageSkia resized_;
122 gfx::Size image_size_; 131 gfx::Size image_size_;
123 int corner_radius_; 132 int corner_radius_;
124 133
134 // True if the given user is the active user and the icon should get
135 // painted as active.
136 bool active_user_;
137
125 DISALLOW_COPY_AND_ASSIGN(RoundedImageView); 138 DISALLOW_COPY_AND_ASSIGN(RoundedImageView);
126 }; 139 };
127 140
128 class ClickableAvatar : public views::CustomButton {
129 public:
130 explicit ClickableAvatar(views::ButtonListener* listener);
131 virtual ~ClickableAvatar();
132
133 private:
134 DISALLOW_COPY_AND_ASSIGN(ClickableAvatar);
135 };
136
137 // The user details shown in public account mode. This is essentially a label 141 // The user details shown in public account mode. This is essentially a label
138 // but with custom painting code as the text is styled with multiple colors and 142 // but with custom painting code as the text is styled with multiple colors and
139 // contains a link. 143 // contains a link.
140 class PublicAccountUserDetails : public views::View, 144 class PublicAccountUserDetails : public views::View,
141 public views::LinkListener { 145 public views::LinkListener {
142 public: 146 public:
143 PublicAccountUserDetails(SystemTrayItem* owner, int used_width); 147 PublicAccountUserDetails(SystemTrayItem* owner, int used_width);
144 virtual ~PublicAccountUserDetails(); 148 virtual ~PublicAccountUserDetails();
145 149
146 private: 150 private:
(...skipping 11 matching lines...) Expand all
158 void CalculatePreferredSize(SystemTrayItem* owner, int used_width); 162 void CalculatePreferredSize(SystemTrayItem* owner, int used_width);
159 163
160 base::string16 text_; 164 base::string16 text_;
161 views::Link* learn_more_; 165 views::Link* learn_more_;
162 gfx::Size preferred_size_; 166 gfx::Size preferred_size_;
163 ScopedVector<gfx::RenderText> lines_; 167 ScopedVector<gfx::RenderText> lines_;
164 168
165 DISALLOW_COPY_AND_ASSIGN(PublicAccountUserDetails); 169 DISALLOW_COPY_AND_ASSIGN(PublicAccountUserDetails);
166 }; 170 };
167 171
172 // The button which holds the user card in case of multi profile.
173 class UserCard : public views::CustomButton {
174 public:
175 UserCard(views::ButtonListener* listener, bool active_user);
176 virtual ~UserCard();
177
178 // Overridden from views::View
179 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
180 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
181
182 private:
183 void ShowActive(bool active);
Nikita (slow) 2013/05/17 17:00:32 nit: Comment?
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Done.
184
185 // True if this is the active user.
186 bool is_active_user_;
187 DISALLOW_COPY_AND_ASSIGN(UserCard);
188 };
189
168 class UserView : public views::View, 190 class UserView : public views::View,
169 public views::ButtonListener { 191 public views::ButtonListener {
170 public: 192 public:
171 explicit UserView(SystemTrayItem* owner, ash::user::LoginStatus login); 193 UserView(SystemTrayItem* owner,
194 ash::user::LoginStatus login,
195 MultiProfileIndex index);
172 virtual ~UserView(); 196 virtual ~UserView();
173 197
174 private: 198 private:
175 // Overridden from views::View. 199 // Overridden from views::View.
176 virtual gfx::Size GetPreferredSize() OVERRIDE; 200 virtual gfx::Size GetPreferredSize() OVERRIDE;
177 virtual int GetHeightForWidth(int width) OVERRIDE; 201 virtual int GetHeightForWidth(int width) OVERRIDE;
178 virtual void Layout() OVERRIDE; 202 virtual void Layout() OVERRIDE;
179 203
180 // Overridden from views::ButtonListener. 204 // Overridden from views::ButtonListener.
181 virtual void ButtonPressed(views::Button* sender, 205 virtual void ButtonPressed(views::Button* sender,
182 const ui::Event& event) OVERRIDE; 206 const ui::Event& event) OVERRIDE;
183 207
184 void AddLogoutButton(ash::user::LoginStatus login); 208 void AddLogoutButton(ash::user::LoginStatus login);
185 void AddUserCard(SystemTrayItem* owner, ash::user::LoginStatus login); 209 void AddUserCard(SystemTrayItem* owner, ash::user::LoginStatus login);
186 210
211 MultiProfileIndex multiprofile_index_;
187 views::View* user_card_; 212 views::View* user_card_;
188 views::View* logout_button_; 213 views::View* logout_button_;
189 ClickableAvatar* profile_picture_;
190 214
191 DISALLOW_COPY_AND_ASSIGN(UserView); 215 DISALLOW_COPY_AND_ASSIGN(UserView);
192 }; 216 };
193 217
194 RoundedImageView::RoundedImageView(int corner_radius) 218 RoundedImageView::RoundedImageView(int corner_radius, bool active_user)
195 : corner_radius_(corner_radius) {} 219 : corner_radius_(corner_radius),
220 active_user_(active_user) {}
196 221
197 RoundedImageView::~RoundedImageView() {} 222 RoundedImageView::~RoundedImageView() {}
198 223
199 void RoundedImageView::SetImage(const gfx::ImageSkia& img, 224 void RoundedImageView::SetImage(const gfx::ImageSkia& img,
200 const gfx::Size& size) { 225 const gfx::Size& size) {
201 image_ = img; 226 image_ = img;
202 image_size_ = size; 227 image_size_ = size;
203 228
204 // Try to get the best image quality for the avatar. 229 // Try to get the best image quality for the avatar.
205 resized_ = gfx::ImageSkiaOperations::CreateResizedImage(image_, 230 resized_ = gfx::ImageSkiaOperations::CreateResizedImage(image_,
(...skipping 12 matching lines...) Expand all
218 void RoundedImageView::OnPaint(gfx::Canvas* canvas) { 243 void RoundedImageView::OnPaint(gfx::Canvas* canvas) {
219 View::OnPaint(canvas); 244 View::OnPaint(canvas);
220 gfx::Rect image_bounds(size()); 245 gfx::Rect image_bounds(size());
221 image_bounds.ClampToCenteredSize(GetPreferredSize()); 246 image_bounds.ClampToCenteredSize(GetPreferredSize());
222 image_bounds.Inset(GetInsets()); 247 image_bounds.Inset(GetInsets());
223 const SkScalar kRadius = SkIntToScalar(corner_radius_); 248 const SkScalar kRadius = SkIntToScalar(corner_radius_);
224 SkPath path; 249 SkPath path;
225 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius, kRadius); 250 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius, kRadius);
226 SkPaint paint; 251 SkPaint paint;
227 paint.setAntiAlias(true); 252 paint.setAntiAlias(true);
228 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 253 paint.setXfermodeMode(active_user_ ? SkXfermode::kSrcOver_Mode :
254 SkXfermode::kLuminosity_Mode);
229 canvas->DrawImageInPath(resized_, image_bounds.x(), image_bounds.y(), 255 canvas->DrawImageInPath(resized_, image_bounds.x(), image_bounds.y(),
230 path, paint); 256 path, paint);
231 } 257 }
232 258
233 ClickableAvatar::ClickableAvatar(views::ButtonListener* listener)
234 : views::CustomButton(listener) {
235 SetLayoutManager(new views::FillLayout());
236 RoundedImageView* user_picture =
237 new RoundedImageView(kProfileRoundedCornerRadius);
238 user_picture->SetImage(
239 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(),
240 gfx::Size(kUserIconSize, kUserIconSize));
241 AddChildView(user_picture);
242 }
243
244 ClickableAvatar::~ClickableAvatar() {}
245
246 PublicAccountUserDetails::PublicAccountUserDetails(SystemTrayItem* owner, 259 PublicAccountUserDetails::PublicAccountUserDetails(SystemTrayItem* owner,
247 int used_width) 260 int used_width)
248 : learn_more_(NULL) { 261 : learn_more_(NULL) {
249 const int inner_padding = 262 const int inner_padding =
250 kTrayPopupPaddingHorizontal - kTrayPopupPaddingBetweenItems; 263 kTrayPopupPaddingHorizontal - kTrayPopupPaddingBetweenItems;
251 const bool rtl = base::i18n::IsRTL(); 264 const bool rtl = base::i18n::IsRTL();
252 set_border(views::Border::CreateEmptyBorder( 265 set_border(views::Border::CreateEmptyBorder(
253 kUserDetailsVerticalPadding, rtl ? 0 : inner_padding, 266 kUserDetailsVerticalPadding, rtl ? 0 : inner_padding,
254 kUserDetailsVerticalPadding, rtl ? inner_padding : 0)); 267 kUserDetailsVerticalPadding, rtl ? inner_padding : 0));
255 268
256 ash::SystemTrayDelegate* delegate =
257 ash::Shell::GetInstance()->system_tray_delegate();
258 // Retrieve the user's display name and wrap it with markers. 269 // Retrieve the user's display name and wrap it with markers.
259 base::string16 display_name = delegate->GetUserDisplayName(); 270 // Note that since this is a public account it always has to be the primary
271 // user.
272 base::string16 display_name =
273 ash::Shell::GetInstance()->session_state_delegate()->GetUserDisplayName(
274 0);
Nikita (slow) 2013/05/17 17:00:32 nit: Please move method name to this line.
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 This was never asked for before. Done.
260 RemoveChars(display_name, kDisplayNameMark, &display_name); 275 RemoveChars(display_name, kDisplayNameMark, &display_name);
261 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; 276 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0];
262 // Retrieve the domain managing the device and wrap it with markers. 277 // Retrieve the domain managing the device and wrap it with markers.
263 base::string16 domain = UTF8ToUTF16(delegate->GetEnterpriseDomain()); 278 base::string16 domain = UTF8ToUTF16(
279 ash::Shell::GetInstance()->system_tray_delegate()->GetEnterpriseDomain());
264 RemoveChars(domain, kDisplayNameMark, &domain); 280 RemoveChars(domain, kDisplayNameMark, &domain);
265 base::i18n::WrapStringWithLTRFormatting(&domain); 281 base::i18n::WrapStringWithLTRFormatting(&domain);
266 // Retrieve the label text, inserting the display name and domain. 282 // Retrieve the label text, inserting the display name and domain.
267 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, 283 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL,
268 display_name, domain); 284 display_name, domain);
269 285
270 learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_ASH_LEARN_MORE)); 286 learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_ASH_LEARN_MORE));
271 learn_more_->SetUnderline(false); 287 learn_more_->SetUnderline(false);
272 learn_more_->set_listener(this); 288 learn_more_->set_listener(this);
273 AddChildView(learn_more_); 289 AddChildView(learn_more_);
274 290
275 CalculatePreferredSize(owner, used_width); 291 CalculatePreferredSize(owner, used_width);
276 } 292 }
277 293
278 PublicAccountUserDetails::~PublicAccountUserDetails() {} 294 PublicAccountUserDetails::~PublicAccountUserDetails() {}
279 295
280 void PublicAccountUserDetails::Layout() { 296 void PublicAccountUserDetails::Layout() {
281 lines_.clear(); 297 lines_.clear();
282 const gfx::Rect contents_area = GetContentsBounds(); 298 const gfx::Rect contents_area = GetContentsBounds();
283 if (contents_area.IsEmpty()) 299 if (contents_area.IsEmpty())
284 return; 300 return;
285 301
286 // Word-wrap the label text. 302 // Word-wrap the label text.
287 const gfx::Font font; 303 const gfx::Font font;
288 std::vector<base::string16> lines; 304 std::vector<base::string16> lines;
289 ui::ElideRectangleText(text_, font, contents_area.width(), 305 ui::ElideRectangleText(text_, font, contents_area.width(),
290 contents_area.height(), ui::ELIDE_LONG_WORDS, &lines); 306 contents_area.height(), ui::ELIDE_LONG_WORDS, &lines);
291 // Loop through the lines, creating a renderer for each. 307 // Loop through the lines, creating a renderer for each.
292 gfx::Point position = contents_area.origin(); 308 gfx::Point position = contents_area.origin();
293 ui::Range display_name(ui::Range::InvalidRange()); 309 ui::Range display_name(ui::Range::InvalidRange());
294 for (std::vector<base::string16>::const_iterator it = lines.begin(); 310 for (std::vector<base::string16>::const_iterator it = lines.begin();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 const int line_height = font.GetHeight(); 426 const int line_height = font.GetHeight();
411 const int link_extra_height = std::max( 427 const int link_extra_height = std::max(
412 link_size.height() - learn_more_->GetInsets().top() - line_height, 0); 428 link_size.height() - learn_more_->GetInsets().top() - line_height, 0);
413 preferred_size_ = gfx::Size( 429 preferred_size_ = gfx::Size(
414 min_width + insets.width(), 430 min_width + insets.width(),
415 line_count * line_height + link_extra_height + insets.height()); 431 line_count * line_height + link_extra_height + insets.height());
416 432
417 bubble_view->SetWidth(preferred_size_.width() + used_width); 433 bubble_view->SetWidth(preferred_size_.width() + used_width);
418 } 434 }
419 435
420 UserView::UserView(SystemTrayItem* owner, ash::user::LoginStatus login) 436 UserCard::UserCard(views::ButtonListener* listener, bool active_user)
421 : user_card_(NULL), 437 : CustomButton(listener),
422 logout_button_(NULL), 438 is_active_user_(active_user) {
423 profile_picture_(NULL) { 439 if (is_active_user_) {
440 set_background(
441 views::Background::CreateSolidBackground(kBackgroundColor));
442 ShowActive(false);
443 }
444 }
445
446 UserCard::~UserCard() {}
447
448 void UserCard::OnMouseEntered(const ui::MouseEvent& event) OVERRIDE {
449 if (is_active_user_) {
450 background()->SetNativeControlColor(kHoverBackgroundColor);
451 ShowActive(true);
452 SchedulePaint();
453 }
454 }
455
456 void UserCard::OnMouseExited(const ui::MouseEvent& event) OVERRIDE {
457 if (is_active_user_) {
458 background()->SetNativeControlColor(kBackgroundColor);
459 ShowActive(false);
460 SchedulePaint();
461 }
462 }
463
464 void UserCard::ShowActive(bool active) {
465 int width = active ? 1 : 0;
466 set_border(views::Border::CreateSolidSidedBorder(width, width, width, 1,
467 kBorderColor));
468 }
469
470 UserView::UserView(SystemTrayItem* owner,
471 ash::user::LoginStatus login,
472 MultiProfileIndex index)
473 : multiprofile_index_(index),
474 user_card_(NULL),
475 logout_button_(NULL) {
424 CHECK_NE(ash::user::LOGGED_IN_NONE, login); 476 CHECK_NE(ash::user::LOGGED_IN_NONE, login);
425 set_background(views::Background::CreateSolidBackground( 477 if (!index) {
426 login == ash::user::LOGGED_IN_PUBLIC ? kPublicAccountBackgroundColor : 478 // Only the logged in user will have a background. All other users will have
427 kBackgroundColor)); 479 // have none to allow the TrayPopupContainer to highlight the menu line.
Nikita (slow) 2013/05/17 17:00:32 nit: drop second "have"
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Done.
480 set_background(views::Background::CreateSolidBackground(
481 login == ash::user::LOGGED_IN_PUBLIC ? kPublicAccountBackgroundColor :
482 kBackgroundColor));
483 }
428 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 484 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
429 kTrayPopupPaddingBetweenItems)); 485 kTrayPopupPaddingBetweenItems));
430 // The logout button must be added before the user card so that the user card 486 // The logout button must be added before the user card so that the user card
431 // can correctly calculate the remaining available width. 487 // can correctly calculate the remaining available width.
432 AddLogoutButton(login); 488 // Note that only the current multiprofile user gets a button.
489 AddLogoutButton(!multiprofile_index_ ? login : ash::user::LOGGED_IN_LOCKED);
433 AddUserCard(owner, login); 490 AddUserCard(owner, login);
434 } 491 }
435 492
436 UserView::~UserView() {} 493 UserView::~UserView() {}
437 494
438 gfx::Size UserView::GetPreferredSize() { 495 gfx::Size UserView::GetPreferredSize() {
439 gfx::Size size = views::View::GetPreferredSize(); 496 gfx::Size size = views::View::GetPreferredSize();
440 if (!user_card_) { 497 if (!user_card_) {
441 // Make sure the default user view item is at least as tall as the other 498 // The default user view item should be at least as tall as the other items.
442 // items.
443 size.set_height(std::max(size.height(), 499 size.set_height(std::max(size.height(),
444 kTrayPopupItemHeight + GetInsets().height())); 500 kTrayPopupItemHeight + GetInsets().height()));
445 } 501 }
446 return size; 502 return size;
447 } 503 }
448 504
449 int UserView::GetHeightForWidth(int width) { 505 int UserView::GetHeightForWidth(int width) {
450 return GetPreferredSize().height(); 506 return GetPreferredSize().height();
451 } 507 }
452 508
453 void UserView::Layout() { 509 void UserView::Layout() {
454 gfx::Rect contents_area(GetContentsBounds()); 510 gfx::Rect contents_area(GetContentsBounds());
455 if (user_card_ && logout_button_) { 511 if (user_card_ && logout_button_) {
456 // Give the logout button the space it requests. 512 // Give the logout button the space it requests.
457 gfx::Rect logout_area = contents_area; 513 gfx::Rect logout_area = contents_area;
458 logout_area.ClampToCenteredSize(logout_button_->GetPreferredSize()); 514 logout_area.ClampToCenteredSize(logout_button_->GetPreferredSize());
459 logout_area.set_x(contents_area.right() - logout_area.width()); 515 logout_area.set_x(contents_area.right() - logout_area.width());
460 logout_button_->SetBoundsRect(logout_area);
461 516
462 // Give the remaining space to the user card. 517 // Give the remaining space to the user card.
463 gfx::Rect user_card_area = contents_area; 518 gfx::Rect user_card_area = contents_area;
464 int remaining_width = contents_area.width() - 519 int remaining_width = contents_area.width() - logout_area.width();
465 (logout_area.width() + kTrayPopupPaddingBetweenItems); 520 if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) {
466 user_card_area.set_width(std::max(0, remaining_width)); 521 // In multiprofile case |user_card_| and |logout_button_| have to have the
522 // same height.
523 int y = std::min(user_card_area.y(), logout_area.y());
524 int height = std::max(user_card_area.height(), logout_area.height());
525 logout_area.set_y(y);
526 logout_area.set_height(height);
527 user_card_area.set_y(y);
528 user_card_area.set_height(height);
529 // In multiprofile mode we have also to increase the size of the card by
Nikita (slow) 2013/05/17 17:00:32 nit: Please insert empty line before comment.
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Never heard that before - done.
530 // the size of the border to make it overlap with the logout button.
531 user_card_area.set_width(std::max(0, remaining_width + 1));
532 // To make the logout button symmetrical with the user card we also make
Nikita (slow) 2013/05/17 17:00:32 nit: Empty line before comment.
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Ditto
533 // the button longer by the same size the hover area in front of the icon
534 // got inset.
535 logout_area.set_width(logout_area.width() +
536 kTrayUserTileHoverBorderInset);
537 } else {
538 // In all other modes we have to make sure that there is enough spacing
539 // between the two.
540 remaining_width -= kTrayPopupPaddingBetweenItems;
541 }
467 user_card_->SetBoundsRect(user_card_area); 542 user_card_->SetBoundsRect(user_card_area);
543 logout_button_->SetBoundsRect(logout_area);
468 } else if (user_card_) { 544 } else if (user_card_) {
469 user_card_->SetBoundsRect(contents_area); 545 user_card_->SetBoundsRect(contents_area);
470 } else if (logout_button_) { 546 } else if (logout_button_) {
471 logout_button_->SetBoundsRect(contents_area); 547 logout_button_->SetBoundsRect(contents_area);
472 } 548 }
473 } 549 }
474 550
475 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) { 551 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) {
476 if (sender == logout_button_) { 552 if (sender == logout_button_) {
477 ash::Shell::GetInstance()->system_tray_delegate()->SignOut(); 553 ash::Shell::GetInstance()->system_tray_delegate()->SignOut();
478 } else if (sender == profile_picture_) { 554 } else if (sender == user_card_ &&
479 if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) 555 ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) {
480 ash::Shell::GetInstance()->system_tray_delegate()->ShowUserLogin(); 556 if (!multiprofile_index_) {
481 else 557 // TODO(skuhne): Need to add the images & adding logic here.
482 ash::Shell::GetInstance()->system_tray_delegate()->ChangeProfilePicture(); 558 // TODO(skuhne): Make sure that we do not offer an add when this mode is
559 // active.
560 // TODO(skuhne): Use IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT as
561 // string.
562 const SessionStateDelegate* session_state_delegate =
563 ash::Shell::GetInstance()->session_state_delegate();
564 if (session_state_delegate->NumberOfLoggedInUsers() >=
565 session_state_delegate->GetMaximumNumberOfLoggedInUsers()) {
566 // TODO(skuhne): Use IDS_ASH_STATUS_TRAY_CAPTION_CANNOT_ADD_USER and
567 // IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER when showing the error
568 // message that no more users can be added.
569 } else {
570 ash::Shell::GetInstance()->system_tray_delegate()->ShowUserLogin();
571 }
572 } else {
573 ash::SessionStateDelegate* delegate =
574 ash::Shell::GetInstance()->session_state_delegate();
575 delegate->SwitchActiveUser(delegate->GetUserEmail(multiprofile_index_));
576 }
483 } else { 577 } else {
484 NOTREACHED(); 578 NOTREACHED();
485 } 579 }
486 } 580 }
487 581
488 void UserView::AddLogoutButton(ash::user::LoginStatus login) { 582 void UserView::AddLogoutButton(ash::user::LoginStatus login) {
489 // A user should not be able to modify logged-in state when screen is 583 // A user should not be able to modify logged-in state when screen is
490 // locked. 584 // locked.
491 if (login == ash::user::LOGGED_IN_LOCKED) 585 if (login == ash::user::LOGGED_IN_LOCKED)
492 return; 586 return;
(...skipping 13 matching lines...) Expand all
506 border->SetPainter(false, views::Button::STATE_HOVERED, 600 border->SetPainter(false, views::Button::STATE_HOVERED,
507 views::Painter::CreateImageGridPainter( 601 views::Painter::CreateImageGridPainter(
508 kPublicAccountLogoutButtonBorderImagesHovered)); 602 kPublicAccountLogoutButtonBorderImagesHovered));
509 border->SetPainter(false, views::Button::STATE_PRESSED, 603 border->SetPainter(false, views::Button::STATE_PRESSED,
510 views::Painter::CreateImageGridPainter( 604 views::Painter::CreateImageGridPainter(
511 kPublicAccountLogoutButtonBorderImagesHovered)); 605 kPublicAccountLogoutButtonBorderImagesHovered));
512 } 606 }
513 AddChildView(logout_button_); 607 AddChildView(logout_button_);
514 } 608 }
515 609
516 void UserView::AddUserCard(SystemTrayItem* owner, 610 void UserView::AddUserCard(SystemTrayItem* owner,
Nikita (slow) 2013/05/17 17:00:32 Seems that this method should be split into smalle
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 I was shorten it. It is still a bit big, but much
517 ash::user::LoginStatus login) { 611 ash::user::LoginStatus login) {
518 if (login == ash::user::LOGGED_IN_GUEST) 612 if (login == ash::user::LOGGED_IN_GUEST)
519 return; 613 return;
520 614
521 set_border(views::Border::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 615 // Add padding around the panel.
522 0, kTrayPopupPaddingHorizontal)); 616 set_border(views::Border::CreateEmptyBorder(
617 kUserCardVerticalPadding, kTrayPopupPaddingHorizontal,
618 kUserCardVerticalPadding, kTrayPopupPaddingHorizontal));
523 619
524 user_card_ = new views::View(); 620 if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled() &&
621 login != ash::user::LOGGED_IN_RETAIL_MODE)
622 user_card_ = new UserCard(this, multiprofile_index_ == 0);
Nikita (slow) 2013/05/17 17:00:32 nit: Add {}
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Well... I always thought that this was okay since
Nikita (slow) 2013/05/17 19:15:47 Seems more readable when condition is on multiple
Mr4D (OOO till 08-26) 2013/05/17 20:04:43 Well - so it is formulated in a way that both is o
623 else
624 user_card_ = new views::View();
625
525 user_card_->SetLayoutManager(new views::BoxLayout( 626 user_card_->SetLayoutManager(new views::BoxLayout(
526 views::BoxLayout::kHorizontal, 0, kUserCardVerticalPadding, 627 views::BoxLayout::kHorizontal, 0, 0 , kTrayPopupPaddingBetweenItems));
527 kTrayPopupPaddingBetweenItems));
528 AddChildViewAt(user_card_, 0); 628 AddChildViewAt(user_card_, 0);
529 629
530 if (login == ash::user::LOGGED_IN_RETAIL_MODE) { 630 if (login == ash::user::LOGGED_IN_RETAIL_MODE) {
531 views::Label* details = new views::Label; 631 views::Label* details = new views::Label;
532 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 632 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
533 details->SetText( 633 details->SetText(
534 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_KIOSK_LABEL)); 634 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_KIOSK_LABEL));
535 details->set_border(views::Border::CreateEmptyBorder(0, 4, 0, 1)); 635 details->set_border(views::Border::CreateEmptyBorder(0, 4, 0, 1));
536 details->SetHorizontalAlignment(gfx::ALIGN_LEFT); 636 details->SetHorizontalAlignment(gfx::ALIGN_LEFT);
537 user_card_->AddChildView(details); 637 user_card_->AddChildView(details);
538 return; 638 return;
539 } 639 }
540 profile_picture_ = new ClickableAvatar(this); 640
541 user_card_->AddChildView(profile_picture_); 641 // The entire user card should trigger hover (the inner items get disabled).
642 user_card_->SetEnabled(true);
643
644 RoundedImageView* icon = new RoundedImageView(kProfileRoundedCornerRadius,
645 multiprofile_index_ == 0);
646 icon->SetEnabled(false);
647 icon->SetImage(
648 ash::Shell::GetInstance()->session_state_delegate()->GetUserImage(
649 multiprofile_index_),
Nikita (slow) 2013/05/17 17:00:32 nit: Please move method name to this line.
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Done.
650 gfx::Size(kUserIconSize, kUserIconSize));
651 user_card_->AddChildView(icon);
542 652
543 if (login == ash::user::LOGGED_IN_PUBLIC) { 653 if (login == ash::user::LOGGED_IN_PUBLIC) {
544 user_card_->AddChildView(new PublicAccountUserDetails( 654 user_card_->AddChildView(new PublicAccountUserDetails(
545 owner, GetPreferredSize().width() + kTrayPopupPaddingBetweenItems)); 655 owner, GetPreferredSize().width() + kTrayPopupPaddingBetweenItems));
546 return; 656 return;
547 } 657 }
548 658
549 ash::SystemTrayDelegate* delegate = 659 // To allow the border to start before the icon, reduce the size before and
550 ash::Shell::GetInstance()->system_tray_delegate(); 660 // add an inset to the icon to get the spacing.
661 if (multiprofile_index_ == 0 &&
662 ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) {
663 icon->set_border(views::Border::CreateEmptyBorder(
664 0, kTrayUserTileHoverBorderInset, 0, 0));
665 set_border(views::Border::CreateEmptyBorder(
666 kUserCardVerticalPadding,
667 kTrayPopupPaddingHorizontal - kTrayUserTileHoverBorderInset,
668 kUserCardVerticalPadding,
669 kTrayPopupPaddingHorizontal));
670 }
671 ash::SessionStateDelegate* delegate =
672 ash::Shell::GetInstance()->session_state_delegate();
551 views::View* details = new views::View; 673 views::View* details = new views::View;
674 details->SetEnabled(false);
552 details->SetLayoutManager(new views::BoxLayout( 675 details->SetLayoutManager(new views::BoxLayout(
553 views::BoxLayout::kVertical, 0, kUserDetailsVerticalPadding, 0)); 676 views::BoxLayout::kVertical, 0, kUserDetailsVerticalPadding, 0));
554 views::Label* username = new views::Label(delegate->GetUserDisplayName()); 677 views::Label* username = NULL;
555 username->SetHorizontalAlignment(gfx::ALIGN_LEFT); 678 if (!multiprofile_index_) {
556 details->AddChildView(username); 679 username =
557 680 new views::Label(delegate->GetUserDisplayName(multiprofile_index_));
681 username->SetEnabled(false);
682 username->SetHorizontalAlignment(gfx::ALIGN_LEFT);
683 details->AddChildView(username);
684 }
558 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 685 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
559 686
560 views::Label* additional = new views::Label(); 687 views::Label* additional = new views::Label();
561 688 additional->SetEnabled(false);
562 additional->SetText(login == ash::user::LOGGED_IN_LOCALLY_MANAGED ? 689 additional->SetText(login == ash::user::LOGGED_IN_LOCALLY_MANAGED ?
563 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL) : 690 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL) :
564 UTF8ToUTF16(delegate->GetUserEmail())); 691 UTF8ToUTF16(delegate->GetUserEmail(multiprofile_index_)));
565 692
566 additional->SetFont(bundle.GetFont(ui::ResourceBundle::SmallFont));
567 additional->SetHorizontalAlignment(gfx::ALIGN_LEFT); 693 additional->SetHorizontalAlignment(gfx::ALIGN_LEFT);
568 additional->SetEnabled(false);
569 details->AddChildView(additional); 694 details->AddChildView(additional);
695 // Adjust text properties dependent on if it is an active or inactive user.
696 if (multiprofile_index_) {
697 // Fade the text of non active users to 50%.
698 SkColor text_color = additional->enabled_color();
699 text_color = SkColorSetA(text_color, SkColorGetA(text_color) / 2);
700 additional->SetDisabledColor(text_color);
701 if (username)
702 username->SetDisabledColor(text_color);
703 }
704
705 // Use a small font for email address if username is given.
706 if (username)
707 additional->SetFont(bundle.GetFont(ui::ResourceBundle::SmallFont));
708
570 user_card_->AddChildView(details); 709 user_card_->AddChildView(details);
571 } 710 }
572 711
573 } // namespace tray 712 } // namespace tray
574 713
575 TrayUser::TrayUser(SystemTray* system_tray) 714 TrayUser::TrayUser(SystemTray* system_tray, MultiProfileIndex index)
576 : SystemTrayItem(system_tray), 715 : SystemTrayItem(system_tray),
716 multiprofile_index_(index),
577 user_(NULL), 717 user_(NULL),
578 layout_view_(NULL), 718 layout_view_(NULL),
579 avatar_(NULL), 719 avatar_(NULL),
580 label_(NULL) { 720 label_(NULL) {
581 Shell::GetInstance()->system_tray_notifier()->AddUserObserver(this); 721 Shell::GetInstance()->system_tray_notifier()->AddUserObserver(this);
582 } 722 }
583 723
584 TrayUser::~TrayUser() { 724 TrayUser::~TrayUser() {
585 Shell::GetInstance()->system_tray_notifier()->RemoveUserObserver(this); 725 Shell::GetInstance()->system_tray_notifier()->RemoveUserObserver(this);
586 } 726 }
587 727
588 views::View* TrayUser::CreateTrayView(user::LoginStatus status) { 728 views::View* TrayUser::CreateTrayView(user::LoginStatus status) {
589 CHECK(layout_view_ == NULL); 729 CHECK(layout_view_ == NULL);
730 // Only the current user gets an icon. All other users will only be
731 // represented in the tray menu.
732 if (multiprofile_index_)
733 return NULL;
734
590 layout_view_ = new views::View(); 735 layout_view_ = new views::View();
591 layout_view_->SetLayoutManager( 736 layout_view_->SetLayoutManager(
592 new views::BoxLayout(views::BoxLayout::kHorizontal, 737 new views::BoxLayout(views::BoxLayout::kHorizontal,
593 0, 0, kUserLabelToIconPadding)); 738 0, 0, kUserLabelToIconPadding));
594 UpdateAfterLoginStatusChange(status); 739 UpdateAfterLoginStatusChange(status);
595 return layout_view_; 740 return layout_view_;
596 } 741 }
597 742
598 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) { 743 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) {
599 if (status == user::LOGGED_IN_NONE) 744 if (status == user::LOGGED_IN_NONE)
600 return NULL; 745 return NULL;
601 746
602 CHECK(user_ == NULL); 747 CHECK(user_ == NULL);
603 user_ = new tray::UserView(this, status); 748
749 const SessionStateDelegate* session_state_delegate =
750 ash::Shell::GetInstance()->session_state_delegate();
751 int logged_in_users = session_state_delegate->NumberOfLoggedInUsers();
752
753 // If there are multiple users logged in, the users will be separated from the
754 // rest of the menu by a separator.
755 if (multiprofile_index_ ==
756 session_state_delegate->GetMaximumNumberOfLoggedInUsers() &&
757 logged_in_users > 1)
758 return new views::View();
Nikita (slow) 2013/05/17 17:00:32 nit: Add {}
Mr4D (OOO till 08-26) 2013/05/17 18:45:09 Ditto. Done.
759
760 // Do not show more UserView's then there are logged in users.
761 if (multiprofile_index_ >= logged_in_users)
762 return NULL;;
763
764 user_ = new tray::UserView(this, status, multiprofile_index_);
604 return user_; 765 return user_;
605 } 766 }
606 767
607 views::View* TrayUser::CreateDetailedView(user::LoginStatus status) { 768 views::View* TrayUser::CreateDetailedView(user::LoginStatus status) {
608 return NULL; 769 return NULL;
609 } 770 }
610 771
611 void TrayUser::DestroyTrayView() { 772 void TrayUser::DestroyTrayView() {
612 layout_view_ = NULL; 773 layout_view_ = NULL;
613 avatar_ = NULL; 774 avatar_ = NULL;
614 label_ = NULL; 775 label_ = NULL;
615 } 776 }
616 777
617 void TrayUser::DestroyDefaultView() { 778 void TrayUser::DestroyDefaultView() {
618 user_ = NULL; 779 user_ = NULL;
619 } 780 }
620 781
621 void TrayUser::DestroyDetailedView() { 782 void TrayUser::DestroyDetailedView() {
622 } 783 }
623 784
624 void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) { 785 void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
625 CHECK(layout_view_); 786 // Only the active user is represented in the tray.
787 if (!layout_view_)
788 return;
626 bool need_label = false; 789 bool need_label = false;
627 bool need_avatar = false; 790 bool need_avatar = false;
628 switch (status) { 791 switch (status) {
629 case user::LOGGED_IN_LOCKED: 792 case user::LOGGED_IN_LOCKED:
630 case user::LOGGED_IN_USER: 793 case user::LOGGED_IN_USER:
631 case user::LOGGED_IN_OWNER: 794 case user::LOGGED_IN_OWNER:
632 case user::LOGGED_IN_PUBLIC: 795 case user::LOGGED_IN_PUBLIC:
633 need_avatar = true; 796 need_avatar = true;
634 break; 797 break;
635 case user::LOGGED_IN_LOCALLY_MANAGED: 798 case user::LOGGED_IN_LOCALLY_MANAGED:
(...skipping 13 matching lines...) Expand all
649 (need_label != (label_ != NULL))) { 812 (need_label != (label_ != NULL))) {
650 layout_view_->RemoveAllChildViews(true); 813 layout_view_->RemoveAllChildViews(true);
651 if (need_label) { 814 if (need_label) {
652 label_ = new views::Label; 815 label_ = new views::Label;
653 SetupLabelForTray(label_); 816 SetupLabelForTray(label_);
654 layout_view_->AddChildView(label_); 817 layout_view_->AddChildView(label_);
655 } else { 818 } else {
656 label_ = NULL; 819 label_ = NULL;
657 } 820 }
658 if (need_avatar) { 821 if (need_avatar) {
659 avatar_ = new tray::RoundedImageView(kProfileRoundedCornerRadius); 822 avatar_ = new tray::RoundedImageView(kProfileRoundedCornerRadius, true);
660 layout_view_->AddChildView(avatar_); 823 layout_view_->AddChildView(avatar_);
661 } else { 824 } else {
662 avatar_ = NULL; 825 avatar_ = NULL;
663 } 826 }
664 } 827 }
665 828
666 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 829 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
667 if (status == user::LOGGED_IN_LOCALLY_MANAGED) { 830 if (status == user::LOGGED_IN_LOCALLY_MANAGED) {
668 label_->SetText( 831 label_->SetText(
669 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL)); 832 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL));
670 } else if (status == user::LOGGED_IN_GUEST) { 833 } else if (status == user::LOGGED_IN_GUEST) {
671 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_GUEST_LABEL)); 834 label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_GUEST_LABEL));
672 } 835 }
673 836
674 if (avatar_) { 837 if (avatar_) {
675 avatar_->SetImage( 838 avatar_->SetImage(
676 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(), 839 ash::Shell::GetInstance()->session_state_delegate()->GetUserImage(
840 multiprofile_index_),
677 gfx::Size(kUserIconSize, kUserIconSize)); 841 gfx::Size(kUserIconSize, kUserIconSize));
678 } 842 }
679 } 843 }
680 844
681 void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 845 void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
682 CHECK(layout_view_); 846 // Inactive users won't have a layout.
847 if (!layout_view_)
848 return;
683 if (alignment == SHELF_ALIGNMENT_BOTTOM || 849 if (alignment == SHELF_ALIGNMENT_BOTTOM ||
684 alignment == SHELF_ALIGNMENT_TOP) { 850 alignment == SHELF_ALIGNMENT_TOP) {
685 if (avatar_) { 851 if (avatar_) {
686 avatar_->set_border(views::Border::CreateEmptyBorder( 852 avatar_->set_border(views::Border::CreateEmptyBorder(
687 0, kTrayImageItemHorizontalPaddingBottomAlignment + 2, 853 0, kTrayImageItemHorizontalPaddingBottomAlignment + 2,
688 0, kTrayImageItemHorizontalPaddingBottomAlignment)); 854 0, kTrayImageItemHorizontalPaddingBottomAlignment));
689 855
690 } 856 }
691 if (label_) { 857 if (label_) {
692 label_->set_border(views::Border::CreateEmptyBorder( 858 label_->set_border(views::Border::CreateEmptyBorder(
(...skipping 16 matching lines...) Expand all
709 layout_view_->SetLayoutManager( 875 layout_view_->SetLayoutManager(
710 new views::BoxLayout(views::BoxLayout::kVertical, 876 new views::BoxLayout(views::BoxLayout::kVertical,
711 0, 0, kUserLabelToIconPadding)); 877 0, 0, kUserLabelToIconPadding));
712 } 878 }
713 } 879 }
714 880
715 void TrayUser::OnUserUpdate() { 881 void TrayUser::OnUserUpdate() {
716 // Check for null to avoid crbug.com/150944. 882 // Check for null to avoid crbug.com/150944.
717 if (avatar_) { 883 if (avatar_) {
718 avatar_->SetImage( 884 avatar_->SetImage(
719 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(), 885 ash::Shell::GetInstance()->session_state_delegate()->GetUserImage(
886 multiprofile_index_),
720 gfx::Size(kUserIconSize, kUserIconSize)); 887 gfx::Size(kUserIconSize, kUserIconSize));
721 } 888 }
722 } 889 }
723 890
724 } // namespace internal 891 } // namespace internal
725 } // namespace ash 892 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698