| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/accessibility/renderer_accessibility.h" | 5 #include "content/renderer/accessibility/renderer_accessibility.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/public/common/content_switches.h" | |
| 9 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
| 10 #include "third_party/WebKit/public/web/WebAXObject.h" | 9 #include "third_party/WebKit/public/web/WebAXObject.h" |
| 11 #include "third_party/WebKit/public/web/WebDocument.h" | 10 #include "third_party/WebKit/public/web/WebDocument.h" |
| 12 #include "third_party/WebKit/public/web/WebFrame.h" | 11 #include "third_party/WebKit/public/web/WebFrame.h" |
| 13 #include "third_party/WebKit/public/web/WebView.h" | 12 #include "third_party/WebKit/public/web/WebView.h" |
| 14 | 13 |
| 15 using blink::WebAXObject; | 14 using blink::WebAXObject; |
| 16 using blink::WebDocument; | 15 using blink::WebDocument; |
| 17 using blink::WebFrame; | 16 using blink::WebFrame; |
| 18 using blink::WebView; | 17 using blink::WebView; |
| 19 | 18 |
| 20 namespace content { | 19 namespace content { |
| 21 | 20 |
| 22 RendererAccessibility::RendererAccessibility( | 21 RendererAccessibility::RendererAccessibility( |
| 23 RenderViewImpl* render_view) | 22 RenderViewImpl* render_view) |
| 24 : RenderViewObserver(render_view), | 23 : RenderViewObserver(render_view), |
| 25 render_view_(render_view), | 24 render_view_(render_view) { |
| 26 logging_(false) { | |
| 27 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 28 if (command_line.HasSwitch(switches::kEnableAccessibilityLogging)) | |
| 29 logging_ = true; | |
| 30 } | 25 } |
| 31 | 26 |
| 32 RendererAccessibility::~RendererAccessibility() { | 27 RendererAccessibility::~RendererAccessibility() { |
| 33 } | 28 } |
| 34 | 29 |
| 35 WebDocument RendererAccessibility::GetMainDocument() { | 30 WebDocument RendererAccessibility::GetMainDocument() { |
| 36 WebView* view = render_view()->GetWebView(); | 31 WebView* view = render_view()->GetWebView(); |
| 37 WebFrame* main_frame = view ? view->mainFrame() : NULL; | 32 WebFrame* main_frame = view ? view->mainFrame() : NULL; |
| 38 | 33 |
| 39 if (main_frame) | 34 if (main_frame) |
| 40 return main_frame->document(); | 35 return main_frame->document(); |
| 41 | 36 |
| 42 return WebDocument(); | 37 return WebDocument(); |
| 43 } | 38 } |
| 44 | 39 |
| 45 #ifndef NDEBUG | |
| 46 const std::string RendererAccessibility::AccessibilityEventToString( | |
| 47 ui::AXEvent event) { | |
| 48 switch (event) { | |
| 49 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: | |
| 50 return "active descendant changed"; | |
| 51 case ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED: | |
| 52 return "aria attribute changed"; | |
| 53 case ui::AX_EVENT_ALERT: | |
| 54 return "alert"; | |
| 55 case ui::AX_EVENT_AUTOCORRECTION_OCCURED: | |
| 56 return "autocorrection occurred"; | |
| 57 case ui::AX_EVENT_BLUR: | |
| 58 return "blur"; | |
| 59 case ui::AX_EVENT_CHECKED_STATE_CHANGED: | |
| 60 return "check state changed"; | |
| 61 case ui::AX_EVENT_CHILDREN_CHANGED: | |
| 62 return "children changed"; | |
| 63 case ui::AX_EVENT_FOCUS: | |
| 64 return "focus changed"; | |
| 65 case ui::AX_EVENT_HIDE: | |
| 66 return "object hide"; | |
| 67 case ui::AX_EVENT_INVALID_STATUS_CHANGED: | |
| 68 return "invalid status changed"; | |
| 69 case ui::AX_EVENT_LAYOUT_COMPLETE: | |
| 70 return "layout complete"; | |
| 71 case ui::AX_EVENT_LIVE_REGION_CHANGED: | |
| 72 return "live region changed"; | |
| 73 case ui::AX_EVENT_LOAD_COMPLETE: | |
| 74 return "load complete"; | |
| 75 case ui::AX_EVENT_LOCATION_CHANGED: | |
| 76 return "location changed"; | |
| 77 case ui::AX_EVENT_MENU_END: | |
| 78 return "menu end"; | |
| 79 case ui::AX_EVENT_MENU_LIST_ITEM_SELECTED: | |
| 80 return "menu list item selected"; | |
| 81 case ui::AX_EVENT_MENU_LIST_VALUE_CHANGED: | |
| 82 return "menu list changed"; | |
| 83 case ui::AX_EVENT_MENU_POPUP_END: | |
| 84 return "menu popup end"; | |
| 85 case ui::AX_EVENT_MENU_POPUP_START: | |
| 86 return "menu popup start"; | |
| 87 case ui::AX_EVENT_MENU_START: | |
| 88 return "menu start"; | |
| 89 case ui::AX_EVENT_NONE: | |
| 90 return "none"; | |
| 91 case ui::AX_EVENT_ROW_COLLAPSED: | |
| 92 return "row collapsed"; | |
| 93 case ui::AX_EVENT_ROW_COUNT_CHANGED: | |
| 94 return "row count changed"; | |
| 95 case ui::AX_EVENT_ROW_EXPANDED: | |
| 96 return "row expanded"; | |
| 97 case ui::AX_EVENT_SCROLL_POSITION_CHANGED: | |
| 98 return "scroll position changed"; | |
| 99 case ui::AX_EVENT_SCROLLED_TO_ANCHOR: | |
| 100 return "scrolled to anchor"; | |
| 101 case ui::AX_EVENT_SELECTED_CHILDREN_CHANGED: | |
| 102 return "selected children changed"; | |
| 103 case ui::AX_EVENT_SELECTED_TEXT_CHANGED: | |
| 104 return "selected text changed"; | |
| 105 case ui::AX_EVENT_SELECTION_CHANGED: | |
| 106 return "selection changed"; | |
| 107 case ui::AX_EVENT_SHOW: | |
| 108 return "object show"; | |
| 109 case ui::AX_EVENT_TEXT_CHANGED: | |
| 110 return "text changed"; | |
| 111 case ui::AX_EVENT_TEXT_INSERTED: | |
| 112 return "text inserted"; | |
| 113 case ui::AX_EVENT_TEXT_REMOVED: | |
| 114 return "text removed"; | |
| 115 case ui::AX_EVENT_VALUE_CHANGED: | |
| 116 return "value changed"; | |
| 117 default: | |
| 118 NOTREACHED(); | |
| 119 } | |
| 120 return ""; | |
| 121 } | |
| 122 #endif | |
| 123 | |
| 124 } // namespace content | 40 } // namespace content |
| OLD | NEW |