| 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 |
| 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/media_controller.h" | 13 #include "ash/common/media_controller.h" |
| 14 #include "ash/common/session/session_controller.h" | 14 #include "ash/common/session/session_controller.h" |
| 15 #include "ash/common/system/tray/system_tray_controller.h" | 15 #include "ash/common/system/tray/system_tray_controller.h" |
| 16 #include "ash/common/system/tray/system_tray_delegate.h" | 16 #include "ash/common/system/tray/system_tray_delegate.h" |
| 17 #include "ash/common/system/tray/tray_constants.h" | 17 #include "ash/common/system/tray/tray_constants.h" |
| 18 #include "ash/common/system/tray/tray_popup_item_style.h" | 18 #include "ash/common/system/tray/tray_popup_item_style.h" |
| 19 #include "ash/common/system/user/rounded_image_view.h" | 19 #include "ash/common/system/user/rounded_image_view.h" |
| 20 #include "ash/common/wm_shell.h" | 20 #include "ash/common/wm_shell.h" |
| 21 #include "ash/resources/vector_icons/vector_icons.h" | 21 #include "ash/resources/vector_icons/vector_icons.h" |
| 22 #include "ash/shell.h" |
| 22 #include "ash/strings/grit/ash_strings.h" | 23 #include "ash/strings/grit/ash_strings.h" |
| 23 #include "base/i18n/rtl.h" | 24 #include "base/i18n/rtl.h" |
| 24 #include "base/memory/ptr_util.h" | 25 #include "base/memory/ptr_util.h" |
| 25 #include "base/strings/string16.h" | 26 #include "base/strings/string16.h" |
| 26 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 28 #include "components/user_manager/user_info.h" | 29 #include "components/user_manager/user_info.h" |
| 29 #include "ui/accessibility/ax_node_data.h" | 30 #include "ui/accessibility/ax_node_data.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/compositor/compositing_recorder.h" | 32 #include "ui/compositor/compositing_recorder.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 // Retrieve the user's display name and wrap it with markers. | 121 // Retrieve the user's display name and wrap it with markers. |
| 121 // Note that since this is a public account it always has to be the primary | 122 // Note that since this is a public account it always has to be the primary |
| 122 // user. | 123 // user. |
| 123 base::string16 display_name = base::UTF8ToUTF16( | 124 base::string16 display_name = base::UTF8ToUTF16( |
| 124 WmShell::Get()->session_controller()->GetUserSession(0)->display_name); | 125 WmShell::Get()->session_controller()->GetUserSession(0)->display_name); |
| 125 base::RemoveChars(display_name, kDisplayNameMark, &display_name); | 126 base::RemoveChars(display_name, kDisplayNameMark, &display_name); |
| 126 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; | 127 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; |
| 127 // Retrieve the domain managing the device and wrap it with markers. | 128 // Retrieve the domain managing the device and wrap it with markers. |
| 128 base::string16 domain = base::UTF8ToUTF16( | 129 base::string16 domain = base::UTF8ToUTF16( |
| 129 WmShell::Get()->system_tray_delegate()->GetEnterpriseDomain()); | 130 Shell::Get()->system_tray_delegate()->GetEnterpriseDomain()); |
| 130 base::RemoveChars(domain, kDisplayNameMark, &domain); | 131 base::RemoveChars(domain, kDisplayNameMark, &domain); |
| 131 base::i18n::WrapStringWithLTRFormatting(&domain); | 132 base::i18n::WrapStringWithLTRFormatting(&domain); |
| 132 // Retrieve the label text, inserting the display name and domain. | 133 // Retrieve the label text, inserting the display name and domain. |
| 133 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, | 134 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, |
| 134 display_name, domain); | 135 display_name, domain); |
| 135 | 136 |
| 136 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)); |
| 137 learn_more_->SetUnderline(false); | 138 learn_more_->SetUnderline(false); |
| 138 learn_more_->set_listener(this); | 139 learn_more_->set_listener(this); |
| 139 AddChildView(learn_more_); | 140 AddChildView(learn_more_); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 224 |
| 224 void PublicAccountUserDetails::GetAccessibleNodeData( | 225 void PublicAccountUserDetails::GetAccessibleNodeData( |
| 225 ui::AXNodeData* node_data) { | 226 ui::AXNodeData* node_data) { |
| 226 node_data->role = ui::AX_ROLE_STATIC_TEXT; | 227 node_data->role = ui::AX_ROLE_STATIC_TEXT; |
| 227 node_data->SetName(text_); | 228 node_data->SetName(text_); |
| 228 } | 229 } |
| 229 | 230 |
| 230 void PublicAccountUserDetails::LinkClicked(views::Link* source, | 231 void PublicAccountUserDetails::LinkClicked(views::Link* source, |
| 231 int event_flags) { | 232 int event_flags) { |
| 232 DCHECK_EQ(source, learn_more_); | 233 DCHECK_EQ(source, learn_more_); |
| 233 WmShell::Get()->system_tray_controller()->ShowPublicAccountInfo(); | 234 Shell::Get()->system_tray_controller()->ShowPublicAccountInfo(); |
| 234 } | 235 } |
| 235 | 236 |
| 236 void PublicAccountUserDetails::CalculatePreferredSize() { | 237 void PublicAccountUserDetails::CalculatePreferredSize() { |
| 237 const gfx::FontList font_list; | 238 const gfx::FontList font_list; |
| 238 const gfx::Size link_size = learn_more_->GetPreferredSize(); | 239 const gfx::Size link_size = learn_more_->GetPreferredSize(); |
| 239 const int space_width = | 240 const int space_width = |
| 240 gfx::GetStringWidth(base::ASCIIToUTF16(" "), font_list); | 241 gfx::GetStringWidth(base::ASCIIToUTF16(" "), font_list); |
| 241 const gfx::Insets insets = GetInsets(); | 242 const gfx::Insets insets = GetInsets(); |
| 242 int min_width = link_size.width(); | 243 int min_width = link_size.width(); |
| 243 int max_width = | 244 int max_width = |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 410 |
| 410 TrayPopupItemStyle user_email_style(TrayPopupItemStyle::FontStyle::CAPTION); | 411 TrayPopupItemStyle user_email_style(TrayPopupItemStyle::FontStyle::CAPTION); |
| 411 // 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 |
| 412 // label starts as black and the entire row is 54% opacity). | 413 // label starts as black and the entire row is 54% opacity). |
| 413 if (is_active_user()) | 414 if (is_active_user()) |
| 414 user_email_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); | 415 user_email_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); |
| 415 auto* user_email = new views::Label(); | 416 auto* user_email = new views::Label(); |
| 416 base::string16 user_email_string; | 417 base::string16 user_email_string; |
| 417 if (login_status != LoginStatus::GUEST) { | 418 if (login_status != LoginStatus::GUEST) { |
| 418 user_email_string = | 419 user_email_string = |
| 419 WmShell::Get()->system_tray_delegate()->IsUserSupervised() | 420 Shell::Get()->system_tray_delegate()->IsUserSupervised() |
| 420 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL) | 421 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL) |
| 421 : base::UTF8ToUTF16( | 422 : base::UTF8ToUTF16( |
| 422 controller->GetUserSession(user_index_)->display_email); | 423 controller->GetUserSession(user_index_)->display_email); |
| 423 } | 424 } |
| 424 user_email->SetText(user_email_string); | 425 user_email->SetText(user_email_string); |
| 425 user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 426 user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 426 user_email_style.SetupLabel(user_email); | 427 user_email_style.SetupLabel(user_email); |
| 427 user_email->SetVisible(!user_email_string.empty()); | 428 user_email->SetVisible(!user_email_string.empty()); |
| 428 user_email->set_collapse_when_hidden(true); | 429 user_email->set_collapse_when_hidden(true); |
| 429 | 430 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 463 |
| 463 media_capture_icon_->set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR); | 464 media_capture_icon_->set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR); |
| 464 AddChildView(media_capture_icon_); | 465 AddChildView(media_capture_icon_); |
| 465 | 466 |
| 466 WmShell::Get()->media_controller()->RequestCaptureState(); | 467 WmShell::Get()->media_controller()->RequestCaptureState(); |
| 467 } | 468 } |
| 468 } | 469 } |
| 469 | 470 |
| 470 } // namespace tray | 471 } // namespace tray |
| 471 } // namespace ash | 472 } // namespace ash |
| OLD | NEW |