| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/common/login_status.h" | 10 #include "ash/common/login_status.h" |
| 11 #include "ash/common/material_design/material_design_controller.h" | 11 #include "ash/common/material_design/material_design_controller.h" |
| 12 #include "ash/common/session/session_state_delegate.h" | 12 #include "ash/common/session/session_state_delegate.h" |
| 13 #include "ash/common/system/tray/system_tray_controller.h" | 13 #include "ash/common/system/tray/system_tray_controller.h" |
| 14 #include "ash/common/system/tray/system_tray_delegate.h" | 14 #include "ash/common/system/tray/system_tray_delegate.h" |
| 15 #include "ash/common/system/tray/system_tray_notifier.h" | 15 #include "ash/common/system/tray/system_tray_notifier.h" |
| 16 #include "ash/common/system/tray/tray_constants.h" | 16 #include "ash/common/system/tray/tray_constants.h" |
| 17 #include "ash/common/system/tray/tray_utils.h" | 17 #include "ash/common/system/tray/tray_utils.h" |
| 18 #include "ash/common/system/user/rounded_image_view.h" | 18 #include "ash/common/system/user/rounded_image_view.h" |
| 19 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 20 #include "base/i18n/rtl.h" | 20 #include "base/i18n/rtl.h" |
| 21 #include "base/memory/scoped_vector.h" | 21 #include "base/memory/scoped_vector.h" |
| 22 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 25 #include "components/user_manager/user_info.h" | 25 #include "components/user_manager/user_info.h" |
| 26 #include "grit/ash_resources.h" | 26 #include "grit/ash_resources.h" |
| 27 #include "grit/ash_strings.h" | 27 #include "grit/ash_strings.h" |
| 28 #include "ui/accessibility/ax_view_state.h" | 28 #include "ui/accessibility/ax_node_data.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 31 #include "ui/gfx/geometry/insets.h" | 31 #include "ui/gfx/geometry/insets.h" |
| 32 #include "ui/gfx/geometry/rect.h" | 32 #include "ui/gfx/geometry/rect.h" |
| 33 #include "ui/gfx/geometry/size.h" | 33 #include "ui/gfx/geometry/size.h" |
| 34 #include "ui/gfx/range/range.h" | 34 #include "ui/gfx/range/range.h" |
| 35 #include "ui/gfx/render_text.h" | 35 #include "ui/gfx/render_text.h" |
| 36 #include "ui/gfx/text_elider.h" | 36 #include "ui/gfx/text_elider.h" |
| 37 #include "ui/gfx/text_utils.h" | 37 #include "ui/gfx/text_utils.h" |
| 38 #include "ui/views/border.h" | 38 #include "ui/views/border.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 kTrayPopupPaddingBetweenItems)); | 332 kTrayPopupPaddingBetweenItems)); |
| 333 if (login_status == LoginStatus::PUBLIC) { | 333 if (login_status == LoginStatus::PUBLIC) { |
| 334 AddPublicModeUserContent(max_width); | 334 AddPublicModeUserContent(max_width); |
| 335 } else { | 335 } else { |
| 336 AddUserContent(login_status, user_index); | 336 AddUserContent(login_status, user_index); |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 UserCardView::~UserCardView() {} | 340 UserCardView::~UserCardView() {} |
| 341 | 341 |
| 342 void UserCardView::GetAccessibleState(ui::AXViewState* state) { | 342 void UserCardView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 343 state->role = ui::AX_ROLE_STATIC_TEXT; | 343 node_data->role = ui::AX_ROLE_STATIC_TEXT; |
| 344 std::vector<base::string16> labels; | 344 std::vector<base::string16> labels; |
| 345 for (int i = 0; i < child_count(); ++i) | 345 for (int i = 0; i < child_count(); ++i) |
| 346 GetAccessibleLabelFromDescendantViews(child_at(i), labels); | 346 GetAccessibleLabelFromDescendantViews(child_at(i), labels); |
| 347 state->name = base::JoinString(labels, base::ASCIIToUTF16(" ")); | 347 node_data->SetName(base::JoinString(labels, base::ASCIIToUTF16(" "))); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void UserCardView::AddPublicModeUserContent(int max_width) { | 350 void UserCardView::AddPublicModeUserContent(int max_width) { |
| 351 views::View* icon = CreateIcon(LoginStatus::PUBLIC, 0); | 351 views::View* icon = CreateIcon(LoginStatus::PUBLIC, 0); |
| 352 AddChildView(icon); | 352 AddChildView(icon); |
| 353 int details_max_width = max_width - icon->GetPreferredSize().width() - | 353 int details_max_width = max_width - icon->GetPreferredSize().width() - |
| 354 kTrayPopupPaddingBetweenItems; | 354 kTrayPopupPaddingBetweenItems; |
| 355 AddChildView(new PublicAccountUserDetails(details_max_width)); | 355 AddChildView(new PublicAccountUserDetails(details_max_width)); |
| 356 } | 356 } |
| 357 | 357 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } else { | 447 } else { |
| 448 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); | 448 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); |
| 449 icon->SetImage(delegate->GetUserInfo(user_index)->GetImage(), | 449 icon->SetImage(delegate->GetUserInfo(user_index)->GetImage(), |
| 450 gfx::Size(kTrayItemSize, kTrayItemSize)); | 450 gfx::Size(kTrayItemSize, kTrayItemSize)); |
| 451 } | 451 } |
| 452 return icon; | 452 return icon; |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace tray | 455 } // namespace tray |
| 456 } // namespace ash | 456 } // namespace ash |
| OLD | NEW |