1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_H_
6 #define CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_H_
8 #include "content/common/accessibility_messages.h"
9 #include "content/public/renderer/render_view_observer.h"
10 #include "third_party/WebKit/public/web/WebAXObject.h"
19 // The browser process implement native accessibility APIs, allowing
20 // assistive technology (e.g., screen readers, magnifiers) to access and
21 // control the web contents with high-level APIs. These APIs are also used
22 // by automation tools, and Windows 8 uses them to determine when the
23 // on-screen keyboard should be shown.
25 // An instance of this class (or rather, a subclass) belongs to RenderViewImpl.
26 // Accessibility is initialized based on the AccessibilityMode of
27 // RenderViewImpl; it lazily starts as Off or EditableTextOnly depending on
28 // the operating system, and switches to Complete if assistive technology is
29 // detected or a flag is set.
31 // A tree of accessible objects is built here and sent to the browser process;
32 // the browser process maintains this as a tree of platform-native
33 // accessible objects that can be used to respond to accessibility requests
34 // from other processes.
36 // This base class just contains common code and will not do anything by itself.
37 // The two subclasses are:
39 // RendererAccessibilityComplete - turns on WebKit accessibility and
40 // provides a full accessibility implementation for when
41 // assistive technology is running.
43 // RendererAccessibilityFocusOnly - does not turn on WebKit
44 // accessibility. Only sends a minimal accessible tree to the
45 // browser whenever focus changes. This mode is currently used
46 // to support opening the on-screen keyboard in response to
47 // touch events on Windows 8 in Metro mode.
49 // What both subclasses have in common is that they are responsible for
51 class CONTENT_EXPORT RendererAccessibility : public RenderViewObserver {
53 explicit RendererAccessibility(RenderViewImpl* render_view);
54 virtual ~RendererAccessibility();
56 // Called when an accessibility notification occurs in WebKit.
57 virtual void HandleWebAccessibilityEvent(
58 const WebKit::WebAXObject& obj, WebKit::WebAXEvent event) = 0;
61 // Returns the main top-level document for this page, or NULL if there's
63 WebKit::WebDocument GetMainDocument();
66 const std::string AccessibilityEventToString(WebKit::WebAXEvent event);
69 // The RenderViewImpl that owns us.
70 RenderViewImpl* render_view_;
72 // True if verbose logging of accessibility events is on.
75 DISALLOW_COPY_AND_ASSIGN(RendererAccessibility);
78 } // namespace content
80 #endif // CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_H_