Commit 871469bf authored by Aga Wronska's avatar Aga Wronska Committed by Commit Bot

Make message center label accessible via ChromeVox on lock screen.

Message center label on lock screen provides user with the information
that device needs to be unlocked for access to notifications. This
information needs to be announced by ChromeVox. Announcement for the
label is not needed in unlocked state. Message center should be dismissed
by pressing Esc on the keyboard.

* Make notification label focusable on lock screen so it gets announcement.
* Move accessibility node information to MessageCenterButtonBar, because
otherwise they are not available when needed.
* Move button bar title to MessageCenterButtonBar to avoid the round
trip to fetch it.
* Remove MessageScrollView because it is no longer needed.

Bug: 793330
Change-Id: Ida23d2557973cbcd182d7ea4d2ee3ebec5a100bc
Reviewed-on: https://chromium-review.googlesource.com/894990Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Aga Wronska <agawronska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534095}
parent 572b06f7
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tray_popup_utils.h"
#include "base/macros.h" #include "base/macros.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/simple_menu_model.h" #include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
...@@ -106,7 +107,7 @@ MessageCenterButtonBar::MessageCenterButtonBar( ...@@ -106,7 +107,7 @@ MessageCenterButtonBar::MessageCenterButtonBar(
MessageCenterView* message_center_view, MessageCenterView* message_center_view,
MessageCenter* message_center, MessageCenter* message_center,
bool settings_initially_visible, bool settings_initially_visible,
const base::string16& title) bool locked)
: message_center_view_(message_center_view), : message_center_view_(message_center_view),
message_center_(message_center), message_center_(message_center),
notification_label_(nullptr), notification_label_(nullptr),
...@@ -119,7 +120,7 @@ MessageCenterButtonBar::MessageCenterButtonBar( ...@@ -119,7 +120,7 @@ MessageCenterButtonBar::MessageCenterButtonBar(
views::CreateSolidBackground(message_center_style::kBackgroundColor)); views::CreateSolidBackground(message_center_style::kBackgroundColor));
SetBorder(views::CreateEmptyBorder(kButtonBarBorder)); SetBorder(views::CreateEmptyBorder(kButtonBarBorder));
notification_label_ = new views::Label(title); notification_label_ = new views::Label(GetTitle(locked));
notification_label_->SetAutoColorReadabilityEnabled(false); notification_label_->SetAutoColorReadabilityEnabled(false);
notification_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); notification_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
notification_label_->SetEnabledColor(kTextColor); notification_label_->SetEnabledColor(kTextColor);
...@@ -273,8 +274,25 @@ void MessageCenterButtonBar::OnImplicitAnimationsCompleted() { ...@@ -273,8 +274,25 @@ void MessageCenterButtonBar::OnImplicitAnimationsCompleted() {
button_container_->SetVisible(!collapse_button_visible_); button_container_->SetVisible(!collapse_button_visible_);
} }
void MessageCenterButtonBar::SetTitle(const base::string16& title) { void MessageCenterButtonBar::SetIsLocked(bool locked) {
notification_label_->SetText(title); SetButtonsVisible(!locked);
UpdateLabel(locked);
}
base::string16 MessageCenterButtonBar::GetTitle(bool locked) const {
return locked
? l10n_util::GetStringUTF16(
IDS_ASH_MESSAGE_CENTER_FOOTER_LOCKSCREEN)
: l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_FOOTER_TITLE);
}
void MessageCenterButtonBar::UpdateLabel(bool locked) {
notification_label_->SetText(GetTitle(locked));
// On lock screen button bar label contains hint for user to unlock device to
// view notifications. Making it focusable will invoke ChromeVox spoken
// feedback when shown.
notification_label_->SetFocusBehavior(locked ? FocusBehavior::ALWAYS
: FocusBehavior::NEVER);
} }
void MessageCenterButtonBar::SetButtonsVisible(bool visible) { void MessageCenterButtonBar::SetButtonsVisible(bool visible) {
...@@ -321,6 +339,11 @@ gfx::Size MessageCenterButtonBar::CalculatePreferredSize() const { ...@@ -321,6 +339,11 @@ gfx::Size MessageCenterButtonBar::CalculatePreferredSize() const {
return gfx::Size(0, preferred_height); return gfx::Size(0, preferred_height);
} }
void MessageCenterButtonBar::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kDialog;
node_data->SetName(notification_label_->text());
}
void MessageCenterButtonBar::ButtonPressed(views::Button* sender, void MessageCenterButtonBar::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
if (sender == close_all_button_) { if (sender == close_all_button_) {
......
...@@ -31,11 +31,10 @@ class MessageCenterButtonBar : public views::View, ...@@ -31,11 +31,10 @@ class MessageCenterButtonBar : public views::View,
public views::ButtonListener, public views::ButtonListener,
public ui::ImplicitAnimationObserver { public ui::ImplicitAnimationObserver {
public: public:
MessageCenterButtonBar( MessageCenterButtonBar(MessageCenterView* message_center_view,
MessageCenterView* message_center_view,
message_center::MessageCenter* message_center, message_center::MessageCenter* message_center,
bool settings_initially_visible, bool settings_initially_visible,
const base::string16& title); bool locked);
~MessageCenterButtonBar() override; ~MessageCenterButtonBar() override;
void SetQuietModeState(bool is_quiet_mode); void SetQuietModeState(bool is_quiet_mode);
...@@ -44,6 +43,7 @@ class MessageCenterButtonBar : public views::View, ...@@ -44,6 +43,7 @@ class MessageCenterButtonBar : public views::View,
void ChildVisibilityChanged(views::View* child) override; void ChildVisibilityChanged(views::View* child) override;
void Layout() override; void Layout() override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// Overridden from views::ButtonListener: // Overridden from views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
...@@ -66,10 +66,8 @@ class MessageCenterButtonBar : public views::View, ...@@ -66,10 +66,8 @@ class MessageCenterButtonBar : public views::View,
// Sometimes we shouldn't see the back arrow (not in settings). // Sometimes we shouldn't see the back arrow (not in settings).
void SetBackArrowVisible(bool visible); void SetBackArrowVisible(bool visible);
// Update the label of the title. // Updates notification label and buttons for state specified by |locked|.
void SetTitle(const base::string16& title); void SetIsLocked(bool locked);
void SetButtonsVisible(bool visible);
private: private:
MessageCenterView* message_center_view() const { MessageCenterView* message_center_view() const {
...@@ -79,6 +77,14 @@ class MessageCenterButtonBar : public views::View, ...@@ -79,6 +77,14 @@ class MessageCenterButtonBar : public views::View,
return message_center_; return message_center_;
} }
// Returns title for state specified by |locked|.
base::string16 GetTitle(bool locked) const;
// Updates notification label for state specified by |locked|.
void UpdateLabel(bool locked);
void SetButtonsVisible(bool visible);
MessageCenterView* message_center_view_; MessageCenterView* message_center_view_;
message_center::MessageCenter* message_center_; message_center::MessageCenter* message_center_;
......
...@@ -111,17 +111,16 @@ class EmptyNotificationView : public views::View { ...@@ -111,17 +111,16 @@ class EmptyNotificationView : public views::View {
class MessageCenterScrollView : public views::ScrollView { class MessageCenterScrollView : public views::ScrollView {
public: public:
explicit MessageCenterScrollView(MessageCenterView* owner) : owner_(owner) {} MessageCenterScrollView() = default;
private: private:
// views::View: // views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override { void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->role = ax::mojom::Role::kDialog; node_data->role = ax::mojom::Role::kDialog;
node_data->SetName(owner_->GetButtonBarTitle()); node_data->SetName(
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_FOOTER_TITLE));
} }
MessageCenterView* owner_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterScrollView); DISALLOW_COPY_AND_ASSIGN(MessageCenterScrollView);
}; };
...@@ -150,12 +149,12 @@ MessageCenterView::MessageCenterView( ...@@ -150,12 +149,12 @@ MessageCenterView::MessageCenterView(
SetFocusBehavior(views::View::FocusBehavior::NEVER); SetFocusBehavior(views::View::FocusBehavior::NEVER);
button_bar_ = new MessageCenterButtonBar( button_bar_ = new MessageCenterButtonBar(
this, message_center, initially_settings_visible, GetButtonBarTitle()); this, message_center, initially_settings_visible, is_locked_);
button_bar_->SetCloseAllButtonEnabled(false); button_bar_->SetCloseAllButtonEnabled(false);
const int button_height = button_bar_->GetPreferredSize().height(); const int button_height = button_bar_->GetPreferredSize().height();
scroller_ = new MessageCenterScrollView(this); scroller_ = new MessageCenterScrollView();
if (!switches::IsSidebarEnabled()) { if (!switches::IsSidebarEnabled()) {
scroller_->SetBackgroundColor(kBackgroundColor); scroller_->SetBackgroundColor(kBackgroundColor);
} else { } else {
...@@ -292,12 +291,6 @@ void MessageCenterView::SetIsClosing(bool is_closing) { ...@@ -292,12 +291,6 @@ void MessageCenterView::SetIsClosing(bool is_closing) {
message_center_->AddObserver(this); message_center_->AddObserver(this);
} }
base::string16 MessageCenterView::GetButtonBarTitle() const {
return is_locked_ ?
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_FOOTER_LOCKSCREEN) :
l10n_util::GetStringUTF16(IDS_ASH_MESSAGE_CENTER_FOOTER_TITLE);
}
void MessageCenterView::OnDidChangeFocus(views::View* before, void MessageCenterView::OnDidChangeFocus(views::View* before,
views::View* now) { views::View* now) {
// Update the button visibility when the focus state is changed. // Update the button visibility when the focus state is changed.
...@@ -622,8 +615,7 @@ void MessageCenterView::UpdateButtonBarStatus() { ...@@ -622,8 +615,7 @@ void MessageCenterView::UpdateButtonBarStatus() {
} }
button_bar_->SetBackArrowVisible(mode_ == Mode::SETTINGS); button_bar_->SetBackArrowVisible(mode_ == Mode::SETTINGS);
button_bar_->SetButtonsVisible(!is_locked_); button_bar_->SetIsLocked(is_locked_);
button_bar_->SetTitle(GetButtonBarTitle());
if (!is_locked_) if (!is_locked_)
EnableCloseAllIfAppropriate(); EnableCloseAllIfAppropriate();
......
...@@ -69,8 +69,6 @@ class ASH_EXPORT MessageCenterView ...@@ -69,8 +69,6 @@ class ASH_EXPORT MessageCenterView
void SetIsClosing(bool is_closing); void SetIsClosing(bool is_closing);
base::string16 GetButtonBarTitle() const;
void SetMaxHeight(int max_height) { max_height_ = max_height; } void SetMaxHeight(int max_height) { max_height_ = max_height; }
// Overridden from views::FocusChangeListener // Overridden from views::FocusChangeListener
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment