| 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" |
| 11 #include "chrome/browser/accessibility/ax_tree_id_registry.h" | 11 #include "chrome/browser/accessibility/ax_tree_id_registry.h" |
| 12 #include "chrome/common/extensions/api/automation_internal.h" | 12 #include "chrome/common/extensions/api/automation_internal.h" |
| 13 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 15 #include "content/public/browser/render_frame_host.h" |
| 16 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/browser/web_contents.h" |
| 13 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 14 #include "ui/accessibility/ax_enums.h" | 19 #include "ui/accessibility/ax_enums.h" |
| 15 #include "ui/accessibility/ax_node_data.h" | 20 #include "ui/accessibility/ax_node_data.h" |
| 16 | 21 |
| 17 namespace extensions { | 22 namespace extensions { |
| 18 | 23 |
| 19 namespace { | 24 namespace { |
| 20 | 25 |
| 21 void PopulateNodeData(const ui::AXNodeData& node_data, | 26 void PopulateNodeData(const ui::AXNodeData& node_data, |
| 22 linked_ptr< api::automation_internal::AXNodeData>& out_node_data) { | 27 linked_ptr< api::automation_internal::AXNodeData>& out_node_data) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 ax_event_params.target_id = event.id; | 150 ax_event_params.target_id = event.id; |
| 146 | 151 |
| 147 AXTreeUpdate& ax_tree_update = ax_event_params.update; | 152 AXTreeUpdate& ax_tree_update = ax_event_params.update; |
| 148 ax_tree_update.node_id_to_clear = event.node_id_to_clear; | 153 ax_tree_update.node_id_to_clear = event.node_id_to_clear; |
| 149 for (size_t i = 0; i < event.nodes.size(); ++i) { | 154 for (size_t i = 0; i < event.nodes.size(); ++i) { |
| 150 ui::AXNodeData src = event.nodes[i]; | 155 ui::AXNodeData src = event.nodes[i]; |
| 151 src.location.Offset(location_offset); | 156 src.location.Offset(location_offset); |
| 152 linked_ptr<api::automation_internal::AXNodeData> out_node( | 157 linked_ptr<api::automation_internal::AXNodeData> out_node( |
| 153 new api::automation_internal::AXNodeData()); | 158 new api::automation_internal::AXNodeData()); |
| 154 PopulateNodeData(src, out_node); | 159 PopulateNodeData(src, out_node); |
| 160 if (src.HasBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) { |
| 161 const auto& iter = event.node_to_browser_plugin_instance_id_map.find( |
| 162 src.id); |
| 163 if (iter != event.node_to_browser_plugin_instance_id_map.end()) { |
| 164 int instance_id = iter->second; |
| 165 content::BrowserPluginGuestManager* guest_manager = |
| 166 browser_context->GetGuestManager(); |
| 167 content::WebContents* guest_web_contents = |
| 168 guest_manager->GetGuestByInstanceID(event.process_id, |
| 169 instance_id); |
| 170 if (guest_web_contents) { |
| 171 content::RenderFrameHost* guest_rfh = |
| 172 guest_web_contents->GetMainFrame(); |
| 173 int guest_tree_id = |
| 174 AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( |
| 175 guest_rfh->GetProcess()->GetID(), |
| 176 guest_rfh->GetRoutingID()); |
| 177 out_node->int_attributes->additional_properties.SetInteger( |
| 178 ToString(ui::AX_ATTR_CHILD_TREE_ID), |
| 179 guest_tree_id); |
| 180 } |
| 181 } |
| 182 } |
| 155 ax_tree_update.nodes.push_back(out_node); | 183 ax_tree_update.nodes.push_back(out_node); |
| 156 } | 184 } |
| 157 | 185 |
| 158 // TODO(dtseng/aboxhall): Why are we sending only one update at a time? We | 186 // TODO(dtseng/aboxhall): Why are we sending only one update at a time? We |
| 159 // should match the behavior from renderer -> browser and send a | 187 // should match the behavior from renderer -> browser and send a |
| 160 // collection of tree updates over (to the extension); see | 188 // collection of tree updates over (to the extension); see |
| 161 // |AccessibilityHostMsg_EventParams| and |AccessibilityHostMsg_Events|. | 189 // |AccessibilityHostMsg_EventParams| and |AccessibilityHostMsg_Events|. |
| 162 DispatchEventInternal( | 190 DispatchEventInternal( |
| 163 browser_context, | 191 browser_context, |
| 164 api::automation_internal::OnAccessibilityEvent::kEventName, | 192 api::automation_internal::OnAccessibilityEvent::kEventName, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 176 DispatchEventInternal( | 204 DispatchEventInternal( |
| 177 browser_context, | 205 browser_context, |
| 178 api::automation_internal::OnAccessibilityTreeDestroyed::kEventName, | 206 api::automation_internal::OnAccessibilityTreeDestroyed::kEventName, |
| 179 api::automation_internal::OnAccessibilityTreeDestroyed::Create(tree_id)); | 207 api::automation_internal::OnAccessibilityTreeDestroyed::Create(tree_id)); |
| 180 AXTreeIDRegistry::GetInstance()->RemoveAXTreeID(tree_id); | 208 AXTreeIDRegistry::GetInstance()->RemoveAXTreeID(tree_id); |
| 181 } | 209 } |
| 182 | 210 |
| 183 } // namespace automation_util | 211 } // namespace automation_util |
| 184 | 212 |
| 185 } // namespace extensions | 213 } // namespace extensions |
| OLD | NEW |