diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-23 04:11:06 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-23 04:11:06 +0000 |
commit | 65cd7365fd60ab2d2285645cf96c133142524fe4 (patch) | |
tree | 5b7f56af2356e80db659b4052a59a01e0eb2462f /ash/system | |
parent | a4b5abdd9e197576c9765542ede63f6234bf8a9c (diff) | |
download | chromium_src-65cd7365fd60ab2d2285645cf96c133142524fe4.zip chromium_src-65cd7365fd60ab2d2285645cf96c133142524fe4.tar.gz chromium_src-65cd7365fd60ab2d2285645cf96c133142524fe4.tar.bz2 |
Add an accessible name to the restart button
R=hashimoto@chromium.org
BUG=chromium-os:29383
TEST=See bug
Review URL: http://codereview.chromium.org/10078009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133403 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system')
-rw-r--r-- | ash/system/settings/tray_settings.cc | 15 | ||||
-rw-r--r-- | ash/system/tray/tray_views.cc | 22 | ||||
-rw-r--r-- | ash/system/tray/tray_views.h | 17 | ||||
-rw-r--r-- | ash/system/tray_update.cc | 1 |
4 files changed, 27 insertions, 28 deletions
diff --git a/ash/system/settings/tray_settings.cc b/ash/system/settings/tray_settings.cc index 9039fa8..bd67ab7 100644 --- a/ash/system/settings/tray_settings.cc +++ b/ash/system/settings/tray_settings.cc @@ -37,9 +37,12 @@ class SettingsView : public ash::internal::ActionableView { icon->SetImage(rb.GetImageNamed(IDR_AURA_UBER_TRAY_SETTINGS).ToSkBitmap()); AddChildView(icon); - label_ = new views::Label(rb.GetLocalizedString( - IDS_ASH_STATUS_TRAY_SETTINGS_AND_HELP)); + string16 text = rb.GetLocalizedString( + IDS_ASH_STATUS_TRAY_SETTINGS_AND_HELP); + label_ = new views::Label(text); AddChildView(label_); + + SetAccessibleName(text); } virtual ~SettingsView() {} @@ -50,14 +53,6 @@ class SettingsView : public ash::internal::ActionableView { 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_views.cc b/ash/system/tray/tray_views.cc index 1c2e75e..e278140 100644 --- a/ash/system/tray/tray_views.cc +++ b/ash/system/tray/tray_views.cc @@ -66,6 +66,10 @@ bool ActionableView::OnMousePressed(const views::MouseEvent& event) { return PerformAction(event); } +void ActionableView::SetAccessibleName(const string16& name) { + accessible_name_ = name; +} + void ActionableView::OnPaintFocusBorder(gfx::Canvas* canvas) { if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { canvas->DrawRect(gfx::Rect(1, 1, width() - 3, height() - 3), @@ -73,6 +77,11 @@ void ActionableView::OnPaintFocusBorder(gfx::Canvas* canvas) { } } +void ActionableView::GetAccessibleState(ui::AccessibleViewState* state) { + state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; + state->name = accessible_name_; +} + //////////////////////////////////////////////////////////////////////////////// // HoverHighlightView @@ -102,7 +111,7 @@ void HoverHighlightView::AddIconAndLabel(const SkBitmap& image, label->SetFont(label->font().DeriveFont(0, style)); AddChildView(label); - accessible_name_ = text; + SetAccessibleName(text); } void HoverHighlightView::AddLabel(const string16& text, @@ -116,11 +125,7 @@ void HoverHighlightView::AddLabel(const string16& text, label->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0)); AddChildView(label); - accessible_name_ = text; -} - -void HoverHighlightView::SetAccessibleName(const string16& name) { - accessible_name_ = name; + SetAccessibleName(text); } bool HoverHighlightView::PerformAction(const views::Event& event) { @@ -147,11 +152,6 @@ void HoverHighlightView::OnMouseExited(const views::MouseEvent& event) { SchedulePaint(); } -void HoverHighlightView::GetAccessibleState(ui::AccessibleViewState* state) { - state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; - state->name = accessible_name_; -} - void HoverHighlightView::OnEnabledChanged() { for (int i = 0; i < child_count(); ++i) child_at(i)->SetEnabled(enabled()); diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h index 8b61ffdc..96e476c 100644 --- a/ash/system/tray/tray_views.h +++ b/ash/system/tray/tray_views.h @@ -49,6 +49,10 @@ class ActionableView : public views::View { virtual ~ActionableView(); + // Set the accessible name. + void SetAccessibleName(const string16& name); + const string16& accessible_name() const { return accessible_name_; } + protected: // Performs an action when user clicks on the view (on mouse-press event), or // presses a key when this view is in focus. Returns true if the event has @@ -58,9 +62,12 @@ class ActionableView : public views::View { // Overridden from views::View. virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; private: + string16 accessible_name_; + DISALLOW_COPY_AND_ASSIGN(ActionableView); }; @@ -78,18 +85,16 @@ class HoverHighlightView : public ActionableView { explicit HoverHighlightView(ViewClickListener* listener); virtual ~HoverHighlightView(); - // Convenience function for adding an icon and a label. + // Convenience function for adding an icon and a label. This also sets the + // accessible name. void AddIconAndLabel(const SkBitmap& image, const string16& text, gfx::Font::FontStyle style); // Convenience function for adding a label with padding on the left for a - // blank icon. + // blank icon. This also sets the accessible name. void AddLabel(const string16& text, gfx::Font::FontStyle style); - // Set the accessible name. Should be used if this doesn't match the label. - void SetAccessibleName(const string16& name); - void set_highlight_color(SkColor color) { highlight_color_ = color; } void set_default_color(SkColor color) { default_color_ = color; } void set_fixed_height(int height) { fixed_height_ = height; } @@ -102,12 +107,10 @@ class HoverHighlightView : public ActionableView { virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; virtual void OnEnabledChanged() OVERRIDE; virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; ViewClickListener* listener_; - string16 accessible_name_; SkColor highlight_color_; SkColor default_color_; int fixed_height_; diff --git a/ash/system/tray_update.cc b/ash/system/tray_update.cc index 8feb0f6..e23f8c2 100644 --- a/ash/system/tray_update.cc +++ b/ash/system/tray_update.cc @@ -36,6 +36,7 @@ class UpdateView : public ash::internal::ActionableView { AddChildView(image); AddChildView(new views::Label( bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE))); + SetAccessibleName(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE)); } virtual ~UpdateView() {} |