logout_button_tray.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef ASH_SYSTEM_SESSION_LOGOUT_BUTTON_TRAY_H_
  5. #define ASH_SYSTEM_SESSION_LOGOUT_BUTTON_TRAY_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ash/public/cpp/session/session_observer.h"
  9. #include "ash/system/tray/tray_background_view.h"
  10. #include "base/time/time.h"
  11. #include "ui/views/controls/button/button.h"
  12. #include "ui/views/view.h"
  13. class PrefChangeRegistrar;
  14. class PrefRegistrySimple;
  15. namespace views {
  16. class MdTextButton;
  17. }
  18. namespace ash {
  19. class Shelf;
  20. // Adds a logout button to the shelf's status area if enabled by the
  21. // kShowLogoutButtonInTray pref.
  22. class ASH_EXPORT LogoutButtonTray : public TrayBackgroundView,
  23. public SessionObserver {
  24. public:
  25. explicit LogoutButtonTray(Shelf* shelf);
  26. LogoutButtonTray(const LogoutButtonTray&) = delete;
  27. LogoutButtonTray& operator=(const LogoutButtonTray&) = delete;
  28. ~LogoutButtonTray() override;
  29. static void RegisterProfilePrefs(PrefRegistrySimple* registry);
  30. // TrayBackgroundView:
  31. void UpdateAfterLoginStatusChange() override;
  32. void UpdateLayout() override;
  33. void UpdateBackground() override;
  34. void ClickedOutsideBubble() override;
  35. void HideBubbleWithView(const TrayBubbleView* bubble_view) override;
  36. std::u16string GetAccessibleNameForTray() override;
  37. void HandleLocaleChange() override;
  38. const char* GetClassName() const override;
  39. void OnThemeChanged() override;
  40. // SessionObserver:
  41. void OnActiveUserPrefServiceChanged(PrefService* prefs) override;
  42. views::MdTextButton* button_for_test() const { return button_; }
  43. private:
  44. void UpdateShowLogoutButtonInTray();
  45. void UpdateLogoutDialogDuration();
  46. void UpdateVisibility();
  47. void UpdateButtonTextAndImage();
  48. void ButtonPressed();
  49. views::MdTextButton* button_;
  50. bool show_logout_button_in_tray_ = false;
  51. base::TimeDelta dialog_duration_;
  52. // Observes user profile prefs.
  53. std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
  54. };
  55. } // namespace ash
  56. #endif // ASH_SYSTEM_SESSION_LOGOUT_BUTTON_TRAY_H_