| 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_SYSTEM_USER_USER_VIEW_H_ | |
| 6 #define ASH_SYSTEM_USER_USER_VIEW_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "ash/common/session/session_types.h" | |
| 11 #include "ash/common/system/tray/tray_constants.h" | |
| 12 #include "ash/system/user/tray_user.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/mouse_watcher.h" | |
| 18 #include "ui/views/view.h" | |
| 19 | |
| 20 namespace gfx { | |
| 21 class Rect; | |
| 22 class Size; | |
| 23 } | |
| 24 | |
| 25 namespace views { | |
| 26 class FocusManager; | |
| 27 } | |
| 28 | |
| 29 namespace ash { | |
| 30 | |
| 31 enum class LoginStatus; | |
| 32 class PopupMessage; | |
| 33 class SystemTrayItem; | |
| 34 | |
| 35 namespace tray { | |
| 36 | |
| 37 // The view of a user item in system tray bubble. | |
| 38 class UserView : public views::View, | |
| 39 public views::ButtonListener, | |
| 40 public views::MouseWatcherListener, | |
| 41 public views::FocusChangeListener { | |
| 42 public: | |
| 43 UserView(SystemTrayItem* owner, LoginStatus login, UserIndex index); | |
| 44 ~UserView() override; | |
| 45 | |
| 46 // Overridden from MouseWatcherListener: | |
| 47 void MouseMovedOutOfHost() override; | |
| 48 | |
| 49 TrayUser::TestState GetStateForTest() const; | |
| 50 gfx::Rect GetBoundsInScreenOfUserButtonForTest(); | |
| 51 | |
| 52 views::View* user_card_view_for_test() const { return user_card_view_; } | |
| 53 | |
| 54 private: | |
| 55 // Overridden from views::View. | |
| 56 gfx::Size GetPreferredSize() const override; | |
| 57 int GetHeightForWidth(int width) const override; | |
| 58 void Layout() override; | |
| 59 | |
| 60 // Overridden from views::ButtonListener. | |
| 61 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
| 62 | |
| 63 // Overridden from views::FocusChangeListener: | |
| 64 void OnWillChangeFocus(View* focused_before, View* focused_now) override; | |
| 65 void OnDidChangeFocus(View* focused_before, View* focused_now) override; | |
| 66 | |
| 67 void AddLogoutButton(LoginStatus login); | |
| 68 void AddUserCard(LoginStatus login); | |
| 69 | |
| 70 // Create the menu option to add another user. If |disabled| is set the user | |
| 71 // cannot actively click on the item. | |
| 72 void ToggleAddUserMenuOption(); | |
| 73 | |
| 74 // Removes the add user menu option. | |
| 75 void RemoveAddUserMenuOption(); | |
| 76 | |
| 77 UserIndex user_index_; | |
| 78 // The view of the user card. | |
| 79 views::View* user_card_view_; | |
| 80 | |
| 81 // This is the owner system tray item of this view. | |
| 82 SystemTrayItem* owner_; | |
| 83 | |
| 84 // True if |user_card_view_| is a |ButtonFromView| - otherwise it is only | |
| 85 // a |UserCardView|. | |
| 86 bool is_user_card_button_; | |
| 87 | |
| 88 views::View* logout_button_; | |
| 89 std::unique_ptr<PopupMessage> popup_message_; | |
| 90 std::unique_ptr<views::Widget> add_menu_option_; | |
| 91 | |
| 92 // False when the add user panel is visible but not activatable. | |
| 93 bool add_user_enabled_; | |
| 94 | |
| 95 // The mouse watcher which takes care of out of window hover events. | |
| 96 std::unique_ptr<views::MouseWatcher> mouse_watcher_; | |
| 97 | |
| 98 // The focus manager which we use to detect focus changes. | |
| 99 views::FocusManager* focus_manager_; | |
| 100 | |
| 101 DISALLOW_COPY_AND_ASSIGN(UserView); | |
| 102 }; | |
| 103 | |
| 104 } // namespace tray | |
| 105 } // namespace ash | |
| 106 | |
| 107 #endif // ASH_SYSTEM_USER_USER_VIEW_H_ | |
| OLD | NEW |