| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" | 5 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/extensions/api/automation_internal/automation_event_rou
ter.h" | 14 #include "chrome/browser/extensions/api/automation_internal/automation_event_rou
ter.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/common/extensions/chrome_extension_messages.h" | 16 #include "chrome/common/extensions/chrome_extension_messages.h" |
| 17 #include "content/public/browser/ax_event_notification_details.h" | 17 #include "content/public/browser/ax_event_notification_details.h" |
| 18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 19 #include "ui/accessibility/ax_action_data.h" | |
| 20 #include "ui/accessibility/ax_enums.h" | |
| 21 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 22 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" | 20 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" |
| 23 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 24 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 25 | 23 |
| 26 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 27 #include "ash/wm/window_util.h" // nogncheck | 25 #include "ash/wm/window_util.h" // nogncheck |
| 28 #endif | 26 #endif |
| 29 | 27 |
| 30 using content::BrowserContext; | 28 using content::BrowserContext; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 const std::string& text) { | 74 const std::string& text) { |
| 77 if (!enabled_) | 75 if (!enabled_) |
| 78 return; | 76 return; |
| 79 | 77 |
| 80 views::AXAuraObjWrapper* obj = | 78 views::AXAuraObjWrapper* obj = |
| 81 static_cast<AXRootObjWrapper*>(current_tree_->GetRoot()) | 79 static_cast<AXRootObjWrapper*>(current_tree_->GetRoot()) |
| 82 ->GetAlertForText(text); | 80 ->GetAlertForText(text); |
| 83 SendEvent(context, obj, ui::AX_EVENT_ALERT); | 81 SendEvent(context, obj, ui::AX_EVENT_ALERT); |
| 84 } | 82 } |
| 85 | 83 |
| 86 void AutomationManagerAura::PerformAction( | 84 void AutomationManagerAura::DoDefault(int32_t id) { |
| 87 const ui::AXActionData& data) { | |
| 88 CHECK(enabled_); | 85 CHECK(enabled_); |
| 86 current_tree_->DoDefault(id); |
| 87 } |
| 89 | 88 |
| 90 switch (data.action) { | 89 void AutomationManagerAura::Focus(int32_t id) { |
| 91 case ui::AX_ACTION_DO_DEFAULT: | 90 CHECK(enabled_); |
| 92 current_tree_->DoDefault(data.target_node_id); | 91 current_tree_->Focus(id); |
| 93 break; | 92 } |
| 94 case ui::AX_ACTION_SET_FOCUS: | 93 |
| 95 current_tree_->Focus(data.target_node_id); | 94 void AutomationManagerAura::MakeVisible(int32_t id) { |
| 96 break; | 95 CHECK(enabled_); |
| 97 case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE: | 96 current_tree_->MakeVisible(id); |
| 98 current_tree_->MakeVisible(data.target_node_id); | 97 } |
| 99 break; | 98 |
| 100 case ui::AX_ACTION_SET_SELECTION: | 99 void AutomationManagerAura::SetSelection(int32_t anchor_id, |
| 101 if (data.anchor_node_id != data.focus_node_id) { | 100 int32_t anchor_offset, |
| 102 NOTREACHED(); | 101 int32_t focus_id, |
| 103 return; | 102 int32_t focus_offset) { |
| 104 } | 103 CHECK(enabled_); |
| 105 current_tree_->SetSelection( | 104 if (anchor_id != focus_id) { |
| 106 data.anchor_node_id, data.anchor_offset, data.focus_offset); | 105 NOTREACHED(); |
| 107 break; | 106 return; |
| 108 case ui::AX_ACTION_SHOW_CONTEXT_MENU: | |
| 109 current_tree_->ShowContextMenu(data.target_node_id); | |
| 110 break; | |
| 111 case ui::AX_ACTION_SET_ACCESSIBILITY_FOCUS: | |
| 112 // Sent by ChromeVox but doesn't need to be handled by aura. | |
| 113 break; | |
| 114 case ui::AX_ACTION_HIT_TEST: | |
| 115 case ui::AX_ACTION_SCROLL_TO_POINT: | |
| 116 case ui::AX_ACTION_SET_SCROLL_OFFSET: | |
| 117 case ui::AX_ACTION_SET_VALUE: | |
| 118 // Not implemented yet. | |
| 119 NOTREACHED(); | |
| 120 break; | |
| 121 case ui::AX_ACTION_NONE: | |
| 122 NOTREACHED(); | |
| 123 break; | |
| 124 } | 107 } |
| 108 current_tree_->SetSelection(anchor_id, anchor_offset, focus_offset); |
| 109 } |
| 110 |
| 111 void AutomationManagerAura::ShowContextMenu(int32_t id) { |
| 112 CHECK(enabled_); |
| 113 current_tree_->ShowContextMenu(id); |
| 125 } | 114 } |
| 126 | 115 |
| 127 void AutomationManagerAura::OnChildWindowRemoved( | 116 void AutomationManagerAura::OnChildWindowRemoved( |
| 128 views::AXAuraObjWrapper* parent) { | 117 views::AXAuraObjWrapper* parent) { |
| 129 if (!enabled_) | 118 if (!enabled_) |
| 130 return; | 119 return; |
| 131 | 120 |
| 132 if (!parent) | 121 if (!parent) |
| 133 parent = current_tree_->GetRoot(); | 122 parent = current_tree_->GetRoot(); |
| 134 | 123 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 173 |
| 185 processing_events_ = false; | 174 processing_events_ = false; |
| 186 auto pending_events_copy = pending_events_; | 175 auto pending_events_copy = pending_events_; |
| 187 pending_events_.clear(); | 176 pending_events_.clear(); |
| 188 for (size_t i = 0; i < pending_events_copy.size(); ++i) { | 177 for (size_t i = 0; i < pending_events_copy.size(); ++i) { |
| 189 SendEvent(context, | 178 SendEvent(context, |
| 190 pending_events_copy[i].first, | 179 pending_events_copy[i].first, |
| 191 pending_events_copy[i].second); | 180 pending_events_copy[i].second); |
| 192 } | 181 } |
| 193 } | 182 } |
| OLD | NEW |