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 e68edce85d3ff451f7ef206e19c291edfaf64043..11d3fcdb92c8ac0a3f37aba6fd2b842d148b1809 100644 |
--- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
+++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
@@ -393,7 +393,10 @@ private: |
AutomationInternalCustomBindings::AutomationInternalCustomBindings( |
ScriptContext* context) |
- : ObjectBackedNativeHandler(context), is_active_profile_(true) { |
+ : ObjectBackedNativeHandler(context), |
+ is_active_profile_(true), |
+ tree_change_observer_mask_( |
+ api::automation::TREE_CHANGE_OBSERVER_MASK_NOTREECHANGES) { |
// It's safe to use base::Unretained(this) here because these bindings |
// will only be called on a valid AutomationInternalCustomBindings instance |
// and none of the functions have any side effects. |
@@ -406,6 +409,7 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( |
ROUTE_FUNCTION(GetRoutingID); |
ROUTE_FUNCTION(StartCachingAccessibilityTrees); |
ROUTE_FUNCTION(DestroyAccessibilityTree); |
+ ROUTE_FUNCTION(SetTreeChangeObserverMask); |
ROUTE_FUNCTION(GetChildIDAtIndex); |
#undef ROUTE_FUNCTION |
@@ -732,6 +736,18 @@ void AutomationInternalCustomBindings::DestroyAccessibilityTree( |
delete cache; |
} |
+void AutomationInternalCustomBindings::SetTreeChangeObserverMask( |
+ const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ if (args.Length() != 1 || !args[0]->IsString()) { |
+ ThrowInvalidArgumentsException(this); |
+ return; |
+ } |
+ |
+ std::string mask_str = *v8::String::Utf8Value(args[0]); |
+ tree_change_observer_mask_ = |
+ api::automation::ParseTreeChangeObserverMask(mask_str); |
+} |
+ |
void AutomationInternalCustomBindings::RouteTreeIDFunction( |
const std::string& name, |
TreeIDFunction callback) { |
@@ -909,6 +925,24 @@ void AutomationInternalCustomBindings::SendTreeChangeEvent( |
if (!is_active_profile_) |
return; |
+ if (node->data().role != ui::AX_ROLE_EMBEDDED_OBJECT && |
+ node->data().role != ui::AX_ROLE_WEB_VIEW) { |
+ switch (tree_change_observer_mask_) { |
+ case api::automation::TREE_CHANGE_OBSERVER_MASK_NOTREECHANGES: |
+ default: |
+ return; |
+ case api::automation::TREE_CHANGE_OBSERVER_MASK_LIVEREGIONTREECHANGES: |
+ if (!node->data().HasStringAttribute( |
+ ui::AX_ATTR_CONTAINER_LIVE_STATUS) && |
+ node->data().role != ui::AX_ROLE_ALERT) { |
+ return; |
+ } |
+ break; |
+ case api::automation::TREE_CHANGE_OBSERVER_MASK_ALLTREECHANGES: |
+ break; |
+ } |
+ } |
+ |
auto iter = axtree_to_tree_cache_map_.find(tree); |
if (iter == axtree_to_tree_cache_map_.end()) |
return; |