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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 ui::AX_TEXT_STYLE_UNDERLINE) != 0; | 687 ui::AX_TEXT_STYLE_UNDERLINE) != 0; |
688 result.Set(v8::Boolean::New(isolate, value)); | 688 result.Set(v8::Boolean::New(isolate, value)); |
689 }); | 689 }); |
690 RouteNodeIDFunction("GetLineThrough", [](v8::Isolate* isolate, | 690 RouteNodeIDFunction("GetLineThrough", [](v8::Isolate* isolate, |
691 v8::ReturnValue<v8::Value> result, | 691 v8::ReturnValue<v8::Value> result, |
692 TreeCache* cache, ui::AXNode* node) { | 692 TreeCache* cache, ui::AXNode* node) { |
693 bool value = (node->data().GetIntAttribute(ui::AX_ATTR_TEXT_STYLE) & | 693 bool value = (node->data().GetIntAttribute(ui::AX_ATTR_TEXT_STYLE) & |
694 ui::AX_TEXT_STYLE_LINE_THROUGH) != 0; | 694 ui::AX_TEXT_STYLE_LINE_THROUGH) != 0; |
695 result.Set(v8::Boolean::New(isolate, value)); | 695 result.Set(v8::Boolean::New(isolate, value)); |
696 }); | 696 }); |
| 697 RouteNodeIDFunction( |
| 698 "GetCustomActions", |
| 699 [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result, |
| 700 TreeCache* cache, ui::AXNode* node) { |
| 701 const std::vector<int32_t>& custom_action_ids = |
| 702 node->data().GetIntListAttribute(ui::AX_ATTR_CUSTOM_ACTION_IDS); |
| 703 if (custom_action_ids.empty()) { |
| 704 result.SetUndefined(); |
| 705 return; |
| 706 } |
| 707 |
| 708 const std::vector<std::string>& custom_action_descriptions = |
| 709 node->data().GetStringListAttribute( |
| 710 ui::AX_ATTR_CUSTOM_ACTION_DESCRIPTIONS); |
| 711 if (custom_action_ids.size() != custom_action_descriptions.size()) { |
| 712 NOTREACHED(); |
| 713 return; |
| 714 } |
| 715 |
| 716 v8::Local<v8::Array> custom_actions( |
| 717 v8::Array::New(isolate, custom_action_ids.size())); |
| 718 for (size_t i = 0; i < custom_action_ids.size(); i++) { |
| 719 gin::DataObjectBuilder custom_action(isolate); |
| 720 custom_action.Set("id", custom_action_ids[i]); |
| 721 custom_action.Set("description", custom_action_descriptions[i]); |
| 722 custom_actions->Set(static_cast<uint32_t>(i), custom_action.Build()); |
| 723 } |
| 724 result.Set(custom_actions); |
| 725 }); |
697 RouteNodeIDFunction("GetChecked", [](v8::Isolate* isolate, | 726 RouteNodeIDFunction("GetChecked", [](v8::Isolate* isolate, |
698 v8::ReturnValue<v8::Value> result, | 727 v8::ReturnValue<v8::Value> result, |
699 TreeCache* cache, ui::AXNode* node) { | 728 TreeCache* cache, ui::AXNode* node) { |
700 const ui::AXCheckedState checked_state = static_cast<ui::AXCheckedState>( | 729 const ui::AXCheckedState checked_state = static_cast<ui::AXCheckedState>( |
701 node->data().GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); | 730 node->data().GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); |
702 if (checked_state) { | 731 if (checked_state) { |
703 const std::string checked_str = ui::ToString(checked_state); | 732 const std::string checked_str = ui::ToString(checked_state); |
704 result.Set(v8::String::NewFromUtf8(isolate, checked_str.c_str())); | 733 result.Set(v8::String::NewFromUtf8(isolate, checked_str.c_str())); |
705 } | 734 } |
706 }); | 735 }); |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 for (auto id : ids) | 1399 for (auto id : ids) |
1371 nodes->AppendInteger(id); | 1400 nodes->AppendInteger(id); |
1372 args.Append(std::move(nodes)); | 1401 args.Append(std::move(nodes)); |
1373 } | 1402 } |
1374 | 1403 |
1375 bindings_system_->DispatchEventInContext("automationInternal.onNodesRemoved", | 1404 bindings_system_->DispatchEventInContext("automationInternal.onNodesRemoved", |
1376 &args, nullptr, context()); | 1405 &args, nullptr, context()); |
1377 } | 1406 } |
1378 | 1407 |
1379 } // namespace extensions | 1408 } // namespace extensions |
OLD | NEW |