Commit 918862d7 authored by stevenjb@chromium.org's avatar stevenjb@chromium.org

Fix accessability for web notification tray.

This makes the system tray the first child so that it is the first tray focused when the status area widget is selected via accessibility.

This depends on http://codereview.chromium.org/10823350/

BUG=142506
For ash/ash_strings.grd:
TBR=sky@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10825389

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152135 0039d316-1c4b-4281-b951-d872f2087c98
parent c254ab51
......@@ -440,6 +440,9 @@ Press Search key to cancel.
<message name="IDS_ASH_WEB_NOTFICATION_TRAY_NO_MESSAGES" desc="The message displayed in the message center when there are no notifications.">
You have no notifications. Relax!
</message>
<message name="IDS_ASH_WEB_NOTIFICATION_TRAY_ACCESSIBLE_NAME" desc="The accessible name of the web notification tray (message center).">
Message Center
</message>
<message name="IDS_ASH_MAXIMIZE_WINDOW" desc="A help text to show that when the button gets clicked the window get maximized.">
Maximize
</message>
......
......@@ -327,8 +327,8 @@ StatusAreaWidget::~StatusAreaWidget() {
}
void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) {
AddWebNotificationTray();
AddSystemTray(shell_delegate);
AddWebNotificationTray();
// Initialize() must be called after all trays have been created.
if (system_tray_)
system_tray_->Initialize();
......
......@@ -96,14 +96,14 @@ void StatusAreaWidgetDelegate::UpdateLayout() {
views::GridLayout::USE_PREF, 0, 0);
}
layout->StartRow(0, 0);
for (int c = 0; c < child_count(); ++c)
for (int c = child_count() - 1; c >= 0; --c)
layout->AddView(child_at(c));
} else {
columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
0, /* resize percent */
views::GridLayout::USE_PREF, 0, 0);
for (int c = 0; c < child_count(); ++c) {
if (c != 0)
for (int c = child_count() - 1; c >= 0; --c) {
if (c != child_count() - 1)
layout->AddPaddingRow(0, kTraySpacing);
layout->StartRow(0, 0);
layout->AddView(child_at(c));
......
......@@ -35,7 +35,6 @@
#include "base/utf_string_conversions.h"
#include "grit/ash_strings.h"
#include "ui/aura/root_window.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/base/events.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer.h"
......@@ -423,6 +422,10 @@ void SystemTray::AnchorUpdated() {
bubble_->bubble_view()->UpdateBubble();
}
string16 SystemTray::GetAccessibleName() {
return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME);
}
bool SystemTray::PerformAction(const ui::Event& event) {
// If we're already showing the default view, hide it; otherwise, show it
// (and hide any popup that's currently shown).
......@@ -445,10 +448,4 @@ bool SystemTray::PerformAction(const ui::Event& event) {
return true;
}
void SystemTray::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
state->name = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME);
}
} // namespace ash
......@@ -156,6 +156,7 @@ class ASH_EXPORT SystemTray : public internal::TrayBackgroundView {
virtual void Initialize() OVERRIDE;
virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
virtual void AnchorUpdated() OVERRIDE;
virtual string16 GetAccessibleName() OVERRIDE;
private:
friend class internal::SystemTrayBubble;
......@@ -192,9 +193,6 @@ class ASH_EXPORT SystemTray : public internal::TrayBackgroundView {
// Overridden from internal::ActionableView.
virtual bool PerformAction(const ui::Event& event) OVERRIDE;
// Overridden from views::View.
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
// Owned items.
ScopedVector<SystemTrayItem> items_;
......
......@@ -333,6 +333,10 @@ void SystemTrayBubble::OnClickedOutsideView() {
bubble_widget_->Close();
}
string16 SystemTrayBubble::GetAccessibleName() {
return tray_->GetAccessibleName();
}
void SystemTrayBubble::DestroyItemViews() {
for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin();
it != items_.end();
......
......@@ -49,6 +49,7 @@ class SystemTrayBubble : public TrayBubbleView::Host,
virtual void OnMouseEnteredView() OVERRIDE;
virtual void OnMouseExitedView() OVERRIDE;
virtual void OnClickedOutsideView() OVERRIDE;
virtual string16 GetAccessibleName() OVERRIDE;
BubbleType bubble_type() const { return bubble_type_; }
TrayBubbleView* bubble_view() const { return bubble_view_; }
......
......@@ -11,6 +11,7 @@
#include "ash/system/status_area_widget_delegate.h"
#include "ash/system/tray/tray_constants.h"
#include "ui/aura/window.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/skia_util.h"
......@@ -206,10 +207,15 @@ void TrayBackgroundView::OnPaintFocusBorder(gfx::Canvas* canvas) {
// The tray itself expands to the right and bottom edge of the screen to make
// sure clicking on the edges brings up the popup. However, the focus border
// should be only around the container.
if (GetWidget() && GetWidget()->IsActive())
if (HasFocus() && (focusable() || IsAccessibilityFocusable()))
DrawBorder(canvas, GetContentsBounds());
}
void TrayBackgroundView::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
state->name = GetAccessibleName();
}
void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) {
// Return focus to the login view. See crbug.com/120500.
views::View* v = GetNextFocusableView();
......@@ -251,9 +257,8 @@ void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
void TrayBackgroundView::SetBorder() {
views::View* parent = status_area_widget_->status_area_widget_delegate();
int child_count = parent->child_count();
DCHECK(child_count > 0);
int on_edge = (this == parent->child_at(child_count-1));
// Tray views are laid out right-to-left or bottom-to-top
int on_edge = (this == parent->child_at(0));
// Change the border padding for different shelf alignment.
if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
set_border(views::Border::CreateEmptyBorder(
......
......@@ -67,6 +67,7 @@ class ASH_EXPORT TrayBackgroundView : public internal::ActionableView,
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE;
// Overridden from internal::ActionableView.
......@@ -81,6 +82,8 @@ class ASH_EXPORT TrayBackgroundView : public internal::ActionableView,
// Called when the anchor (tray or bubble) may have moved or changed.
virtual void AnchorUpdated() {}
virtual string16 GetAccessibleName() = 0;
// Sets |contents| as a child and sets its background to |background_|.
void SetContents(views::View* contents);
......
......@@ -404,8 +404,7 @@ void TrayBubbleView::OnMouseExited(const ui::MouseEvent& event) {
void TrayBubbleView::GetAccessibleState(ui::AccessibleViewState* state) {
if (params_.can_activate) {
state->role = ui::AccessibilityTypes::ROLE_WINDOW;
state->name = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME);
state->name = host_->GetAccessibleName();
}
}
......
......@@ -45,6 +45,7 @@ class TrayBubbleView : public views::BubbleDelegateView {
virtual void OnMouseEnteredView() = 0;
virtual void OnMouseExitedView() = 0;
virtual void OnClickedOutsideView() = 0;
virtual string16 GetAccessibleName() = 0;
// Overridden from aura::EventFilter.
virtual bool PreHandleKeyEvent(aura::Window* target,
......
......@@ -717,6 +717,7 @@ class WebNotificationTray::Bubble : public TrayBubbleView::Host,
init_params.bubble_width = kWebNotificationWidth;
if (bubble_type == BUBBLE_TYPE_MESAGE_CENTER) {
init_params.max_height = kWebNotificationBubbleMaxHeight;
init_params.can_activate = true;
} else {
init_params.arrow_color = kBackgroundColor;
init_params.close_on_deactivate = false;
......@@ -790,6 +791,10 @@ class WebNotificationTray::Bubble : public TrayBubbleView::Host,
tray_->HideMessageCenterBubble();
}
virtual string16 GetAccessibleName() OVERRIDE {
return tray_->GetAccessibleName();
}
// Overridden from views::WidgetObserver:
virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE {
CHECK_EQ(bubble_widget_, widget);
......@@ -997,6 +1002,11 @@ void WebNotificationTray::AnchorUpdated() {
message_center_bubble_->bubble_view()->UpdateBubble();
}
string16 WebNotificationTray::GetAccessibleName() {
return l10n_util::GetStringUTF16(
IDS_ASH_WEB_NOTIFICATION_TRAY_ACCESSIBLE_NAME);
}
// Protected methods (invoked only from Bubble and its child classes)
void WebNotificationTray::SendRemoveNotification(const std::string& id) {
......
......@@ -125,6 +125,7 @@ class ASH_EXPORT WebNotificationTray : public internal::TrayBackgroundView {
// Overridden from TrayBackgroundView.
virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
virtual void AnchorUpdated() OVERRIDE;
virtual string16 GetAccessibleName() OVERRIDE;
// Overridden from internal::ActionableView.
virtual bool PerformAction(const ui::Event& event) OVERRIDE;
......
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