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

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: git cl set_commit 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 ui::AXTree* tree,
994 const ui::AXNodeData& old_node_data,
995 const ui::AXNodeData& new_node_data) {
996 if (old_node_data.GetStringAttribute(ui::AX_ATTR_NAME) !=
997 new_node_data.GetStringAttribute(ui::AX_ATTR_NAME))
998 text_changed_node_ids_.push_back(new_node_data.id);
999 }
992 1000
993 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {} 1001 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {}
994 1002
995 void AutomationInternalCustomBindings::OnNodeWillBeDeleted(ui::AXTree* tree, 1003 void AutomationInternalCustomBindings::OnNodeWillBeDeleted(ui::AXTree* tree,
996 ui::AXNode* node) { 1004 ui::AXNode* node) {
997 SendTreeChangeEvent( 1005 SendTreeChangeEvent(
998 api::automation::TREE_CHANGE_TYPE_NODEREMOVED, 1006 api::automation::TREE_CHANGE_TYPE_NODEREMOVED,
999 tree, node); 1007 tree, node);
1000 deleted_node_ids_.push_back(node->id()); 1008 deleted_node_ids_.push_back(node->id());
1001 } 1009 }
(...skipping 21 matching lines...) Expand all
1023 } 1031 }
1024 1032
1025 void AutomationInternalCustomBindings::OnAtomicUpdateFinished( 1033 void AutomationInternalCustomBindings::OnAtomicUpdateFinished(
1026 ui::AXTree* tree, 1034 ui::AXTree* tree,
1027 bool root_changed, 1035 bool root_changed,
1028 const std::vector<ui::AXTreeDelegate::Change>& changes) { 1036 const std::vector<ui::AXTreeDelegate::Change>& changes) {
1029 auto iter = axtree_to_tree_cache_map_.find(tree); 1037 auto iter = axtree_to_tree_cache_map_.find(tree);
1030 if (iter == axtree_to_tree_cache_map_.end()) 1038 if (iter == axtree_to_tree_cache_map_.end())
1031 return; 1039 return;
1032 1040
1033 for (auto change : changes) { 1041 for (const auto change : changes) {
1034 ui::AXNode* node = change.node; 1042 ui::AXNode* node = change.node;
1035 switch (change.type) { 1043 switch (change.type) {
1036 case NODE_CREATED: 1044 case NODE_CREATED:
1037 SendTreeChangeEvent( 1045 SendTreeChangeEvent(
1038 api::automation::TREE_CHANGE_TYPE_NODECREATED, 1046 api::automation::TREE_CHANGE_TYPE_NODECREATED,
1039 tree, node); 1047 tree, node);
1040 break; 1048 break;
1041 case SUBTREE_CREATED: 1049 case SUBTREE_CREATED:
1042 SendTreeChangeEvent( 1050 SendTreeChangeEvent(
1043 api::automation::TREE_CHANGE_TYPE_SUBTREECREATED, 1051 api::automation::TREE_CHANGE_TYPE_SUBTREECREATED,
1044 tree, node); 1052 tree, node);
1045 break; 1053 break;
1046 case NODE_CHANGED: 1054 case NODE_CHANGED:
1047 SendTreeChangeEvent( 1055 SendTreeChangeEvent(
1048 api::automation::TREE_CHANGE_TYPE_NODECHANGED, 1056 api::automation::TREE_CHANGE_TYPE_NODECHANGED,
1049 tree, node); 1057 tree, node);
1050 break; 1058 break;
1051 } 1059 }
1052 } 1060 }
1061
1062 for (int id : text_changed_node_ids_) {
1063 LOG(ERROR) << "got id!" << id;
1064 SendTreeChangeEvent(api::automation::TREE_CHANGE_TYPE_TEXTCHANGED, tree,
1065 tree->GetFromId(id));
1066 }
1067 text_changed_node_ids_.clear();
1053 } 1068 }
1054 1069
1055 void AutomationInternalCustomBindings::SendTreeChangeEvent( 1070 void AutomationInternalCustomBindings::SendTreeChangeEvent(
1056 api::automation::TreeChangeType change_type, 1071 api::automation::TreeChangeType change_type,
1057 ui::AXTree* tree, 1072 ui::AXTree* tree,
1058 ui::AXNode* node) { 1073 ui::AXNode* node) {
1059 // Don't send tree change events when it's not the active profile. 1074 // Don't send tree change events when it's not the active profile.
1060 if (!is_active_profile_) 1075 if (!is_active_profile_)
1061 return; 1076 return;
1062 1077
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); 1161 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U));
1147 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); 1162 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id));
1148 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); 1163 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size()));
1149 args->Set(1U, nodes); 1164 args->Set(1U, nodes);
1150 for (size_t i = 0; i < ids.size(); ++i) 1165 for (size_t i = 0; i < ids.size(); ++i)
1151 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); 1166 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i]));
1152 context()->DispatchEvent("automationInternal.onNodesRemoved", args); 1167 context()->DispatchEvent("automationInternal.onNodesRemoved", args);
1153 } 1168 }
1154 1169
1155 } // namespace extensions 1170 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698