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

Unified Diff: chrome/renderer/extensions/automation_internal_custom_bindings.cc

Issue 1407413002: Move some AX attrs from AXNodeData to AXTreeData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finish automation API changes Created 5 years, 2 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 844fd87dd09790dbc38ce9615333ee5698240fdd..aa3f199343c1dc0612c6e69743b1d5397a534020 100644
--- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc
+++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc
@@ -116,6 +116,14 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings(
ROUTE_FUNCTION(StartCachingAccessibilityTrees);
ROUTE_FUNCTION(DestroyAccessibilityTree);
ROUTE_FUNCTION(GetRootID);
+ ROUTE_FUNCTION(GetDocURL);
David Tseng 2015/10/19 18:21:38 I would like to see us to re-use get*Attribute her
+ ROUTE_FUNCTION(GetDocTitle);
+ ROUTE_FUNCTION(GetDocLoaded);
+ ROUTE_FUNCTION(GetDocLoadingProgress);
+ ROUTE_FUNCTION(GetAnchorObjectID);
+ ROUTE_FUNCTION(GetAnchorOffset);
+ ROUTE_FUNCTION(GetFocusObjectID);
+ ROUTE_FUNCTION(GetFocusOffset);
ROUTE_FUNCTION(GetParentID);
ROUTE_FUNCTION(GetChildCount);
ROUTE_FUNCTION(GetChildIDAtIndex);
@@ -237,6 +245,142 @@ void AutomationInternalCustomBindings::GetRootID(
args.GetReturnValue().Set(v8::Integer::New(GetIsolate(), root_id));
}
+void AutomationInternalCustomBindings::GetDocURL(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsNumber()) {
+ ThrowInvalidArgumentsException(args);
+ return;
+ }
+
+ int tree_id = args[0]->Int32Value();
+ const auto iter = tree_id_to_tree_cache_map_.find(tree_id);
+ if (iter == tree_id_to_tree_cache_map_.end())
+ return;
+
+ TreeCache* cache = iter->second;
+ args.GetReturnValue().Set(
+ v8::String::NewFromUtf8(GetIsolate(), cache->tree.data().url.c_str()));
+}
+
+void AutomationInternalCustomBindings::GetDocTitle(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsNumber()) {
+ ThrowInvalidArgumentsException(args);
+ return;
+ }
+
+ int tree_id = args[0]->Int32Value();
+ const auto iter = tree_id_to_tree_cache_map_.find(tree_id);
+ if (iter == tree_id_to_tree_cache_map_.end())
+ return;
+
+ TreeCache* cache = iter->second;
+ args.GetReturnValue().Set(
+ v8::String::NewFromUtf8(GetIsolate(), cache->tree.data().title.c_str()));
+}
+
+void AutomationInternalCustomBindings::GetDocLoaded(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsNumber()) {
+ ThrowInvalidArgumentsException(args);
+ return;
+ }
+
+ int tree_id = args[0]->Int32Value();
+ const auto iter = tree_id_to_tree_cache_map_.find(tree_id);
+ if (iter == tree_id_to_tree_cache_map_.end())
+ return;
+
+ TreeCache* cache = iter->second;
+ args.GetReturnValue().Set(
+ v8::Boolean::New(GetIsolate(), cache->tree.data().loaded));
+}
+
+void AutomationInternalCustomBindings::GetDocLoadingProgress(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsNumber()) {
+ ThrowInvalidArgumentsException(args);
+ return;
+ }
+
+ int tree_id = args[0]->Int32Value();
+ const auto iter = tree_id_to_tree_cache_map_.find(tree_id);
+ if (iter == tree_id_to_tree_cache_map_.end())
+ return;
+
+ TreeCache* cache = iter->second;
+ args.GetReturnValue().Set(
+ v8::Number::New(GetIsolate(), cache->tree.data().loading_progress));
+}
+
+void AutomationInternalCustomBindings::GetAnchorObjectID(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsNumber()) {
+ ThrowInvalidArgumentsException(args);
+ return;
+ }
+
+ int tree_id = args[0]->Int32Value();
+ const auto iter = tree_id_to_tree_cache_map_.find(tree_id);
+ if (iter == tree_id_to_tree_cache_map_.end())
+ return;
+
+ TreeCache* cache = iter->second;
+ args.GetReturnValue().Set(
+ v8::Number::New(GetIsolate(), cache->tree.data().sel_anchor_object_id));
+}
+
+void AutomationInternalCustomBindings::GetAnchorOffset(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsNumber()) {
+ ThrowInvalidArgumentsException(args);
+ return;
+ }
+
+ int tree_id = args[0]->Int32Value();
+ const auto iter = tree_id_to_tree_cache_map_.find(tree_id);
+ if (iter == tree_id_to_tree_cache_map_.end())
+ return;
+
+ TreeCache* cache = iter->second;
+ args.GetReturnValue().Set(
+ v8::Number::New(GetIsolate(), cache->tree.data().sel_anchor_offset));
+}
+
+void AutomationInternalCustomBindings::GetFocusObjectID(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsNumber()) {
+ ThrowInvalidArgumentsException(args);
+ return;
+ }
+
+ int tree_id = args[0]->Int32Value();
+ const auto iter = tree_id_to_tree_cache_map_.find(tree_id);
+ if (iter == tree_id_to_tree_cache_map_.end())
+ return;
+
+ TreeCache* cache = iter->second;
+ args.GetReturnValue().Set(
+ v8::Number::New(GetIsolate(), cache->tree.data().sel_focus_object_id));
+}
+
+void AutomationInternalCustomBindings::GetFocusOffset(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ if (args.Length() != 1 || !args[0]->IsNumber()) {
+ ThrowInvalidArgumentsException(args);
+ return;
+ }
+
+ int tree_id = args[0]->Int32Value();
+ const auto iter = tree_id_to_tree_cache_map_.find(tree_id);
+ if (iter == tree_id_to_tree_cache_map_.end())
+ return;
+
+ TreeCache* cache = iter->second;
+ args.GetReturnValue().Set(
+ v8::Number::New(GetIsolate(), cache->tree.data().sel_focus_offset));
+}
+
void AutomationInternalCustomBindings::GetParentID(
const v8::FunctionCallbackInfo<v8::Value>& args) {
ui::AXNode* node = nullptr;
@@ -561,6 +705,8 @@ void AutomationInternalCustomBindings::OnAccessibilityEvent(
context()->DispatchEvent("automationInternal.onAccessibilityEvent", args);
}
+void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {}
+
void AutomationInternalCustomBindings::OnNodeWillBeDeleted(ui::AXTree* tree,
ui::AXNode* node) {
SendTreeChangeEvent(

Powered by Google App Engine
This is Rietveld 408576698