#ifndef ASH_SYSTEM_SESSION_LOGOUT_BUTTON_TRAY_H_
#define ASH_SYSTEM_SESSION_LOGOUT_BUTTON_TRAY_H_
#include <memory>
#include "ash/ash_export.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/system/tray/tray_background_view.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"
class PrefChangeRegistrar;
class PrefRegistrySimple;
namespace views {
class MdTextButton;
}
namespace ash {
class Shelf;
class ASH_EXPORT LogoutButtonTray : public TrayBackgroundView,
public SessionObserver {
METADATA_HEADER(LogoutButtonTray, TrayBackgroundView)
public:
explicit LogoutButtonTray(Shelf* shelf);
LogoutButtonTray(const LogoutButtonTray&) = delete;
LogoutButtonTray& operator=(const LogoutButtonTray&) = delete;
~LogoutButtonTray() override;
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
void UpdateAfterLoginStatusChange() override;
void UpdateLayout() override;
void UpdateBackground() override;
void ClickedOutsideBubble(const ui::LocatedEvent& event) override;
void UpdateTrayItemColor(bool is_active) override {}
void HideBubbleWithView(const TrayBubbleView* bubble_view) override;
void HideBubble(const TrayBubbleView* bubble_view) override;
void HandleLocaleChange() override;
void OnThemeChanged() override;
void OnActiveUserPrefServiceChanged(PrefService* prefs) override;
std::u16string GetLoginStatusString();
views::MdTextButton* button_for_test() const { return button_; }
private:
void UpdateShowLogoutButtonInTray();
void UpdateLogoutDialogDuration();
void UpdateVisibility();
void UpdateButtonTextAndImage();
void OnButtonTextChangedCallback(ax::mojom::StringAttribute attribute,
const std::optional<std::string>& name);
void SubscribeCallbacksForAccessibility();
void ButtonPressed();
raw_ptr<views::MdTextButton> button_;
bool show_logout_button_in_tray_ = false;
base::TimeDelta dialog_duration_;
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
base::CallbackListSubscription button_text_changed_subscription_;
};
}
#endif