1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_BROWSER_ACCESSIBILITY_H_
6 #define CHROME_BROWSER_BROWSER_ACCESSIBILITY_H_
13 #include "chrome/common/render_messages.h"
15 ////////////////////////////////////////////////////////////////////////////////
17 // BrowserAccessibility
19 // Class implementing the MSAA IAccessible COM interface for the
20 // Browser-Renderer communication of MSAA information, providing accessibility
21 // to be used by screen readers and other assistive technology (AT).
23 ////////////////////////////////////////////////////////////////////////////////
24 class ATL_NO_VTABLE BrowserAccessibility
25 : public CComObjectRootEx
<CComMultiThreadModel
>,
26 public IDispatchImpl
<IAccessible
, &IID_IAccessible
, &LIBID_Accessibility
> {
28 BEGIN_COM_MAP(BrowserAccessibility
)
29 COM_INTERFACE_ENTRY2(IDispatch
, IAccessible
)
30 COM_INTERFACE_ENTRY(IAccessible
)
33 BrowserAccessibility();
34 ~BrowserAccessibility() {}
36 // Supported IAccessible methods.
38 // Performs the default action on a given object.
39 STDMETHODIMP
accDoDefaultAction(VARIANT var_id
);
41 // Retrieves the child element or child object at a given point on the screen.
42 STDMETHODIMP
accHitTest(LONG x_left
, LONG y_top
, VARIANT
* child
);
44 // Retrieves the specified object's current screen location.
45 STDMETHODIMP
accLocation(LONG
* x_left
,
51 // Traverses to another UI element and retrieves the object.
52 STDMETHODIMP
accNavigate(LONG nav_dir
, VARIANT start
, VARIANT
* end
);
54 // Retrieves an IDispatch interface pointer for the specified child.
55 STDMETHODIMP
get_accChild(VARIANT var_child
, IDispatch
** disp_child
);
57 // Retrieves the number of accessible children.
58 STDMETHODIMP
get_accChildCount(LONG
* child_count
);
60 // Retrieves a string that describes the object's default action.
61 STDMETHODIMP
get_accDefaultAction(VARIANT var_id
, BSTR
* default_action
);
63 // Retrieves the object's description.
64 STDMETHODIMP
get_accDescription(VARIANT var_id
, BSTR
* desc
);
66 // Retrieves the object that has the keyboard focus.
67 STDMETHODIMP
get_accFocus(VARIANT
* focus_child
);
69 // Retrieves the help information associated with the object.
70 STDMETHODIMP
get_accHelp(VARIANT var_id
, BSTR
* help
);
72 // Retrieves the specified object's shortcut.
73 STDMETHODIMP
get_accKeyboardShortcut(VARIANT var_id
, BSTR
* access_key
);
75 // Retrieves the name of the specified object.
76 STDMETHODIMP
get_accName(VARIANT var_id
, BSTR
* name
);
78 // Retrieves the IDispatch interface of the object's parent.
79 STDMETHODIMP
get_accParent(IDispatch
** disp_parent
);
81 // Retrieves information describing the role of the specified object.
82 STDMETHODIMP
get_accRole(VARIANT var_id
, VARIANT
* role
);
84 // Retrieves the current state of the specified object.
85 STDMETHODIMP
get_accState(VARIANT var_id
, VARIANT
* state
);
87 // Returns the value associated with the object.
88 STDMETHODIMP
get_accValue(VARIANT var_id
, BSTR
* value
);
90 // Non-supported (by WebKit) IAccessible methods.
91 STDMETHODIMP
accSelect(LONG flags_sel
, VARIANT var_id
);
93 STDMETHODIMP
get_accHelpTopic(BSTR
* help_file
,
97 STDMETHODIMP
get_accSelection(VARIANT
* selected
);
99 // Deprecated functions, not implemented here.
100 STDMETHODIMP
put_accName(VARIANT var_id
, BSTR put_name
);
101 STDMETHODIMP
put_accValue(VARIANT var_id
, BSTR put_val
);
103 // Modify/retrieve the unique id of this IAccessible instance.
104 void set_iaccessible_id(int iaccessible_id
) {
105 iaccessible_id_
= iaccessible_id
;
107 int iaccessible_id() const { return iaccessible_id_
; }
109 // Modify/retrieve the unique id of this IAccessible's routing variables.
110 void set_instance_id(int instance_id
) {
111 instance_id_
= instance_id
;
113 int instance_id() const { return instance_id_
; }
115 // Modify/retrieve the state (active/inactive) of this instance.
116 void set_instance_active(bool instance_active
) {
117 instance_active_
= instance_active
;
119 int instance_active() const { return instance_active_
; }
122 // Creates an empty VARIANT. Used as the equivalent of a NULL (unused) input
124 VARIANT
EmptyVariant() const {
130 // Wrapper functions, calling through to singleton instance of
131 // BrowserAccessibilityManager.
133 // Creates an instance of BrowserAccessibility, initializes it and sets the
134 // |iaccessible_id| and |parent_id|.
135 STDMETHODIMP
CreateInstance(REFIID iid
,
137 void** interface_ptr
);
139 // Composes and sends a message for requesting needed accessibility
140 // information. Unused LONG input parameters should be NULL, and the VARIANT
141 // an empty, valid instance.
142 bool RequestAccessibilityInfo(int iaccessible_func_id
,
144 LONG input1
, LONG input2
);
147 ViewHostMsg_Accessibility_Out_Params
response();
150 // Id to uniquely distinguish this instance in the render-side caching,
151 // mapping it to the correct IAccessible on that side. Initialized to -1.
154 // The unique id of this IAccessible instance. Used to help
155 // BrowserAccessibilityManager instance retrieve the correct member
156 // variables for this process.
159 // The instance should only be active if there is a non-terminated
160 // RenderProcessHost associated with it. The BrowserAccessibilityManager keeps
161 // track of this state, and sets it to false to disable all calls into the
162 // renderer from this instance of BroweserAccessibility, and have all
163 // IAccessible functions return E_FAIL.
164 bool instance_active_
;
166 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility
);
168 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_H_