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

Side by Side Diff: chrome/browser/accessibility/browser_accessibility_manager_win.h

Issue 3591003: Make BrowserAccessibilityManager cross platform. Step 1.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Some cleanup. Created 10 years, 2 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 | Annotate | Revision Log
OLDNEW
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_WIN_H_ 5 #ifndef CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
6 #define CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_ 6 #define CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <atlbase.h> 9 #include <atlbase.h>
10 #include <atlcom.h> 10 #include <atlcom.h>
11 #include <oleacc.h> 11 #include <oleacc.h>
12 12
13 #include <hash_map>
14 #include <vector> 13 #include <vector>
15 14
15 #include "chrome/browser/accessibility/browser_accessibility_manager.h"
16 #include "base/hash_tables.h" 16 #include "base/hash_tables.h"
17 #include "base/scoped_comptr_win.h" 17 #include "base/scoped_comptr_win.h"
18 #include "base/scoped_ptr.h" 18 #include "base/scoped_ptr.h"
19 #include "webkit/glue/webaccessibility.h" 19 #include "webkit/glue/webaccessibility.h"
20 20
21 class BrowserAccessibility; 21 class BrowserAccessibilityWin;
22 struct ViewHostMsg_AccessibilityNotification_Params; 22 struct ViewHostMsg_AccessibilityNotification_Params;
23 23
24 class BrowserAccessibilityFactory { 24 class BrowserAccessibilityFactory {
dmazzoni 2010/10/01 17:14:37 Should this be a BrowserAccessibilityWinFactory?
Chris Guillory 2010/10/01 17:42:23 Done.
25 public: 25 public:
26 virtual ~BrowserAccessibilityFactory() {} 26 virtual ~BrowserAccessibilityFactory() {}
27 27
28 // Create an instance of BrowserAccessibility and return a new 28 // Create an instance of BrowserAccessibilityWin and return a new
29 // reference to it. 29 // reference to it.
30 virtual BrowserAccessibility* Create(); 30 virtual BrowserAccessibilityWin* Create();
31 }; 31 };
32 32
33 // Class that can perform actions on behalf of the BrowserAccessibilityManager. 33 // Manages a tree of BrowserAccessibilityWin objects.
34 class BrowserAccessibilityDelegate { 34 class BrowserAccessibilityManagerWin : public BrowserAccessibilityManager {
35 public: 35 public:
36 virtual ~BrowserAccessibilityDelegate() {} 36 BrowserAccessibilityManagerWin(
37 virtual void SetAccessibilityFocus(int acc_obj_id) = 0; 37 HWND parent_window,
38 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0;
39 };
40
41 // Manages a tree of BrowserAccessibility objects.
42 class BrowserAccessibilityManager {
43 public:
44 BrowserAccessibilityManager(
45 HWND parent_hwnd,
46 const webkit_glue::WebAccessibility& src, 38 const webkit_glue::WebAccessibility& src,
47 BrowserAccessibilityDelegate* delegate, 39 BrowserAccessibilityDelegate* delegate,
48 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); 40 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory());
49 41
50 virtual ~BrowserAccessibilityManager(); 42 virtual ~BrowserAccessibilityManagerWin();
51 43
52 // Return a pointer to the root of the tree, does not make a new reference. 44 // Return a pointer to the root of the tree, does not make a new reference.
53 BrowserAccessibility* GetRoot(); 45 BrowserAccessibilityWin* GetRoot();
54 46
55 // Removes the BrowserAccessibility child_id from the manager. 47 // Removes the BrowserAccessibilityWin child_id from the manager.
56 void Remove(LONG child_id); 48 void Remove(LONG child_id);
57 49
58 // Return a pointer to the object corresponding to the given child_id, 50 // Return a pointer to the object corresponding to the given child_id,
59 // does not make a new reference. 51 // does not make a new reference.
60 BrowserAccessibility* GetFromChildID(LONG child_id); 52 BrowserAccessibilityWin* GetFromChildID(LONG child_id);
61 53
62 // Get a the default IAccessible for the parent window, does not make a 54 // Get a the default IAccessible for the parent window, does not make a
63 // new reference. 55 // new reference.
64 IAccessible* GetParentWindowIAccessible(); 56 IAccessible* GetParentWindowIAccessible();
65 57
66 // Get the parent window.
67 HWND GetParentHWND();
68
69 // Return the object that has focus, if it's a descandant of the 58 // Return the object that has focus, if it's a descandant of the
70 // given root (inclusive). Does not make a new reference. 59 // given root (inclusive). Does not make a new reference.
71 BrowserAccessibility* GetFocus(BrowserAccessibility* root); 60 BrowserAccessibilityWin* GetFocus(BrowserAccessibilityWin* root);
72 61
73 // Tell the renderer to set focus to this node. 62 // Tell the renderer to set focus to this node.
74 void SetFocus(const BrowserAccessibility& node); 63 void SetFocus(const BrowserAccessibilityWin& node);
75 64
76 // Tell the renderer to do the default action for this node. 65 // Tell the renderer to do the default action for this node.
77 void DoDefaultAction(const BrowserAccessibility& node); 66 void DoDefaultAction(const BrowserAccessibilityWin& node);
78 67
79 // Called when the renderer process has notified us of about tree changes. 68 // BrowserAccessibilityManager Methods
80 // Send a notification to MSAA clients of the change. 69 virtual IAccessible* GetRootAccessible();
81 void OnAccessibilityNotifications( 70 virtual void OnAccessibilityObjectStateChange(
82 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params); 71 const webkit_glue::WebAccessibility& acc_obj);
72 virtual void OnAccessibilityObjectChildrenChange(
73 const webkit_glue::WebAccessibility& acc_obj);
74 virtual void OnAccessibilityObjectFocusChange(
75 const webkit_glue::WebAccessibility& acc_obj);
76 virtual void OnAccessibilityObjectLoadComplete(
77 const webkit_glue::WebAccessibility& acc_obj);
78 virtual void OnAccessibilityObjectValueChange(
79 const webkit_glue::WebAccessibility& acc_obj);
83 80
84 private: 81 private:
85 // Update the accessibility tree with an updated WebAccessibility tree or 82 // Update the accessibility tree with an updated WebAccessibility tree or
86 // subtree received from the renderer process. Returns the updated node or 83 // subtree received from the renderer process. Returns the updated node or
87 // NULL if no node was updated. 84 // NULL if no node was updated.
88 BrowserAccessibility* UpdateTree( 85 BrowserAccessibilityWin* UpdateTree(
89 const webkit_glue::WebAccessibility& acc_obj);
90
91 void OnAccessibilityObjectStateChange(
92 const webkit_glue::WebAccessibility& acc_obj);
93 void OnAccessibilityObjectChildrenChange(
94 const webkit_glue::WebAccessibility& acc_obj);
95 void OnAccessibilityObjectFocusChange(
96 const webkit_glue::WebAccessibility& acc_obj);
97 void OnAccessibilityObjectLoadComplete(
98 const webkit_glue::WebAccessibility& acc_obj);
99 void OnAccessibilityObjectValueChange(
100 const webkit_glue::WebAccessibility& acc_obj); 86 const webkit_glue::WebAccessibility& acc_obj);
101 87
102 // Returns the next MSAA child id. 88 // Returns the next MSAA child id.
103 static LONG GetNextChildID(); 89 static LONG GetNextChildID();
104 90
105 // Recursively build a tree of BrowserAccessibility objects from 91 // Recursively build a tree of BrowserAccessibilityWin objects from
106 // the WebAccessibility tree received from the renderer process. 92 // the WebAccessibility tree received from the renderer process.
107 BrowserAccessibility* CreateAccessibilityTree( 93 BrowserAccessibilityWin* CreateAccessibilityTree(
108 BrowserAccessibility* parent, 94 BrowserAccessibilityWin* parent,
109 int child_id, 95 int child_id,
110 const webkit_glue::WebAccessibility& src, 96 const webkit_glue::WebAccessibility& src,
111 int index_in_parent); 97 int index_in_parent);
112 98
113 // The parent window.
114 HWND parent_hwnd_;
115
116 // The object that can perform actions on our behalf. 99 // The object that can perform actions on our behalf.
117 BrowserAccessibilityDelegate* delegate_; 100 BrowserAccessibilityDelegate* delegate_;
118 101
119 // Factory to create BrowserAccessibility objects (for dependency injection). 102 // Factory to create BrowserAccessibility objects (for dependency injection).
120 scoped_ptr<BrowserAccessibilityFactory> factory_; 103 scoped_ptr<BrowserAccessibilityFactory> factory_;
121 104
122 // A default IAccessible instance for the parent window. 105 // A default IAccessible instance for the parent window.
123 ScopedComPtr<IAccessible> window_iaccessible_; 106 ScopedComPtr<IAccessible> window_iaccessible_;
124 107
125 // The root of the tree of IAccessible objects and the element that 108 // The root of the tree of IAccessible objects and the element that
126 // currently has focus, if any. 109 // currently has focus, if any.
127 BrowserAccessibility* root_; 110 BrowserAccessibilityWin* root_;
128 BrowserAccessibility* focus_; 111 BrowserAccessibilityWin* focus_;
129 112
130 // A mapping from the IDs of objects in the renderer, to the child IDs 113 // A mapping from the IDs of objects in the renderer, to the child IDs
131 // we use internally here. 114 // we use internally here.
132 base::hash_map<int, LONG> renderer_id_to_child_id_map_; 115 base::hash_map<int, LONG> renderer_id_to_child_id_map_;
133 116
134 // A mapping from child IDs to BrowserAccessibility objects. 117 // A mapping from child IDs to BrowserAccessibilityWin objects.
135 base::hash_map<LONG, BrowserAccessibility*> child_id_map_; 118 base::hash_map<LONG, BrowserAccessibilityWin*> child_id_map_;
136 119
137 // The next child ID to use; static so that they're global to the process. 120 // The next child ID to use; static so that they're global to the process.
138 // Screen readers cache these IDs to see if they've seen the same object 121 // Screen readers cache these IDs to see if they've seen the same object
139 // before so we should avoid reusing them within the same project. 122 // before so we should avoid reusing them within the same project.
140 static LONG next_child_id_; 123 static LONG next_child_id_;
141 124
142 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); 125 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerWin);
143 }; 126 };
144 127
145 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_ 128 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698