summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_accessibility_manager.h
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 00:39:41 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 00:39:41 +0000
commit2ee0e7564803f87b195d63c497a1101a2b29ab4f (patch)
tree0795001761a54463b710c58799cc41655dd842c0 /chrome/browser/browser_accessibility_manager.h
parent3a51cfdd1775075f13dab50f6d8a9cb04bd6beb9 (diff)
downloadchromium_src-2ee0e7564803f87b195d63c497a1101a2b29ab4f.zip
chromium_src-2ee0e7564803f87b195d63c497a1101a2b29ab4f.tar.gz
chromium_src-2ee0e7564803f87b195d63c497a1101a2b29ab4f.tar.bz2
Revert 46567 - Reimplement accessibility of web content by caching the entire
accessibility tree in the browser process. Adds new RPCs for a browser tab to request accessibility info from a renderer; the renderer responds with a complete tree of accessibility metadata for the entire DOM, which is then cached in the RenderWidgetHostView. This part is crossplatform and will help with accessibility on both Windows and Mac OS X. For Windows, MSAA support for web content has been rewritten to use this new cache. Tested in JAWS and NVDA screen readers. Using Chrome with a screen reader is now fast and stable, unlike the previous implementation. However, note that most advanced functionality is still not supported, and much work remains to make Chrome work well with a screen reader. This is a necessary step to improve stability first. BUG=25564 BUG=13291 TEST=See http://codereview.chromium.org/1806001 Review URL: http://codereview.chromium.org/1637018 TBR=dmazzoni@chromium.org Review URL: http://codereview.chromium.org/2031004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46642 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_accessibility_manager.h')
-rw-r--r--chrome/browser/browser_accessibility_manager.h156
1 files changed, 79 insertions, 77 deletions
diff --git a/chrome/browser/browser_accessibility_manager.h b/chrome/browser/browser_accessibility_manager.h
index 1db8100..4850242 100644
--- a/chrome/browser/browser_accessibility_manager.h
+++ b/chrome/browser/browser_accessibility_manager.h
@@ -1,102 +1,104 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_
#define CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_
-#include <atlbase.h>
-#include <atlcom.h>
-#include <oleacc.h>
-
#include <map>
-#include "base/hash_tables.h"
-#include "base/scoped_comptr_win.h"
-#include "base/scoped_ptr.h"
+#include "base/singleton.h"
+#include "chrome/common/notification_registrar.h"
#include "webkit/glue/webaccessibility.h"
class BrowserAccessibility;
class RenderProcessHost;
class RenderWidgetHost;
-class BrowserAccessibilityFactory {
- public:
- virtual ~BrowserAccessibilityFactory() {}
-
- // Create an instance of BrowserAccessibility and return a new
- // reference to it.
- virtual BrowserAccessibility* Create();
-};
-
-// Manages a tree of BrowserAccessibility objects.
-class BrowserAccessibilityManager {
+using webkit_glue::WebAccessibility;
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// BrowserAccessibilityManager
+//
+// Used to manage instance creation and memory handling for browser side
+// accessibility. A singleton class. It implements NotificationObserver to
+// ensure that a termination of a renderer process gets propagated to the
+// active BrowserAccessibility instances calling into it. Each such instance
+// will upon such an event be set to an inactive state, failing calls from the
+// assistive technology gracefully.
+////////////////////////////////////////////////////////////////////////////////
+class BrowserAccessibilityManager : public NotificationObserver {
public:
- BrowserAccessibilityManager(
- HWND parent_hwnd,
- const webkit_glue::WebAccessibility& src,
- BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory());
-
- virtual ~BrowserAccessibilityManager();
-
- // Return a pointer to the root of the tree, does not make a new reference.
- BrowserAccessibility* GetRoot();
-
- // Return a pointer to the object corresponding to the given child_id,
- // does not make a new reference.
- BrowserAccessibility* GetFromChildID(LONG child_id);
-
- // Get a the default IAccessible for the parent window, does not make a
- // new reference.
- IAccessible* GetParentWindowIAccessible();
-
- // Get the parent window.
- HWND GetParentHWND();
-
- // Return the object that has focus, if it's a descandant of the
- // given root (inclusive). Does not make a new reference.
- BrowserAccessibility* GetFocus(BrowserAccessibility* root);
-
- // Called when the renderer process has notified us of a focus or state
- // change. Send a notification to MSAA clients of the change.
- void OnAccessibilityFocusChange(int acc_obj_id);
- void OnAccessibilityObjectStateChange(int acc_obj_id);
+ // Gets the singleton BrowserAccessibilityManager object. The first time this
+ // method is called, a CacheManagerHost object is constructed and returned.
+ // Subsequent calls will return the same object.
+ static BrowserAccessibilityManager* GetInstance();
+
+ // Creates an instance of BrowserAccessibility, initializes it and sets the
+ // |acc_obj_id|, which is used for IPC communication, and |instance_id|,
+ // which is used to identify the mapping between accessibility instance and
+ // RenderProcess.
+ STDMETHODIMP CreateAccessibilityInstance(REFIID iid,
+ int acc_obj_id,
+ int routing_id,
+ int process_id,
+ HWND parent_hwnd,
+ void** interface_ptr);
+
+ // Composes and sends a message for requesting needed accessibility
+ // information.
+ bool RequestAccessibilityInfo(WebAccessibility::InParams* in,
+ int routing_id,
+ int process_id);
+
+ // Notifies assistive technology that renderer focus changed, through the
+ // platform-specific channels.
+ bool ChangeAccessibilityFocus(int acc_obj_id, int process_id, int routing_id);
+
+ // Notifies assistive technology that an object's state changed, through the
+ // platform-specific channels.
+ bool OnAccessibilityObjectStateChange(int acc_obj_id,
+ int process_id,
+ int routing_id);
+
+ // Wrapper function, for cleaner code.
+ const WebAccessibility::OutParams& response();
+
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ protected:
+ // This class is a singleton. Do not instantiate directly.
+ BrowserAccessibilityManager();
+ friend struct DefaultSingletonTraits<BrowserAccessibilityManager>;
+
+ ~BrowserAccessibilityManager();
private:
- // Recursively build a tree of BrowserAccessibility objects from
- // the WebAccessibility tree received from the renderer process.
- BrowserAccessibility* CreateAccessibilityTree(
- BrowserAccessibility* parent,
- const webkit_glue::WebAccessibility& src,
- int index_in_parent);
+ // Retrieves the BrowserAccessibility instance connected to the
+ // RenderProcessHost identified by the process/routing id pair.
+ BrowserAccessibility* GetBrowserAccessibility(int process_id, int routing_id);
- // The parent window.
- HWND parent_hwnd_;
+ // Multi-map from process id (key) to active BrowserAccessibility instances
+ // for that RenderProcessHost.
+ typedef std::multimap<int, BrowserAccessibility*> RenderProcessHostMap;
+ typedef std::pair<int, BrowserAccessibility*> MapEntry;
- // Factory to create BrowserAccessibility objects (for dependency injection).
- scoped_ptr<BrowserAccessibilityFactory> factory_;
+ NotificationRegistrar registrar_;
- // A default IAccessible instance for the parent window.
- ScopedComPtr<IAccessible> window_iaccessible_;
+ // Mapping to track which RenderProcessHosts ids are active. If a
+ // RenderProcessHost is found to be terminated, its id (key) should be removed
+ // from this mapping, and the connected BrowserAccessibility ids/instances
+ // invalidated.
+ RenderProcessHostMap render_process_host_map_;
- // The root of the tree of IAccessible objects and the element that
- // currently has focus, if any.
- BrowserAccessibility* root_;
- BrowserAccessibility* focus_;
-
- // A mapping from the IDs of objects in the renderer, to the child IDs
- // we use internally here.
- base::hash_map<int, LONG> renderer_id_to_child_id_map_;
-
- // A mapping from child IDs to BrowserAccessibility objects.
- base::hash_map<LONG, BrowserAccessibility*> child_id_map_;
-
- // The next child ID to use; static so that they're global to the process.
- // Screen readers cache these IDs to see if they've seen the same object
- // before so we should avoid reusing them within the same project.
- static LONG next_child_id_;
+ // Structure passed by reference to hold response parameters from the
+ // renderer.
+ WebAccessibility::OutParams out_params_;
DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManager);
};
-
#endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_MANAGER_H_