| 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" |
| 19 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 20 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" | 22 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" |
| 21 #include "ui/views/view.h" | 23 #include "ui/views/view.h" |
| 22 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 23 | 25 |
| 24 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
| 25 #include "ash/wm/window_util.h" // nogncheck | 27 #include "ash/wm/window_util.h" // nogncheck |
| 26 #endif | 28 #endif |
| 27 | 29 |
| 28 using content::BrowserContext; | 30 using content::BrowserContext; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const std::string& text) { | 76 const std::string& text) { |
| 75 if (!enabled_) | 77 if (!enabled_) |
| 76 return; | 78 return; |
| 77 | 79 |
| 78 views::AXAuraObjWrapper* obj = | 80 views::AXAuraObjWrapper* obj = |
| 79 static_cast<AXRootObjWrapper*>(current_tree_->GetRoot()) | 81 static_cast<AXRootObjWrapper*>(current_tree_->GetRoot()) |
| 80 ->GetAlertForText(text); | 82 ->GetAlertForText(text); |
| 81 SendEvent(context, obj, ui::AX_EVENT_ALERT); | 83 SendEvent(context, obj, ui::AX_EVENT_ALERT); |
| 82 } | 84 } |
| 83 | 85 |
| 84 void AutomationManagerAura::DoDefault(int32_t id) { | 86 void AutomationManagerAura::PerformAction( |
| 87 const ui::AXActionData& data) { |
| 85 CHECK(enabled_); | 88 CHECK(enabled_); |
| 86 current_tree_->DoDefault(id); | |
| 87 } | |
| 88 | 89 |
| 89 void AutomationManagerAura::Focus(int32_t id) { | 90 switch (data.action) { |
| 90 CHECK(enabled_); | 91 case ui::AX_ACTION_DO_DEFAULT: |
| 91 current_tree_->Focus(id); | 92 current_tree_->DoDefault(data.target_node_id); |
| 92 } | 93 break; |
| 93 | 94 case ui::AX_ACTION_SET_FOCUS: |
| 94 void AutomationManagerAura::MakeVisible(int32_t id) { | 95 current_tree_->Focus(data.target_node_id); |
| 95 CHECK(enabled_); | 96 break; |
| 96 current_tree_->MakeVisible(id); | 97 case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE: |
| 97 } | 98 current_tree_->MakeVisible(data.target_node_id); |
| 98 | 99 break; |
| 99 void AutomationManagerAura::SetSelection(int32_t anchor_id, | 100 case ui::AX_ACTION_SET_SELECTION: |
| 100 int32_t anchor_offset, | 101 if (data.anchor_node_id != data.focus_node_id) { |
| 101 int32_t focus_id, | 102 NOTREACHED(); |
| 102 int32_t focus_offset) { | 103 return; |
| 103 CHECK(enabled_); | 104 } |
| 104 if (anchor_id != focus_id) { | 105 current_tree_->SetSelection( |
| 105 NOTREACHED(); | 106 data.anchor_node_id, data.anchor_offset, data.focus_offset); |
| 106 return; | 107 break; |
| 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; |
| 107 } | 124 } |
| 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); | |
| 114 } | 125 } |
| 115 | 126 |
| 116 void AutomationManagerAura::OnChildWindowRemoved( | 127 void AutomationManagerAura::OnChildWindowRemoved( |
| 117 views::AXAuraObjWrapper* parent) { | 128 views::AXAuraObjWrapper* parent) { |
| 118 if (!enabled_) | 129 if (!enabled_) |
| 119 return; | 130 return; |
| 120 | 131 |
| 121 if (!parent) | 132 if (!parent) |
| 122 parent = current_tree_->GetRoot(); | 133 parent = current_tree_->GetRoot(); |
| 123 | 134 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 184 |
| 174 processing_events_ = false; | 185 processing_events_ = false; |
| 175 auto pending_events_copy = pending_events_; | 186 auto pending_events_copy = pending_events_; |
| 176 pending_events_.clear(); | 187 pending_events_.clear(); |
| 177 for (size_t i = 0; i < pending_events_copy.size(); ++i) { | 188 for (size_t i = 0; i < pending_events_copy.size(); ++i) { |
| 178 SendEvent(context, | 189 SendEvent(context, |
| 179 pending_events_copy[i].first, | 190 pending_events_copy[i].first, |
| 180 pending_events_copy[i].second); | 191 pending_events_copy[i].second); |
| 181 } | 192 } |
| 182 } | 193 } |
| OLD | NEW |