#ifndef ASH_SYSTEM_MEDIA_MEDIA_TRAY_H_
#define ASH_SYSTEM_MEDIA_MEDIA_TRAY_H_
#include "ash/ash_export.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/style/icon_button.h"
#include "ash/system/media/media_notification_provider_observer.h"
#include "ash/system/tray/tray_background_view.h"
#include "base/memory/raw_ptr.h"
#include "ui/base/metadata/metadata_header_macros.h"
class PrefChangeRegistrar;
class PrefRegistrySimple;
class PrefService;
namespace views {
class Button;
class ImageView;
class View;
class Widget;
}
namespace ash {
class Shelf;
class TrayBubbleWrapper;
class ASH_EXPORT MediaTray : public MediaNotificationProviderObserver,
public TrayBackgroundView,
public SessionObserver {
METADATA_HEADER(MediaTray, TrayBackgroundView)
public:
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
static bool IsPinnedToShelf();
static void SetPinnedToShelf(bool pinned);
class PinButton : public IconButton {
METADATA_HEADER(PinButton, IconButton)
public:
PinButton();
PinButton(const PinButton&) = delete;
PinButton& operator=(const PinButton&) = delete;
~PinButton() override = default;
private:
void ButtonPressed();
};
explicit MediaTray(Shelf* shelf);
MediaTray(const MediaTray&) = delete;
MediaTray& operator=(const MediaTray&) = delete;
~MediaTray() override;
void OnNotificationListChanged() override;
void OnNotificationListViewSizeChanged() override;
void UpdateAfterLoginStatusChange() override;
void HandleLocaleChange() override;
views::Widget* GetBubbleWidget() const override;
TrayBubbleView* GetBubbleView() override;
void ShowBubble() override;
void CloseBubbleInternal() override;
void HideBubbleWithView(const TrayBubbleView* bubble_view) override;
void ClickedOutsideBubble(const ui::LocatedEvent& event) override;
void UpdateTrayItemColor(bool is_active) override;
void OnLockStateChanged(bool locked) override;
void OnActiveUserPrefServiceChanged(PrefService* pref_service) override;
void OnTrayButtonPressed();
void UpdateDisplayState();
void ShowBubbleWithItem(const std::string& item_id);
TrayBubbleWrapper* tray_bubble_wrapper_for_testing() const {
return bubble_.get();
}
views::View* content_view_for_testing() const { return content_view_; }
views::View* pin_button_for_testing() const { return pin_button_; }
private:
friend class MediaTrayTest;
std::u16string GetAccessibleNameForBubble() override;
void HideBubble(const TrayBubbleView* bubble_view) override;
void SetNotificationColorTheme();
void OnGlobalMediaControlsPinPrefChanged();
void ShowEmptyState();
raw_ptr<views::Button> pin_button_ = nullptr;
std::unique_ptr<TrayBubbleWrapper> bubble_;
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
raw_ptr<views::ImageView> icon_;
raw_ptr<views::View> content_view_ = nullptr;
raw_ptr<views::View> empty_state_view_ = nullptr;
bool bubble_has_shown_ = false;
};
}
#endif