Chromium Code Reviews| 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_view.h" | 5 #include "ash/common/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/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 | 49 |
| 50 namespace ash { | 50 namespace ash { |
| 51 namespace tray { | 51 namespace tray { |
| 52 | 52 |
| 53 namespace { | 53 namespace { |
| 54 | 54 |
| 55 bool UseMd() { | 55 bool UseMd() { |
| 56 return MaterialDesignController::IsSystemTrayMenuMaterial(); | 56 return MaterialDesignController::IsSystemTrayMenuMaterial(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 const int kPublicAccountLogoutButtonBorderImagesNormal[] = { | |
| 60 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 61 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, | |
| 62 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, | |
| 63 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 64 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, | |
| 65 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, | |
| 66 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 67 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, | |
| 68 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_NORMAL_BACKGROUND, | |
| 69 }; | |
| 70 | |
| 71 const int kPublicAccountLogoutButtonBorderImagesHovered[] = { | |
| 72 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 73 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 74 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 75 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 76 IDR_AURA_TRAY_POPUP_LABEL_BUTTON_HOVER_BACKGROUND, | |
| 77 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 78 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 79 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 80 IDR_AURA_TRAY_POPUP_PUBLIC_ACCOUNT_LOGOUT_BUTTON_BORDER, | |
| 81 }; | |
| 82 | |
| 83 // When a hover border is used, it is starting this many pixels before the icon | 59 // When a hover border is used, it is starting this many pixels before the icon |
| 84 // position. | 60 // position. |
| 85 const int kTrayUserTileHoverBorderInset = 10; | 61 const int kTrayUserTileHoverBorderInset = 10; |
| 86 | 62 |
| 87 // Offsetting the popup message relative to the tray menu. | 63 // Offsetting the popup message relative to the tray menu. |
| 88 const int kPopupMessageOffset = 25; | 64 const int kPopupMessageOffset = 25; |
| 89 | 65 |
| 90 // Switch to a user with the given |user_index|. | 66 // Switch to a user with the given |user_index|. |
| 91 void SwitchUser(UserIndex user_index) { | 67 void SwitchUser(UserIndex user_index) { |
| 92 // Do not switch users when the log screen is presented. | 68 // Do not switch users when the log screen is presented. |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 void UserView::OnWillChangeFocus(View* focused_before, View* focused_now) { | 459 void UserView::OnWillChangeFocus(View* focused_before, View* focused_now) { |
| 484 if (focused_now) | 460 if (focused_now) |
| 485 RemoveAddUserMenuOption(); | 461 RemoveAddUserMenuOption(); |
| 486 } | 462 } |
| 487 | 463 |
| 488 void UserView::OnDidChangeFocus(View* focused_before, View* focused_now) { | 464 void UserView::OnDidChangeFocus(View* focused_before, View* focused_now) { |
| 489 // Nothing to do here. | 465 // Nothing to do here. |
| 490 } | 466 } |
| 491 | 467 |
| 492 void UserView::AddLogoutButton(LoginStatus login) { | 468 void UserView::AddLogoutButton(LoginStatus login) { |
| 493 const base::string16 title = | 469 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); |
| 494 user::GetLocalizedSignOutStringForStatus(login, true); | 470 logout_button_ = TrayPopupUtils::CreateTrayPopupBorderlessButton( |
| 495 auto* logout_button = | 471 this, user::GetLocalizedSignOutStringForStatus(login, true)); |
| 496 TrayPopupUtils::CreateTrayPopupBorderlessButton(this, title); | |
| 497 logout_button->SetAccessibleName(title); | |
|
bruthig
2017/02/06 17:42:50
Why are we dropping the accessible name, isn't it
Evan Stade
2017/02/06 18:15:50
this is already done for us in the base class:
htt
bruthig
2017/02/06 18:36:40
Gotcha, thx!
| |
| 498 logout_button_ = logout_button; | |
| 499 if (UseMd()) { | |
| 500 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); | |
| 501 } else if (login == LoginStatus::PUBLIC) { | |
| 502 // In public account mode, the logout button border has a custom color. | |
| 503 std::unique_ptr<TrayPopupLabelButtonBorder> border( | |
| 504 new TrayPopupLabelButtonBorder()); | |
| 505 border->SetPainter(false, views::Button::STATE_NORMAL, | |
| 506 views::Painter::CreateImageGridPainter( | |
| 507 kPublicAccountLogoutButtonBorderImagesNormal)); | |
| 508 border->SetPainter(false, views::Button::STATE_HOVERED, | |
| 509 views::Painter::CreateImageGridPainter( | |
| 510 kPublicAccountLogoutButtonBorderImagesHovered)); | |
| 511 border->SetPainter(false, views::Button::STATE_PRESSED, | |
| 512 views::Painter::CreateImageGridPainter( | |
| 513 kPublicAccountLogoutButtonBorderImagesHovered)); | |
| 514 logout_button_->SetBorder(std::move(border)); | |
| 515 } | |
| 516 AddChildView(logout_button_); | 472 AddChildView(logout_button_); |
| 517 } | 473 } |
| 518 | 474 |
| 519 void UserView::AddUserCard(LoginStatus login) { | 475 void UserView::AddUserCard(LoginStatus login) { |
| 520 if (UseMd()) | 476 if (UseMd()) |
| 521 return AddUserCardMd(login); | 477 return AddUserCardMd(login); |
| 522 | 478 |
| 523 // Add padding around the panel. | 479 // Add padding around the panel. |
| 524 const int kSidePadding = kTrayPopupPaddingHorizontal; | 480 const int kSidePadding = kTrayPopupPaddingHorizontal; |
| 525 SetBorder(views::CreateEmptyBorder( | 481 SetBorder(views::CreateEmptyBorder( |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 focus_manager_ = nullptr; | 697 focus_manager_ = nullptr; |
| 742 if (user_card_view_->GetFocusManager()) | 698 if (user_card_view_->GetFocusManager()) |
| 743 user_card_view_->GetFocusManager()->ClearFocus(); | 699 user_card_view_->GetFocusManager()->ClearFocus(); |
| 744 popup_message_.reset(); | 700 popup_message_.reset(); |
| 745 mouse_watcher_.reset(); | 701 mouse_watcher_.reset(); |
| 746 add_menu_option_.reset(); | 702 add_menu_option_.reset(); |
| 747 } | 703 } |
| 748 | 704 |
| 749 } // namespace tray | 705 } // namespace tray |
| 750 } // namespace ash | 706 } // namespace ash |
| OLD | NEW |