| 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/extensions/api/automation_internal/automation_util.h" | 5 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 EventRouter::Get(context)->BroadcastEvent(event.Pass()); | 118 EventRouter::Get(context)->BroadcastEvent(event.Pass()); |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace | 122 } // namespace |
| 123 | 123 |
| 124 namespace automation_util { | 124 namespace automation_util { |
| 125 | 125 |
| 126 void DispatchAccessibilityEventsToAutomation( | 126 void DispatchAccessibilityEventsToAutomation( |
| 127 const std::vector<content::AXEventNotificationDetails>& details, | 127 const std::vector<content::AXEventNotificationDetails>& details, |
| 128 content::BrowserContext* browser_context) { | 128 content::BrowserContext* browser_context, |
| 129 const gfx::Vector2d& location_offset) { |
| 129 using api::automation_internal::AXEventParams; | 130 using api::automation_internal::AXEventParams; |
| 130 using api::automation_internal::AXTreeUpdate; | 131 using api::automation_internal::AXTreeUpdate; |
| 131 | 132 |
| 132 std::vector<content::AXEventNotificationDetails>::const_iterator iter = | 133 std::vector<content::AXEventNotificationDetails>::const_iterator iter = |
| 133 details.begin(); | 134 details.begin(); |
| 134 for (; iter != details.end(); ++iter) { | 135 for (; iter != details.end(); ++iter) { |
| 135 const content::AXEventNotificationDetails& event = *iter; | 136 const content::AXEventNotificationDetails& event = *iter; |
| 136 | 137 |
| 137 AXEventParams ax_event_params; | 138 AXEventParams ax_event_params; |
| 138 ax_event_params.process_id = event.process_id; | 139 ax_event_params.process_id = event.process_id; |
| 139 ax_event_params.routing_id = event.routing_id; | 140 ax_event_params.routing_id = event.routing_id; |
| 140 ax_event_params.event_type = ToString(iter->event_type); | 141 ax_event_params.event_type = ToString(iter->event_type); |
| 141 ax_event_params.target_id = event.id; | 142 ax_event_params.target_id = event.id; |
| 142 | 143 |
| 143 AXTreeUpdate& ax_tree_update = ax_event_params.update; | 144 AXTreeUpdate& ax_tree_update = ax_event_params.update; |
| 144 ax_tree_update.node_id_to_clear = event.node_id_to_clear; | 145 ax_tree_update.node_id_to_clear = event.node_id_to_clear; |
| 145 for (size_t i = 0; i < event.nodes.size(); ++i) { | 146 for (size_t i = 0; i < event.nodes.size(); ++i) { |
| 147 ui::AXNodeData src = event.nodes[i]; |
| 148 src.location.Offset(location_offset); |
| 146 linked_ptr<api::automation_internal::AXNodeData> out_node( | 149 linked_ptr<api::automation_internal::AXNodeData> out_node( |
| 147 new api::automation_internal::AXNodeData()); | 150 new api::automation_internal::AXNodeData()); |
| 148 PopulateNodeData(event.nodes[i], out_node); | 151 PopulateNodeData(src, out_node); |
| 149 ax_tree_update.nodes.push_back(out_node); | 152 ax_tree_update.nodes.push_back(out_node); |
| 150 } | 153 } |
| 151 | 154 |
| 152 // TODO(dtseng/aboxhall): Why are we sending only one update at a time? We | 155 // TODO(dtseng/aboxhall): Why are we sending only one update at a time? We |
| 153 // should match the behavior from renderer -> browser and send a | 156 // should match the behavior from renderer -> browser and send a |
| 154 // collection of tree updates over (to the extension); see | 157 // collection of tree updates over (to the extension); see |
| 155 // |AccessibilityHostMsg_EventParams| and |AccessibilityHostMsg_Events|. | 158 // |AccessibilityHostMsg_EventParams| and |AccessibilityHostMsg_Events|. |
| 156 DispatchEventInternal( | 159 DispatchEventInternal( |
| 157 browser_context, | 160 browser_context, |
| 158 api::automation_internal::OnAccessibilityEvent::kEventName, | 161 api::automation_internal::OnAccessibilityEvent::kEventName, |
| 159 api::automation_internal::OnAccessibilityEvent::Create( | 162 api::automation_internal::OnAccessibilityEvent::Create( |
| 160 ax_event_params)); | 163 ax_event_params)); |
| 161 } | 164 } |
| 162 } | 165 } |
| 163 | 166 |
| 164 void DispatchTreeDestroyedEventToAutomation( | 167 void DispatchTreeDestroyedEventToAutomation( |
| 165 int process_id, | 168 int process_id, |
| 166 int routing_id, | 169 int routing_id, |
| 167 content::BrowserContext* browser_context) { | 170 content::BrowserContext* browser_context) { |
| 168 DispatchEventInternal( | 171 DispatchEventInternal( |
| 169 browser_context, | 172 browser_context, |
| 170 api::automation_internal::OnAccessibilityTreeDestroyed::kEventName, | 173 api::automation_internal::OnAccessibilityTreeDestroyed::kEventName, |
| 171 api::automation_internal::OnAccessibilityTreeDestroyed::Create( | 174 api::automation_internal::OnAccessibilityTreeDestroyed::Create( |
| 172 process_id, routing_id)); | 175 process_id, routing_id)); |
| 173 } | 176 } |
| 174 | 177 |
| 175 } // namespace automation_util | 178 } // namespace automation_util |
| 176 | 179 |
| 177 } // namespace extensions | 180 } // namespace extensions |
| OLD | NEW |