Chromium Code Reviews| 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 ui::AXAction action, | |
| 88 const ui::AXActionData& data) { | |
| 85 CHECK(enabled_); | 89 CHECK(enabled_); |
| 86 current_tree_->DoDefault(id); | |
| 87 } | |
| 88 | 90 |
| 89 void AutomationManagerAura::Focus(int32_t id) { | 91 switch (action) { |
| 90 CHECK(enabled_); | 92 case ui::AX_ACTION_DO_DEFAULT: |
| 91 current_tree_->Focus(id); | 93 current_tree_->DoDefault(data.target_node_id); |
| 92 } | 94 break; |
| 93 | 95 case ui::AX_ACTION_SET_FOCUS: |
| 94 void AutomationManagerAura::MakeVisible(int32_t id) { | 96 current_tree_->Focus(data.target_node_id); |
| 95 CHECK(enabled_); | 97 break; |
| 96 current_tree_->MakeVisible(id); | 98 case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE: |
| 97 } | 99 current_tree_->MakeVisible(data.target_node_id); |
| 98 | 100 break; |
| 99 void AutomationManagerAura::SetSelection(int32_t anchor_id, | 101 case ui::AX_ACTION_SET_SELECTION: |
| 100 int32_t anchor_offset, | 102 if (data.anchor_node_id != data.focus_node_id) { |
| 101 int32_t focus_id, | 103 NOTREACHED(); |
| 102 int32_t focus_offset) { | 104 return; |
| 103 CHECK(enabled_); | 105 } |
| 104 if (anchor_id != focus_id) { | 106 current_tree_->SetSelection( |
| 105 NOTREACHED(); | 107 data.anchor_node_id, data.anchor_offset, data.focus_offset); |
| 106 return; | 108 break; |
| 109 case ui::AX_ACTION_SHOW_CONTEXT_MENU: | |
| 110 current_tree_->ShowContextMenu(data.target_node_id); | |
| 111 break; | |
| 112 case ui::AX_ACTION_HIT_TEST: | |
| 113 case ui::AX_ACTION_SCROLL_TO_POINT: | |
| 114 case ui::AX_ACTION_SET_ACCESSIBILITY_FOCUS: | |
| 115 case ui::AX_ACTION_SET_SCROLL_OFFSET: | |
| 116 case ui::AX_ACTION_SET_VALUE: | |
| 117 // Not implemented yet. | |
|
David Tseng
2016/10/13 22:15:14
NOTREACHED
dmazzoni
2016/10/14 20:49:39
Done
| |
| 118 break; | |
| 119 case ui::AX_ACTION_NONE: | |
| 120 NOTREACHED(); | |
| 121 break; | |
|
David Tseng
2016/10/13 22:15:14
default, to get a compile time warning?
dmazzoni
2016/10/14 20:49:39
I deliberately left out default so that if we
add
| |
| 107 } | 122 } |
| 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 } | 123 } |
| 115 | 124 |
| 116 void AutomationManagerAura::OnChildWindowRemoved( | 125 void AutomationManagerAura::OnChildWindowRemoved( |
| 117 views::AXAuraObjWrapper* parent) { | 126 views::AXAuraObjWrapper* parent) { |
| 118 if (!enabled_) | 127 if (!enabled_) |
| 119 return; | 128 return; |
| 120 | 129 |
| 121 if (!parent) | 130 if (!parent) |
| 122 parent = current_tree_->GetRoot(); | 131 parent = current_tree_->GetRoot(); |
| 123 | 132 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 | 182 |
| 174 processing_events_ = false; | 183 processing_events_ = false; |
| 175 auto pending_events_copy = pending_events_; | 184 auto pending_events_copy = pending_events_; |
| 176 pending_events_.clear(); | 185 pending_events_.clear(); |
| 177 for (size_t i = 0; i < pending_events_copy.size(); ++i) { | 186 for (size_t i = 0; i < pending_events_copy.size(); ++i) { |
| 178 SendEvent(context, | 187 SendEvent(context, |
| 179 pending_events_copy[i].first, | 188 pending_events_copy[i].first, |
| 180 pending_events_copy[i].second); | 189 pending_events_copy[i].second); |
| 181 } | 190 } |
| 182 } | 191 } |
| OLD | NEW |