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