| OLD | NEW |
| 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 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 } // namespace | 287 } // namespace |
| 288 | 288 |
| 289 UserCardView::UserCardView(LoginStatus login_status, | 289 UserCardView::UserCardView(LoginStatus login_status, |
| 290 int max_width, | 290 int max_width, |
| 291 int user_index) | 291 int user_index) |
| 292 : user_index_(user_index), | 292 : user_index_(user_index), |
| 293 user_name_(nullptr), | 293 user_name_(nullptr), |
| 294 media_capture_label_(nullptr), | 294 media_capture_label_(nullptr), |
| 295 media_capture_icon_(nullptr) { | 295 media_capture_icon_(nullptr) { |
| 296 auto layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 296 auto* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
| 297 kTrayPopupLabelHorizontalPadding); | 297 kTrayPopupLabelHorizontalPadding); |
| 298 SetLayoutManager(layout); | 298 SetLayoutManager(layout); |
| 299 layout->set_minimum_cross_axis_size( | 299 layout->set_minimum_cross_axis_size( |
| 300 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); | 300 GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)); |
| 301 layout->set_cross_axis_alignment( | 301 layout->set_cross_axis_alignment( |
| 302 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); | 302 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
| 303 // For active users, the left inset is provided by ActiveUserBorder, which | 303 // For active users, the left inset is provided by ActiveUserBorder, which |
| 304 // is necessary to make sure the ripple does not cover that part of the row. | 304 // is necessary to make sure the ripple does not cover that part of the row. |
| 305 // For inactive users, we set the inset here and this causes the ripple to | 305 // For inactive users, we set the inset here and this causes the ripple to |
| 306 // extend all the way to the edges of the menu. | 306 // extend all the way to the edges of the menu. |
| 307 if (!is_active_user()) | 307 if (!is_active_user()) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 329 } | 329 } |
| 330 | 330 |
| 331 void UserCardView::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 331 void UserCardView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 332 node_data->role = ui::AX_ROLE_STATIC_TEXT; | 332 node_data->role = ui::AX_ROLE_STATIC_TEXT; |
| 333 std::vector<base::string16> labels; | 333 std::vector<base::string16> labels; |
| 334 | 334 |
| 335 // Construct the name by concatenating descendants' names. | 335 // Construct the name by concatenating descendants' names. |
| 336 std::list<views::View*> descendants; | 336 std::list<views::View*> descendants; |
| 337 descendants.push_back(this); | 337 descendants.push_back(this); |
| 338 while (!descendants.empty()) { | 338 while (!descendants.empty()) { |
| 339 auto view = descendants.front(); | 339 auto* view = descendants.front(); |
| 340 descendants.pop_front(); | 340 descendants.pop_front(); |
| 341 if (view != this) { | 341 if (view != this) { |
| 342 ui::AXNodeData descendant_data; | 342 ui::AXNodeData descendant_data; |
| 343 view->GetAccessibleNodeData(&descendant_data); | 343 view->GetAccessibleNodeData(&descendant_data); |
| 344 base::string16 label = | 344 base::string16 label = |
| 345 descendant_data.GetString16Attribute(ui::AX_ATTR_NAME); | 345 descendant_data.GetString16Attribute(ui::AX_ATTR_NAME); |
| 346 // If we find a non-empty name, use that and don't descend further into | 346 // If we find a non-empty name, use that and don't descend further into |
| 347 // the tree. | 347 // the tree. |
| 348 if (!label.empty()) { | 348 if (!label.empty()) { |
| 349 labels.push_back(label); | 349 labels.push_back(label); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 user_name_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 406 user_name_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 407 TrayPopupItemStyle user_name_style( | 407 TrayPopupItemStyle user_name_style( |
| 408 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); | 408 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); |
| 409 user_name_style.SetupLabel(user_name_); | 409 user_name_style.SetupLabel(user_name_); |
| 410 | 410 |
| 411 TrayPopupItemStyle user_email_style(TrayPopupItemStyle::FontStyle::CAPTION); | 411 TrayPopupItemStyle user_email_style(TrayPopupItemStyle::FontStyle::CAPTION); |
| 412 // Only the active user's email label is lightened (for the inactive user, the | 412 // Only the active user's email label is lightened (for the inactive user, the |
| 413 // label starts as black and the entire row is 54% opacity). | 413 // label starts as black and the entire row is 54% opacity). |
| 414 if (is_active_user()) | 414 if (is_active_user()) |
| 415 user_email_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); | 415 user_email_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); |
| 416 auto user_email = new views::Label(); | 416 auto* user_email = new views::Label(); |
| 417 base::string16 user_email_string; | 417 base::string16 user_email_string; |
| 418 if (login_status != LoginStatus::GUEST) { | 418 if (login_status != LoginStatus::GUEST) { |
| 419 user_email_string = | 419 user_email_string = |
| 420 WmShell::Get()->system_tray_delegate()->IsUserSupervised() | 420 WmShell::Get()->system_tray_delegate()->IsUserSupervised() |
| 421 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL) | 421 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL) |
| 422 : base::UTF8ToUTF16( | 422 : base::UTF8ToUTF16( |
| 423 delegate->GetUserInfo(user_index_)->GetDisplayEmail()); | 423 delegate->GetUserInfo(user_index_)->GetDisplayEmail()); |
| 424 } | 424 } |
| 425 user_email->SetText(user_email_string); | 425 user_email->SetText(user_email_string); |
| 426 user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 426 user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 464 |
| 465 media_capture_icon_->set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR); | 465 media_capture_icon_->set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR); |
| 466 AddChildView(media_capture_icon_); | 466 AddChildView(media_capture_icon_); |
| 467 | 467 |
| 468 WmShell::Get()->media_controller()->RequestCaptureState(); | 468 WmShell::Get()->media_controller()->RequestCaptureState(); |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace tray | 472 } // namespace tray |
| 473 } // namespace ash | 473 } // namespace ash |
| OLD | NEW |