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/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "content/common/accessibility_node_data.h" | 13 #include "content/common/accessibility_node_data.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "third_party/WebKit/public/web/WebAXEnums.h" |
15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
16 | 17 |
17 struct AccessibilityHostMsg_NotificationParams; | 18 struct AccessibilityHostMsg_EventParams; |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 class BrowserAccessibility; | 21 class BrowserAccessibility; |
21 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
22 class BrowserAccessibilityManagerWin; | 23 class BrowserAccessibilityManagerWin; |
23 #endif | 24 #endif |
24 | 25 |
25 // Class that can perform actions on behalf of the BrowserAccessibilityManager. | 26 // Class that can perform actions on behalf of the BrowserAccessibilityManager. |
26 class CONTENT_EXPORT BrowserAccessibilityDelegate { | 27 class CONTENT_EXPORT BrowserAccessibilityDelegate { |
27 public: | 28 public: |
(...skipping 30 matching lines...) Expand all Loading... |
58 const AccessibilityNodeData& src, | 59 const AccessibilityNodeData& src, |
59 BrowserAccessibilityDelegate* delegate, | 60 BrowserAccessibilityDelegate* delegate, |
60 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); | 61 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); |
61 | 62 |
62 virtual ~BrowserAccessibilityManager(); | 63 virtual ~BrowserAccessibilityManager(); |
63 | 64 |
64 void Initialize(const AccessibilityNodeData src); | 65 void Initialize(const AccessibilityNodeData src); |
65 | 66 |
66 static AccessibilityNodeData GetEmptyDocument(); | 67 static AccessibilityNodeData GetEmptyDocument(); |
67 | 68 |
68 // Type is enum AccessibilityNotification. | |
69 // We pass it as int so that we don't include the message declaration | |
70 // header here. | |
71 virtual void NotifyAccessibilityEvent( | 69 virtual void NotifyAccessibilityEvent( |
72 int type, | 70 WebKit::WebAXEvent event_type, BrowserAccessibility* node) { } |
73 BrowserAccessibility* node) { } | |
74 | 71 |
75 // Return a pointer to the root of the tree, does not make a new reference. | 72 // Return a pointer to the root of the tree, does not make a new reference. |
76 BrowserAccessibility* GetRoot(); | 73 BrowserAccessibility* GetRoot(); |
77 | 74 |
78 // Removes a node from the manager. | 75 // Removes a node from the manager. |
79 virtual void RemoveNode(BrowserAccessibility* node); | 76 virtual void RemoveNode(BrowserAccessibility* node); |
80 | 77 |
81 // Return a pointer to the object corresponding to the given renderer_id, | 78 // Return a pointer to the object corresponding to the given renderer_id, |
82 // does not make a new reference. | 79 // does not make a new reference. |
83 BrowserAccessibility* GetFromRendererID(int32 renderer_id); | 80 BrowserAccessibility* GetFromRendererID(int32 renderer_id); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 116 |
120 // Tell the renderer to set the text selection on a node. | 117 // Tell the renderer to set the text selection on a node. |
121 void SetTextSelection( | 118 void SetTextSelection( |
122 const BrowserAccessibility& node, int start_offset, int end_offset); | 119 const BrowserAccessibility& node, int start_offset, int end_offset); |
123 | 120 |
124 // Retrieve the bounds of the parent View in screen coordinates. | 121 // Retrieve the bounds of the parent View in screen coordinates. |
125 gfx::Rect GetViewBounds(); | 122 gfx::Rect GetViewBounds(); |
126 | 123 |
127 // Called when the renderer process has notified us of about tree changes. | 124 // Called when the renderer process has notified us of about tree changes. |
128 // Send a notification to MSAA clients of the change. | 125 // Send a notification to MSAA clients of the change. |
129 void OnAccessibilityNotifications( | 126 void OnAccessibilityEvents( |
130 const std::vector<AccessibilityHostMsg_NotificationParams>& params); | 127 const std::vector<AccessibilityHostMsg_EventParams>& params); |
131 | 128 |
132 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
133 BrowserAccessibilityManagerWin* ToBrowserAccessibilityManagerWin(); | 130 BrowserAccessibilityManagerWin* ToBrowserAccessibilityManagerWin(); |
134 #endif | 131 #endif |
135 | 132 |
136 // Return the object that has focus, if it's a descandant of the | 133 // Return the object that has focus, if it's a descandant of the |
137 // given root (inclusive). Does not make a new reference. | 134 // given root (inclusive). Does not make a new reference. |
138 BrowserAccessibility* GetFocus(BrowserAccessibility* root); | 135 BrowserAccessibility* GetFocus(BrowserAccessibility* root); |
139 | 136 |
140 // Is the on-screen keyboard allowed to be shown, in response to a | 137 // Is the on-screen keyboard allowed to be shown, in response to a |
141 // focus event on a text box? | 138 // focus event on a text box? |
142 bool IsOSKAllowed(const gfx::Rect& bounds); | 139 bool IsOSKAllowed(const gfx::Rect& bounds); |
143 | 140 |
144 // True by default, but some platforms want to treat the root | 141 // True by default, but some platforms want to treat the root |
145 // scroll offsets separately. | 142 // scroll offsets separately. |
146 virtual bool UseRootScrollOffsetsWhenComputingBounds(); | 143 virtual bool UseRootScrollOffsetsWhenComputingBounds(); |
147 | 144 |
148 // For testing only: update the given nodes as if they were | 145 // For testing only: update the given nodes as if they were |
149 // received from the renderer process in OnAccessibilityNotifications. | 146 // received from the renderer process in OnAccessibilityEvents. |
150 // Takes up to 7 nodes at once so tests don't need to create a vector | 147 // Takes up to 7 nodes at once so tests don't need to create a vector |
151 // each time. | 148 // each time. |
152 void UpdateNodesForTesting( | 149 void UpdateNodesForTesting( |
153 const AccessibilityNodeData& node, | 150 const AccessibilityNodeData& node, |
154 const AccessibilityNodeData& node2 = AccessibilityNodeData(), | 151 const AccessibilityNodeData& node2 = AccessibilityNodeData(), |
155 const AccessibilityNodeData& node3 = AccessibilityNodeData(), | 152 const AccessibilityNodeData& node3 = AccessibilityNodeData(), |
156 const AccessibilityNodeData& node4 = AccessibilityNodeData(), | 153 const AccessibilityNodeData& node4 = AccessibilityNodeData(), |
157 const AccessibilityNodeData& node5 = AccessibilityNodeData(), | 154 const AccessibilityNodeData& node5 = AccessibilityNodeData(), |
158 const AccessibilityNodeData& node6 = AccessibilityNodeData(), | 155 const AccessibilityNodeData& node6 = AccessibilityNodeData(), |
159 const AccessibilityNodeData& node7 = AccessibilityNodeData()); | 156 const AccessibilityNodeData& node7 = AccessibilityNodeData()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 224 |
228 // A mapping from renderer IDs to BrowserAccessibility objects. | 225 // A mapping from renderer IDs to BrowserAccessibility objects. |
229 base::hash_map<int32, BrowserAccessibility*> renderer_id_map_; | 226 base::hash_map<int32, BrowserAccessibility*> renderer_id_map_; |
230 | 227 |
231 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); | 228 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); |
232 }; | 229 }; |
233 | 230 |
234 } // namespace content | 231 } // namespace content |
235 | 232 |
236 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 233 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
OLD | NEW |