diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 17:25:54 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 17:25:54 +0000 |
commit | 856603a213cabe2c7b8e66e314dc041584a38e1a (patch) | |
tree | f8b636050eeb28bd34ca33cc65a5cf7d72441042 /ash | |
parent | c8a61d09266f97873a2ece1657ebd655edfb599f (diff) | |
download | chromium_src-856603a213cabe2c7b8e66e314dc041584a38e1a.zip chromium_src-856603a213cabe2c7b8e66e314dc041584a38e1a.tar.gz chromium_src-856603a213cabe2c7b8e66e314dc041584a38e1a.tar.bz2 |
Initial system tray accessibility fixes
This makes most system tray items keyboard-focusable and gives many of them
an accessible role and name. Some work still remains - please use this as
a guide when finishing support for remaining items!
BUG=119608
TEST=manual testing: open tray, tab through items, open with space/enter, close with esc
Review URL: http://codereview.chromium.org/9838030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/system/audio/tray_volume.cc | 1 | ||||
-rw-r--r-- | ash/system/brightness/tray_brightness.cc | 1 | ||||
-rw-r--r-- | ash/system/network/tray_network.cc | 1 | ||||
-rw-r--r-- | ash/system/settings/tray_settings.cc | 21 | ||||
-rw-r--r-- | ash/system/tray/tray_item_more.cc | 20 | ||||
-rw-r--r-- | ash/system/tray/tray_item_more.h | 7 | ||||
-rw-r--r-- | ash/system/tray/tray_views.cc | 22 | ||||
-rw-r--r-- | ash/system/tray/tray_views.h | 3 | ||||
-rw-r--r-- | ash/system/user/tray_user.cc | 1 |
9 files changed, 77 insertions, 0 deletions
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc index 4fdc77e..e58806b 100644 --- a/ash/system/audio/tray_volume.cc +++ b/ash/system/audio/tray_volume.cc @@ -115,6 +115,7 @@ class VolumeView : public views::View, ash::Shell::GetInstance()->tray_delegate(); slider_ = new views::Slider(this, views::Slider::HORIZONTAL); slider_->SetValue(delegate->GetVolumeLevel()); + slider_->set_focusable(true); AddChildView(slider_); } diff --git a/ash/system/brightness/tray_brightness.cc b/ash/system/brightness/tray_brightness.cc index 0a1e987..6df363a 100644 --- a/ash/system/brightness/tray_brightness.cc +++ b/ash/system/brightness/tray_brightness.cc @@ -45,6 +45,7 @@ class BrightnessView : public views::View, // level of the system. So start with a random value. // http://crosbug.com/26935 slider_->SetValue(0.8f); + slider_->set_focusable(true); AddChildView(slider_); } diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc index 8faa0a8..4b9fe71 100644 --- a/ash/system/network/tray_network.cc +++ b/ash/system/network/tray_network.cc @@ -97,6 +97,7 @@ class NetworkDefaultView : public TrayItemMore { void Update(const NetworkIconInfo& info) { icon_->Update(info); label_->SetText(info.description); + SetAccessibleName(info.description); } private: diff --git a/ash/system/settings/tray_settings.cc b/ash/system/settings/tray_settings.cc index 04b7b8c..0bafcbb 100644 --- a/ash/system/settings/tray_settings.cc +++ b/ash/system/settings/tray_settings.cc @@ -13,6 +13,7 @@ #include "grit/ash_strings.h" #include "grit/ui_resources.h" #include "third_party/skia/include/core/SkColor.h" +#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" #include "ui/views/controls/image_view.h" @@ -39,16 +40,36 @@ class SettingsView : public views::View { label_ = new views::Label(rb.GetLocalizedString( IDS_ASH_STATUS_TRAY_SETTINGS_AND_HELP)); AddChildView(label_); + + set_focusable(true); } virtual ~SettingsView() {} // Overridden from views::View. + bool OnKeyPressed(const views::KeyEvent& event) { + if (event.key_code() == ui::VKEY_SPACE || + event.key_code() == ui::VKEY_RETURN) { + ash::Shell::GetInstance()->tray_delegate()->ShowSettings(); + return true; + } + return false; + } + + // Overridden from views::View. virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE { ash::Shell::GetInstance()->tray_delegate()->ShowSettings(); return true; } + // Overridden from views::View. + void GetAccessibleState(ui::AccessibleViewState* state) { + state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); + state->name = rb.GetLocalizedString( + IDS_ASH_STATUS_TRAY_SETTINGS_AND_HELP); + } + private: views::Label* label_; diff --git a/ash/system/tray/tray_item_more.cc b/ash/system/tray/tray_item_more.cc index cb5c4ec..dd05aed 100644 --- a/ash/system/tray/tray_item_more.cc +++ b/ash/system/tray/tray_item_more.cc @@ -7,6 +7,7 @@ #include "ash/system/tray/system_tray_item.h" #include "ash/system/tray/tray_constants.h" #include "grit/ui_resources.h" +#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" #include "ui/views/controls/image_view.h" @@ -17,6 +18,7 @@ namespace internal { TrayItemMore::TrayItemMore(SystemTrayItem* owner) : owner_(owner), more_(NULL) { + set_focusable(true); } TrayItemMore::~TrayItemMore() { @@ -29,6 +31,15 @@ void TrayItemMore::AddMore() { AddChildView(more_); } +void TrayItemMore::SetAccessibleName(const string16& name) { + accessible_name_ = name; +} + +void TrayItemMore::GetAccessibleState(ui::AccessibleViewState* state) { + state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; + state->name = accessible_name_; +} + void TrayItemMore::Layout() { // Let the box-layout do the layout first. Then move the '>' arrow to right // align. @@ -39,6 +50,15 @@ void TrayItemMore::Layout() { more_->SetBoundsRect(bounds); } +bool TrayItemMore::OnKeyPressed(const views::KeyEvent& event) { + if (event.key_code() == ui::VKEY_SPACE || + event.key_code() == ui::VKEY_RETURN) { + owner_->PopupDetailedView(0, true); + return true; + } + return false; +} + bool TrayItemMore::OnMousePressed(const views::MouseEvent& event) { owner_->PopupDetailedView(0, true); return true; diff --git a/ash/system/tray/tray_item_more.h b/ash/system/tray/tray_item_more.h index dd3aef5..27db542 100644 --- a/ash/system/tray/tray_item_more.h +++ b/ash/system/tray/tray_item_more.h @@ -27,13 +27,20 @@ class TrayItemMore : public views::View { void AddMore(); + void SetAccessibleName(const string16& name); + + // Overridden from View: + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + private: // Overridden from views::View. virtual void Layout() OVERRIDE; + virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; SystemTrayItem* owner_; views::ImageView* more_; + string16 accessible_name_; DISALLOW_COPY_AND_ASSIGN(TrayItemMore); }; diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc index cbc7a7f..efe25ed 100644 --- a/ash/system/tray/tray_views.cc +++ b/ash/system/tray/tray_views.cc @@ -7,6 +7,7 @@ #include "ash/system/tray/tray_constants.h" #include "third_party/skia/include/core/SkBitmap.h" #include "grit/ui_resources.h" +#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" #include "ui/views/controls/label.h" @@ -45,6 +46,7 @@ gfx::Size FixedSizedImageView::GetPreferredSize() { HoverHighlightView::HoverHighlightView(ViewClickListener* listener) : listener_(listener) { set_notify_enter_exit_on_child(true); + set_focusable(true); } HoverHighlightView::~HoverHighlightView() { @@ -63,6 +65,8 @@ void HoverHighlightView::AddIconAndLabel(const SkBitmap& image, views::Label* label = new views::Label(text); label->SetFont(label->font().DeriveFont(0, style)); AddChildView(label); + + accessible_name_ = text; } void HoverHighlightView::AddLabel(const string16& text, @@ -74,6 +78,19 @@ void HoverHighlightView::AddLabel(const string16& text, label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); label->SetFont(label->font().DeriveFont(0, style)); AddChildView(label); + + accessible_name_ = text; +} + +bool HoverHighlightView::OnKeyPressed(const views::KeyEvent& event) { + if (event.key_code() == ui::VKEY_SPACE || + event.key_code() == ui::VKEY_RETURN) { + if (!listener_) + return false; + listener_->ClickedOn(this); + return true; + } + return false; } bool HoverHighlightView::OnMousePressed(const views::MouseEvent& event) { @@ -94,6 +111,11 @@ void HoverHighlightView::OnMouseExited(const views::MouseEvent& event) { SchedulePaint(); } +void HoverHighlightView::GetAccessibleState(ui::AccessibleViewState* state) { + state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; + state->name = accessible_name_; +} + //////////////////////////////////////////////////////////////////////////////// // FixedSizedScrollView diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h index 5c69526..11c9703 100644 --- a/ash/system/tray/tray_views.h +++ b/ash/system/tray/tray_views.h @@ -61,11 +61,14 @@ class HoverHighlightView : public views::View { private: // Overridden from views::View. + virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; ViewClickListener* listener_; + string16 accessible_name_; DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); }; diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc index 74e6962..beb8704 100644 --- a/ash/system/user/tray_user.cc +++ b/ash/system/user/tray_user.cc @@ -51,6 +51,7 @@ class TrayButton : public views::TextButton { hover_border_(views::Border::CreateSolidBorder(1, kButtonStrokeColor)) { set_alignment(ALIGN_CENTER); set_border(NULL); + set_focusable(true); } virtual ~TrayButton() {} |