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

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

Issue 2041233005: Moves ash::user::LoginStatus to ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test 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
« no previous file with comments | « ash/system/user/user_view.h ('k') | ash/system/web_notification/web_notification_tray.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_view.h" 5 #include "ash/system/user/user_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 // Add the command text. 176 // Add the command text.
177 views::Label* command_label = new views::Label( 177 views::Label* command_label = new views::Label(
178 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT)); 178 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
179 command_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 179 command_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
180 add_user_->AddChildView(command_label); 180 add_user_->AddChildView(command_label);
181 } 181 }
182 182
183 } // namespace 183 } // namespace
184 184
185 UserView::UserView(SystemTrayItem* owner, 185 UserView::UserView(SystemTrayItem* owner, LoginStatus login, UserIndex index)
186 user::LoginStatus login,
187 UserIndex index)
188 : user_index_(index), 186 : user_index_(index),
189 user_card_view_(NULL), 187 user_card_view_(NULL),
190 owner_(owner), 188 owner_(owner),
191 is_user_card_button_(false), 189 is_user_card_button_(false),
192 logout_button_(NULL), 190 logout_button_(NULL),
193 add_user_enabled_(true), 191 add_user_enabled_(true),
194 focus_manager_(NULL) { 192 focus_manager_(NULL) {
195 CHECK_NE(user::LOGGED_IN_NONE, login); 193 CHECK_NE(LoginStatus::NOT_LOGGED_IN, login);
196 if (!index) { 194 if (!index) {
197 // Only the logged in user will have a background. All other users will have 195 // Only the logged in user will have a background. All other users will have
198 // to allow the TrayPopupContainer highlighting the menu line. 196 // to allow the TrayPopupContainer highlighting the menu line.
199 set_background(views::Background::CreateSolidBackground( 197 set_background(views::Background::CreateSolidBackground(
200 login == user::LOGGED_IN_PUBLIC ? kPublicAccountBackgroundColor 198 login == LoginStatus::PUBLIC ? kPublicAccountBackgroundColor
201 : kBackgroundColor)); 199 : kBackgroundColor));
202 } 200 }
203 SetLayoutManager(new views::BoxLayout( 201 SetLayoutManager(new views::BoxLayout(
204 views::BoxLayout::kHorizontal, 0, 0, kTrayPopupPaddingBetweenItems)); 202 views::BoxLayout::kHorizontal, 0, 0, kTrayPopupPaddingBetweenItems));
205 // The logout button must be added before the user card so that the user card 203 // The logout button must be added before the user card so that the user card
206 // can correctly calculate the remaining available width. 204 // can correctly calculate the remaining available width.
207 // Note that only the current multiprofile user gets a button. 205 // Note that only the current multiprofile user gets a button.
208 if (!user_index_) 206 if (!user_index_)
209 AddLogoutButton(login); 207 AddLogoutButton(login);
210 AddUserCard(login); 208 AddUserCard(login);
211 } 209 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 324
327 void UserView::OnWillChangeFocus(View* focused_before, View* focused_now) { 325 void UserView::OnWillChangeFocus(View* focused_before, View* focused_now) {
328 if (focused_now) 326 if (focused_now)
329 RemoveAddUserMenuOption(); 327 RemoveAddUserMenuOption();
330 } 328 }
331 329
332 void UserView::OnDidChangeFocus(View* focused_before, View* focused_now) { 330 void UserView::OnDidChangeFocus(View* focused_before, View* focused_now) {
333 // Nothing to do here. 331 // Nothing to do here.
334 } 332 }
335 333
336 void UserView::AddLogoutButton(user::LoginStatus login) { 334 void UserView::AddLogoutButton(LoginStatus login) {
337 const base::string16 title = 335 const base::string16 title =
338 user::GetLocalizedSignOutStringForStatus(login, true); 336 user::GetLocalizedSignOutStringForStatus(login, true);
339 auto* logout_button = new TrayPopupLabelButton(this, title); 337 auto* logout_button = new TrayPopupLabelButton(this, title);
340 logout_button->SetAccessibleName(title); 338 logout_button->SetAccessibleName(title);
341 logout_button_ = logout_button; 339 logout_button_ = logout_button;
342 // In public account mode, the logout button border has a custom color. 340 // In public account mode, the logout button border has a custom color.
343 if (login == user::LOGGED_IN_PUBLIC) { 341 if (login == LoginStatus::PUBLIC) {
344 std::unique_ptr<TrayPopupLabelButtonBorder> border( 342 std::unique_ptr<TrayPopupLabelButtonBorder> border(
345 new TrayPopupLabelButtonBorder()); 343 new TrayPopupLabelButtonBorder());
346 border->SetPainter(false, 344 border->SetPainter(false,
347 views::Button::STATE_NORMAL, 345 views::Button::STATE_NORMAL,
348 views::Painter::CreateImageGridPainter( 346 views::Painter::CreateImageGridPainter(
349 kPublicAccountLogoutButtonBorderImagesNormal)); 347 kPublicAccountLogoutButtonBorderImagesNormal));
350 border->SetPainter(false, 348 border->SetPainter(false,
351 views::Button::STATE_HOVERED, 349 views::Button::STATE_HOVERED,
352 views::Painter::CreateImageGridPainter( 350 views::Painter::CreateImageGridPainter(
353 kPublicAccountLogoutButtonBorderImagesHovered)); 351 kPublicAccountLogoutButtonBorderImagesHovered));
354 border->SetPainter(false, 352 border->SetPainter(false,
355 views::Button::STATE_PRESSED, 353 views::Button::STATE_PRESSED,
356 views::Painter::CreateImageGridPainter( 354 views::Painter::CreateImageGridPainter(
357 kPublicAccountLogoutButtonBorderImagesHovered)); 355 kPublicAccountLogoutButtonBorderImagesHovered));
358 logout_button_->SetBorder(std::move(border)); 356 logout_button_->SetBorder(std::move(border));
359 } 357 }
360 AddChildView(logout_button_); 358 AddChildView(logout_button_);
361 } 359 }
362 360
363 void UserView::AddUserCard(user::LoginStatus login) { 361 void UserView::AddUserCard(LoginStatus login) {
364 // Add padding around the panel. 362 // Add padding around the panel.
365 SetBorder(views::Border::CreateEmptyBorder(kTrayPopupUserCardVerticalPadding, 363 SetBorder(views::Border::CreateEmptyBorder(kTrayPopupUserCardVerticalPadding,
366 kTrayPopupPaddingHorizontal, 364 kTrayPopupPaddingHorizontal,
367 kTrayPopupUserCardVerticalPadding, 365 kTrayPopupUserCardVerticalPadding,
368 kTrayPopupPaddingHorizontal)); 366 kTrayPopupPaddingHorizontal));
369 367
370 views::TrayBubbleView* bubble_view = 368 views::TrayBubbleView* bubble_view =
371 owner_->system_tray()->GetSystemBubble()->bubble_view(); 369 owner_->system_tray()->GetSystemBubble()->bubble_view();
372 int max_card_width = 370 int max_card_width =
373 bubble_view->GetMaximumSize().width() - 371 bubble_view->GetMaximumSize().width() -
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 insets = gfx::Insets(1, 1, 1, 3); 405 insets = gfx::Insets(1, 1, 1, 3);
408 } 406 }
409 auto* button = 407 auto* button =
410 new ButtonFromView(contents_view, this, !user_index_, insets); 408 new ButtonFromView(contents_view, this, !user_index_, insets);
411 user_card_view_ = button; 409 user_card_view_ = button;
412 is_user_card_button_ = true; 410 is_user_card_button_ = true;
413 } 411 }
414 AddChildViewAt(user_card_view_, 0); 412 AddChildViewAt(user_card_view_, 0);
415 // Card for supervised user can consume more space than currently 413 // Card for supervised user can consume more space than currently
416 // available. In that case we should increase system bubble's width. 414 // available. In that case we should increase system bubble's width.
417 if (login == user::LOGGED_IN_PUBLIC) 415 if (login == LoginStatus::PUBLIC)
418 bubble_view->SetWidth(GetPreferredSize().width()); 416 bubble_view->SetWidth(GetPreferredSize().width());
419 } 417 }
420 418
421 void UserView::ToggleAddUserMenuOption() { 419 void UserView::ToggleAddUserMenuOption() {
422 if (add_menu_option_.get()) { 420 if (add_menu_option_.get()) {
423 RemoveAddUserMenuOption(); 421 RemoveAddUserMenuOption();
424 return; 422 return;
425 } 423 }
426 424
427 // Note: We do not need to install a global event handler to delete this 425 // Note: We do not need to install a global event handler to delete this
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 focus_manager_ = NULL; 523 focus_manager_ = NULL;
526 if (user_card_view_->GetFocusManager()) 524 if (user_card_view_->GetFocusManager())
527 user_card_view_->GetFocusManager()->ClearFocus(); 525 user_card_view_->GetFocusManager()->ClearFocus();
528 popup_message_.reset(); 526 popup_message_.reset();
529 mouse_watcher_.reset(); 527 mouse_watcher_.reset();
530 add_menu_option_.reset(); 528 add_menu_option_.reset();
531 } 529 }
532 530
533 } // namespace tray 531 } // namespace tray
534 } // namespace ash 532 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/user/user_view.h ('k') | ash/system/web_notification/web_notification_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698