OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 virtual ~BrowserAccessibilityManager(); | 62 virtual ~BrowserAccessibilityManager(); |
63 | 63 |
64 // Type is enum AccessibilityNotification. | 64 // Type is enum AccessibilityNotification. |
65 // We pass it as int so that we don't include the message declaration | 65 // We pass it as int so that we don't include the message declaration |
66 // header here. | 66 // header here. |
67 virtual void NotifyAccessibilityEvent( | 67 virtual void NotifyAccessibilityEvent( |
68 int type, | 68 int type, |
69 BrowserAccessibility* node) { } | 69 BrowserAccessibility* node) { } |
70 | 70 |
71 // Returns the next unique child id. | |
72 static int32 GetNextChildID(); | |
73 | |
74 // Return a pointer to the root of the tree, does not make a new reference. | 71 // Return a pointer to the root of the tree, does not make a new reference. |
75 BrowserAccessibility* GetRoot(); | 72 BrowserAccessibility* GetRoot(); |
76 | 73 |
77 // Removes a node from the manager. | 74 // Removes a node from the manager. |
78 void Remove(BrowserAccessibility* node); | 75 virtual void RemoveNode(BrowserAccessibility* node); |
79 | |
80 // Return a pointer to the object corresponding to the given child_id, | |
81 // does not make a new reference. | |
82 BrowserAccessibility* GetFromChildID(int32 child_id); | |
83 | 76 |
84 // Return a pointer to the object corresponding to the given renderer_id, | 77 // Return a pointer to the object corresponding to the given renderer_id, |
85 // does not make a new reference. | 78 // does not make a new reference. |
86 BrowserAccessibility* GetFromRendererID(int32 renderer_id); | 79 BrowserAccessibility* GetFromRendererID(int32 renderer_id); |
87 | 80 |
88 // Called to notify the accessibility manager that its associated native | 81 // Called to notify the accessibility manager that its associated native |
89 // view got focused. This implies that it is shown (opposite of WasHidden, | 82 // view got focused. This implies that it is shown (opposite of WasHidden, |
90 // below). | 83 // below). |
91 // The touch_event_context parameter indicates that we were called in the | 84 // The touch_event_context parameter indicates that we were called in the |
92 // context of a touch event. | 85 // context of a touch event. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 const AccessibilityNodeData& node5 = AccessibilityNodeData(), | 149 const AccessibilityNodeData& node5 = AccessibilityNodeData(), |
157 const AccessibilityNodeData& node6 = AccessibilityNodeData(), | 150 const AccessibilityNodeData& node6 = AccessibilityNodeData(), |
158 const AccessibilityNodeData& node7 = AccessibilityNodeData()); | 151 const AccessibilityNodeData& node7 = AccessibilityNodeData()); |
159 | 152 |
160 protected: | 153 protected: |
161 BrowserAccessibilityManager( | 154 BrowserAccessibilityManager( |
162 const AccessibilityNodeData& src, | 155 const AccessibilityNodeData& src, |
163 BrowserAccessibilityDelegate* delegate, | 156 BrowserAccessibilityDelegate* delegate, |
164 BrowserAccessibilityFactory* factory); | 157 BrowserAccessibilityFactory* factory); |
165 | 158 |
| 159 virtual void AddNodeToMap(BrowserAccessibility* node); |
| 160 |
166 private: | 161 private: |
167 // The following states keep track of whether or not the | 162 // The following states keep track of whether or not the |
168 // on-screen keyboard is allowed to be shown. | 163 // on-screen keyboard is allowed to be shown. |
169 enum OnScreenKeyboardState { | 164 enum OnScreenKeyboardState { |
170 // Never show the on-screen keyboard because this tab is hidden. | 165 // Never show the on-screen keyboard because this tab is hidden. |
171 OSK_DISALLOWED_BECAUSE_TAB_HIDDEN, | 166 OSK_DISALLOWED_BECAUSE_TAB_HIDDEN, |
172 | 167 |
173 // This tab was just shown, so don't pop-up the on-screen keyboard if a | 168 // This tab was just shown, so don't pop-up the on-screen keyboard if a |
174 // text field gets focus that wasn't the result of an explicit touch. | 169 // text field gets focus that wasn't the result of an explicit touch. |
175 OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED, | 170 OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED, |
(...skipping 17 matching lines...) Expand all Loading... |
193 // Update one node from the tree using data received from the renderer | 188 // Update one node from the tree using data received from the renderer |
194 // process. Returns true on success, false on fatal error. | 189 // process. Returns true on success, false on fatal error. |
195 bool UpdateNode(const AccessibilityNodeData& src); | 190 bool UpdateNode(const AccessibilityNodeData& src); |
196 | 191 |
197 BrowserAccessibility* CreateNode( | 192 BrowserAccessibility* CreateNode( |
198 BrowserAccessibility* parent, | 193 BrowserAccessibility* parent, |
199 int32 renderer_id, | 194 int32 renderer_id, |
200 int32 index_in_parent); | 195 int32 index_in_parent); |
201 | 196 |
202 protected: | 197 protected: |
203 // The next unique id for a BrowserAccessibility instance. | |
204 static int32 next_child_id_; | |
205 | |
206 // The object that can perform actions on our behalf. | 198 // The object that can perform actions on our behalf. |
207 BrowserAccessibilityDelegate* delegate_; | 199 BrowserAccessibilityDelegate* delegate_; |
208 | 200 |
209 // Factory to create BrowserAccessibility objects (for dependency injection). | 201 // Factory to create BrowserAccessibility objects (for dependency injection). |
210 scoped_ptr<BrowserAccessibilityFactory> factory_; | 202 scoped_ptr<BrowserAccessibilityFactory> factory_; |
211 | 203 |
212 // The root of the tree of accessible objects and the element that | 204 // The root of the tree of accessible objects and the element that |
213 // currently has focus, if any. | 205 // currently has focus, if any. |
214 BrowserAccessibility* root_; | 206 BrowserAccessibility* root_; |
215 BrowserAccessibility* focus_; | 207 BrowserAccessibility* focus_; |
216 | 208 |
217 // The on-screen keyboard state. | 209 // The on-screen keyboard state. |
218 OnScreenKeyboardState osk_state_; | 210 OnScreenKeyboardState osk_state_; |
219 | 211 |
220 // A mapping from the IDs of objects in the renderer, to the child IDs | 212 // A mapping from renderer IDs to BrowserAccessibility objects. |
221 // we use internally here. | 213 base::hash_map<int32, BrowserAccessibility*> renderer_id_map_; |
222 base::hash_map<int32, int32> renderer_id_to_child_id_map_; | |
223 | |
224 // A mapping from child IDs to BrowserAccessibility objects. | |
225 base::hash_map<int32, BrowserAccessibility*> child_id_map_; | |
226 | 214 |
227 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); | 215 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); |
228 }; | 216 }; |
229 | 217 |
230 } // namespace content | 218 } // namespace content |
231 | 219 |
232 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 220 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
OLD | NEW |