| 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/renderer/extensions/automation_internal_custom_bindings.h" | 5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 cache->tree.SetDelegate(nullptr); | 678 cache->tree.SetDelegate(nullptr); |
| 679 delete cache; | 679 delete cache; |
| 680 } | 680 } |
| 681 tree_id_to_tree_cache_map_.clear(); | 681 tree_id_to_tree_cache_map_.clear(); |
| 682 } | 682 } |
| 683 | 683 |
| 684 void AutomationInternalCustomBindings::OnMessageReceived( | 684 void AutomationInternalCustomBindings::OnMessageReceived( |
| 685 const IPC::Message& message) { | 685 const IPC::Message& message) { |
| 686 IPC_BEGIN_MESSAGE_MAP(AutomationInternalCustomBindings, message) | 686 IPC_BEGIN_MESSAGE_MAP(AutomationInternalCustomBindings, message) |
| 687 IPC_MESSAGE_HANDLER(ExtensionMsg_AccessibilityEvent, OnAccessibilityEvent) | 687 IPC_MESSAGE_HANDLER(ExtensionMsg_AccessibilityEvent, OnAccessibilityEvent) |
| 688 IPC_MESSAGE_HANDLER(ExtensionMsg_AccessibilityLocationChange, |
| 689 OnAccessibilityLocationChange) |
| 688 IPC_END_MESSAGE_MAP() | 690 IPC_END_MESSAGE_MAP() |
| 689 } | 691 } |
| 690 | 692 |
| 691 TreeCache* AutomationInternalCustomBindings::GetTreeCacheFromTreeID( | 693 TreeCache* AutomationInternalCustomBindings::GetTreeCacheFromTreeID( |
| 692 int tree_id) { | 694 int tree_id) { |
| 693 const auto iter = tree_id_to_tree_cache_map_.find(tree_id); | 695 const auto iter = tree_id_to_tree_cache_map_.find(tree_id); |
| 694 if (iter == tree_id_to_tree_cache_map_.end()) | 696 if (iter == tree_id_to_tree_cache_map_.end()) |
| 695 return nullptr; | 697 return nullptr; |
| 696 | 698 |
| 697 return iter->second; | 699 return iter->second; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 event_params->Set(CreateV8String(isolate, "treeID"), | 1121 event_params->Set(CreateV8String(isolate, "treeID"), |
| 1120 v8::Integer::New(GetIsolate(), params.tree_id)); | 1122 v8::Integer::New(GetIsolate(), params.tree_id)); |
| 1121 event_params->Set(CreateV8String(isolate, "targetID"), | 1123 event_params->Set(CreateV8String(isolate, "targetID"), |
| 1122 v8::Integer::New(GetIsolate(), params.id)); | 1124 v8::Integer::New(GetIsolate(), params.id)); |
| 1123 event_params->Set(CreateV8String(isolate, "eventType"), | 1125 event_params->Set(CreateV8String(isolate, "eventType"), |
| 1124 CreateV8String(isolate, ToString(params.event_type))); | 1126 CreateV8String(isolate, ToString(params.event_type))); |
| 1125 args->Set(0U, event_params); | 1127 args->Set(0U, event_params); |
| 1126 context()->DispatchEvent("automationInternal.onAccessibilityEvent", args); | 1128 context()->DispatchEvent("automationInternal.onAccessibilityEvent", args); |
| 1127 } | 1129 } |
| 1128 | 1130 |
| 1131 void AutomationInternalCustomBindings::OnAccessibilityLocationChange( |
| 1132 const ExtensionMsg_AccessibilityLocationChangeParams& params) { |
| 1133 int tree_id = params.tree_id; |
| 1134 auto iter = tree_id_to_tree_cache_map_.find(tree_id); |
| 1135 if (iter == tree_id_to_tree_cache_map_.end()) |
| 1136 return; |
| 1137 TreeCache* cache = iter->second; |
| 1138 ui::AXNode* node = cache->tree.GetFromId(params.id); |
| 1139 if (!node) |
| 1140 return; |
| 1141 node->SetLocation(params.new_location.offset_container_id, |
| 1142 params.new_location.bounds, |
| 1143 params.new_location.transform.get()); |
| 1144 } |
| 1145 |
| 1129 void AutomationInternalCustomBindings::OnNodeDataWillChange( | 1146 void AutomationInternalCustomBindings::OnNodeDataWillChange( |
| 1130 ui::AXTree* tree, | 1147 ui::AXTree* tree, |
| 1131 const ui::AXNodeData& old_node_data, | 1148 const ui::AXNodeData& old_node_data, |
| 1132 const ui::AXNodeData& new_node_data) { | 1149 const ui::AXNodeData& new_node_data) { |
| 1133 if (old_node_data.GetStringAttribute(ui::AX_ATTR_NAME) != | 1150 if (old_node_data.GetStringAttribute(ui::AX_ATTR_NAME) != |
| 1134 new_node_data.GetStringAttribute(ui::AX_ATTR_NAME)) | 1151 new_node_data.GetStringAttribute(ui::AX_ATTR_NAME)) |
| 1135 text_changed_node_ids_.push_back(new_node_data.id); | 1152 text_changed_node_ids_.push_back(new_node_data.id); |
| 1136 } | 1153 } |
| 1137 | 1154 |
| 1138 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {} | 1155 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {} |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); | 1331 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); |
| 1315 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 1332 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
| 1316 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); | 1333 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); |
| 1317 args->Set(1U, nodes); | 1334 args->Set(1U, nodes); |
| 1318 for (size_t i = 0; i < ids.size(); ++i) | 1335 for (size_t i = 0; i < ids.size(); ++i) |
| 1319 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); | 1336 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); |
| 1320 context()->DispatchEvent("automationInternal.onNodesRemoved", args); | 1337 context()->DispatchEvent("automationInternal.onNodesRemoved", args); |
| 1321 } | 1338 } |
| 1322 | 1339 |
| 1323 } // namespace extensions | 1340 } // namespace extensions |
| OLD | NEW |