#ifndef ASH_SYSTEM_NOTIFICATION_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_
#define ASH_SYSTEM_NOTIFICATION_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_
#include <memory>
#include <set>
#include "ash/ash_export.h"
#include "ash/public/cpp/notifier_settings_observer.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/message_center/public/cpp/notifier_id.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/view.h"
namespace views {
class Label;
class ScrollBar;
class ToggleButton;
}
namespace ash {
class ASH_EXPORT NotifierSettingsView : public views::View,
public NotifierSettingsObserver {
METADATA_HEADER(NotifierSettingsView, views::View)
public:
NotifierSettingsView();
NotifierSettingsView(const NotifierSettingsView&) = delete;
NotifierSettingsView& operator=(const NotifierSettingsView&) = delete;
~NotifierSettingsView() override;
bool IsScrollable();
void SetQuietModeState(bool is_quiet_mode);
void OnNotifiersUpdated(
const std::vector<NotifierMetadata>& notifiers) override;
void OnNotifierIconUpdated(const message_center::NotifierId& notifier_id,
const gfx::ImageSkia& icon) override;
views::ScrollView* get_scroller_view_for_test() { return scroller_; }
views::Label* get_notification_settings_lable_for_test() {
return notification_settings_label_;
}
views::ImageView* get_quiet_mode_icon_view_for_test() {
return quiet_mode_icon_;
}
views::ToggleButton* get_quiet_mode_toggle_for_test() {
return quiet_mode_toggle_;
}
private:
FRIEND_TEST_ALL_PREFIXES(NotifierSettingsViewTest, TestLearnMoreButton);
FRIEND_TEST_ALL_PREFIXES(NotifierSettingsViewTest, TestEmptyNotifierView);
FRIEND_TEST_ALL_PREFIXES(NotifierSettingsViewTest,
NotifierButtonsAccessibleProperties);
class ASH_EXPORT NotifierButton : public views::Button {
METADATA_HEADER(NotifierButton, views::Button)
public:
explicit NotifierButton(const NotifierMetadata& notifier);
NotifierButton(const NotifierButton&) = delete;
NotifierButton& operator=(const NotifierButton&) = delete;
~NotifierButton() override;
void UpdateIconImage(const gfx::ImageSkia& icon);
void SetChecked(bool checked);
bool GetChecked() const;
const message_center::NotifierId& notifier_id() const {
return notifier_id_;
}
private:
FRIEND_TEST_ALL_PREFIXES(NotifierSettingsViewTest,
NotifierButtonsAccessibleProperties);
void GridChanged();
message_center::NotifierId notifier_id_;
raw_ptr<views::ImageView> icon_view_ = nullptr;
raw_ptr<views::Label> name_view_ = nullptr;
raw_ptr<views::Checkbox> checkbox_ = nullptr;
void OnAccessibleRoleChangedCallback(ax::mojom::Role role);
void OnAccessibleNameChangedCallback(
ax::mojom::StringAttribute attribute,
const std::optional<std::string>& name);
void OnAccessibleCheckedStateChangedCallback(
ax::mojom::IntAttribute attribute,
std::optional<int> value);
void OnAccessibleIsDefaultChangedCallback(ax::mojom::State state,
bool is_default);
void OnAccessibleIsEnabledChangedCallback(ax::mojom::IntAttribute attribute,
std::optional<int> value);
void OnAccessibleHoveredChangedCallback(ax::mojom::State state, bool value);
void OnAccessibleDefaultActionVerbChangedCallback(
ax::mojom::IntAttribute attribute,
std::optional<int> value);
void SubscribeCallbacksForAccessibility();
base::CallbackListSubscription role_changed_subscription_;
base::CallbackListSubscription name_changed_subscription_;
base::CallbackListSubscription checked_state_changed_subscription_;
base::CallbackListSubscription is_default_changed_subscription_;
base::CallbackListSubscription is_enabled_changed_subscription_;
base::CallbackListSubscription hovered_changed_subscription_;
base::CallbackListSubscription default_action_verb_changed_subscription_;
};
void Layout(PassKey) override;
gfx::Size GetMinimumSize() const override;
gfx::Size CalculatePreferredSize(
const views::SizeBounds& available_size) const override;
bool OnKeyPressed(const ui::KeyEvent& event) override;
bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
std::unique_ptr<views::View> CreateToggleButtonRow(
std::unique_ptr<views::ImageView> icon,
std::unique_ptr<views::Label> label,
std::unique_ptr<views::ToggleButton> toggle_button);
void AppBadgingTogglePressed();
void QuietModeTogglePressed();
void NotifierButtonPressed(NotifierButton* button);
raw_ptr<views::ToggleButton> app_badging_toggle_ = nullptr;
raw_ptr<views::ImageView> quiet_mode_icon_ = nullptr;
raw_ptr<views::ToggleButton> quiet_mode_toggle_ = nullptr;
raw_ptr<views::View> header_view_ = nullptr;
raw_ptr<views::Label> notification_settings_label_ = nullptr;
raw_ptr<views::Label> top_label_ = nullptr;
raw_ptr<views::ScrollBar> scroll_bar_ = nullptr;
raw_ptr<views::ScrollView> scroller_ = nullptr;
raw_ptr<views::View> no_notifiers_view_ = nullptr;
std::set<raw_ptr<NotifierButton, SetExperimental>> buttons_;
};
}
#endif