OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "content/renderer/renderer_accessibility.h" | |
6 | |
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/WebAccessibilityObjec
t.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" | |
14 | |
15 using WebKit::WebAccessibilityNotification; | |
16 using WebKit::WebAccessibilityObject; | |
17 using WebKit::WebDocument; | |
18 using WebKit::WebFrame; | |
19 using WebKit::WebView; | |
20 | |
21 namespace content { | |
22 | |
23 RendererAccessibility::RendererAccessibility( | |
24 RenderViewImpl* render_view) | |
25 : RenderViewObserver(render_view), | |
26 render_view_(render_view), | |
27 logging_(false) { | |
28 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
29 if (command_line.HasSwitch(switches::kEnableAccessibilityLogging)) | |
30 logging_ = true; | |
31 } | |
32 | |
33 RendererAccessibility::~RendererAccessibility() { | |
34 } | |
35 | |
36 WebDocument RendererAccessibility::GetMainDocument() { | |
37 WebView* view = render_view()->GetWebView(); | |
38 WebFrame* main_frame = view ? view->mainFrame() : NULL; | |
39 | |
40 if (main_frame) | |
41 return main_frame->document(); | |
42 | |
43 return WebDocument(); | |
44 } | |
45 | |
46 #ifndef NDEBUG | |
47 const std::string RendererAccessibility::AccessibilityNotificationToString( | |
48 AccessibilityNotification notification) { | |
49 switch (notification) { | |
50 case AccessibilityNotificationActiveDescendantChanged: | |
51 return "active descendant changed"; | |
52 case AccessibilityNotificationBlur: | |
53 return "blur"; | |
54 case AccessibilityNotificationAlert: | |
55 return "alert"; | |
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: | |
71 return "object show"; | |
72 case AccessibilityNotificationObjectHide: | |
73 return "object hide"; | |
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"; | |
92 default: | |
93 NOTREACHED(); | |
94 } | |
95 return ""; | |
96 } | |
97 #endif | |
98 | |
99 } // namespace content | |
OLD | NEW |