diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 07:30:51 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 07:30:51 +0000 |
commit | 2b1fbb9ddee254ec1b427c993e1b5db54e7c5fa5 (patch) | |
tree | 5b5cb8a75e67c5f474a3bae04258d0aa1639ac1d /ash/launcher | |
parent | 1f9a6d1bbb415d8ebd7403ddb41534441a4a6b0d (diff) | |
download | chromium_src-2b1fbb9ddee254ec1b427c993e1b5db54e7c5fa5.zip chromium_src-2b1fbb9ddee254ec1b427c993e1b5db54e7c5fa5.tar.gz chromium_src-2b1fbb9ddee254ec1b427c993e1b5db54e7c5fa5.tar.bz2 |
Reland http://codereview.chromium.org/9121050/ with fix for aura_win
Add accessible names to the launcher buttons
BUG=104192
TEST=None
Review URL: https://chromiumcodereview.appspot.com/9307037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120950 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/launcher')
-rw-r--r-- | ash/launcher/app_launcher_button.cc | 6 | ||||
-rw-r--r-- | ash/launcher/app_launcher_button.h | 1 | ||||
-rw-r--r-- | ash/launcher/launcher_button_host.h | 5 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 25 | ||||
-rw-r--r-- | ash/launcher/launcher_view.h | 1 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.cc | 6 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.h | 1 |
7 files changed, 45 insertions, 0 deletions
diff --git a/ash/launcher/app_launcher_button.cc b/ash/launcher/app_launcher_button.cc index ae23d19..cc73255 100644 --- a/ash/launcher/app_launcher_button.cc +++ b/ash/launcher/app_launcher_button.cc @@ -7,6 +7,7 @@ #include <algorithm> #include "ash/launcher/launcher_button_host.h" +#include "ui/base/accessibility/accessible_view_state.h" #include "ui/gfx/canvas_skia.h" namespace ash { @@ -81,5 +82,10 @@ void AppLauncherButton::OnMouseExited(const views::MouseEvent& event) { host_->MouseExitedButton(this); } +void AppLauncherButton::GetAccessibleState(ui::AccessibleViewState* state) { + state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; + state->name = host_->GetAccessibleName(this); +} + } // namespace internal } // namespace ash diff --git a/ash/launcher/app_launcher_button.h b/ash/launcher/app_launcher_button.h index 8084062..bcd4f8c 100644 --- a/ash/launcher/app_launcher_button.h +++ b/ash/launcher/app_launcher_button.h @@ -31,6 +31,7 @@ class AppLauncherButton : public views::ImageButton { virtual void OnMouseCaptureLost() OVERRIDE; virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; private: LauncherButtonHost* host_; diff --git a/ash/launcher/launcher_button_host.h b/ash/launcher/launcher_button_host.h index 1cc9461..2c81385 100644 --- a/ash/launcher/launcher_button_host.h +++ b/ash/launcher/launcher_button_host.h @@ -6,6 +6,8 @@ #define ASH_LAUNCHER_LAUNCHER_BUTTON_HOST_H_ #pragma once +#include "base/string16.h" + namespace views { class MouseEvent; class View; @@ -33,6 +35,9 @@ class LauncherButtonHost { // Invoked when the mouse exits the item. virtual void MouseExitedButton(views::View* view) = 0; + // Invoked to get the accessible name of the item. + virtual string16 GetAccessibleName(views::View* view) = 0; + protected: virtual ~LauncherButtonHost() {} }; diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index d674bb3..ec93a28 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -13,10 +13,12 @@ #include "ash/shell.h" #include "ash/shell_delegate.h" #include "base/utf_string_conversions.h" +#include "grit/ash_strings.h" #include "grit/ui_resources.h" #include "ui/aura/window.h" #include "ui/base/animation/animation.h" #include "ui/base/animation/throb_animation.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/base/models/simple_menu_model.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/compositor/layer.h" @@ -643,5 +645,28 @@ void LauncherView::ButtonPressed(views::Button* sender, } } +string16 LauncherView::GetAccessibleName(views::View* view) { + ShellDelegate* delegate = Shell::GetInstance()->delegate(); + if (!delegate) + return string16(); + int view_index = view_model_->GetIndexOfView(view); + // May be -1 while in the process of animating closed. + if (view_index == -1) + return string16(); + + switch (model_->items()[view_index].type) { + case TYPE_TABBED: + case TYPE_APP: + return delegate->GetLauncherItemTitle(model_->items()[view_index]); + + case TYPE_APP_LIST: + return l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE); + + case TYPE_BROWSER_SHORTCUT: + return l10n_util::GetStringUTF16(IDS_AURA_CYCLER_TITLE); + } + return string16(); +} + } // namespace internal } // namespace ash diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h index 4e41be5..f43e369 100644 --- a/ash/launcher/launcher_view.h +++ b/ash/launcher/launcher_view.h @@ -109,6 +109,7 @@ class LauncherView : public views::WidgetDelegateView, virtual void MouseReleasedOnButton(views::View* view, bool canceled) OVERRIDE; virtual void MouseExitedButton(views::View* view) OVERRIDE; + virtual string16 GetAccessibleName(views::View* view) OVERRIDE; // Overriden from views::ButtonListener: virtual void ButtonPressed(views::Button* sender, diff --git a/ash/launcher/tabbed_launcher_button.cc b/ash/launcher/tabbed_launcher_button.cc index 09da1a9..84d061e 100644 --- a/ash/launcher/tabbed_launcher_button.cc +++ b/ash/launcher/tabbed_launcher_button.cc @@ -8,6 +8,7 @@ #include "ash/launcher/launcher_button_host.h" #include "grit/ui_resources.h" +#include "ui/base/accessibility/accessible_view_state.h" #include "ui/base/animation/multi_animation.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" @@ -162,6 +163,11 @@ void TabbedLauncherButton::OnMouseExited(const views::MouseEvent& event) { hover_controller_.Hide(); } +void TabbedLauncherButton::GetAccessibleState(ui::AccessibleViewState* state) { + state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; + state->name = host_->GetAccessibleName(this); +} + // static TabbedLauncherButton::ImageSet* TabbedLauncherButton::CreateImageSet( int normal_id, diff --git a/ash/launcher/tabbed_launcher_button.h b/ash/launcher/tabbed_launcher_button.h index c950a11..44917b7 100644 --- a/ash/launcher/tabbed_launcher_button.h +++ b/ash/launcher/tabbed_launcher_button.h @@ -44,6 +44,7 @@ class TabbedLauncherButton : public views::ImageButton { virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; private: // Used as the delegate for |animation_|. TabbedLauncherButton doesn't |