| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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_LOGOUT_BUTTON_LOGOUT_BUTTON_TRAY_H_ | |
| 6 #define ASH_SYSTEM_LOGOUT_BUTTON_LOGOUT_BUTTON_TRAY_H_ | |
| 7 | |
| 8 #include "ash/ash_export.h" | |
| 9 #include "ash/system/logout_button/logout_button_observer.h" | |
| 10 #include "ash/system/logout_button/logout_confirmation_dialog_view.h" | |
| 11 #include "ash/system/tray/tray_background_view.h" | |
| 12 #include "ash/system/user/login_status.h" | |
| 13 #include "base/basictypes.h" | |
| 14 #include "base/compiler_specific.h" | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/time/time.h" | |
| 17 #include "ui/views/controls/button/button.h" | |
| 18 | |
| 19 namespace views { | |
| 20 class LabelButton; | |
| 21 } | |
| 22 | |
| 23 namespace ash { | |
| 24 namespace internal { | |
| 25 | |
| 26 class StatusAreaWidget; | |
| 27 | |
| 28 // Adds a logout button to the launcher's status area if enabled by the | |
| 29 // kShowLogoutButtonInTray pref. | |
| 30 class ASH_EXPORT LogoutButtonTray : public TrayBackgroundView, | |
| 31 public LogoutButtonObserver, | |
| 32 public views::ButtonListener { | |
| 33 public: | |
| 34 explicit LogoutButtonTray(StatusAreaWidget* status_area_widget); | |
| 35 virtual ~LogoutButtonTray(); | |
| 36 | |
| 37 // TrayBackgroundView: | |
| 38 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; | |
| 39 virtual base::string16 GetAccessibleNameForTray() OVERRIDE; | |
| 40 virtual void HideBubbleWithView( | |
| 41 const views::TrayBubbleView* bubble_view) OVERRIDE; | |
| 42 virtual bool ClickedOutsideBubble() OVERRIDE; | |
| 43 | |
| 44 // LogoutButtonObserver: | |
| 45 virtual void OnShowLogoutButtonInTrayChanged(bool show) OVERRIDE; | |
| 46 virtual void OnLogoutDialogDurationChanged(base::TimeDelta duration) OVERRIDE; | |
| 47 | |
| 48 // views::ButtonListener: | |
| 49 virtual void ButtonPressed(views::Button* sender, | |
| 50 const ui::Event& event) OVERRIDE; | |
| 51 | |
| 52 void UpdateAfterLoginStatusChange(user::LoginStatus login_status); | |
| 53 | |
| 54 // Nullify the pointer to confirmation dialog, this is expected to be called | |
| 55 // when the confirmation dialog is going to be destroyed. | |
| 56 // Note: the confirmation dialog is not owned by LogoutButtonTray. | |
| 57 void ReleaseConfirmationDialog(); | |
| 58 | |
| 59 void SetDelegateForTest( | |
| 60 scoped_ptr<LogoutConfirmationDialogView::Delegate> delegate); | |
| 61 | |
| 62 private: | |
| 63 friend class LogoutConfirmationDialogTest; | |
| 64 | |
| 65 bool IsConfirmationDialogShowing() const; | |
| 66 void EnsureConfirmationDialogIsShowing(); | |
| 67 void EnsureConfirmationDialogIsClosed(); | |
| 68 | |
| 69 void UpdateVisibility(); | |
| 70 | |
| 71 views::LabelButton* button_; // Not owned. | |
| 72 user::LoginStatus login_status_; | |
| 73 bool show_logout_button_in_tray_; | |
| 74 base::TimeDelta dialog_duration_; | |
| 75 | |
| 76 LogoutConfirmationDialogView* confirmation_dialog_; // Not owned. | |
| 77 scoped_ptr<LogoutConfirmationDialogView::Delegate> confirmation_delegate_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(LogoutButtonTray); | |
| 80 }; | |
| 81 | |
| 82 } // namespace internal | |
| 83 } // namespace ash | |
| 84 | |
| 85 #endif // ASH_SYSTEM_LOGOUT_BUTTON_LOGOUT_BUTTON_TRAY_H_ | |
| OLD | NEW |