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

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

Issue 2911493002: cros: Pull user info from session_controller_client.mojom into separate mojom. (Closed)
Patch Set: Fix ordering in typemaps Created 3 years, 6 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
« no previous file with comments | « ash/system/user/tray_user_unittest.cc ('k') | ash/system/user/user_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/user_card_view.h" 5 #include "ash/system/user/user_card_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 const base::char16 kDisplayNameMark[] = {0x2060, 0}; 58 const base::char16 kDisplayNameMark[] = {0x2060, 0};
59 59
60 views::View* CreateUserAvatarView(LoginStatus login_status, int user_index) { 60 views::View* CreateUserAvatarView(LoginStatus login_status, int user_index) {
61 RoundedImageView* image_view = new RoundedImageView(kTrayItemSize / 2); 61 RoundedImageView* image_view = new RoundedImageView(kTrayItemSize / 2);
62 if (login_status == LoginStatus::GUEST) { 62 if (login_status == LoginStatus::GUEST) {
63 gfx::ImageSkia icon = 63 gfx::ImageSkia icon =
64 gfx::CreateVectorIcon(kSystemMenuGuestIcon, kMenuIconColor); 64 gfx::CreateVectorIcon(kSystemMenuGuestIcon, kMenuIconColor);
65 image_view->SetImage(icon, icon.size()); 65 image_view->SetImage(icon, icon.size());
66 } else { 66 } else {
67 SessionController* controller = Shell::Get()->session_controller(); 67 SessionController* controller = Shell::Get()->session_controller();
68 image_view->SetImage(controller->GetUserSession(user_index)->avatar, 68 image_view->SetImage(
69 gfx::Size(kTrayItemSize, kTrayItemSize)); 69 controller->GetUserSession(user_index)->user_info->avatar,
70 gfx::Size(kTrayItemSize, kTrayItemSize));
70 } 71 }
71 72
72 image_view->SetBorder(views::CreateEmptyBorder(gfx::Insets( 73 image_view->SetBorder(views::CreateEmptyBorder(gfx::Insets(
73 (kTrayPopupItemMinStartWidth - image_view->GetPreferredSize().width()) / 74 (kTrayPopupItemMinStartWidth - image_view->GetPreferredSize().width()) /
74 2))); 75 2)));
75 return image_view; 76 return image_view;
76 } 77 }
77 78
78 // The user details shown in public account mode. This is essentially a label 79 // The user details shown in public account mode. This is essentially a label
79 // but with custom painting code as the text is styled with multiple colors and 80 // but with custom painting code as the text is styled with multiple colors and
(...skipping 29 matching lines...) Expand all
109 const int inner_padding = 110 const int inner_padding =
110 kTrayPopupPaddingHorizontal - kTrayPopupPaddingBetweenItems; 111 kTrayPopupPaddingHorizontal - kTrayPopupPaddingBetweenItems;
111 const bool rtl = base::i18n::IsRTL(); 112 const bool rtl = base::i18n::IsRTL();
112 SetBorder(views::CreateEmptyBorder( 113 SetBorder(views::CreateEmptyBorder(
113 kUserDetailsVerticalPadding, rtl ? 0 : inner_padding, 114 kUserDetailsVerticalPadding, rtl ? 0 : inner_padding,
114 kUserDetailsVerticalPadding, rtl ? inner_padding : 0)); 115 kUserDetailsVerticalPadding, rtl ? inner_padding : 0));
115 116
116 // Retrieve the user's display name and wrap it with markers. 117 // Retrieve the user's display name and wrap it with markers.
117 // Note that since this is a public account it always has to be the primary 118 // Note that since this is a public account it always has to be the primary
118 // user. 119 // user.
119 base::string16 display_name = base::UTF8ToUTF16( 120 base::string16 display_name =
120 Shell::Get()->session_controller()->GetUserSession(0)->display_name); 121 base::UTF8ToUTF16(Shell::Get()
122 ->session_controller()
123 ->GetUserSession(0)
124 ->user_info->display_name);
121 base::RemoveChars(display_name, kDisplayNameMark, &display_name); 125 base::RemoveChars(display_name, kDisplayNameMark, &display_name);
122 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; 126 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0];
123 // Retrieve the domain managing the device and wrap it with markers. 127 // Retrieve the domain managing the device and wrap it with markers.
124 base::string16 domain = base::UTF8ToUTF16( 128 base::string16 domain = base::UTF8ToUTF16(
125 Shell::Get()->system_tray_controller()->enterprise_domain()); 129 Shell::Get()->system_tray_controller()->enterprise_domain());
126 base::RemoveChars(domain, kDisplayNameMark, &domain); 130 base::RemoveChars(domain, kDisplayNameMark, &domain);
127 base::i18n::WrapStringWithLTRFormatting(&domain); 131 base::i18n::WrapStringWithLTRFormatting(&domain);
128 // Retrieve the label text, inserting the display name and domain. 132 // Retrieve the label text, inserting the display name and domain.
129 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, 133 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL,
130 display_name, domain); 134 display_name, domain);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 AddChildView(new PublicAccountUserDetails()); 379 AddChildView(new PublicAccountUserDetails());
376 } 380 }
377 381
378 void UserCardView::AddUserContent(views::BoxLayout* layout, 382 void UserCardView::AddUserContent(views::BoxLayout* layout,
379 LoginStatus login_status) { 383 LoginStatus login_status) {
380 AddChildView(CreateUserAvatarView(login_status, user_index_)); 384 AddChildView(CreateUserAvatarView(login_status, user_index_));
381 SessionController* controller = Shell::Get()->session_controller(); 385 SessionController* controller = Shell::Get()->session_controller();
382 base::string16 user_name_string = 386 base::string16 user_name_string =
383 login_status == LoginStatus::GUEST 387 login_status == LoginStatus::GUEST
384 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL) 388 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL)
385 : base::UTF8ToUTF16( 389 : base::UTF8ToUTF16(controller->GetUserSession(user_index_)
386 controller->GetUserSession(user_index_)->display_name); 390 ->user_info->display_name);
387 user_name_ = new views::Label(user_name_string); 391 user_name_ = new views::Label(user_name_string);
388 user_name_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 392 user_name_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
389 TrayPopupItemStyle user_name_style( 393 TrayPopupItemStyle user_name_style(
390 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); 394 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
391 user_name_style.SetupLabel(user_name_); 395 user_name_style.SetupLabel(user_name_);
392 396
393 TrayPopupItemStyle user_email_style(TrayPopupItemStyle::FontStyle::CAPTION); 397 TrayPopupItemStyle user_email_style(TrayPopupItemStyle::FontStyle::CAPTION);
394 user_email_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); 398 user_email_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE);
395 auto* user_email = new views::Label(); 399 auto* user_email = new views::Label();
396 base::string16 user_email_string; 400 base::string16 user_email_string;
397 if (login_status != LoginStatus::GUEST) { 401 if (login_status != LoginStatus::GUEST) {
398 user_email_string = 402 user_email_string =
399 Shell::Get()->session_controller()->IsUserSupervised() 403 Shell::Get()->session_controller()->IsUserSupervised()
400 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL) 404 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL)
401 : base::UTF8ToUTF16( 405 : base::UTF8ToUTF16(controller->GetUserSession(user_index_)
402 controller->GetUserSession(user_index_)->display_email); 406 ->user_info->display_email);
403 } 407 }
404 user_email->SetText(user_email_string); 408 user_email->SetText(user_email_string);
405 user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT); 409 user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT);
406 user_email_style.SetupLabel(user_email); 410 user_email_style.SetupLabel(user_email);
407 user_email->SetVisible(!user_email_string.empty()); 411 user_email->SetVisible(!user_email_string.empty());
408 user_email->set_collapse_when_hidden(true); 412 user_email->set_collapse_when_hidden(true);
409 413
410 views::View* stack_of_labels = new views::View; 414 views::View* stack_of_labels = new views::View;
411 AddChildView(stack_of_labels); 415 AddChildView(stack_of_labels);
412 layout->SetFlexForView(stack_of_labels, 1); 416 layout->SetFlexForView(stack_of_labels, 1);
(...skipping 22 matching lines...) Expand all
435 media_capture_container_ = new views::View(); 439 media_capture_container_ = new views::View();
436 media_capture_container_->SetLayoutManager(new views::FillLayout()); 440 media_capture_container_->SetLayoutManager(new views::FillLayout());
437 media_capture_container_->AddChildView(media_capture_icon_); 441 media_capture_container_->AddChildView(media_capture_icon_);
438 AddChildView(media_capture_container_); 442 AddChildView(media_capture_container_);
439 443
440 Shell::Get()->media_controller()->RequestCaptureState(); 444 Shell::Get()->media_controller()->RequestCaptureState();
441 } 445 }
442 446
443 } // namespace tray 447 } // namespace tray
444 } // namespace ash 448 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/user/tray_user_unittest.cc ('k') | ash/system/user/user_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698