diff options
-rw-r--r-- | chrome/browser/views/bookmark_manager_view.cc | 6 | ||||
-rw-r--r-- | views/controls/textfield/textfield.cc | 36 | ||||
-rw-r--r-- | views/controls/textfield/textfield.h | 13 |
3 files changed, 51 insertions, 4 deletions
diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc index d7b0dd8..503af86 100644 --- a/chrome/browser/views/bookmark_manager_view.cc +++ b/chrome/browser/views/bookmark_manager_view.cc @@ -170,8 +170,11 @@ BookmarkManagerView::BookmarkManagerView(Profile* profile) sync_service_(NULL), sync_relogin_required_(false), ALLOW_THIS_IN_INITIALIZER_LIST(search_factory_(this)) { + views::Label* search_label = new views::Label( + l10n_util::GetString(IDS_BOOKMARK_MANAGER_SEARCH_TITLE)); search_tf_ = new views::Textfield(); search_tf_->set_default_width_in_chars(30); + search_tf_->SetAccessibleName(search_label->GetText()); table_view_ = new BookmarkTableView(profile_, NULL); table_view_->SetObserver(this); @@ -226,8 +229,7 @@ BookmarkManagerView::BookmarkManagerView(Profile* profile) layout->AddView(tools_menu_button); sync_status_button_ = new views::TextButton(this, std::wstring()); layout->AddView(sync_status_button_); - layout->AddView(new views::Label( - l10n_util::GetString(IDS_BOOKMARK_MANAGER_SEARCH_TITLE))); + layout->AddView(search_label); layout->AddView(search_tf_); layout->AddPaddingRow(0, 3); // 3px padding between rows. diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc index b650530..7f7251b 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -227,6 +227,40 @@ void Textfield::PaintFocusBorder(gfx::Canvas* canvas) { View::PaintFocusBorder(canvas); } +bool Textfield::GetAccessibleRole(AccessibilityTypes::Role* role) { + DCHECK(role); + if (!role) + return false; + + *role = AccessibilityTypes::ROLE_TEXT; + return true; +} + +bool Textfield::GetAccessibleName(std::wstring* name) { + DCHECK(name); + if (!name) + return false; + + if (!accessible_name_.empty()) { + *name = accessible_name_; + return true; + } + return false; +} + +bool Textfield::GetAccessibleState(AccessibilityTypes::State* state) { + DCHECK(state); + if (!state) + return false; + + *state = AccessibilityTypes::STATE_READONLY; + return true; +} + +void Textfield::SetAccessibleName(const std::wstring& name) { + accessible_name_.assign(name); +} + void Textfield::SetEnabled(bool enabled) { View::SetEnabled(enabled); if (native_wrapper_) diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h index bccd07e..b20f9ec 100644 --- a/views/controls/textfield/textfield.h +++ b/views/controls/textfield/textfield.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,6 +9,8 @@ #include <gdk/gdk.h> #endif +#include <string> + #include "app/gfx/font.h" #include "base/basictypes.h" #include "base/keyboard_codes.h" @@ -202,6 +204,12 @@ class Textfield : public View { virtual void SetEnabled(bool enabled); virtual void PaintFocusBorder(gfx::Canvas* canvas); + // Accessibility accessors, overridden from View: + virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); + virtual bool GetAccessibleName(std::wstring* name); + virtual bool GetAccessibleState(AccessibilityTypes::State* state); + virtual void SetAccessibleName(const std::wstring& name); + protected: virtual void Focus(); virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); @@ -262,6 +270,9 @@ class Textfield : public View { // NativeControlWin. bool initialized_; + // The storage string for the accessibility name associated with this control. + std::wstring accessible_name_; + DISALLOW_COPY_AND_ASSIGN(Textfield); }; |