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 #include "content/renderer/renderer_accessibility.h"
7 #include "base/command_line.h"
8 #include "content/public/common/content_switches.h"
9 #include "content/renderer/render_view_impl.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
15 using WebKit::WebAccessibilityNotification
;
16 using WebKit::WebAccessibilityObject
;
17 using WebKit::WebDocument
;
18 using WebKit::WebFrame
;
19 using WebKit::WebView
;
23 RendererAccessibility::RendererAccessibility(
24 RenderViewImpl
* render_view
)
25 : RenderViewObserver(render_view
),
26 render_view_(render_view
),
28 const CommandLine
& command_line
= *CommandLine::ForCurrentProcess();
29 if (command_line
.HasSwitch(switches::kEnableAccessibilityLogging
))
33 RendererAccessibility::~RendererAccessibility() {
36 WebDocument
RendererAccessibility::GetMainDocument() {
37 WebView
* view
= render_view()->GetWebView();
38 WebFrame
* main_frame
= view
? view
->mainFrame() : NULL
;
41 return main_frame
->document();
47 const std::string
RendererAccessibility::AccessibilityNotificationToString(
48 AccessibilityNotification notification
) {
49 switch (notification
) {
50 case AccessibilityNotificationActiveDescendantChanged
:
51 return "active descendant changed";
52 case AccessibilityNotificationBlur
:
54 case AccessibilityNotificationAlert
:
56 case AccessibilityNotificationCheckStateChanged
:
57 return "check state changed";
58 case AccessibilityNotificationChildrenChanged
:
59 return "children changed";
60 case AccessibilityNotificationFocusChanged
:
61 return "focus changed";
62 case AccessibilityNotificationLayoutComplete
:
63 return "layout complete";
64 case AccessibilityNotificationLiveRegionChanged
:
65 return "live region changed";
66 case AccessibilityNotificationLoadComplete
:
67 return "load complete";
68 case AccessibilityNotificationMenuListValueChanged
:
69 return "menu list changed";
70 case AccessibilityNotificationObjectShow
:
72 case AccessibilityNotificationObjectHide
:
74 case AccessibilityNotificationRowCountChanged
:
75 return "row count changed";
76 case AccessibilityNotificationRowCollapsed
:
77 return "row collapsed";
78 case AccessibilityNotificationRowExpanded
:
79 return "row expanded";
80 case AccessibilityNotificationScrolledToAnchor
:
81 return "scrolled to anchor";
82 case AccessibilityNotificationSelectedChildrenChanged
:
83 return "selected children changed";
84 case AccessibilityNotificationSelectedTextChanged
:
85 return "selected text changed";
86 case AccessibilityNotificationTextInserted
:
87 return "text inserted";
88 case AccessibilityNotificationTextRemoved
:
89 return "text removed";
90 case AccessibilityNotificationValueChanged
:
91 return "value changed";
99 } // namespace content