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 int checked_state = |
| 718 node->data().GetIntAttribute(ui::AX_ATTR_CHECKED_STATE); |
| 719 const char* checked_str = GetCheckedStateName(checked_state); |
| 720 result.Set(v8::String::NewFromUtf8(isolate, checked_str)); |
| 721 }); |
714 } | 722 } |
715 | 723 |
716 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() {} | 724 AutomationInternalCustomBindings::~AutomationInternalCustomBindings() {} |
717 | 725 |
718 void AutomationInternalCustomBindings::Invalidate() { | 726 void AutomationInternalCustomBindings::Invalidate() { |
719 ObjectBackedNativeHandler::Invalidate(); | 727 ObjectBackedNativeHandler::Invalidate(); |
720 | 728 |
721 if (message_filter_) | 729 if (message_filter_) |
722 message_filter_->Detach(); | 730 message_filter_->Detach(); |
723 | 731 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 } | 1002 } |
995 } | 1003 } |
996 if (cache->tree.data().focus_id == node->id()) { | 1004 if (cache->tree.data().focus_id == node->id()) { |
997 state->Set(CreateV8String(isolate, "focused"), | 1005 state->Set(CreateV8String(isolate, "focused"), |
998 v8::Boolean::New(isolate, true)); | 1006 v8::Boolean::New(isolate, true)); |
999 } | 1007 } |
1000 | 1008 |
1001 args.GetReturnValue().Set(state); | 1009 args.GetReturnValue().Set(state); |
1002 } | 1010 } |
1003 | 1011 |
| 1012 const char* AutomationInternalCustomBindings::GetCheckedStateName( |
| 1013 const int checked_state) { |
| 1014 switch (checked_state) { |
| 1015 case ui::AX_CHECKED_STATE_TRUE: |
| 1016 return "true"; |
| 1017 case ui::AX_CHECKED_STATE_MIXED: |
| 1018 return "mixed"; |
| 1019 default: |
| 1020 break; |
| 1021 } |
| 1022 return "false"; |
| 1023 } |
| 1024 |
1004 void AutomationInternalCustomBindings::UpdateOverallTreeChangeObserverFilter() { | 1025 void AutomationInternalCustomBindings::UpdateOverallTreeChangeObserverFilter() { |
1005 tree_change_observer_overall_filter_ = 0; | 1026 tree_change_observer_overall_filter_ = 0; |
1006 for (const auto& observer : tree_change_observers_) | 1027 for (const auto& observer : tree_change_observers_) |
1007 tree_change_observer_overall_filter_ |= 1 << observer.filter; | 1028 tree_change_observer_overall_filter_ |= 1 << observer.filter; |
1008 } | 1029 } |
1009 | 1030 |
1010 ui::AXNode* AutomationInternalCustomBindings::GetParent( | 1031 ui::AXNode* AutomationInternalCustomBindings::GetParent( |
1011 ui::AXNode* node, | 1032 ui::AXNode* node, |
1012 TreeCache** in_out_cache) { | 1033 TreeCache** in_out_cache) { |
1013 if (node->parent()) | 1034 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)); | 1414 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); |
1394 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 1415 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
1395 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); | 1416 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); |
1396 args->Set(1U, nodes); | 1417 args->Set(1U, nodes); |
1397 for (size_t i = 0; i < ids.size(); ++i) | 1418 for (size_t i = 0; i < ids.size(); ++i) |
1398 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); | 1419 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); |
1399 context()->DispatchEvent("automationInternal.onNodesRemoved", args); | 1420 context()->DispatchEvent("automationInternal.onNodesRemoved", args); |
1400 } | 1421 } |
1401 | 1422 |
1402 } // namespace extensions | 1423 } // namespace extensions |
OLD | NEW |