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

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

Issue 3562011: Revert 61740 - Make BrowserAccessibilityManager cross platform. Step 2. ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ 5 #ifndef CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_
6 #define CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ 6 #define CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h"
10
11 #if defined(OS_WIN)
12 #include <oleacc.h>
13 #endif
14
9 #include <vector> 15 #include <vector>
10 16
11 #include "base/hash_tables.h"
12 #include "base/scoped_ptr.h"
13 #include "build/build_config.h"
14 #include "chrome/common/render_messages_params.h"
15 #include "gfx/native_widget_types.h" 17 #include "gfx/native_widget_types.h"
16 #include "webkit/glue/webaccessibility.h" 18 #include "webkit/glue/webaccessibility.h"
17 19
18 20 struct ViewHostMsg_AccessibilityNotification_Params;
19 class BrowserAccessibility;
20 #if defined(OS_WIN)
21 class BrowserAccessibilityManagerWin;
22 #endif
23 21
24 using webkit_glue::WebAccessibility; 22 using webkit_glue::WebAccessibility;
25 23
26 // Class that can perform actions on behalf of the BrowserAccessibilityManager. 24 // Class that can perform actions on behalf of the BrowserAccessibilityManager.
27 class BrowserAccessibilityDelegate { 25 class BrowserAccessibilityDelegate {
28 public: 26 public:
29 virtual ~BrowserAccessibilityDelegate() {} 27 virtual ~BrowserAccessibilityDelegate() {}
30 virtual void SetAccessibilityFocus(int acc_obj_id) = 0; 28 virtual void SetAccessibilityFocus(int acc_obj_id) = 0;
31 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0; 29 virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0;
32 virtual bool HasFocus() = 0; 30 virtual bool HasFocus() = 0;
33 }; 31 };
34 32
35 class BrowserAccessibilityFactory {
36 public:
37 virtual ~BrowserAccessibilityFactory() {}
38
39 // Create an instance of BrowserAccessibility and return a new
40 // reference to it.
41 virtual BrowserAccessibility* Create();
42 };
43
44 // Manages a tree of BrowserAccessibility objects. 33 // Manages a tree of BrowserAccessibility objects.
45 class BrowserAccessibilityManager { 34 class BrowserAccessibilityManager {
46 public: 35 public:
47 // Creates the platform specific BrowserAccessibilityManager. Ownership passes 36 // Creates the platform specific BrowserAccessibilityManager. Ownership passes
48 // to the caller. 37 // to the caller.
49 static BrowserAccessibilityManager* Create( 38 static BrowserAccessibilityManager* Create(
50 gfx::NativeView parent_view, 39 gfx::NativeWindow parent_window,
51 const WebAccessibility& src, 40 const webkit_glue::WebAccessibility& src,
52 BrowserAccessibilityDelegate* delegate, 41 BrowserAccessibilityDelegate* delegate);
53 BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory());
54 42
55 virtual ~BrowserAccessibilityManager(); 43 virtual ~BrowserAccessibilityManager();
56 44
57 virtual void NotifyAccessibilityEvent(
58 ViewHostMsg_AccessibilityNotification_Params::NotificationType n,
59 BrowserAccessibility* node) = 0;
60
61 // Returns the next unique child id.
62 static int32 GetNextChildID();
63
64 // Return a pointer to the root of the tree, does not make a new reference.
65 BrowserAccessibility* GetRoot();
66
67 // Removes the BrowserAccessibility child_id from the manager.
68 void Remove(int32 child_id);
69
70 // Return a pointer to the object corresponding to the given child_id,
71 // does not make a new reference.
72 BrowserAccessibility* GetFromChildID(int32 child_id);
73
74 // Called to notify the accessibility manager that its associated native 45 // Called to notify the accessibility manager that its associated native
75 // view got focused. 46 // window got focused.
76 void GotFocus(); 47 virtual void GotFocus() = 0;
77
78 // Tell the renderer to set focus to this node.
79 void SetFocus(const BrowserAccessibility& node);
80
81 // Tell the renderer to do the default action for this node.
82 void DoDefaultAction(const BrowserAccessibility& node);
83 48
84 // Called when the renderer process has notified us of about tree changes. 49 // Called when the renderer process has notified us of about tree changes.
85 // Send a notification to MSAA clients of the change. 50 // Send a notification to MSAA clients of the change.
86 void OnAccessibilityNotifications( 51 void OnAccessibilityNotifications(
87 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params); 52 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params);
88 53
89 gfx::NativeView GetParentView(); 54 gfx::NativeWindow GetParentWindow();
90 55
91 #if defined(OS_WIN) 56 #if defined(OS_WIN)
92 BrowserAccessibilityManagerWin* toBrowserAccessibilityManagerWin(); 57 virtual IAccessible* GetRootAccessible() = 0;
93 #endif 58 #endif
94 59
95 // Return the object that has focus, if it's a descandant of the 60 protected:
96 // given root (inclusive). Does not make a new reference. 61 explicit BrowserAccessibilityManager(gfx::NativeWindow parent_window);
97 BrowserAccessibility* GetFocus(BrowserAccessibility* root);
98 62
99 protected: 63 virtual void OnAccessibilityObjectStateChange(
100 BrowserAccessibilityManager( 64 const webkit_glue::WebAccessibility& acc_obj) = 0;
101 gfx::NativeView parent_view, 65 virtual void OnAccessibilityObjectChildrenChange(
102 const WebAccessibility& src, 66 const webkit_glue::WebAccessibility& acc_obj) = 0;
103 BrowserAccessibilityDelegate* delegate, 67 virtual void OnAccessibilityObjectFocusChange(
104 BrowserAccessibilityFactory* factory); 68 const webkit_glue::WebAccessibility& acc_obj) = 0;
69 virtual void OnAccessibilityObjectLoadComplete(
70 const webkit_glue::WebAccessibility& acc_obj) = 0;
71 virtual void OnAccessibilityObjectValueChange(
72 const webkit_glue::WebAccessibility& acc_obj) = 0;
73 virtual void OnAccessibilityObjectTextChange(
74 const webkit_glue::WebAccessibility& acc_obj) = 0;
105 75
106 private: 76 private:
107 void OnAccessibilityObjectStateChange( 77 // The parent window.
108 const WebAccessibility& acc_obj); 78 gfx::NativeWindow parent_window_;
109 void OnAccessibilityObjectChildrenChange(
110 const WebAccessibility& acc_obj);
111 void OnAccessibilityObjectFocusChange(
112 const WebAccessibility& acc_obj);
113 void OnAccessibilityObjectLoadComplete(
114 const WebAccessibility& acc_obj);
115 void OnAccessibilityObjectValueChange(
116 const WebAccessibility& acc_obj);
117 void OnAccessibilityObjectTextChange(
118 const WebAccessibility& acc_obj);
119
120 // Recursively compare the IDs of our subtree to a new subtree received
121 // from the renderer and return true if their IDs match exactly.
122 bool CanModifyTreeInPlace(
123 BrowserAccessibility* current_root,
124 const WebAccessibility& new_root);
125
126 // Recursively modify a subtree (by reinitializing) to match a new
127 // subtree received from the renderer process. Should only be called
128 // if CanModifyTreeInPlace returned true.
129 void ModifyTreeInPlace(
130 BrowserAccessibility* current_root,
131 const WebAccessibility& new_root);
132
133 // Update the accessibility tree with an updated WebAccessibility tree or
134 // subtree received from the renderer process. First attempts to modify
135 // the tree in place, and if that fails, replaces the entire subtree.
136 // Returns the updated node or NULL if no node was updated.
137 BrowserAccessibility* UpdateTree(
138 const WebAccessibility& acc_obj);
139
140 // Recursively build a tree of BrowserAccessibility objects from
141 // the WebAccessibility tree received from the renderer process.
142 BrowserAccessibility* CreateAccessibilityTree(
143 BrowserAccessibility* parent,
144 int child_id,
145 const WebAccessibility& src,
146 int index_in_parent);
147
148 protected:
149 // The next unique id for a BrowserAccessibility instance.
150 static int32 next_child_id_;
151
152 // The parent view.
153 gfx::NativeView parent_view_;
154
155 // The object that can perform actions on our behalf.
156 BrowserAccessibilityDelegate* delegate_;
157
158 // Factory to create BrowserAccessibility objects (for dependency injection).
159 scoped_ptr<BrowserAccessibilityFactory> factory_;
160
161 // The root of the tree of IAccessible objects and the element that
162 // currently has focus, if any.
163 BrowserAccessibility* root_;
164 BrowserAccessibility* focus_;
165
166 // A mapping from the IDs of objects in the renderer, to the child IDs
167 // we use internally here.
168 base::hash_map<int, int32> renderer_id_to_child_id_map_;
169
170 // A mapping from child IDs to BrowserAccessibility objects.
171 base::hash_map<int32, BrowserAccessibility*> child_id_map_;
172 79
173 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); 80 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager);
174 }; 81 };
175 82
176 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_ 83 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/accessibility/browser_accessibility.cc ('k') | chrome/browser/accessibility/browser_accessibility_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698