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

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

Issue 2058173002: mash: Move SystemTrayDelegate ownership to WmShell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review feedback Created 4 years, 6 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
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/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
11 #include "ash/common/system/tray/system_tray_delegate.h" 11 #include "ash/common/system/tray/system_tray_delegate.h"
12 #include "ash/common/system/tray/tray_constants.h" 12 #include "ash/common/system/tray/tray_constants.h"
13 #include "ash/common/wm_shell.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "ash/system/tray/system_tray_notifier.h" 15 #include "ash/system/tray/system_tray_notifier.h"
15 #include "ash/system/tray/tray_utils.h" 16 #include "ash/system/tray/tray_utils.h"
16 #include "ash/system/user/rounded_image_view.h" 17 #include "ash/system/user/rounded_image_view.h"
17 #include "base/i18n/rtl.h" 18 #include "base/i18n/rtl.h"
18 #include "base/memory/scoped_vector.h" 19 #include "base/memory/scoped_vector.h"
19 #include "base/strings/string16.h" 20 #include "base/strings/string16.h"
20 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "components/user_manager/user_info.h" 23 #include "components/user_manager/user_info.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // Note that since this is a public account it always has to be the primary 163 // Note that since this is a public account it always has to be the primary
163 // user. 164 // user.
164 base::string16 display_name = Shell::GetInstance() 165 base::string16 display_name = Shell::GetInstance()
165 ->session_state_delegate() 166 ->session_state_delegate()
166 ->GetUserInfo(0) 167 ->GetUserInfo(0)
167 ->GetDisplayName(); 168 ->GetDisplayName();
168 base::RemoveChars(display_name, kDisplayNameMark, &display_name); 169 base::RemoveChars(display_name, kDisplayNameMark, &display_name);
169 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; 170 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0];
170 // Retrieve the domain managing the device and wrap it with markers. 171 // Retrieve the domain managing the device and wrap it with markers.
171 base::string16 domain = base::UTF8ToUTF16( 172 base::string16 domain = base::UTF8ToUTF16(
172 Shell::GetInstance()->system_tray_delegate()->GetEnterpriseDomain()); 173 WmShell::Get()->system_tray_delegate()->GetEnterpriseDomain());
173 base::RemoveChars(domain, kDisplayNameMark, &domain); 174 base::RemoveChars(domain, kDisplayNameMark, &domain);
174 base::i18n::WrapStringWithLTRFormatting(&domain); 175 base::i18n::WrapStringWithLTRFormatting(&domain);
175 // Retrieve the label text, inserting the display name and domain. 176 // Retrieve the label text, inserting the display name and domain.
176 text_ = l10n_util::GetStringFUTF16( 177 text_ = l10n_util::GetStringFUTF16(
177 IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, display_name, domain); 178 IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, display_name, domain);
178 179
179 learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_ASH_LEARN_MORE)); 180 learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_ASH_LEARN_MORE));
180 learn_more_->SetUnderline(false); 181 learn_more_->SetUnderline(false);
181 learn_more_->set_listener(this); 182 learn_more_->set_listener(this);
182 AddChildView(learn_more_); 183 AddChildView(learn_more_);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 it != lines_.end(); 268 it != lines_.end();
268 ++it) { 269 ++it) {
269 (*it)->Draw(canvas); 270 (*it)->Draw(canvas);
270 } 271 }
271 views::View::OnPaint(canvas); 272 views::View::OnPaint(canvas);
272 } 273 }
273 274
274 void PublicAccountUserDetails::LinkClicked(views::Link* source, 275 void PublicAccountUserDetails::LinkClicked(views::Link* source,
275 int event_flags) { 276 int event_flags) {
276 DCHECK_EQ(source, learn_more_); 277 DCHECK_EQ(source, learn_more_);
277 Shell::GetInstance()->system_tray_delegate()->ShowPublicAccountInfo(); 278 WmShell::Get()->system_tray_delegate()->ShowPublicAccountInfo();
278 } 279 }
279 280
280 void PublicAccountUserDetails::CalculatePreferredSize(int max_allowed_width) { 281 void PublicAccountUserDetails::CalculatePreferredSize(int max_allowed_width) {
281 const gfx::FontList font_list; 282 const gfx::FontList font_list;
282 const gfx::Size link_size = learn_more_->GetPreferredSize(); 283 const gfx::Size link_size = learn_more_->GetPreferredSize();
283 const int space_width = 284 const int space_width =
284 gfx::GetStringWidth(base::ASCIIToUTF16(" "), font_list); 285 gfx::GetStringWidth(base::ASCIIToUTF16(" "), font_list);
285 const gfx::Insets insets = GetInsets(); 286 const gfx::Insets insets = GetInsets();
286 int min_width = link_size.width(); 287 int min_width = link_size.width();
287 int max_width = std::min( 288 int max_width = std::min(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL) 375 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL)
375 : delegate->GetUserInfo(user_index)->GetDisplayName(); 376 : delegate->GetUserInfo(user_index)->GetDisplayName();
376 if (!user_name_string.empty()) { 377 if (!user_name_string.empty()) {
377 user_name = new views::Label(user_name_string); 378 user_name = new views::Label(user_name_string);
378 user_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); 379 user_name->SetHorizontalAlignment(gfx::ALIGN_LEFT);
379 } 380 }
380 } 381 }
381 382
382 views::Label* user_email = NULL; 383 views::Label* user_email = NULL;
383 if (login_status != LoginStatus::GUEST) { 384 if (login_status != LoginStatus::GUEST) {
384 SystemTrayDelegate* tray_delegate = 385 SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate();
385 Shell::GetInstance()->system_tray_delegate();
386 base::string16 user_email_string = 386 base::string16 user_email_string =
387 tray_delegate->IsUserSupervised() 387 tray_delegate->IsUserSupervised()
388 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL) 388 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL)
389 : base::UTF8ToUTF16(delegate->GetUserInfo(user_index)->GetEmail()); 389 : base::UTF8ToUTF16(delegate->GetUserInfo(user_index)->GetEmail());
390 if (!user_email_string.empty()) { 390 if (!user_email_string.empty()) {
391 user_email = new views::Label(user_email_string); 391 user_email = new views::Label(user_email_string);
392 user_email->SetFontList( 392 user_email->SetFontList(
393 ui::ResourceBundle::GetSharedInstance().GetFontList( 393 ui::ResourceBundle::GetSharedInstance().GetFontList(
394 ui::ResourceBundle::SmallFont)); 394 ui::ResourceBundle::SmallFont));
395 user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT); 395 user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 SessionStateDelegate* delegate = 453 SessionStateDelegate* delegate =
454 Shell::GetInstance()->session_state_delegate(); 454 Shell::GetInstance()->session_state_delegate();
455 icon->SetImage(delegate->GetUserInfo(user_index)->GetImage(), 455 icon->SetImage(delegate->GetUserInfo(user_index)->GetImage(),
456 gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); 456 gfx::Size(kTrayAvatarSize, kTrayAvatarSize));
457 } 457 }
458 return icon; 458 return icon;
459 } 459 }
460 460
461 } // namespace tray 461 } // namespace tray
462 } // namespace ash 462 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698