| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 using api::automation_internal::AXEventParams; | 129 using api::automation_internal::AXEventParams; |
| 130 using api::automation_internal::AXTreeUpdate; | 130 using api::automation_internal::AXTreeUpdate; |
| 131 | 131 |
| 132 std::vector<content::AXEventNotificationDetails>::const_iterator iter = | 132 std::vector<content::AXEventNotificationDetails>::const_iterator iter = |
| 133 details.begin(); | 133 details.begin(); |
| 134 for (; iter != details.end(); ++iter) { | 134 for (; iter != details.end(); ++iter) { |
| 135 const content::AXEventNotificationDetails& event = *iter; | 135 const content::AXEventNotificationDetails& event = *iter; |
| 136 |
| 136 AXEventParams ax_event_params; | 137 AXEventParams ax_event_params; |
| 137 ax_event_params.process_id = event.process_id; | 138 ax_event_params.process_id = event.process_id; |
| 138 ax_event_params.routing_id = event.routing_id; | 139 ax_event_params.routing_id = event.routing_id; |
| 139 ax_event_params.event_type = ToString(iter->event_type); | 140 ax_event_params.event_type = ToString(iter->event_type); |
| 140 ax_event_params.target_id = event.id; | 141 ax_event_params.target_id = event.id; |
| 141 | 142 |
| 142 AXTreeUpdate& ax_tree_update = ax_event_params.update; | 143 AXTreeUpdate& ax_tree_update = ax_event_params.update; |
| 143 ax_tree_update.node_id_to_clear = event.node_id_to_clear; | 144 ax_tree_update.node_id_to_clear = event.node_id_to_clear; |
| 144 for (size_t i = 0; i < event.nodes.size(); ++i) { | 145 for (size_t i = 0; i < event.nodes.size(); ++i) { |
| 145 linked_ptr<api::automation_internal::AXNodeData> out_node( | 146 linked_ptr<api::automation_internal::AXNodeData> out_node( |
| 146 new api::automation_internal::AXNodeData()); | 147 new api::automation_internal::AXNodeData()); |
| 147 PopulateNodeData(event.nodes[i], out_node); | 148 PopulateNodeData(event.nodes[i], out_node); |
| 148 ax_tree_update.nodes.push_back(out_node); | 149 ax_tree_update.nodes.push_back(out_node); |
| 149 } | 150 } |
| 150 | 151 |
| 151 DLOG(INFO) << "AccessibilityEventReceived { " | |
| 152 << "process_id: " << event.process_id | |
| 153 << ", routing_id:" << event.routing_id | |
| 154 << ", event_type:" << ui::ToString(event.event_type) | |
| 155 << "}; dispatching to JS"; | |
| 156 | |
| 157 // TODO(dtseng/aboxhall): Why are we sending only one update at a time? We | 152 // TODO(dtseng/aboxhall): Why are we sending only one update at a time? We |
| 158 // should match the behavior from renderer -> browser and send a | 153 // should match the behavior from renderer -> browser and send a |
| 159 // collection of tree updates over (to the extension); see | 154 // collection of tree updates over (to the extension); see |
| 160 // |AccessibilityHostMsg_EventParams| and |AccessibilityHostMsg_Events|. | 155 // |AccessibilityHostMsg_EventParams| and |AccessibilityHostMsg_Events|. |
| 161 DispatchEventInternal( | 156 DispatchEventInternal( |
| 162 browser_context, | 157 browser_context, |
| 163 api::automation_internal::OnAccessibilityEvent::kEventName, | 158 api::automation_internal::OnAccessibilityEvent::kEventName, |
| 164 api::automation_internal::OnAccessibilityEvent::Create( | 159 api::automation_internal::OnAccessibilityEvent::Create( |
| 165 ax_event_params)); | 160 ax_event_params)); |
| 166 } | 161 } |
| 167 } | 162 } |
| 168 | 163 |
| 169 void DispatchTreeDestroyedEventToAutomation( | 164 void DispatchTreeDestroyedEventToAutomation( |
| 170 int process_id, | 165 int process_id, |
| 171 int routing_id, | 166 int routing_id, |
| 172 content::BrowserContext* browser_context) { | 167 content::BrowserContext* browser_context) { |
| 173 DispatchEventInternal( | 168 DispatchEventInternal( |
| 174 browser_context, | 169 browser_context, |
| 175 api::automation_internal::OnAccessibilityTreeDestroyed::kEventName, | 170 api::automation_internal::OnAccessibilityTreeDestroyed::kEventName, |
| 176 api::automation_internal::OnAccessibilityTreeDestroyed::Create( | 171 api::automation_internal::OnAccessibilityTreeDestroyed::Create( |
| 177 process_id, routing_id)); | 172 process_id, routing_id)); |
| 178 } | 173 } |
| 179 | 174 |
| 180 } // namespace automation_util | 175 } // namespace automation_util |
| 181 | 176 |
| 182 } // namespace extensions | 177 } // namespace extensions |
| OLD | NEW |