OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ |
6 #define CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ | 6 #define CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlcom.h> | 9 #include <atlcom.h> |
10 #include <oleacc.h> | 10 #include <oleacc.h> |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 class BrowserAccessibilityFactory { | 23 class BrowserAccessibilityFactory { |
24 public: | 24 public: |
25 virtual ~BrowserAccessibilityFactory() {} | 25 virtual ~BrowserAccessibilityFactory() {} |
26 | 26 |
27 // Create an instance of BrowserAccessibility and return a new | 27 // Create an instance of BrowserAccessibility and return a new |
28 // reference to it. | 28 // reference to it. |
29 virtual BrowserAccessibility* Create(); | 29 virtual BrowserAccessibility* Create(); |
30 }; | 30 }; |
31 | 31 |
| 32 // Class that can perform actions on behalf of the BrowserAccessibilityManager. |
| 33 class BrowserAccessibilityDelegate { |
| 34 public: |
| 35 virtual ~BrowserAccessibilityDelegate() {} |
| 36 virtual void SetAccessibilityFocus(int acc_obj_id) = 0; |
| 37 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0; |
| 38 }; |
| 39 |
32 // Manages a tree of BrowserAccessibility objects. | 40 // Manages a tree of BrowserAccessibility objects. |
33 class BrowserAccessibilityManager { | 41 class BrowserAccessibilityManager { |
34 public: | 42 public: |
35 BrowserAccessibilityManager( | 43 BrowserAccessibilityManager( |
36 HWND parent_hwnd, | 44 HWND parent_hwnd, |
37 const webkit_glue::WebAccessibility& src, | 45 const webkit_glue::WebAccessibility& src, |
| 46 BrowserAccessibilityDelegate* delegate, |
38 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); | 47 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); |
39 | 48 |
40 virtual ~BrowserAccessibilityManager(); | 49 virtual ~BrowserAccessibilityManager(); |
41 | 50 |
42 // Return a pointer to the root of the tree, does not make a new reference. | 51 // Return a pointer to the root of the tree, does not make a new reference. |
43 BrowserAccessibility* GetRoot(); | 52 BrowserAccessibility* GetRoot(); |
44 | 53 |
45 // Return a pointer to the object corresponding to the given child_id, | 54 // Return a pointer to the object corresponding to the given child_id, |
46 // does not make a new reference. | 55 // does not make a new reference. |
47 BrowserAccessibility* GetFromChildID(LONG child_id); | 56 BrowserAccessibility* GetFromChildID(LONG child_id); |
48 | 57 |
49 // Get a the default IAccessible for the parent window, does not make a | 58 // Get a the default IAccessible for the parent window, does not make a |
50 // new reference. | 59 // new reference. |
51 IAccessible* GetParentWindowIAccessible(); | 60 IAccessible* GetParentWindowIAccessible(); |
52 | 61 |
53 // Get the parent window. | 62 // Get the parent window. |
54 HWND GetParentHWND(); | 63 HWND GetParentHWND(); |
55 | 64 |
56 // Return the object that has focus, if it's a descandant of the | 65 // Return the object that has focus, if it's a descandant of the |
57 // given root (inclusive). Does not make a new reference. | 66 // given root (inclusive). Does not make a new reference. |
58 BrowserAccessibility* GetFocus(BrowserAccessibility* root); | 67 BrowserAccessibility* GetFocus(BrowserAccessibility* root); |
59 | 68 |
| 69 // Tell the renderer to set focus to this node. |
| 70 void SetFocus(const BrowserAccessibility& node); |
| 71 |
| 72 // Tell the renderer to do the default action for this node. |
| 73 void DoDefaultAction(const BrowserAccessibility& node); |
| 74 |
60 // Called when the renderer process has notified us of a focus or state | 75 // Called when the renderer process has notified us of a focus or state |
61 // change. Send a notification to MSAA clients of the change. | 76 // change. Send a notification to MSAA clients of the change. |
62 void OnAccessibilityFocusChange(int acc_obj_id); | 77 void OnAccessibilityFocusChange(int acc_obj_id); |
63 void OnAccessibilityObjectStateChange(int acc_obj_id); | 78 void OnAccessibilityObjectStateChange(int acc_obj_id); |
64 | 79 |
65 private: | 80 private: |
66 // Recursively build a tree of BrowserAccessibility objects from | 81 // Recursively build a tree of BrowserAccessibility objects from |
67 // the WebAccessibility tree received from the renderer process. | 82 // the WebAccessibility tree received from the renderer process. |
68 BrowserAccessibility* CreateAccessibilityTree( | 83 BrowserAccessibility* CreateAccessibilityTree( |
69 BrowserAccessibility* parent, | 84 BrowserAccessibility* parent, |
70 const webkit_glue::WebAccessibility& src, | 85 const webkit_glue::WebAccessibility& src, |
71 int index_in_parent); | 86 int index_in_parent); |
72 | 87 |
73 // The parent window. | 88 // The parent window. |
74 HWND parent_hwnd_; | 89 HWND parent_hwnd_; |
75 | 90 |
| 91 // The object that can perform actions on our behalf. |
| 92 BrowserAccessibilityDelegate* delegate_; |
| 93 |
76 // Factory to create BrowserAccessibility objects (for dependency injection). | 94 // Factory to create BrowserAccessibility objects (for dependency injection). |
77 scoped_ptr<BrowserAccessibilityFactory> factory_; | 95 scoped_ptr<BrowserAccessibilityFactory> factory_; |
78 | 96 |
79 // A default IAccessible instance for the parent window. | 97 // A default IAccessible instance for the parent window. |
80 ScopedComPtr<IAccessible> window_iaccessible_; | 98 ScopedComPtr<IAccessible> window_iaccessible_; |
81 | 99 |
82 // The root of the tree of IAccessible objects and the element that | 100 // The root of the tree of IAccessible objects and the element that |
83 // currently has focus, if any. | 101 // currently has focus, if any. |
84 BrowserAccessibility* root_; | 102 BrowserAccessibility* root_; |
85 BrowserAccessibility* focus_; | 103 BrowserAccessibility* focus_; |
86 | 104 |
87 // A mapping from the IDs of objects in the renderer, to the child IDs | 105 // A mapping from the IDs of objects in the renderer, to the child IDs |
88 // we use internally here. | 106 // we use internally here. |
89 base::hash_map<int, LONG> renderer_id_to_child_id_map_; | 107 base::hash_map<int, LONG> renderer_id_to_child_id_map_; |
90 | 108 |
91 // A mapping from child IDs to BrowserAccessibility objects. | 109 // A mapping from child IDs to BrowserAccessibility objects. |
92 base::hash_map<LONG, BrowserAccessibility*> child_id_map_; | 110 base::hash_map<LONG, BrowserAccessibility*> child_id_map_; |
93 | 111 |
94 // The next child ID to use; static so that they're global to the process. | 112 // The next child ID to use; static so that they're global to the process. |
95 // Screen readers cache these IDs to see if they've seen the same object | 113 // Screen readers cache these IDs to see if they've seen the same object |
96 // before so we should avoid reusing them within the same project. | 114 // before so we should avoid reusing them within the same project. |
97 static LONG next_child_id_; | 115 static LONG next_child_id_; |
98 | 116 |
99 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); | 117 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); |
100 }; | 118 }; |
101 | 119 |
102 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ | 120 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ |
OLD | NEW |