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

Side by Side Diff: trunk/src/ash/system/user/user_card_view.cc

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

Powered by Google App Engine
This is Rietveld 408576698