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

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

Issue 2059533003: Expose html attributes in automation tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 <memory> 10 #include <memory>
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 base::Unretained(this))) 427 base::Unretained(this)))
428 ROUTE_FUNCTION(IsInteractPermitted); 428 ROUTE_FUNCTION(IsInteractPermitted);
429 ROUTE_FUNCTION(GetSchemaAdditions); 429 ROUTE_FUNCTION(GetSchemaAdditions);
430 ROUTE_FUNCTION(GetRoutingID); 430 ROUTE_FUNCTION(GetRoutingID);
431 ROUTE_FUNCTION(StartCachingAccessibilityTrees); 431 ROUTE_FUNCTION(StartCachingAccessibilityTrees);
432 ROUTE_FUNCTION(DestroyAccessibilityTree); 432 ROUTE_FUNCTION(DestroyAccessibilityTree);
433 ROUTE_FUNCTION(AddTreeChangeObserver); 433 ROUTE_FUNCTION(AddTreeChangeObserver);
434 ROUTE_FUNCTION(RemoveTreeChangeObserver); 434 ROUTE_FUNCTION(RemoveTreeChangeObserver);
435 ROUTE_FUNCTION(GetChildIDAtIndex); 435 ROUTE_FUNCTION(GetChildIDAtIndex);
436 ROUTE_FUNCTION(GetFocus); 436 ROUTE_FUNCTION(GetFocus);
437 ROUTE_FUNCTION(GetHtmlAttributes);
437 ROUTE_FUNCTION(GetState); 438 ROUTE_FUNCTION(GetState);
438 #undef ROUTE_FUNCTION 439 #undef ROUTE_FUNCTION
439 440
440 // Bindings that take a Tree ID and return a property of the tree. 441 // Bindings that take a Tree ID and return a property of the tree.
441 442
442 RouteTreeIDFunction( 443 RouteTreeIDFunction(
443 "GetRootID", [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, 444 "GetRootID", [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
444 TreeCache* cache) { 445 TreeCache* cache) {
445 result.Set(v8::Integer::New(isolate, cache->tree.root()->id())); 446 result.Set(v8::Integer::New(isolate, cache->tree.root()->id()));
446 }); 447 });
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 867
867 v8::Isolate* isolate = GetIsolate(); 868 v8::Isolate* isolate = GetIsolate();
868 v8::Local<v8::Object> result(v8::Object::New(isolate)); 869 v8::Local<v8::Object> result(v8::Object::New(isolate));
869 result->Set(CreateV8String(isolate, "treeId"), 870 result->Set(CreateV8String(isolate, "treeId"),
870 v8::Integer::New(isolate, focused_tree_cache->tree_id)); 871 v8::Integer::New(isolate, focused_tree_cache->tree_id));
871 result->Set(CreateV8String(isolate, "nodeId"), 872 result->Set(CreateV8String(isolate, "nodeId"),
872 v8::Integer::New(isolate, focused_node->id())); 873 v8::Integer::New(isolate, focused_node->id()));
873 args.GetReturnValue().Set(result); 874 args.GetReturnValue().Set(result);
874 } 875 }
875 876
877 void AutomationInternalCustomBindings::GetHtmlAttributes(
878 const v8::FunctionCallbackInfo<v8::Value>& args) {
879 v8::Isolate* isolate = GetIsolate();
880 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
881 ThrowInvalidArgumentsException(this);
882
883 int tree_id = args[0]->Int32Value();
884 int node_id = args[1]->Int32Value();
885
886 TreeCache* cache = GetTreeCacheFromTreeID(tree_id);
887 if (!cache)
888 return;
889
890 ui::AXNode* node = cache->tree.GetFromId(node_id);
891 if (!node)
892 return;
893
894 v8::Local<v8::Object> dst(v8::Object::New(isolate));
895 base::StringPairs src = node->data().html_attributes;
896 for (size_t i = 0; i < src.size(); i++) {
897 std::string& key = src[i].first;
898 std::string& value = src[i].second;
899 dst->Set(CreateV8String(isolate, key), CreateV8String(isolate, value));
900 }
901 args.GetReturnValue().Set(dst);
902 }
903
876 void AutomationInternalCustomBindings::GetState( 904 void AutomationInternalCustomBindings::GetState(
877 const v8::FunctionCallbackInfo<v8::Value>& args) { 905 const v8::FunctionCallbackInfo<v8::Value>& args) {
878 v8::Isolate* isolate = GetIsolate(); 906 v8::Isolate* isolate = GetIsolate();
879 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber()) 907 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
880 ThrowInvalidArgumentsException(this); 908 ThrowInvalidArgumentsException(this);
881 909
882 int tree_id = args[0]->Int32Value(); 910 int tree_id = args[0]->Int32Value();
883 int node_id = args[1]->Int32Value(); 911 int node_id = args[1]->Int32Value();
884 912
885 TreeCache* cache = GetTreeCacheFromTreeID(tree_id); 913 TreeCache* cache = GetTreeCacheFromTreeID(tree_id);
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); 1287 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U));
1260 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); 1288 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id));
1261 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); 1289 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size()));
1262 args->Set(1U, nodes); 1290 args->Set(1U, nodes);
1263 for (size_t i = 0; i < ids.size(); ++i) 1291 for (size_t i = 0; i < ids.size(); ++i)
1264 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); 1292 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i]));
1265 context()->DispatchEvent("automationInternal.onNodesRemoved", args); 1293 context()->DispatchEvent("automationInternal.onNodesRemoved", args);
1266 } 1294 }
1267 1295
1268 } // namespace extensions 1296 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698