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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/automation_internal_custom_bindings.cc
diff --git a/chrome/renderer/extensions/automation_internal_custom_bindings.cc b/chrome/renderer/extensions/automation_internal_custom_bindings.cc
index f54aae809acd9bea2724b15328da6e164da28fe2..63069ae508d427716c92ea176f2b4007259c5869 100644
--- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc
+++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc
@@ -434,6 +434,7 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings(
ROUTE_FUNCTION(RemoveTreeChangeObserver);
ROUTE_FUNCTION(GetChildIDAtIndex);
ROUTE_FUNCTION(GetFocus);
+ ROUTE_FUNCTION(GetHtmlAttributes);
ROUTE_FUNCTION(GetState);
#undef ROUTE_FUNCTION
@@ -873,6 +874,33 @@ void AutomationInternalCustomBindings::GetFocus(
args.GetReturnValue().Set(result);
}
+void AutomationInternalCustomBindings::GetHtmlAttributes(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::Isolate* isolate = GetIsolate();
+ if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber())
+ ThrowInvalidArgumentsException(this);
+
+ int tree_id = args[0]->Int32Value();
+ int node_id = args[1]->Int32Value();
+
+ TreeCache* cache = GetTreeCacheFromTreeID(tree_id);
+ if (!cache)
+ return;
+
+ ui::AXNode* node = cache->tree.GetFromId(node_id);
+ if (!node)
+ return;
+
+ v8::Local<v8::Object> dst(v8::Object::New(isolate));
+ base::StringPairs src = node->data().html_attributes;
+ for (size_t i = 0; i < src.size(); i++) {
+ std::string& key = src[i].first;
+ std::string& value = src[i].second;
+ dst->Set(CreateV8String(isolate, key), CreateV8String(isolate, value));
+ }
+ args.GetReturnValue().Set(dst);
+}
+
void AutomationInternalCustomBindings::GetState(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = GetIsolate();

Powered by Google App Engine
This is Rietveld 408576698