| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_COMMON_SYSTEM_USER_USER_VIEW_H_ | |
| 6 #define ASH_COMMON_SYSTEM_USER_USER_VIEW_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "ash/common/system/tray/tray_constants.h" | |
| 11 #include "ash/common/system/user/tray_user.h" | |
| 12 #include "ash/public/cpp/session_types.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "ui/views/controls/button/button.h" | |
| 15 #include "ui/views/focus/focus_manager.h" | |
| 16 #include "ui/views/layout/box_layout.h" | |
| 17 #include "ui/views/view.h" | |
| 18 | |
| 19 namespace gfx { | |
| 20 class Rect; | |
| 21 } | |
| 22 | |
| 23 namespace views { | |
| 24 class FocusManager; | |
| 25 } | |
| 26 | |
| 27 namespace ash { | |
| 28 | |
| 29 enum class LoginStatus; | |
| 30 class SystemTrayItem; | |
| 31 | |
| 32 namespace tray { | |
| 33 | |
| 34 // The view of a user item in system tray bubble. | |
| 35 class UserView : public views::View, | |
| 36 public views::ButtonListener, | |
| 37 public views::FocusChangeListener { | |
| 38 public: | |
| 39 UserView(SystemTrayItem* owner, LoginStatus login, UserIndex index); | |
| 40 ~UserView() override; | |
| 41 | |
| 42 TrayUser::TestState GetStateForTest() const; | |
| 43 gfx::Rect GetBoundsInScreenOfUserButtonForTest(); | |
| 44 | |
| 45 views::View* user_card_view_for_test() const { return user_card_view_; } | |
| 46 | |
| 47 private: | |
| 48 // Retruns true if |this| view is for the currently active user, i.e. top row. | |
| 49 bool IsActiveUser() const; | |
| 50 | |
| 51 // Overridden from views::View. | |
| 52 int GetHeightForWidth(int width) const override; | |
| 53 | |
| 54 // Overridden from views::ButtonListener. | |
| 55 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
| 56 | |
| 57 // Overridden from views::FocusChangeListener: | |
| 58 void OnWillChangeFocus(View* focused_before, View* focused_now) override; | |
| 59 void OnDidChangeFocus(View* focused_before, View* focused_now) override; | |
| 60 | |
| 61 void AddLogoutButton(LoginStatus login); | |
| 62 void AddUserCard(LoginStatus login); | |
| 63 | |
| 64 // Create the menu option to add another user. If |disabled| is set the user | |
| 65 // cannot actively click on the item. | |
| 66 void ToggleAddUserMenuOption(); | |
| 67 | |
| 68 // Removes the add user menu option. | |
| 69 void RemoveAddUserMenuOption(); | |
| 70 | |
| 71 const UserIndex user_index_; | |
| 72 views::View* user_card_view_; | |
| 73 | |
| 74 // This is the owner system tray item of this view. | |
| 75 SystemTrayItem* owner_; | |
| 76 | |
| 77 // True if |user_card_view_| is a |ButtonFromView| - otherwise it is only | |
| 78 // a |UserCardView|. | |
| 79 bool is_user_card_button_; | |
| 80 | |
| 81 views::View* logout_button_; | |
| 82 std::unique_ptr<views::Widget> add_menu_option_; | |
| 83 | |
| 84 // False when the add user panel is visible but not activatable. | |
| 85 bool add_user_enabled_; | |
| 86 | |
| 87 // The focus manager which we use to detect focus changes. | |
| 88 views::FocusManager* focus_manager_; | |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(UserView); | |
| 91 }; | |
| 92 | |
| 93 } // namespace tray | |
| 94 } // namespace ash | |
| 95 | |
| 96 #endif // ASH_COMMON_SYSTEM_USER_USER_VIEW_H_ | |
| OLD | NEW |