OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
15 #include "webkit/glue/webaccessibility.h" | 15 #include "webkit/glue/webaccessibility.h" |
16 | 16 |
17 class BrowserAccessibility; | 17 class BrowserAccessibility; |
18 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
19 class BrowserAccessibilityManagerWin; | 19 class BrowserAccessibilityManagerWin; |
20 #endif | 20 #endif |
21 | 21 |
| 22 using webkit_glue::WebAccessibility; |
| 23 |
22 struct ViewHostMsg_AccessibilityNotification_Params; | 24 struct ViewHostMsg_AccessibilityNotification_Params; |
23 | 25 |
24 using webkit_glue::WebAccessibility; | |
25 | |
26 // Class that can perform actions on behalf of the BrowserAccessibilityManager. | 26 // Class that can perform actions on behalf of the BrowserAccessibilityManager. |
27 class BrowserAccessibilityDelegate { | 27 class BrowserAccessibilityDelegate { |
28 public: | 28 public: |
29 virtual ~BrowserAccessibilityDelegate() {} | 29 virtual ~BrowserAccessibilityDelegate() {} |
30 virtual void SetAccessibilityFocus(int acc_obj_id) = 0; | 30 virtual void SetAccessibilityFocus(int acc_obj_id) = 0; |
31 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0; | 31 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0; |
32 virtual bool HasFocus() = 0; | 32 virtual bool HasFocus() = 0; |
33 virtual gfx::Rect GetViewBounds() const = 0; | 33 virtual gfx::Rect GetViewBounds() const = 0; |
34 }; | 34 }; |
35 | 35 |
(...skipping 20 matching lines...) Expand all Loading... |
56 // Creates the platform specific BrowserAccessibilityManager. Ownership passes | 56 // Creates the platform specific BrowserAccessibilityManager. Ownership passes |
57 // to the caller. | 57 // to the caller. |
58 static BrowserAccessibilityManager* CreateEmptyDocument( | 58 static BrowserAccessibilityManager* CreateEmptyDocument( |
59 gfx::NativeView parent_view, | 59 gfx::NativeView parent_view, |
60 WebAccessibility::State state, | 60 WebAccessibility::State state, |
61 BrowserAccessibilityDelegate* delegate, | 61 BrowserAccessibilityDelegate* delegate, |
62 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); | 62 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); |
63 | 63 |
64 virtual ~BrowserAccessibilityManager(); | 64 virtual ~BrowserAccessibilityManager(); |
65 | 65 |
66 // Type is a ViewHostMsg_AccessibilityNotification_Params::int. | 66 // Type is a ViewHostMsg_AccessibilityNotification_Type::int. |
67 // We pass it as int so that we don't include the render message declaration | 67 // We pass it as int so that we don't include the render message declaration |
68 // header here. | 68 // header here. |
69 virtual void NotifyAccessibilityEvent( | 69 virtual void NotifyAccessibilityEvent( |
70 int type, | 70 int type, |
71 BrowserAccessibility* node) { } | 71 BrowserAccessibility* node) { } |
72 | 72 |
73 // Returns the next unique child id. | 73 // Returns the next unique child id. |
74 static int32 GetNextChildID(); | 74 static int32 GetNextChildID(); |
75 | 75 |
76 // Return a pointer to the root of the tree, does not make a new reference. | 76 // Return a pointer to the root of the tree, does not make a new reference. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 BrowserAccessibility* GetFocus(BrowserAccessibility* root); | 118 BrowserAccessibility* GetFocus(BrowserAccessibility* root); |
119 | 119 |
120 protected: | 120 protected: |
121 BrowserAccessibilityManager( | 121 BrowserAccessibilityManager( |
122 gfx::NativeView parent_view, | 122 gfx::NativeView parent_view, |
123 const WebAccessibility& src, | 123 const WebAccessibility& src, |
124 BrowserAccessibilityDelegate* delegate, | 124 BrowserAccessibilityDelegate* delegate, |
125 BrowserAccessibilityFactory* factory); | 125 BrowserAccessibilityFactory* factory); |
126 | 126 |
127 private: | 127 private: |
128 void OnAccessibilityObjectStateChange( | 128 // Type is a ViewHostMsg_AccessibilityNotification_Type::int. |
129 const WebAccessibility& acc_obj); | 129 // We pass it as int so that we don't include the render message declaration |
130 void OnAccessibilityObjectChildrenChange( | 130 // header here. |
131 const WebAccessibility& acc_obj); | 131 void OnSimpleAccessibilityNotification( |
| 132 const WebAccessibility& acc_obj, |
| 133 int type, |
| 134 bool include_children); |
| 135 |
132 void OnAccessibilityObjectFocusChange( | 136 void OnAccessibilityObjectFocusChange( |
133 const WebAccessibility& acc_obj); | 137 const WebAccessibility& acc_obj); |
134 void OnAccessibilityObjectLoadComplete( | 138 void OnAccessibilityObjectLoadComplete( |
135 const WebAccessibility& acc_obj); | 139 const WebAccessibility& acc_obj); |
136 void OnAccessibilityObjectValueChange( | |
137 const WebAccessibility& acc_obj); | |
138 void OnAccessibilityObjectTextChange( | |
139 const WebAccessibility& acc_obj); | |
140 | 140 |
141 // Update an accessibility node with an updated WebAccessibility node | 141 // Update an accessibility node with an updated WebAccessibility node |
142 // received from the renderer process. When |include_children| is true | 142 // received from the renderer process. When |include_children| is true |
143 // the node's children will also be updated, otherwise only the node | 143 // the node's children will also be updated, otherwise only the node |
144 // itself is updated. Returns the updated node or NULL if no node was | 144 // itself is updated. Returns the updated node or NULL if no node was |
145 // updated. | 145 // updated. |
146 BrowserAccessibility* UpdateNode( | 146 BrowserAccessibility* UpdateNode( |
147 const WebAccessibility& src, | 147 const WebAccessibility& src, |
148 bool include_children); | 148 bool include_children); |
149 | 149 |
150 // Recursively build a tree of BrowserAccessibility objects from | 150 // Recursively build a tree of BrowserAccessibility objects from |
151 // the WebAccessibility tree received from the renderer process. | 151 // the WebAccessibility tree received from the renderer process. |
152 BrowserAccessibility* CreateAccessibilityTree( | 152 BrowserAccessibility* CreateAccessibilityTree( |
153 BrowserAccessibility* parent, | 153 BrowserAccessibility* parent, |
154 const WebAccessibility& src, | 154 const WebAccessibility& src, |
155 int index_in_parent); | 155 int index_in_parent, |
| 156 bool send_show_events); |
156 | 157 |
157 protected: | 158 protected: |
158 // The next unique id for a BrowserAccessibility instance. | 159 // The next unique id for a BrowserAccessibility instance. |
159 static int32 next_child_id_; | 160 static int32 next_child_id_; |
160 | 161 |
161 // The parent view. | 162 // The parent view. |
162 gfx::NativeView parent_view_; | 163 gfx::NativeView parent_view_; |
163 | 164 |
164 // The object that can perform actions on our behalf. | 165 // The object that can perform actions on our behalf. |
165 BrowserAccessibilityDelegate* delegate_; | 166 BrowserAccessibilityDelegate* delegate_; |
(...skipping 10 matching lines...) Expand all Loading... |
176 // we use internally here. | 177 // we use internally here. |
177 base::hash_map<int32, int32> renderer_id_to_child_id_map_; | 178 base::hash_map<int32, int32> renderer_id_to_child_id_map_; |
178 | 179 |
179 // A mapping from child IDs to BrowserAccessibility objects. | 180 // A mapping from child IDs to BrowserAccessibility objects. |
180 base::hash_map<int32, BrowserAccessibility*> child_id_map_; | 181 base::hash_map<int32, BrowserAccessibility*> child_id_map_; |
181 | 182 |
182 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); | 183 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); |
183 }; | 184 }; |
184 | 185 |
185 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ | 186 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ |
OLD | NEW |