| 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 #ifndef CHROME_RENDERER_EXTENSIONS_AUTOMATION_INTERNAL_CUSTOM_BINDINGS_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_AUTOMATION_INTERNAL_CUSTOM_BINDINGS_H_ |
| 6 #define CHROME_RENDERER_EXTENSIONS_AUTOMATION_INTERNAL_CUSTOM_BINDINGS_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_AUTOMATION_INTERNAL_CUSTOM_BINDINGS_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "extensions/renderer/object_backed_native_handler.h" | 9 #include "extensions/renderer/object_backed_native_handler.h" |
| 10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
| 11 #include "ui/accessibility/ax_tree.h" | 11 #include "ui/accessibility/ax_tree.h" |
| 12 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
| 13 | 13 |
| 14 struct ExtensionMsg_AccessibilityEventParams; | 14 struct ExtensionMsg_AccessibilityEventParams; |
| 15 | 15 |
| 16 namespace extensions { | 16 namespace extensions { |
| 17 | 17 |
| 18 class AutomationMessageFilter; | 18 class AutomationMessageFilter; |
| 19 | 19 |
| 20 struct TreeCache { |
| 21 TreeCache(); |
| 22 ~TreeCache(); |
| 23 |
| 24 int tab_id; |
| 25 int tree_id; |
| 26 |
| 27 gfx::Vector2d location_offset; |
| 28 ui::AXTree tree; |
| 29 }; |
| 30 |
| 20 // The native component of custom bindings for the chrome.automationInternal | 31 // The native component of custom bindings for the chrome.automationInternal |
| 21 // API. | 32 // API. |
| 22 class AutomationInternalCustomBindings : public ObjectBackedNativeHandler { | 33 class AutomationInternalCustomBindings : public ObjectBackedNativeHandler, |
| 34 public ui::AXTreeDelegate { |
| 23 public: | 35 public: |
| 24 explicit AutomationInternalCustomBindings(ScriptContext* context); | 36 explicit AutomationInternalCustomBindings(ScriptContext* context); |
| 25 | 37 |
| 26 ~AutomationInternalCustomBindings() override; | 38 ~AutomationInternalCustomBindings() override; |
| 27 | 39 |
| 28 bool OnMessageReceived(const IPC::Message& message); | 40 bool OnMessageReceived(const IPC::Message& message); |
| 29 | 41 |
| 30 private: | 42 private: |
| 31 // Returns whether this extension has the "interact" permission set (either | 43 // Returns whether this extension has the "interact" permission set (either |
| 32 // explicitly or implicitly after manifest parsing). | 44 // explicitly or implicitly after manifest parsing). |
| 33 void IsInteractPermitted(const v8::FunctionCallbackInfo<v8::Value>& args); | 45 void IsInteractPermitted(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 34 | 46 |
| 35 // Returns an object with bindings that will be added to the | 47 // Returns an object with bindings that will be added to the |
| 36 // chrome.automation namespace. | 48 // chrome.automation namespace. |
| 37 void GetSchemaAdditions(const v8::FunctionCallbackInfo<v8::Value>& args); | 49 void GetSchemaAdditions(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 38 | 50 |
| 39 // Get the routing ID for the extension. | 51 // Get the routing ID for the extension. |
| 40 void GetRoutingID(const v8::FunctionCallbackInfo<v8::Value>& args); | 52 void GetRoutingID(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 41 | 53 |
| 54 // |
| 55 void StartCachingAccessibilityTrees( |
| 56 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 57 |
| 58 // |
| 59 void DestroyAccessibilityTree( |
| 60 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 61 |
| 62 void GetRootID( |
| 63 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 64 |
| 65 bool GetNodeHelper( |
| 66 const v8::FunctionCallbackInfo<v8::Value>& args, |
| 67 TreeCache** out_cache, |
| 68 ui::AXNode** out_node); |
| 69 void SetReturnValueFromBaseValue( |
| 70 const v8::FunctionCallbackInfo<v8::Value>& args, |
| 71 base::Value* value); |
| 72 |
| 73 void GetParentID( |
| 74 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 75 void GetChildCount( |
| 76 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 77 void GetChildIDAtIndex( |
| 78 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 79 void GetIndexInParent( |
| 80 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 81 |
| 82 void GetState( |
| 83 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 84 void GetRole( |
| 85 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 86 void GetLocation( |
| 87 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 88 |
| 89 bool GetAttributeHelper( |
| 90 const v8::FunctionCallbackInfo<v8::Value>& args, |
| 91 ui::AXNode** out_node, |
| 92 std::string* out_attribute_name); |
| 93 |
| 94 void GetStringAttribute( |
| 95 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 96 void GetBoolAttribute( |
| 97 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 98 void GetIntAttribute( |
| 99 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 100 void GetFloatAttribute( |
| 101 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 102 void GetIntListAttribute( |
| 103 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 104 |
| 42 // Handle accessibility events from the browser process. | 105 // Handle accessibility events from the browser process. |
| 43 void OnAccessibilityEvent( | 106 void OnAccessibilityEvent( |
| 44 const ExtensionMsg_AccessibilityEventParams& params); | 107 const ExtensionMsg_AccessibilityEventParams& params); |
| 45 | 108 |
| 109 // AXTreeDelegate implementation. |
| 110 void OnNodeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; |
| 111 void OnSubtreeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; |
| 112 void OnNodeCreated(ui::AXTree* tree, ui::AXNode* node) override; |
| 113 void OnNodeChanged(ui::AXTree* tree, ui::AXNode* node) override; |
| 114 void OnAtomicUpdateFinished(ui::AXTree* tree, |
| 115 bool root_changed, |
| 116 const std::vector<Change>& changes) override; |
| 117 |
| 118 void SendTreeChangeEvent(const char *change_type, |
| 119 ui::AXTree* tree, |
| 120 ui::AXNode* node); |
| 121 |
| 122 base::hash_map<int, TreeCache*> tree_id_to_tree_cache_map_; |
| 123 base::hash_map<ui::AXTree*, TreeCache*> axtree_to_tree_cache_map_; |
| 46 scoped_refptr<AutomationMessageFilter> message_filter_; | 124 scoped_refptr<AutomationMessageFilter> message_filter_; |
| 47 | 125 |
| 48 DISALLOW_COPY_AND_ASSIGN(AutomationInternalCustomBindings); | 126 DISALLOW_COPY_AND_ASSIGN(AutomationInternalCustomBindings); |
| 49 }; | 127 }; |
| 50 | 128 |
| 51 } // namespace extensions | 129 } // namespace extensions |
| 52 | 130 |
| 53 #endif // CHROME_RENDERER_EXTENSIONS_AUTOMATION_INTERNAL_CUSTOM_BINDINGS_H_ | 131 #endif // CHROME_RENDERER_EXTENSIONS_AUTOMATION_INTERNAL_CUSTOM_BINDINGS_H_ |
| OLD | NEW |