OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_BROWSER_ACCESSIBILITY_H_ |
| 6 #define CHROME_BROWSER_BROWSER_ACCESSIBILITY_H_ |
| 7 |
| 8 #include <atlbase.h> |
| 9 #include <atlcom.h> |
| 10 |
| 11 #include <oleacc.h> |
| 12 |
| 13 #include "chrome/common/render_messages.h" |
| 14 |
| 15 //////////////////////////////////////////////////////////////////////////////// |
| 16 // |
| 17 // BrowserAccessibility |
| 18 // |
| 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). |
| 22 // |
| 23 //////////////////////////////////////////////////////////////////////////////// |
| 24 class ATL_NO_VTABLE BrowserAccessibility |
| 25 : public CComObjectRootEx<CComMultiThreadModel>, |
| 26 public IDispatchImpl<IAccessible, &IID_IAccessible, &LIBID_Accessibility> { |
| 27 public: |
| 28 BEGIN_COM_MAP(BrowserAccessibility) |
| 29 COM_INTERFACE_ENTRY2(IDispatch, IAccessible) |
| 30 COM_INTERFACE_ENTRY(IAccessible) |
| 31 END_COM_MAP() |
| 32 |
| 33 BrowserAccessibility(); |
| 34 ~BrowserAccessibility() {} |
| 35 |
| 36 // Supported IAccessible methods. |
| 37 |
| 38 // Performs the default action on a given object. |
| 39 STDMETHODIMP accDoDefaultAction(VARIANT var_id); |
| 40 |
| 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); |
| 43 |
| 44 // Retrieves the specified object's current screen location. |
| 45 STDMETHODIMP accLocation(LONG* x_left, |
| 46 LONG* y_top, |
| 47 LONG* width, |
| 48 LONG* height, |
| 49 VARIANT var_id); |
| 50 |
| 51 // Traverses to another UI element and retrieves the object. |
| 52 STDMETHODIMP accNavigate(LONG nav_dir, VARIANT start, VARIANT* end); |
| 53 |
| 54 // Retrieves an IDispatch interface pointer for the specified child. |
| 55 STDMETHODIMP get_accChild(VARIANT var_child, IDispatch** disp_child); |
| 56 |
| 57 // Retrieves the number of accessible children. |
| 58 STDMETHODIMP get_accChildCount(LONG* child_count); |
| 59 |
| 60 // Retrieves a string that describes the object's default action. |
| 61 STDMETHODIMP get_accDefaultAction(VARIANT var_id, BSTR* default_action); |
| 62 |
| 63 // Retrieves the object's description. |
| 64 STDMETHODIMP get_accDescription(VARIANT var_id, BSTR* desc); |
| 65 |
| 66 // Retrieves the object that has the keyboard focus. |
| 67 STDMETHODIMP get_accFocus(VARIANT* focus_child); |
| 68 |
| 69 // Retrieves the help information associated with the object. |
| 70 STDMETHODIMP get_accHelp(VARIANT var_id, BSTR* help); |
| 71 |
| 72 // Retrieves the specified object's shortcut. |
| 73 STDMETHODIMP get_accKeyboardShortcut(VARIANT var_id, BSTR* access_key); |
| 74 |
| 75 // Retrieves the name of the specified object. |
| 76 STDMETHODIMP get_accName(VARIANT var_id, BSTR* name); |
| 77 |
| 78 // Retrieves the IDispatch interface of the object's parent. |
| 79 STDMETHODIMP get_accParent(IDispatch** disp_parent); |
| 80 |
| 81 // Retrieves information describing the role of the specified object. |
| 82 STDMETHODIMP get_accRole(VARIANT var_id, VARIANT* role); |
| 83 |
| 84 // Retrieves the current state of the specified object. |
| 85 STDMETHODIMP get_accState(VARIANT var_id, VARIANT* state); |
| 86 |
| 87 // Returns the value associated with the object. |
| 88 STDMETHODIMP get_accValue(VARIANT var_id, BSTR* value); |
| 89 |
| 90 // Non-supported (by WebKit) IAccessible methods. |
| 91 STDMETHODIMP accSelect(LONG flags_sel, VARIANT var_id); |
| 92 |
| 93 STDMETHODIMP get_accHelpTopic(BSTR* help_file, |
| 94 VARIANT var_id, |
| 95 LONG* topic_id); |
| 96 |
| 97 STDMETHODIMP get_accSelection(VARIANT* selected); |
| 98 |
| 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); |
| 102 |
| 103 // Modify/retrieve the unique id of this IAccessible instance. |
| 104 void set_iaccessible_id(int iaccessible_id) { |
| 105 iaccessible_id_ = iaccessible_id; |
| 106 } |
| 107 int iaccessible_id() const { return iaccessible_id_; } |
| 108 |
| 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; |
| 112 } |
| 113 int instance_id() const { return instance_id_; } |
| 114 |
| 115 // Modify/retrieve the state (active/inactive) of this instance. |
| 116 void set_instance_active(bool instance_active) { |
| 117 instance_active_ = instance_active; |
| 118 } |
| 119 int instance_active() const { return instance_active_; } |
| 120 |
| 121 private: |
| 122 // Creates an empty VARIANT. Used as the equivalent of a NULL (unused) input |
| 123 // parameter. |
| 124 VARIANT EmptyVariant() const { |
| 125 VARIANT empty; |
| 126 empty.vt = VT_EMPTY; |
| 127 return empty; |
| 128 } |
| 129 |
| 130 // Wrapper functions, calling through to singleton instance of |
| 131 // BrowserAccessibilityManager. |
| 132 |
| 133 // Creates an instance of BrowserAccessibility, initializes it and sets the |
| 134 // |iaccessible_id| and |parent_id|. |
| 135 STDMETHODIMP CreateInstance(REFIID iid, |
| 136 int iaccessible_id, |
| 137 void** interface_ptr); |
| 138 |
| 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, |
| 143 VARIANT var_id, |
| 144 LONG input1, LONG input2); |
| 145 |
| 146 // Accessors. |
| 147 ViewHostMsg_Accessibility_Out_Params response(); |
| 148 HWND parent_hwnd(); |
| 149 |
| 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. |
| 152 int iaccessible_id_; |
| 153 |
| 154 // The unique id of this IAccessible instance. Used to help |
| 155 // BrowserAccessibilityManager instance retrieve the correct member |
| 156 // variables for this process. |
| 157 int instance_id_; |
| 158 |
| 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_; |
| 165 |
| 166 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
| 167 }; |
| 168 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_H_ |
| 169 |
OLD | NEW |