OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ |
| 6 #define CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ |
| 7 |
| 8 #include <oaidl.h> // Needed for VARIANT structure. |
| 9 #include <hash_map> |
| 10 |
| 11 #include "base/singleton.h" |
| 12 #include "chrome/common/notification_service.h" |
| 13 #include "chrome/common/render_messages.h" |
| 14 |
| 15 class BrowserAccessibility; |
| 16 class RenderProcessHost; |
| 17 class RenderWidgetHost; |
| 18 |
| 19 // Member variable structure, used in instance hashmap. |
| 20 struct UniqueMembers { |
| 21 RenderWidgetHost* render_widget_host_; |
| 22 HWND parent_hwnd_; |
| 23 |
| 24 UniqueMembers(HWND parent_hwnd, RenderWidgetHost* render_widget_host) |
| 25 : parent_hwnd_(parent_hwnd), |
| 26 render_widget_host_(render_widget_host) { |
| 27 } |
| 28 }; |
| 29 |
| 30 typedef stdext::hash_map<int, UniqueMembers*> InstanceMap; |
| 31 typedef stdext::hash_map<RenderProcessHost*, BrowserAccessibility*> |
| 32 RenderProcessHostMap; |
| 33 |
| 34 //////////////////////////////////////////////////////////////////////////////// |
| 35 // |
| 36 // BrowserAccessibilityManager |
| 37 // |
| 38 // Used to manage instance creation and memory handling for browser side |
| 39 // accessibility. A singleton class. It implements NotificationObserver to |
| 40 // ensure that a termination of a renderer process gets propagated to the |
| 41 // active BrowserAccessibility instances calling into it. Each such instance |
| 42 // will upon such an event be set to an inactive state, failing calls from the |
| 43 // assistive technology gracefully. |
| 44 //////////////////////////////////////////////////////////////////////////////// |
| 45 class BrowserAccessibilityManager : public NotificationObserver { |
| 46 public: |
| 47 // Gets the singleton BrowserAccessibilityManager object. The first time this |
| 48 // method is called, a CacheManagerHost object is constructed and returned. |
| 49 // Subsequent calls will return the same object. |
| 50 static BrowserAccessibilityManager* Instance(); |
| 51 |
| 52 // Creates an instance of BrowserAccessibility, initializes it and sets the |
| 53 // iaccessible_id and parent_id. |
| 54 STDMETHODIMP CreateAccessibilityInstance(REFIID iid, |
| 55 int iaccessible_id, |
| 56 int instance_id, |
| 57 void** interface_ptr); |
| 58 |
| 59 // Composes and sends a message for requesting needed accessibility |
| 60 // information. Unused LONG input parameters should be NULL, and the VARIANT |
| 61 // an empty, valid instance. |
| 62 bool RequestAccessibilityInfo(int iaccessible_id, |
| 63 int instance_id, |
| 64 int iaccessible_func_id, |
| 65 VARIANT var_id, |
| 66 LONG input1, |
| 67 LONG input2); |
| 68 |
| 69 // Wrapper function, for cleaner code. |
| 70 ViewHostMsg_Accessibility_Out_Params response(); |
| 71 |
| 72 // Retrieves the parent HWND connected to the provided id. |
| 73 HWND parent_hwnd(int id); |
| 74 |
| 75 // Mutator, needed since constructor does not take any arguments, and to keep |
| 76 // instance accessor clean. |
| 77 int SetMembers(BrowserAccessibility* browser_acc, |
| 78 HWND parent_hwnd, |
| 79 RenderWidgetHost* render_widget_host); |
| 80 |
| 81 // NotificationObserver implementation. |
| 82 virtual void Observe(NotificationType type, |
| 83 const NotificationSource& source, |
| 84 const NotificationDetails& details); |
| 85 |
| 86 protected: |
| 87 // This class is a singleton. Do not instantiate directly. |
| 88 BrowserAccessibilityManager(); |
| 89 friend DefaultSingletonTraits<BrowserAccessibilityManager>; |
| 90 |
| 91 ~BrowserAccessibilityManager(); |
| 92 |
| 93 private: |
| 94 // Caching of the unique member variables used to handle browser accessibility |
| 95 // requests from multiple processes. |
| 96 InstanceMap instance_map_; |
| 97 int instance_id_; |
| 98 |
| 99 // Reverse mapping to track which RenderProcessHosts are active. If a |
| 100 // RenderProcessHost is found to be terminated, it should be removed from this |
| 101 // mapping, and the connected BrowserAccessibility ids/instances invalidated. |
| 102 RenderProcessHostMap render_process_host_map_; |
| 103 |
| 104 ViewHostMsg_Accessibility_Out_Params out_params_; |
| 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager); |
| 107 }; |
| 108 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_ |
OLD | NEW |