OLD | NEW |
---|---|
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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 result.Set(v8::String::NewFromUtf8(isolate, attr_value.c_str())); | 704 result.Set(v8::String::NewFromUtf8(isolate, attr_value.c_str())); |
705 }); | 705 }); |
706 RouteNodeIDFunction( | 706 RouteNodeIDFunction( |
707 "GetNameFrom", [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, | 707 "GetNameFrom", [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, |
708 TreeCache* cache, ui::AXNode* node) { | 708 TreeCache* cache, ui::AXNode* node) { |
709 ui::AXNameFrom name_from = static_cast<ui::AXNameFrom>( | 709 ui::AXNameFrom name_from = static_cast<ui::AXNameFrom>( |
710 node->data().GetIntAttribute(ui::AX_ATTR_NAME_FROM)); | 710 node->data().GetIntAttribute(ui::AX_ATTR_NAME_FROM)); |
711 std::string name_from_str = ui::ToString(name_from); | 711 std::string name_from_str = ui::ToString(name_from); |
712 result.Set(v8::String::NewFromUtf8(isolate, name_from_str.c_str())); | 712 result.Set(v8::String::NewFromUtf8(isolate, name_from_str.c_str())); |
713 }); | 713 }); |
714 RouteNodeIDFunction( | |
715 "GetChecked", [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, | |
716 TreeCache* cache, ui::AXNode* node) { | |
717 const auto checked_state = static_cast<ui::AXCheckedState>( | |
718 node->data().GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); | |
719 const char* checked_str = GetCheckedStateName(checked_state); | |
720 if (checked_state) { | |
721 result.Set(v8::String::NewFromUtf8(isolate, checked_str)); | |
722 } | |
723 }); | |
714 } | 724 } |
715 | 725 |
716 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() {} | 726 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() {} |
717 | 727 |
718 void AutomationInternalCustomBindings::Invalidate() { | 728 void AutomationInternalCustomBindings::Invalidate() { |
719 ObjectBackedNativeHandler::Invalidate(); | 729 ObjectBackedNativeHandler::Invalidate(); |
720 | 730 |
721 if (message_filter_) | 731 if (message_filter_) |
722 message_filter_->Detach(); | 732 message_filter_->Detach(); |
723 | 733 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
994 } | 1004 } |
995 } | 1005 } |
996 if (cache->tree.data().focus_id == node->id()) { | 1006 if (cache->tree.data().focus_id == node->id()) { |
997 state->Set(CreateV8String(isolate, "focused"), | 1007 state->Set(CreateV8String(isolate, "focused"), |
998 v8::Boolean::New(isolate, true)); | 1008 v8::Boolean::New(isolate, true)); |
999 } | 1009 } |
1000 | 1010 |
1001 args.GetReturnValue().Set(state); | 1011 args.GetReturnValue().Set(state); |
1002 } | 1012 } |
1003 | 1013 |
1014 const char* AutomationInternalCustomBindings::GetCheckedStateName( | |
David Tseng
2017/03/13 18:10:54
ax_enums.h should generate this for you (ToString(
| |
1015 const ui::AXCheckedState checked_state) { | |
1016 switch (checked_state) { | |
1017 case ui::AX_CHECKED_STATE_NONE: | |
1018 return nullptr; | |
1019 case ui::AX_CHECKED_STATE_TRUE: | |
1020 return "true"; | |
1021 case ui::AX_CHECKED_STATE_MIXED: | |
1022 return "mixed"; | |
1023 default: | |
1024 break; | |
1025 } | |
1026 return "false"; | |
1027 } | |
1028 | |
1004 void AutomationInternalCustomBindings::UpdateOverallTreeChangeObserverFilter() { | 1029 void AutomationInternalCustomBindings::UpdateOverallTreeChangeObserverFilter() { |
1005 tree_change_observer_overall_filter_ = 0; | 1030 tree_change_observer_overall_filter_ = 0; |
1006 for (const auto& observer : tree_change_observers_) | 1031 for (const auto& observer : tree_change_observers_) |
1007 tree_change_observer_overall_filter_ |= 1 << observer.filter; | 1032 tree_change_observer_overall_filter_ |= 1 << observer.filter; |
1008 } | 1033 } |
1009 | 1034 |
1010 ui::AXNode* AutomationInternalCustomBindings::GetParent( | 1035 ui::AXNode* AutomationInternalCustomBindings::GetParent( |
1011 ui::AXNode* node, | 1036 ui::AXNode* node, |
1012 TreeCache** in_out_cache) { | 1037 TreeCache** in_out_cache) { |
1013 if (node->parent()) | 1038 if (node->parent()) |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1393 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); | 1418 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); |
1394 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 1419 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
1395 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); | 1420 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); |
1396 args->Set(1U, nodes); | 1421 args->Set(1U, nodes); |
1397 for (size_t i = 0; i < ids.size(); ++i) | 1422 for (size_t i = 0; i < ids.size(); ++i) |
1398 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); | 1423 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); |
1399 context()->DispatchEvent("automationInternal.onNodesRemoved", args); | 1424 context()->DispatchEvent("automationInternal.onNodesRemoved", args); |
1400 } | 1425 } |
1401 | 1426 |
1402 } // namespace extensions | 1427 } // namespace extensions |
OLD | NEW |