| 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/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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| 11 #include "ash/session/user_info.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/system/tray/system_tray_delegate.h" | 13 #include "ash/system/tray/system_tray_delegate.h" |
| 13 #include "ash/system/tray/tray_constants.h" | 14 #include "ash/system/tray/tray_constants.h" |
| 14 #include "ash/system/user/config.h" | 15 #include "ash/system/user/config.h" |
| 15 #include "ash/system/user/rounded_image_view.h" | 16 #include "ash/system/user/rounded_image_view.h" |
| 16 #include "base/i18n/rtl.h" | 17 #include "base/i18n/rtl.h" |
| 17 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 18 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 kTrayPopupPaddingHorizontal - kTrayPopupPaddingBetweenItems; | 83 kTrayPopupPaddingHorizontal - kTrayPopupPaddingBetweenItems; |
| 83 const bool rtl = base::i18n::IsRTL(); | 84 const bool rtl = base::i18n::IsRTL(); |
| 84 SetBorder(views::Border::CreateEmptyBorder(kUserDetailsVerticalPadding, | 85 SetBorder(views::Border::CreateEmptyBorder(kUserDetailsVerticalPadding, |
| 85 rtl ? 0 : inner_padding, | 86 rtl ? 0 : inner_padding, |
| 86 kUserDetailsVerticalPadding, | 87 kUserDetailsVerticalPadding, |
| 87 rtl ? inner_padding : 0)); | 88 rtl ? inner_padding : 0)); |
| 88 | 89 |
| 89 // Retrieve the user's display name and wrap it with markers. | 90 // Retrieve the user's display name and wrap it with markers. |
| 90 // Note that since this is a public account it always has to be the primary | 91 // Note that since this is a public account it always has to be the primary |
| 91 // user. | 92 // user. |
| 92 base::string16 display_name = | 93 base::string16 display_name = Shell::GetInstance() |
| 93 Shell::GetInstance()->session_state_delegate()->GetUserDisplayName(0); | 94 ->session_state_delegate() |
| 95 ->GetUserInfo(0) |
| 96 ->GetDisplayName(); |
| 94 base::RemoveChars(display_name, kDisplayNameMark, &display_name); | 97 base::RemoveChars(display_name, kDisplayNameMark, &display_name); |
| 95 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; | 98 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; |
| 96 // Retrieve the domain managing the device and wrap it with markers. | 99 // Retrieve the domain managing the device and wrap it with markers. |
| 97 base::string16 domain = base::UTF8ToUTF16( | 100 base::string16 domain = base::UTF8ToUTF16( |
| 98 Shell::GetInstance()->system_tray_delegate()->GetEnterpriseDomain()); | 101 Shell::GetInstance()->system_tray_delegate()->GetEnterpriseDomain()); |
| 99 base::RemoveChars(domain, kDisplayNameMark, &domain); | 102 base::RemoveChars(domain, kDisplayNameMark, &domain); |
| 100 base::i18n::WrapStringWithLTRFormatting(&domain); | 103 base::i18n::WrapStringWithLTRFormatting(&domain); |
| 101 // Retrieve the label text, inserting the display name and domain. | 104 // Retrieve the label text, inserting the display name and domain. |
| 102 text_ = l10n_util::GetStringFUTF16( | 105 text_ = l10n_util::GetStringFUTF16( |
| 103 IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, display_name, domain); | 106 IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, display_name, domain); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 int multiprofile_index) { | 301 int multiprofile_index) { |
| 299 views::View* icon = CreateIcon(login_status, multiprofile_index); | 302 views::View* icon = CreateIcon(login_status, multiprofile_index); |
| 300 AddChildView(icon); | 303 AddChildView(icon); |
| 301 views::Label* username = NULL; | 304 views::Label* username = NULL; |
| 302 SessionStateDelegate* delegate = | 305 SessionStateDelegate* delegate = |
| 303 Shell::GetInstance()->session_state_delegate(); | 306 Shell::GetInstance()->session_state_delegate(); |
| 304 if (!multiprofile_index) { | 307 if (!multiprofile_index) { |
| 305 base::string16 user_name_string = | 308 base::string16 user_name_string = |
| 306 login_status == user::LOGGED_IN_GUEST | 309 login_status == user::LOGGED_IN_GUEST |
| 307 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL) | 310 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL) |
| 308 : delegate->GetUserDisplayName(multiprofile_index); | 311 : delegate->GetUserInfo(multiprofile_index)->GetDisplayName(); |
| 309 if (user_name_string.empty() && IsMultiAccountSupportedAndUserActive()) | 312 if (user_name_string.empty() && IsMultiAccountSupportedAndUserActive()) |
| 310 user_name_string = | 313 user_name_string = base::ASCIIToUTF16( |
| 311 base::ASCIIToUTF16(delegate->GetUserEmail(multiprofile_index)); | 314 delegate->GetUserInfo(multiprofile_index)->GetEmail()); |
| 312 if (!user_name_string.empty()) { | 315 if (!user_name_string.empty()) { |
| 313 username = new views::Label(user_name_string); | 316 username = new views::Label(user_name_string); |
| 314 username->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 317 username->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 315 } | 318 } |
| 316 } | 319 } |
| 317 | 320 |
| 318 views::Label* additional = NULL; | 321 views::Label* additional = NULL; |
| 319 if (login_status != user::LOGGED_IN_GUEST && | 322 if (login_status != user::LOGGED_IN_GUEST && |
| 320 (multiprofile_index || !IsMultiAccountSupportedAndUserActive())) { | 323 (multiprofile_index || !IsMultiAccountSupportedAndUserActive())) { |
| 321 base::string16 user_email_string = | 324 base::string16 user_email_string = |
| 322 login_status == user::LOGGED_IN_LOCALLY_MANAGED | 325 login_status == user::LOGGED_IN_LOCALLY_MANAGED |
| 323 ? l10n_util::GetStringUTF16( | 326 ? l10n_util::GetStringUTF16( |
| 324 IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL) | 327 IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL) |
| 325 : base::UTF8ToUTF16(delegate->GetUserEmail(multiprofile_index)); | 328 : base::UTF8ToUTF16( |
| 329 delegate->GetUserInfo(multiprofile_index)->GetEmail()); |
| 326 if (!user_email_string.empty()) { | 330 if (!user_email_string.empty()) { |
| 327 additional = new views::Label(user_email_string); | 331 additional = new views::Label(user_email_string); |
| 328 additional->SetFontList( | 332 additional->SetFontList( |
| 329 ui::ResourceBundle::GetSharedInstance().GetFontList( | 333 ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 330 ui::ResourceBundle::SmallFont)); | 334 ui::ResourceBundle::SmallFont)); |
| 331 additional->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 335 additional->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 332 } | 336 } |
| 333 } | 337 } |
| 334 | 338 |
| 335 // Adjust text properties dependent on if it is an active or inactive user. | 339 // Adjust text properties dependent on if it is an active or inactive user. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 365 if (login_status == user::LOGGED_IN_GUEST) { | 369 if (login_status == user::LOGGED_IN_GUEST) { |
| 366 icon->SetImage(*ui::ResourceBundle::GetSharedInstance() | 370 icon->SetImage(*ui::ResourceBundle::GetSharedInstance() |
| 367 .GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON) | 371 .GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON) |
| 368 .ToImageSkia(), | 372 .ToImageSkia(), |
| 369 gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); | 373 gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); |
| 370 } else { | 374 } else { |
| 371 SessionStateDelegate* delegate = | 375 SessionStateDelegate* delegate = |
| 372 Shell::GetInstance()->session_state_delegate(); | 376 Shell::GetInstance()->session_state_delegate(); |
| 373 content::BrowserContext* context = | 377 content::BrowserContext* context = |
| 374 delegate->GetBrowserContextByIndex(multiprofile_index); | 378 delegate->GetBrowserContextByIndex(multiprofile_index); |
| 375 icon->SetImage(delegate->GetUserImage(context), | 379 icon->SetImage(delegate->GetUserInfo(context)->GetImage(), |
| 376 gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); | 380 gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); |
| 377 } | 381 } |
| 378 return icon; | 382 return icon; |
| 379 } | 383 } |
| 380 | 384 |
| 381 } // namespace tray | 385 } // namespace tray |
| 382 } // namespace ash | 386 } // namespace ash |
| OLD | NEW |