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

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

Issue 2678353005: Remove pre-MD code related to tray/menu user profiles. (Closed)
Patch Set: back out a11y changes and rebase Created 3 years, 10 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/common/system/user/user_card_view.h ('k') | ash/common/system/user/user_view.h » ('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/common/system/user/user_card_view.h" 5 #include "ash/common/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
11 #include "ash/common/ash_view_ids.h" 11 #include "ash/common/ash_view_ids.h"
12 #include "ash/common/login_status.h" 12 #include "ash/common/login_status.h"
13 #include "ash/common/material_design/material_design_controller.h"
14 #include "ash/common/media_controller.h" 13 #include "ash/common/media_controller.h"
15 #include "ash/common/session/session_state_delegate.h" 14 #include "ash/common/session/session_state_delegate.h"
16 #include "ash/common/system/tray/system_tray_controller.h" 15 #include "ash/common/system/tray/system_tray_controller.h"
17 #include "ash/common/system/tray/system_tray_delegate.h" 16 #include "ash/common/system/tray/system_tray_delegate.h"
18 #include "ash/common/system/tray/tray_constants.h" 17 #include "ash/common/system/tray/tray_constants.h"
19 #include "ash/common/system/tray/tray_popup_item_style.h" 18 #include "ash/common/system/tray/tray_popup_item_style.h"
20 #include "ash/common/system/tray/tray_utils.h" 19 #include "ash/common/system/tray/tray_utils.h"
21 #include "ash/common/system/user/rounded_image_view.h" 20 #include "ash/common/system/user/rounded_image_view.h"
22 #include "ash/common/wm_shell.h" 21 #include "ash/common/wm_shell.h"
23 #include "ash/resources/vector_icons/vector_icons.h" 22 #include "ash/resources/vector_icons/vector_icons.h"
24 #include "base/i18n/rtl.h" 23 #include "base/i18n/rtl.h"
25 #include "base/memory/ptr_util.h" 24 #include "base/memory/ptr_util.h"
26 #include "base/strings/string16.h" 25 #include "base/strings/string16.h"
27 #include "base/strings/string_util.h" 26 #include "base/strings/string_util.h"
28 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
29 #include "components/user_manager/user_info.h" 28 #include "components/user_manager/user_info.h"
30 #include "grit/ash_resources.h"
31 #include "grit/ash_strings.h" 29 #include "grit/ash_strings.h"
32 #include "ui/accessibility/ax_node_data.h" 30 #include "ui/accessibility/ax_node_data.h"
33 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h"
35 #include "ui/compositor/compositing_recorder.h" 32 #include "ui/compositor/compositing_recorder.h"
36 #include "ui/gfx/canvas.h" 33 #include "ui/gfx/canvas.h"
37 #include "ui/gfx/color_palette.h" 34 #include "ui/gfx/color_palette.h"
38 #include "ui/gfx/geometry/insets.h" 35 #include "ui/gfx/geometry/insets.h"
39 #include "ui/gfx/geometry/rect.h" 36 #include "ui/gfx/geometry/rect.h"
40 #include "ui/gfx/geometry/size.h" 37 #include "ui/gfx/geometry/size.h"
41 #include "ui/gfx/paint_vector_icon.h" 38 #include "ui/gfx/paint_vector_icon.h"
42 #include "ui/gfx/range/range.h" 39 #include "ui/gfx/range/range.h"
43 #include "ui/gfx/render_text.h" 40 #include "ui/gfx/render_text.h"
44 #include "ui/gfx/text_elider.h" 41 #include "ui/gfx/text_elider.h"
45 #include "ui/gfx/text_utils.h" 42 #include "ui/gfx/text_utils.h"
46 #include "ui/views/border.h" 43 #include "ui/views/border.h"
47 #include "ui/views/controls/image_view.h" 44 #include "ui/views/controls/image_view.h"
48 #include "ui/views/controls/link.h" 45 #include "ui/views/controls/link.h"
49 #include "ui/views/controls/link_listener.h" 46 #include "ui/views/controls/link_listener.h"
50 #include "ui/views/layout/box_layout.h" 47 #include "ui/views/layout/box_layout.h"
51 #include "ui/views/layout/fill_layout.h"
52 48
53 namespace ash { 49 namespace ash {
54 namespace tray { 50 namespace tray {
55 51
56 namespace { 52 namespace {
57 53
58 const int kUserDetailsVerticalPadding = 5; 54 const int kUserDetailsVerticalPadding = 5;
59 55
60 // The invisible word joiner character, used as a marker to indicate the start 56 // The invisible word joiner character, used as a marker to indicate the start
61 // and end of the user's display name in the public account user card's text. 57 // and end of the user's display name in the public account user card's text.
62 const base::char16 kDisplayNameMark[] = {0x2060, 0}; 58 const base::char16 kDisplayNameMark[] = {0x2060, 0};
63 59
64 bool UseMd() {
65 return MaterialDesignController::IsSystemTrayMenuMaterial();
66 }
67
68 views::View* CreateUserAvatarView(LoginStatus login_status, int user_index) { 60 views::View* CreateUserAvatarView(LoginStatus login_status, int user_index) {
69 RoundedImageView* image_view = new RoundedImageView( 61 RoundedImageView* image_view = new RoundedImageView(kTrayItemSize / 2);
70 UseMd() ? kTrayItemSize / 2 : kTrayRoundedBorderRadius, user_index == 0);
71 if (login_status == LoginStatus::GUEST) { 62 if (login_status == LoginStatus::GUEST) {
72 gfx::ImageSkia icon = 63 gfx::ImageSkia icon =
73 UseMd() ? gfx::CreateVectorIcon(kSystemMenuGuestIcon, kMenuIconColor) 64 gfx::CreateVectorIcon(kSystemMenuGuestIcon, kMenuIconColor);
74 : *ui::ResourceBundle::GetSharedInstance()
75 .GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON)
76 .ToImageSkia();
77 image_view->SetImage(icon, icon.size()); 65 image_view->SetImage(icon, icon.size());
78 } else { 66 } else {
79 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); 67 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
80 image_view->SetImage(delegate->GetUserInfo(user_index)->GetImage(), 68 image_view->SetImage(delegate->GetUserInfo(user_index)->GetImage(),
81 gfx::Size(kTrayItemSize, kTrayItemSize)); 69 gfx::Size(kTrayItemSize, kTrayItemSize));
82 } 70 }
83 71
84 if (UseMd()) { 72 image_view->SetBorder(views::CreateEmptyBorder(
85 image_view->SetBorder(views::CreateEmptyBorder(gfx::Insets( 73 gfx::Insets((GetTrayConstant(TRAY_POPUP_ITEM_MAIN_IMAGE_CONTAINER_WIDTH) -
86 (GetTrayConstant(TRAY_POPUP_ITEM_MAIN_IMAGE_CONTAINER_WIDTH) - 74 image_view->GetPreferredSize().width()) /
87 image_view->GetPreferredSize().width()) / 75 2)));
88 2)));
89 }
90 return image_view; 76 return image_view;
91 } 77 }
92 78
93 class MediaIndicator : public views::View, public MediaCaptureObserver {
94 public:
95 explicit MediaIndicator(UserIndex index)
96 : index_(index), label_(new views::Label) {
97 DCHECK(!UseMd());
98 SetLayoutManager(new views::FillLayout);
99 views::ImageView* icon = new views::ImageView;
100 icon->SetImage(ui::ResourceBundle::GetSharedInstance()
101 .GetImageNamed(IDR_AURA_UBER_TRAY_RECORDING_RED)
102 .ToImageSkia());
103 AddChildView(icon);
104 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
105 label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
106 ui::ResourceBundle::SmallFont));
107 WmShell::Get()->media_controller()->AddObserver(this);
108 SetVisible(false);
109 WmShell::Get()->media_controller()->RequestCaptureState();
110 set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR);
111 }
112
113 ~MediaIndicator() override {
114 WmShell::Get()->media_controller()->RemoveObserver(this);
115 }
116
117 // MediaCaptureObserver:
118 void OnMediaCaptureChanged(
119 const std::vector<mojom::MediaCaptureState>& capture_states) override {
120 if (static_cast<size_t>(index_) >= capture_states.size()) {
121 NOTREACHED();
122 return;
123 }
124
125 mojom::MediaCaptureState state = capture_states[index_];
126 int res_id = 0;
127 switch (state) {
128 case mojom::MediaCaptureState::AUDIO_VIDEO:
129 res_id = IDS_ASH_STATUS_TRAY_MEDIA_RECORDING_AUDIO_VIDEO;
130 break;
131 case mojom::MediaCaptureState::AUDIO:
132 res_id = IDS_ASH_STATUS_TRAY_MEDIA_RECORDING_AUDIO;
133 break;
134 case mojom::MediaCaptureState::VIDEO:
135 res_id = IDS_ASH_STATUS_TRAY_MEDIA_RECORDING_VIDEO;
136 break;
137 case mojom::MediaCaptureState::NONE:
138 break;
139 }
140 SetMessage(res_id ? l10n_util::GetStringUTF16(res_id) : base::string16());
141 }
142
143 views::View* GetMessageView() { return label_; }
144
145 void SetMessage(const base::string16& message) {
146 SetVisible(!message.empty());
147 label_->SetText(message);
148 label_->SetVisible(!message.empty());
149 }
150
151 private:
152 UserIndex index_;
153 views::Label* label_;
154
155 DISALLOW_COPY_AND_ASSIGN(MediaIndicator);
156 };
157
158 // 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
159 // 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
160 // contains a link. 81 // contains a link.
161 class PublicAccountUserDetails : public views::View, 82 class PublicAccountUserDetails : public views::View,
162 public views::LinkListener { 83 public views::LinkListener {
163 public: 84 public:
164 PublicAccountUserDetails(int max_width); 85 PublicAccountUserDetails(int max_width);
165 ~PublicAccountUserDetails() override; 86 ~PublicAccountUserDetails() override;
166 87
167 private: 88 private:
168 // Overridden from views::View. 89 // Overridden from views::View.
169 void Layout() override; 90 void Layout() override;
170 gfx::Size GetPreferredSize() const override; 91 gfx::Size GetPreferredSize() const override;
171 void OnPaint(gfx::Canvas* canvas) override; 92 void OnPaint(gfx::Canvas* canvas) override;
172 93
173 // Overridden from views::LinkListener. 94 // Overridden from views::LinkListener.
174 void LinkClicked(views::Link* source, int event_flags) override; 95 void LinkClicked(views::Link* source, int event_flags) override;
175 96
176 // Calculate a preferred size that ensures the label text and the following 97 // Calculate a preferred size that ensures the label text and the following
177 // link do not wrap over more than three lines in total for aesthetic reasons 98 // link do not wrap over more than three lines in total for aesthetic reasons
178 // if possible. 99 // if possible.
179 void CalculatePreferredSize(int max_allowed_width); 100 void CalculatePreferredSize();
180 101
181 base::string16 text_; 102 base::string16 text_;
182 views::Link* learn_more_; 103 views::Link* learn_more_;
183 gfx::Size preferred_size_; 104 gfx::Size preferred_size_;
184 std::vector<std::unique_ptr<gfx::RenderText>> lines_; 105 std::vector<std::unique_ptr<gfx::RenderText>> lines_;
185 106
186 DISALLOW_COPY_AND_ASSIGN(PublicAccountUserDetails); 107 DISALLOW_COPY_AND_ASSIGN(PublicAccountUserDetails);
187 }; 108 };
188 109
189 PublicAccountUserDetails::PublicAccountUserDetails(int max_width) 110 PublicAccountUserDetails::PublicAccountUserDetails(int max_width)
(...skipping 21 matching lines...) Expand all
211 base::i18n::WrapStringWithLTRFormatting(&domain); 132 base::i18n::WrapStringWithLTRFormatting(&domain);
212 // Retrieve the label text, inserting the display name and domain. 133 // Retrieve the label text, inserting the display name and domain.
213 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, 134 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL,
214 display_name, domain); 135 display_name, domain);
215 136
216 learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_ASH_LEARN_MORE)); 137 learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_ASH_LEARN_MORE));
217 learn_more_->SetUnderline(false); 138 learn_more_->SetUnderline(false);
218 learn_more_->set_listener(this); 139 learn_more_->set_listener(this);
219 AddChildView(learn_more_); 140 AddChildView(learn_more_);
220 141
221 CalculatePreferredSize(max_width); 142 CalculatePreferredSize();
222 } 143 }
223 144
224 PublicAccountUserDetails::~PublicAccountUserDetails() {} 145 PublicAccountUserDetails::~PublicAccountUserDetails() {}
225 146
226 void PublicAccountUserDetails::Layout() { 147 void PublicAccountUserDetails::Layout() {
227 lines_.clear(); 148 lines_.clear();
228 const gfx::Rect contents_area = GetContentsBounds(); 149 const gfx::Rect contents_area = GetContentsBounds();
229 if (contents_area.IsEmpty()) 150 if (contents_area.IsEmpty())
230 return; 151 return;
231 152
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 221
301 views::View::OnPaint(canvas); 222 views::View::OnPaint(canvas);
302 } 223 }
303 224
304 void PublicAccountUserDetails::LinkClicked(views::Link* source, 225 void PublicAccountUserDetails::LinkClicked(views::Link* source,
305 int event_flags) { 226 int event_flags) {
306 DCHECK_EQ(source, learn_more_); 227 DCHECK_EQ(source, learn_more_);
307 WmShell::Get()->system_tray_controller()->ShowPublicAccountInfo(); 228 WmShell::Get()->system_tray_controller()->ShowPublicAccountInfo();
308 } 229 }
309 230
310 void PublicAccountUserDetails::CalculatePreferredSize(int max_allowed_width) { 231 void PublicAccountUserDetails::CalculatePreferredSize() {
311 const gfx::FontList font_list; 232 const gfx::FontList font_list;
312 const gfx::Size link_size = learn_more_->GetPreferredSize(); 233 const gfx::Size link_size = learn_more_->GetPreferredSize();
313 const int space_width = 234 const int space_width =
314 gfx::GetStringWidth(base::ASCIIToUTF16(" "), font_list); 235 gfx::GetStringWidth(base::ASCIIToUTF16(" "), font_list);
315 const gfx::Insets insets = GetInsets(); 236 const gfx::Insets insets = GetInsets();
316 int min_width = link_size.width(); 237 int min_width = link_size.width();
317 int max_width = 238 int max_width =
318 gfx::GetStringWidth(text_, font_list) + space_width + link_size.width(); 239 gfx::GetStringWidth(text_, font_list) + space_width + link_size.width();
319 // TODO(estade): |max_allowed_width| isn't used in MD. 240
320 if (UseMd())
321 DCHECK_EQ(-1, max_allowed_width);
322 else
323 max_width = std::min(max_width, max_allowed_width - insets.width());
324 // Do a binary search for the minimum width that ensures no more than three 241 // Do a binary search for the minimum width that ensures no more than three
325 // lines are needed. The lower bound is the minimum of the current bubble 242 // lines are needed. The lower bound is the minimum of the current bubble
326 // width and the width of the link (as no wrapping is permitted inside the 243 // width and the width of the link (as no wrapping is permitted inside the
327 // link). The upper bound is the maximum of the largest allowed bubble width 244 // link). The upper bound is the maximum of the largest allowed bubble width
328 // and the sum of the label text and link widths when put on a single line. 245 // and the sum of the label text and link widths when put on a single line.
329 std::vector<base::string16> lines; 246 std::vector<base::string16> lines;
330 while (min_width < max_width) { 247 while (min_width < max_width) {
331 lines.clear(); 248 lines.clear();
332 const int width = (min_width + max_width) / 2; 249 const int width = (min_width + max_width) / 2;
333 const bool too_narrow = 250 const bool too_narrow =
(...skipping 30 matching lines...) Expand all
364 } // namespace 281 } // namespace
365 282
366 UserCardView::UserCardView(LoginStatus login_status, 283 UserCardView::UserCardView(LoginStatus login_status,
367 int max_width, 284 int max_width,
368 int user_index) 285 int user_index)
369 : user_index_(user_index), 286 : user_index_(user_index),
370 user_name_(nullptr), 287 user_name_(nullptr),
371 media_capture_label_(nullptr), 288 media_capture_label_(nullptr),
372 media_capture_icon_(nullptr) { 289 media_capture_icon_(nullptr) {
373 auto layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 290 auto layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
374 UseMd() ? kTrayPopupLabelHorizontalPadding 291 kTrayPopupLabelHorizontalPadding);
375 : kTrayPopupPaddingBetweenItems);
376 SetLayoutManager(layout); 292 SetLayoutManager(layout);
377 if (UseMd()) { 293 layout->set_minimum_cross_axis_size(
378 layout->set_minimum_cross_axis_size( 294 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT));
379 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); 295 layout->set_cross_axis_alignment(
380 layout->set_cross_axis_alignment( 296 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
381 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 297 // For active users, the left inset is provided by ActiveUserBorder, which
382 // For active users, the left inset is provided by ActiveUserBorder, which 298 // is necessary to make sure the ripple does not cover that part of the row.
383 // is necessary to make sure the ripple does not cover that part of the row. 299 // For inactive users, we set the inset here and this causes the ripple to
384 // For inactive users, we set the inset here and this causes the ripple to 300 // extend all the way to the edges of the menu.
385 // extend all the way to the edges of the menu. 301 if (!is_active_user())
386 if (!is_active_user()) { 302 SetBorder(views::CreateEmptyBorder(0, kMenuExtraMarginFromLeftEdge, 0, 0));
387 SetBorder(
388 views::CreateEmptyBorder(0, kMenuExtraMarginFromLeftEdge, 0, 0));
389 }
390 303
391 WmShell::Get()->media_controller()->AddObserver(this); 304 WmShell::Get()->media_controller()->AddObserver(this);
392 }
393 305
394 if (login_status == LoginStatus::PUBLIC) 306 if (login_status == LoginStatus::PUBLIC)
395 AddPublicModeUserContent(max_width); 307 AddPublicModeUserContent(max_width);
396 else if (UseMd())
397 AddUserContentMd(layout, login_status);
398 else 308 else
399 AddUserContent(login_status); 309 AddUserContent(layout, login_status);
400 } 310 }
401 311
402 UserCardView::~UserCardView() { 312 UserCardView::~UserCardView() {
403 if (UseMd()) 313 WmShell::Get()->media_controller()->RemoveObserver(this);
404 WmShell::Get()->media_controller()->RemoveObserver(this);
405 } 314 }
406 315
407 void UserCardView::PaintChildren(const ui::PaintContext& context) { 316 void UserCardView::PaintChildren(const ui::PaintContext& context) {
408 if (!is_active_user()) { 317 if (!is_active_user()) {
409 ui::CompositingRecorder alpha(context, 0xFF / 2, true); 318 ui::CompositingRecorder alpha(context, 0xFF / 2, true);
410 View::PaintChildren(context); 319 View::PaintChildren(context);
411 } else { 320 } else {
412 View::PaintChildren(context); 321 View::PaintChildren(context);
413 } 322 }
414 } 323 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 359 }
451 360
452 void UserCardView::AddPublicModeUserContent(int max_width) { 361 void UserCardView::AddPublicModeUserContent(int max_width) {
453 views::View* avatar = CreateUserAvatarView(LoginStatus::PUBLIC, 0); 362 views::View* avatar = CreateUserAvatarView(LoginStatus::PUBLIC, 0);
454 AddChildView(avatar); 363 AddChildView(avatar);
455 int details_max_width = max_width - avatar->GetPreferredSize().width() - 364 int details_max_width = max_width - avatar->GetPreferredSize().width() -
456 kTrayPopupPaddingBetweenItems; 365 kTrayPopupPaddingBetweenItems;
457 AddChildView(new PublicAccountUserDetails(details_max_width)); 366 AddChildView(new PublicAccountUserDetails(details_max_width));
458 } 367 }
459 368
460 void UserCardView::AddUserContent(LoginStatus login_status) { 369 void UserCardView::AddUserContent(views::BoxLayout* layout,
461 DCHECK(!UseMd()); 370 LoginStatus login_status) {
462 views::View* avatar = CreateUserAvatarView(login_status, user_index_);
463 AddChildView(avatar);
464 views::Label* user_name = NULL;
465 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
466 if (!user_index_) {
467 base::string16 user_name_string =
468 login_status == LoginStatus::GUEST
469 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL)
470 : delegate->GetUserInfo(user_index_)->GetDisplayName();
471 if (!user_name_string.empty()) {
472 user_name = new views::Label(user_name_string);
473 user_name->SetHorizontalAlignment(gfx::ALIGN_LEFT);
474 }
475 }
476
477 views::Label* user_email = NULL;
478 if (login_status != LoginStatus::GUEST) {
479 SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate();
480 base::string16 user_email_string =
481 tray_delegate->IsUserSupervised()
482 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL)
483 : base::UTF8ToUTF16(
484 delegate->GetUserInfo(user_index_)->GetDisplayEmail());
485 if (!user_email_string.empty()) {
486 user_email = new views::Label(user_email_string);
487 user_email->SetFontList(
488 ui::ResourceBundle::GetSharedInstance().GetFontList(
489 ui::ResourceBundle::SmallFont));
490 user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT);
491 }
492 }
493
494 // Adjust text properties dependent on if it is an active or inactive user.
495 if (user_index_) {
496 // Fade the text of non active users to 50%.
497 SkColor text_color = user_email->enabled_color();
498 text_color = SkColorSetA(text_color, SkColorGetA(text_color) / 2);
499 if (user_email)
500 user_email->SetDisabledColor(text_color);
501 if (user_name)
502 user_name->SetDisabledColor(text_color);
503 }
504
505 if (user_email && user_name) {
506 views::View* details = new views::View;
507 details->SetLayoutManager(new views::BoxLayout(
508 views::BoxLayout::kVertical, 0, kUserDetailsVerticalPadding, 0));
509 details->AddChildView(user_name);
510 details->AddChildView(user_email);
511 AddChildView(details);
512 } else {
513 if (user_name)
514 AddChildView(user_name);
515 if (user_email) {
516 // Only non active user can have a media indicator.
517 MediaIndicator* media_indicator = new MediaIndicator(user_index_);
518 views::View* email_indicator_view = new views::View;
519 email_indicator_view->SetLayoutManager(new views::BoxLayout(
520 views::BoxLayout::kHorizontal, 0, 0, kTrayPopupPaddingBetweenItems));
521 email_indicator_view->AddChildView(user_email);
522 email_indicator_view->AddChildView(media_indicator);
523
524 views::View* details = new views::View;
525 details->SetLayoutManager(new views::BoxLayout(
526 views::BoxLayout::kVertical, 0, kUserDetailsVerticalPadding, 0));
527 details->AddChildView(email_indicator_view);
528 details->AddChildView(media_indicator->GetMessageView());
529 AddChildView(details);
530 }
531 }
532 }
533
534 void UserCardView::AddUserContentMd(views::BoxLayout* layout,
535 LoginStatus login_status) {
536 AddChildView(CreateUserAvatarView(login_status, user_index_)); 371 AddChildView(CreateUserAvatarView(login_status, user_index_));
537 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); 372 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
538 base::string16 user_name_string = 373 base::string16 user_name_string =
539 login_status == LoginStatus::GUEST 374 login_status == LoginStatus::GUEST
540 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL) 375 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL)
541 : delegate->GetUserInfo(user_index_)->GetDisplayName(); 376 : delegate->GetUserInfo(user_index_)->GetDisplayName();
542 user_name_ = new views::Label(user_name_string); 377 user_name_ = new views::Label(user_name_string);
543 user_name_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 378 user_name_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
544 TrayPopupItemStyle user_name_style( 379 TrayPopupItemStyle user_name_style(
545 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); 380 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 436
602 media_capture_icon_->set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR); 437 media_capture_icon_->set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR);
603 AddChildView(media_capture_icon_); 438 AddChildView(media_capture_icon_);
604 439
605 WmShell::Get()->media_controller()->RequestCaptureState(); 440 WmShell::Get()->media_controller()->RequestCaptureState();
606 } 441 }
607 } 442 }
608 443
609 } // namespace tray 444 } // namespace tray
610 } // namespace ash 445 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/user/user_card_view.h ('k') | ash/common/system/user/user_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698