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

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

Issue 115374: Adds propagation and handling of render-side focus events, for the benefit of... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <oaidl.h> // Needed for VARIANT structure. 8 #include <map>
9 #include <hash_map>
10 9
11 #include "base/singleton.h" 10 #include "base/singleton.h"
12 #include "chrome/common/notification_observer.h" 11 #include "chrome/common/notification_observer.h"
13 #include "webkit/glue/webaccessibility.h" 12 #include "webkit/glue/webaccessibility.h"
14 13
15 class BrowserAccessibility; 14 class BrowserAccessibility;
16 class RenderProcessHost; 15 class RenderProcessHost;
17 class RenderWidgetHost; 16 class RenderWidgetHost;
18 17
18 using webkit_glue::WebAccessibility;
19
19 //////////////////////////////////////////////////////////////////////////////// 20 ////////////////////////////////////////////////////////////////////////////////
20 // 21 //
21 // BrowserAccessibilityManager 22 // BrowserAccessibilityManager
22 // 23 //
23 // Used to manage instance creation and memory handling for browser side 24 // Used to manage instance creation and memory handling for browser side
24 // accessibility. A singleton class. It implements NotificationObserver to 25 // accessibility. A singleton class. It implements NotificationObserver to
25 // ensure that a termination of a renderer process gets propagated to the 26 // ensure that a termination of a renderer process gets propagated to the
26 // active BrowserAccessibility instances calling into it. Each such instance 27 // active BrowserAccessibility instances calling into it. Each such instance
27 // will upon such an event be set to an inactive state, failing calls from the 28 // will upon such an event be set to an inactive state, failing calls from the
28 // assistive technology gracefully. 29 // assistive technology gracefully.
29 //////////////////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////////////////
30 class BrowserAccessibilityManager : public NotificationObserver { 31 class BrowserAccessibilityManager : public NotificationObserver {
31 public: 32 public:
32 // Gets the singleton BrowserAccessibilityManager object. The first time this 33 // Gets the singleton BrowserAccessibilityManager object. The first time this
33 // method is called, a CacheManagerHost object is constructed and returned. 34 // method is called, a CacheManagerHost object is constructed and returned.
34 // Subsequent calls will return the same object. 35 // Subsequent calls will return the same object.
35 static BrowserAccessibilityManager* GetInstance(); 36 static BrowserAccessibilityManager* GetInstance();
36 37
37 // Creates an instance of BrowserAccessibility, initializes it and sets the 38 // Creates an instance of BrowserAccessibility, initializes it and sets the
38 // [acc_obj_id], which is used for IPC communication, and [instance_id], 39 // |acc_obj_id|, which is used for IPC communication, and |instance_id|,
39 // which is used to identify the mapping between accessibility instance and 40 // which is used to identify the mapping between accessibility instance and
40 // RenderProcess. 41 // RenderProcess.
41 STDMETHODIMP CreateAccessibilityInstance(REFIID iid, 42 STDMETHODIMP CreateAccessibilityInstance(REFIID iid,
42 int acc_obj_id, 43 int acc_obj_id,
43 int instance_id, 44 int routing_id,
45 int process_id,
46 HWND parent_hwnd,
44 void** interface_ptr); 47 void** interface_ptr);
45 48
46 // Composes and sends a message for requesting needed accessibility 49 // Composes and sends a message for requesting needed accessibility
47 // information. Unused LONG input parameters should be NULL, and the VARIANT 50 // information.
48 // [var_id] an empty, valid instance. 51 bool RequestAccessibilityInfo(WebAccessibility::InParams* in,
49 bool RequestAccessibilityInfo(int acc_obj_id, 52 int routing_id,
50 int instance_id, 53 int process_id);
51 int acc_func_id, 54
52 int child_id, 55 // Notifies assistive technology that renderer focus changed, through the
53 long input1, 56 // platform-specific channels.
54 long input2); 57 bool ChangeAccessibilityFocus(int acc_obj_id, int process_id, int routing_id);
55 58
56 // Wrapper function, for cleaner code. 59 // Wrapper function, for cleaner code.
57 const webkit_glue::WebAccessibility::OutParams& response(); 60 const WebAccessibility::OutParams& response();
58
59 // Retrieves the parent HWND connected to the provided id.
60 HWND parent_hwnd(int id);
61
62 // Mutator, needed since constructor does not take any arguments, and to keep
63 // instance accessor clean.
64 int SetMembers(BrowserAccessibility* browser_acc,
65 HWND parent_hwnd,
66 RenderWidgetHost* render_widget_host);
67 61
68 // NotificationObserver implementation. 62 // NotificationObserver implementation.
69 virtual void Observe(NotificationType type, 63 virtual void Observe(NotificationType type,
70 const NotificationSource& source, 64 const NotificationSource& source,
71 const NotificationDetails& details); 65 const NotificationDetails& details);
72 66
73 protected: 67 protected:
74 // This class is a singleton. Do not instantiate directly. 68 // This class is a singleton. Do not instantiate directly.
75 BrowserAccessibilityManager(); 69 BrowserAccessibilityManager();
76 friend struct DefaultSingletonTraits<BrowserAccessibilityManager>; 70 friend struct DefaultSingletonTraits<BrowserAccessibilityManager>;
77 71
78 ~BrowserAccessibilityManager(); 72 ~BrowserAccessibilityManager();
79 73
80 private: 74 private:
81 // Member variable structure, used in instance hashmap. 75 // Retrieves the BrowserAccessibility instance connected to the
82 struct UniqueMembers { 76 // RenderProcessHost identified by the process/routing id pair.
83 RenderWidgetHost* render_widget_host_; 77 BrowserAccessibility* GetBrowserAccessibility(int process_id, int routing_id);
84 HWND parent_hwnd_;
85 78
86 UniqueMembers(HWND parent_hwnd, RenderWidgetHost* render_widget_host) 79 // Multi-map from process id (key) to active BrowserAccessibility instances
87 : parent_hwnd_(parent_hwnd), 80 // for that RenderProcessHost.
88 render_widget_host_(render_widget_host) { 81 typedef std::multimap<int, BrowserAccessibility*> RenderProcessHostMap;
89 } 82 typedef std::pair<int, BrowserAccessibility*> MapEntry;
90 };
91 83
92 typedef stdext::hash_map<int, UniqueMembers*> InstanceMap; 84 // Mapping to track which RenderProcessHosts ids are active. If a
93 typedef stdext::hash_map<RenderProcessHost*, BrowserAccessibility*> 85 // RenderProcessHost is found to be terminated, its id (key) should be removed
94 RenderProcessHostMap; 86 // from this mapping, and the connected BrowserAccessibility ids/instances
95 87 // invalidated.
96 // Caching of the unique member variables used to handle browser accessibility
97 // requests from multiple processes.
98 InstanceMap instance_map_;
99 int instance_id_;
100
101 // Reverse mapping to track which RenderProcessHosts are active. If a
102 // RenderProcessHost is found to be terminated, it should be removed from this
103 // mapping, and the connected BrowserAccessibility ids/instances invalidated.
104 RenderProcessHostMap render_process_host_map_; 88 RenderProcessHostMap render_process_host_map_;
105 89
106 webkit_glue::WebAccessibility::OutParams out_params_; 90 // Structure passed by reference to hold response parameters from the
91 // renderer.
92 WebAccessibility::OutParams out_params_;
107 93
108 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); 94 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager);
109 }; 95 };
110 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ 96 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698