summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/controls/textfield/textfield.cc36
-rw-r--r--views/controls/textfield/textfield.h13
2 files changed, 47 insertions, 2 deletions
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);
};