Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/renderer/extensions/automation_internal_custom_bindings.cc

Issue 1716663002: Add a treeChange type to Automation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 10 #include "base/bind.h"
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate())); 982 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate()));
983 event_params->Set(CreateV8String(isolate, "treeID"), 983 event_params->Set(CreateV8String(isolate, "treeID"),
984 v8::Integer::New(GetIsolate(), params.tree_id)); 984 v8::Integer::New(GetIsolate(), params.tree_id));
985 event_params->Set(CreateV8String(isolate, "targetID"), 985 event_params->Set(CreateV8String(isolate, "targetID"),
986 v8::Integer::New(GetIsolate(), params.id)); 986 v8::Integer::New(GetIsolate(), params.id));
987 event_params->Set(CreateV8String(isolate, "eventType"), 987 event_params->Set(CreateV8String(isolate, "eventType"),
988 CreateV8String(isolate, ToString(params.event_type))); 988 CreateV8String(isolate, ToString(params.event_type)));
989 args->Set(0U, event_params); 989 args->Set(0U, event_params);
990 context()->DispatchEvent("automationInternal.onAccessibilityEvent", args); 990 context()->DispatchEvent("automationInternal.onAccessibilityEvent", args);
991 } 991 }
992 void AutomationInternalCustomBindings::OnNodeDataWillChange(
993 const ui::AXNodeData& old_node_data,
994 const ui::AXNodeData& new_node_data) {
995 if (old_node_data.GetStringAttribute(ui::AX_ATTR_NAME) !=
996 new_node_data.GetStringAttribute(ui::AX_ATTR_NAME))
997 text_changed_node_ids_.push_back(new_node_data.id);
998 }
992 999
993 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {} 1000 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {}
994 1001
995 void AutomationInternalCustomBindings::OnNodeWillBeDeleted(ui::AXTree* tree, 1002 void AutomationInternalCustomBindings::OnNodeWillBeDeleted(ui::AXTree* tree,
996 ui::AXNode* node) { 1003 ui::AXNode* node) {
997 SendTreeChangeEvent( 1004 SendTreeChangeEvent(
998 api::automation::TREE_CHANGE_TYPE_NODEREMOVED, 1005 api::automation::TREE_CHANGE_TYPE_NODEREMOVED,
999 tree, node); 1006 tree, node);
1000 deleted_node_ids_.push_back(node->id()); 1007 deleted_node_ids_.push_back(node->id());
1001 } 1008 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 api::automation::TREE_CHANGE_TYPE_SUBTREECREATED, 1050 api::automation::TREE_CHANGE_TYPE_SUBTREECREATED,
1044 tree, node); 1051 tree, node);
1045 break; 1052 break;
1046 case NODE_CHANGED: 1053 case NODE_CHANGED:
1047 SendTreeChangeEvent( 1054 SendTreeChangeEvent(
1048 api::automation::TREE_CHANGE_TYPE_NODECHANGED, 1055 api::automation::TREE_CHANGE_TYPE_NODECHANGED,
1049 tree, node); 1056 tree, node);
1050 break; 1057 break;
1051 } 1058 }
1052 } 1059 }
1060
1061 for (size_t i = 0; i < text_changed_node_ids_.size(); ++i) {
1062 SendTreeChangeEvent(api::automation::TREE_CHANGE_TYPE_TEXTCHANGED, tree,
1063 tree->GetFromId(text_changed_node_ids_[i]));
1064 text_changed_node_ids_.clear();
dmazzoni 2016/02/19 23:20:23 This clear should go after the for loop, not insid
1065 }
1053 } 1066 }
1054 1067
1055 void AutomationInternalCustomBindings::SendTreeChangeEvent( 1068 void AutomationInternalCustomBindings::SendTreeChangeEvent(
1056 api::automation::TreeChangeType change_type, 1069 api::automation::TreeChangeType change_type,
1057 ui::AXTree* tree, 1070 ui::AXTree* tree,
1058 ui::AXNode* node) { 1071 ui::AXNode* node) {
1059 // Don't send tree change events when it's not the active profile. 1072 // Don't send tree change events when it's not the active profile.
1060 if (!is_active_profile_) 1073 if (!is_active_profile_)
1061 return; 1074 return;
1062 1075
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); 1159 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U));
1147 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); 1160 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id));
1148 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); 1161 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size()));
1149 args->Set(1U, nodes); 1162 args->Set(1U, nodes);
1150 for (size_t i = 0; i < ids.size(); ++i) 1163 for (size_t i = 0; i < ids.size(); ++i)
1151 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); 1164 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i]));
1152 context()->DispatchEvent("automationInternal.onNodesRemoved", args); 1165 context()->DispatchEvent("automationInternal.onNodesRemoved", args);
1153 } 1166 }
1154 1167
1155 } // namespace extensions 1168 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698