| 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 "chrome/common/extensions/api/automation.h" | 9 #include "chrome/common/extensions/api/automation.h" |
| 10 #include "extensions/renderer/object_backed_native_handler.h" | 10 #include "extensions/renderer/object_backed_native_handler.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 TreeCache(); | 22 TreeCache(); |
| 23 ~TreeCache(); | 23 ~TreeCache(); |
| 24 | 24 |
| 25 int tab_id; | 25 int tab_id; |
| 26 int tree_id; | 26 int tree_id; |
| 27 | 27 |
| 28 gfx::Vector2d location_offset; | 28 gfx::Vector2d location_offset; |
| 29 ui::AXTree tree; | 29 ui::AXTree tree; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 struct TreeChangeObserver { |
| 33 int id; |
| 34 api::automation::TreeChangeObserverFilter filter; |
| 35 }; |
| 36 |
| 32 // The native component of custom bindings for the chrome.automationInternal | 37 // The native component of custom bindings for the chrome.automationInternal |
| 33 // API. | 38 // API. |
| 34 class AutomationInternalCustomBindings : public ObjectBackedNativeHandler, | 39 class AutomationInternalCustomBindings : public ObjectBackedNativeHandler, |
| 35 public ui::AXTreeDelegate { | 40 public ui::AXTreeDelegate { |
| 36 public: | 41 public: |
| 37 explicit AutomationInternalCustomBindings(ScriptContext* context); | 42 explicit AutomationInternalCustomBindings(ScriptContext* context); |
| 38 | 43 |
| 39 ~AutomationInternalCustomBindings() override; | 44 ~AutomationInternalCustomBindings() override; |
| 40 | 45 |
| 41 void OnMessageReceived(const IPC::Message& message); | 46 void OnMessageReceived(const IPC::Message& message); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 // events forwarded to this process. | 72 // events forwarded to this process. |
| 68 void StartCachingAccessibilityTrees( | 73 void StartCachingAccessibilityTrees( |
| 69 const v8::FunctionCallbackInfo<v8::Value>& args); | 74 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 70 | 75 |
| 71 // Called when an accessibility tree is destroyed and needs to be | 76 // Called when an accessibility tree is destroyed and needs to be |
| 72 // removed from our cache. | 77 // removed from our cache. |
| 73 // Args: int ax_tree_id | 78 // Args: int ax_tree_id |
| 74 void DestroyAccessibilityTree( | 79 void DestroyAccessibilityTree( |
| 75 const v8::FunctionCallbackInfo<v8::Value>& args); | 80 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 76 | 81 |
| 82 void AddTreeChangeObserver(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 83 |
| 84 void RemoveTreeChangeObserver( |
| 85 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 86 |
| 77 void RouteTreeIDFunction(const std::string& name, | 87 void RouteTreeIDFunction(const std::string& name, |
| 78 void (*callback)(v8::Isolate* isolate, | 88 void (*callback)(v8::Isolate* isolate, |
| 79 v8::ReturnValue<v8::Value> result, | 89 v8::ReturnValue<v8::Value> result, |
| 80 TreeCache* cache)); | 90 TreeCache* cache)); |
| 81 | 91 |
| 82 void RouteNodeIDFunction(const std::string& name, | 92 void RouteNodeIDFunction(const std::string& name, |
| 83 void (*callback)(v8::Isolate* isolate, | 93 void (*callback)(v8::Isolate* isolate, |
| 84 v8::ReturnValue<v8::Value> result, | 94 v8::ReturnValue<v8::Value> result, |
| 85 TreeCache* cache, | 95 TreeCache* cache, |
| 86 ui::AXNode* node)); | 96 ui::AXNode* node)); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 void GetHtmlAttribute(const v8::FunctionCallbackInfo<v8::Value>& args); | 162 void GetHtmlAttribute(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 153 | 163 |
| 154 // | 164 // |
| 155 // Helper functions. | 165 // Helper functions. |
| 156 // | 166 // |
| 157 | 167 |
| 158 // Handle accessibility events from the browser process. | 168 // Handle accessibility events from the browser process. |
| 159 void OnAccessibilityEvent(const ExtensionMsg_AccessibilityEventParams& params, | 169 void OnAccessibilityEvent(const ExtensionMsg_AccessibilityEventParams& params, |
| 160 bool is_active_profile); | 170 bool is_active_profile); |
| 161 | 171 |
| 172 void UpdateOverallTreeChangeObserverFilter(); |
| 173 |
| 162 // AXTreeDelegate implementation. | 174 // AXTreeDelegate implementation. |
| 163 void OnTreeDataChanged(ui::AXTree* tree) override; | 175 void OnTreeDataChanged(ui::AXTree* tree) override; |
| 164 void OnNodeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; | 176 void OnNodeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; |
| 165 void OnSubtreeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; | 177 void OnSubtreeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override; |
| 166 void OnNodeCreated(ui::AXTree* tree, ui::AXNode* node) override; | 178 void OnNodeCreated(ui::AXTree* tree, ui::AXNode* node) override; |
| 167 void OnNodeChanged(ui::AXTree* tree, ui::AXNode* node) override; | 179 void OnNodeChanged(ui::AXTree* tree, ui::AXNode* node) override; |
| 168 void OnAtomicUpdateFinished(ui::AXTree* tree, | 180 void OnAtomicUpdateFinished(ui::AXTree* tree, |
| 169 bool root_changed, | 181 bool root_changed, |
| 170 const std::vector<Change>& changes) override; | 182 const std::vector<Change>& changes) override; |
| 171 | |
| 172 void SendTreeChangeEvent(api::automation::TreeChangeType change_type, | 183 void SendTreeChangeEvent(api::automation::TreeChangeType change_type, |
| 173 ui::AXTree* tree, | 184 ui::AXTree* tree, |
| 174 ui::AXNode* node); | 185 ui::AXNode* node); |
| 186 void SendChildTreeIDEvent(ui::AXTree* tree, ui::AXNode* node); |
| 187 void SendNodesRemovedEvent(ui::AXTree* tree, const std::vector<int>& ids); |
| 175 | 188 |
| 176 base::hash_map<int, TreeCache*> tree_id_to_tree_cache_map_; | 189 base::hash_map<int, TreeCache*> tree_id_to_tree_cache_map_; |
| 177 base::hash_map<ui::AXTree*, TreeCache*> axtree_to_tree_cache_map_; | 190 base::hash_map<ui::AXTree*, TreeCache*> axtree_to_tree_cache_map_; |
| 178 scoped_refptr<AutomationMessageFilter> message_filter_; | 191 scoped_refptr<AutomationMessageFilter> message_filter_; |
| 179 bool is_active_profile_; | 192 bool is_active_profile_; |
| 193 std::vector<TreeChangeObserver> tree_change_observers_; |
| 194 api::automation::TreeChangeObserverFilter |
| 195 tree_change_observer_overall_filter_; |
| 196 std::vector<int> deleted_node_ids_; |
| 180 | 197 |
| 181 DISALLOW_COPY_AND_ASSIGN(AutomationInternalCustomBindings); | 198 DISALLOW_COPY_AND_ASSIGN(AutomationInternalCustomBindings); |
| 182 }; | 199 }; |
| 183 | 200 |
| 184 } // namespace extensions | 201 } // namespace extensions |
| 185 | 202 |
| 186 #endif // CHROME_RENDERER_EXTENSIONS_AUTOMATION_INTERNAL_CUSTOM_BINDINGS_H_ | 203 #endif // CHROME_RENDERER_EXTENSIONS_AUTOMATION_INTERNAL_CUSTOM_BINDINGS_H_ |
| OLD | NEW |