| 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 cache->owner = this; | 1138 cache->owner = this; |
| 1139 tree_id_to_tree_cache_map_.insert(std::make_pair(tree_id, cache)); | 1139 tree_id_to_tree_cache_map_.insert(std::make_pair(tree_id, cache)); |
| 1140 axtree_to_tree_cache_map_.insert(std::make_pair(&cache->tree, cache)); | 1140 axtree_to_tree_cache_map_.insert(std::make_pair(&cache->tree, cache)); |
| 1141 } else { | 1141 } else { |
| 1142 cache = iter->second; | 1142 cache = iter->second; |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 // Update the internal state whether it's the active profile or not. | 1145 // Update the internal state whether it's the active profile or not. |
| 1146 cache->location_offset = params.location_offset; | 1146 cache->location_offset = params.location_offset; |
| 1147 deleted_node_ids_.clear(); | 1147 deleted_node_ids_.clear(); |
| 1148 v8::Isolate* isolate = GetIsolate(); |
| 1149 v8::HandleScope handle_scope(isolate); |
| 1150 v8::Context::Scope context_scope(context()->v8_context()); |
| 1151 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 1U)); |
| 1148 if (!cache->tree.Unserialize(params.update)) { | 1152 if (!cache->tree.Unserialize(params.update)) { |
| 1149 LOG(ERROR) << cache->tree.error(); | 1153 LOG(ERROR) << cache->tree.error(); |
| 1154 args->Set(0U, v8::Number::New(isolate, tree_id)); |
| 1155 context()->DispatchEvent( |
| 1156 "automationInternal.onAccessibilityTreeSerializationError", args); |
| 1150 return; | 1157 return; |
| 1151 } | 1158 } |
| 1152 | 1159 |
| 1153 // Don't send any events if it's not the active profile. | 1160 // Don't send any events if it's not the active profile. |
| 1154 if (!is_active_profile) | 1161 if (!is_active_profile) |
| 1155 return; | 1162 return; |
| 1156 | 1163 |
| 1157 SendNodesRemovedEvent(&cache->tree, deleted_node_ids_); | 1164 SendNodesRemovedEvent(&cache->tree, deleted_node_ids_); |
| 1158 deleted_node_ids_.clear(); | 1165 deleted_node_ids_.clear(); |
| 1159 | 1166 |
| 1160 v8::Isolate* isolate = GetIsolate(); | |
| 1161 v8::HandleScope handle_scope(isolate); | |
| 1162 v8::Context::Scope context_scope(context()->v8_context()); | |
| 1163 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 1U)); | |
| 1164 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate())); | 1167 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate())); |
| 1165 event_params->Set(CreateV8String(isolate, "treeID"), | 1168 event_params->Set(CreateV8String(isolate, "treeID"), |
| 1166 v8::Integer::New(GetIsolate(), params.tree_id)); | 1169 v8::Integer::New(GetIsolate(), params.tree_id)); |
| 1167 event_params->Set(CreateV8String(isolate, "targetID"), | 1170 event_params->Set(CreateV8String(isolate, "targetID"), |
| 1168 v8::Integer::New(GetIsolate(), params.id)); | 1171 v8::Integer::New(GetIsolate(), params.id)); |
| 1169 event_params->Set(CreateV8String(isolate, "eventType"), | 1172 event_params->Set(CreateV8String(isolate, "eventType"), |
| 1170 CreateV8String(isolate, ToString(params.event_type))); | 1173 CreateV8String(isolate, ToString(params.event_type))); |
| 1171 event_params->Set(CreateV8String(isolate, "eventFrom"), | 1174 event_params->Set(CreateV8String(isolate, "eventFrom"), |
| 1172 CreateV8String(isolate, ToString(params.event_from))); | 1175 CreateV8String(isolate, ToString(params.event_from))); |
| 1173 args->Set(0U, event_params); | 1176 args->Set(0U, event_params); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); | 1399 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); |
| 1397 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 1400 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
| 1398 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); | 1401 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); |
| 1399 args->Set(1U, nodes); | 1402 args->Set(1U, nodes); |
| 1400 for (size_t i = 0; i < ids.size(); ++i) | 1403 for (size_t i = 0; i < ids.size(); ++i) |
| 1401 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); | 1404 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); |
| 1402 context()->DispatchEvent("automationInternal.onNodesRemoved", args); | 1405 context()->DispatchEvent("automationInternal.onNodesRemoved", args); |
| 1403 } | 1406 } |
| 1404 | 1407 |
| 1405 } // namespace extensions | 1408 } // namespace extensions |
| OLD | NEW |