Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager.h

Issue 15741009: Native Android accessibility. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address most reviewer feedback Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 #endif 130 #endif
131 131
132 // Return the object that has focus, if it's a descandant of the 132 // Return the object that has focus, if it's a descandant of the
133 // given root (inclusive). Does not make a new reference. 133 // given root (inclusive). Does not make a new reference.
134 BrowserAccessibility* GetFocus(BrowserAccessibility* root); 134 BrowserAccessibility* GetFocus(BrowserAccessibility* root);
135 135
136 // Is the on-screen keyboard allowed to be shown, in response to a 136 // Is the on-screen keyboard allowed to be shown, in response to a
137 // focus event on a text box? 137 // focus event on a text box?
138 bool IsOSKAllowed(const gfx::Rect& bounds); 138 bool IsOSKAllowed(const gfx::Rect& bounds);
139 139
140 // True by default, but some platforms want to treat the root
141 // scroll offsets separately.
142 virtual bool UseRootScrollOffsetsWhenComputingBounds();
143
140 // For testing only: update the given nodes as if they were 144 // For testing only: update the given nodes as if they were
141 // received from the renderer process in OnAccessibilityNotifications. 145 // received from the renderer process in OnAccessibilityNotifications.
142 // Takes up to 7 nodes at once so tests don't need to create a vector 146 // Takes up to 7 nodes at once so tests don't need to create a vector
143 // each time. 147 // each time.
144 void UpdateNodesForTesting( 148 void UpdateNodesForTesting(
145 const AccessibilityNodeData& node, 149 const AccessibilityNodeData& node,
146 const AccessibilityNodeData& node2 = AccessibilityNodeData(), 150 const AccessibilityNodeData& node2 = AccessibilityNodeData(),
147 const AccessibilityNodeData& node3 = AccessibilityNodeData(), 151 const AccessibilityNodeData& node3 = AccessibilityNodeData(),
148 const AccessibilityNodeData& node4 = AccessibilityNodeData(), 152 const AccessibilityNodeData& node4 = AccessibilityNodeData(),
149 const AccessibilityNodeData& node5 = AccessibilityNodeData(), 153 const AccessibilityNodeData& node5 = AccessibilityNodeData(),
150 const AccessibilityNodeData& node6 = AccessibilityNodeData(), 154 const AccessibilityNodeData& node6 = AccessibilityNodeData(),
151 const AccessibilityNodeData& node7 = AccessibilityNodeData()); 155 const AccessibilityNodeData& node7 = AccessibilityNodeData());
152 156
153 protected: 157 protected:
154 BrowserAccessibilityManager( 158 BrowserAccessibilityManager(
155 const AccessibilityNodeData& src, 159 const AccessibilityNodeData& src,
156 BrowserAccessibilityDelegate* delegate, 160 BrowserAccessibilityDelegate* delegate,
157 BrowserAccessibilityFactory* factory); 161 BrowserAccessibilityFactory* factory);
158 162
159 virtual void AddNodeToMap(BrowserAccessibility* node); 163 virtual void AddNodeToMap(BrowserAccessibility* node);
160 164
165 virtual void NotifyRootChanged() {}
166
161 private: 167 private:
162 // The following states keep track of whether or not the 168 // The following states keep track of whether or not the
163 // on-screen keyboard is allowed to be shown. 169 // on-screen keyboard is allowed to be shown.
164 enum OnScreenKeyboardState { 170 enum OnScreenKeyboardState {
165 // Never show the on-screen keyboard because this tab is hidden. 171 // Never show the on-screen keyboard because this tab is hidden.
166 OSK_DISALLOWED_BECAUSE_TAB_HIDDEN, 172 OSK_DISALLOWED_BECAUSE_TAB_HIDDEN,
167 173
168 // This tab was just shown, so don't pop-up the on-screen keyboard if a 174 // This tab was just shown, so don't pop-up the on-screen keyboard if a
169 // text field gets focus that wasn't the result of an explicit touch. 175 // text field gets focus that wasn't the result of an explicit touch.
170 OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED, 176 OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED,
(...skipping 11 matching lines...) Expand all
182 }; 188 };
183 189
184 // Update a set of nodes using data received from the renderer 190 // Update a set of nodes using data received from the renderer
185 // process. 191 // process.
186 bool UpdateNodes(const std::vector<AccessibilityNodeData>& nodes); 192 bool UpdateNodes(const std::vector<AccessibilityNodeData>& nodes);
187 193
188 // Update one node from the tree using data received from the renderer 194 // Update one node from the tree using data received from the renderer
189 // process. Returns true on success, false on fatal error. 195 // process. Returns true on success, false on fatal error.
190 bool UpdateNode(const AccessibilityNodeData& src); 196 bool UpdateNode(const AccessibilityNodeData& src);
191 197
198 void SetRoot(BrowserAccessibility* root);
199
192 BrowserAccessibility* CreateNode( 200 BrowserAccessibility* CreateNode(
193 BrowserAccessibility* parent, 201 BrowserAccessibility* parent,
194 int32 renderer_id, 202 int32 renderer_id,
195 int32 index_in_parent); 203 int32 index_in_parent);
196 204
197 protected: 205 protected:
198 // The object that can perform actions on our behalf. 206 // The object that can perform actions on our behalf.
199 BrowserAccessibilityDelegate* delegate_; 207 BrowserAccessibilityDelegate* delegate_;
200 208
201 // Factory to create BrowserAccessibility objects (for dependency injection). 209 // Factory to create BrowserAccessibility objects (for dependency injection).
202 scoped_ptr<BrowserAccessibilityFactory> factory_; 210 scoped_ptr<BrowserAccessibilityFactory> factory_;
203 211
204 // The root of the tree of accessible objects and the element that 212 // The root of the tree of accessible objects and the element that
205 // currently has focus, if any. 213 // currently has focus, if any.
206 BrowserAccessibility* root_; 214 BrowserAccessibility* root_;
207 BrowserAccessibility* focus_; 215 BrowserAccessibility* focus_;
208 216
209 // The on-screen keyboard state. 217 // The on-screen keyboard state.
210 OnScreenKeyboardState osk_state_; 218 OnScreenKeyboardState osk_state_;
211 219
212 // A mapping from renderer IDs to BrowserAccessibility objects. 220 // A mapping from renderer IDs to BrowserAccessibility objects.
213 base::hash_map<int32, BrowserAccessibility*> renderer_id_map_; 221 base::hash_map<int32, BrowserAccessibility*> renderer_id_map_;
214 222
215 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); 223 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager);
216 }; 224 };
217 225
218 } // namespace content 226 } // namespace content
219 227
220 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ 228 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698