Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Side by Side Diff: chrome/browser/resources/chromeos/switch_access/switch_access.js

Issue 2837023004: Moved code dealing with accessibility tree from switch_access.js to new file, automation_manager.js (Closed)
Patch Set: Small documentation change Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/switch_access/manifest.json.jinja2 ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 /** 5 /**
6 * Class to manage SwitchAccess and interact with other controllers. 6 * Class to manage SwitchAccess and interact with other controllers.
7 * 7 *
8 * @constructor 8 * @constructor
9 * @implements {SwitchAccessInterface} 9 * @implements {SwitchAccessInterface}
10 */ 10 */
(...skipping 15 matching lines...) Expand all
26 this.autoScanManager_ = null; 26 this.autoScanManager_ = null;
27 27
28 /** 28 /**
29 * Handles keyboard input. 29 * Handles keyboard input.
30 * 30 *
31 * @private {KeyboardHandler} 31 * @private {KeyboardHandler}
32 */ 32 */
33 this.keyboardHandler_ = null; 33 this.keyboardHandler_ = null;
34 34
35 /** 35 /**
36 * Moves to the appropriate node in the accessibility tree. 36 * Handles interactions with the accessibility tree, including moving to and
37 * selecting nodes.
37 * 38 *
38 * @private {AutomationTreeWalker} 39 * @private {AutomationManager}
39 */ 40 */
40 this.treeWalker_ = null; 41 this.automationManager_ = null;
41
42 /**
43 * Currently selected node.
44 *
45 * @private {chrome.automation.AutomationNode}
46 */
47 this.node_ = null;
48
49 /**
50 * Root node (i.e., the desktop).
51 *
52 * @private {chrome.automation.AutomationNode}
53 */
54 this.root_ = null;
55 42
56 this.init_(); 43 this.init_();
57 }; 44 };
58 45
59 SwitchAccess.prototype = { 46 SwitchAccess.prototype = {
60 /** 47 /**
61 * Set this.node_ and this.root_ to the desktop node, and set up preferences, 48 * Set up preferences, controllers, and event listeners.
62 * controllers, and event listeners.
63 * 49 *
64 * @private 50 * @private
65 */ 51 */
66 init_: function() { 52 init_: function() {
67 this.switchAccessPrefs = new SwitchAccessPrefs(); 53 this.switchAccessPrefs = new SwitchAccessPrefs();
68 this.autoScanManager_ = new AutoScanManager(this); 54 this.autoScanManager_ = new AutoScanManager(this);
69 this.keyboardHandler_ = new KeyboardHandler(this); 55 this.keyboardHandler_ = new KeyboardHandler(this);
70 this.treeWalker_ = new AutomationTreeWalker(); 56 this.automationManager_ = new AutomationManager();
71
72 chrome.automation.getDesktop(function(desktop) {
73 this.node_ = desktop;
74 this.root_ = desktop;
75 console.log('AutomationNode for desktop is loaded');
76 this.printNode_(this.node_);
77 }.bind(this));
78 57
79 document.addEventListener( 58 document.addEventListener(
80 'prefsUpdate', this.handlePrefsUpdate_.bind(this)); 59 'prefsUpdate', this.handlePrefsUpdate_.bind(this));
81 }, 60 },
82 61
83 /** 62 /**
84 * Set this.node_ to the next/previous interesting node. If no interesting 63 * Move to the next/previous interesting node. If |doNext| is true, move to
85 * node is found, set this.node_ to the first/last interesting node. If 64 * the next node. Otherwise, move to the previous node.
86 * |doNext| is true, will search for next node. Otherwise, will search for
87 * previous node.
88 * 65 *
89 * @param {boolean} doNext 66 * @param {boolean} doNext
90 * @override 67 * @override
91 */ 68 */
92 moveToNode: function(doNext) { 69 moveToNode: function(doNext) {
93 let node = this.treeWalker_.moveToNode(this.node_, this.root_, doNext); 70 this.automationManager_.moveToNode(doNext);
94 if (node) {
95 this.node_ = node;
96 this.printNode_(this.node_);
97 chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
98 }
99 }, 71 },
100 72
101 /** 73 /**
102 * Perform the default action on the currently selected node. 74 * Perform the default action on the current node.
103 * 75 *
104 * @override 76 * @override
105 */ 77 */
106 doDefault: function() { 78 doDefault: function() {
107 if (!this.node_) 79 this.automationManager_.doDefault();
108 return;
109
110 this.node_.doDefault();
111 }, 80 },
112 81
113 /** 82 /**
114 * Open the options page in a new tab. 83 * Open the options page in a new tab.
115 * 84 *
116 * @override 85 * @override
117 */ 86 */
118 showOptionsPage: function() { 87 showOptionsPage: function() {
119 let optionsPage = {url: 'options.html'}; 88 let optionsPage = {url: 'options.html'};
120 chrome.tabs.create(optionsPage); 89 chrome.tabs.create(optionsPage);
(...skipping 22 matching lines...) Expand all
143 case 'enableAutoScan': 112 case 'enableAutoScan':
144 this.autoScanManager_.setEnabled(updatedPrefs[key]); 113 this.autoScanManager_.setEnabled(updatedPrefs[key]);
145 break; 114 break;
146 case 'autoScanTime': 115 case 'autoScanTime':
147 this.autoScanManager_.setScanTime(updatedPrefs[key]); 116 this.autoScanManager_.setScanTime(updatedPrefs[key]);
148 break; 117 break;
149 } 118 }
150 } 119 }
151 }, 120 },
152 121
153 // TODO(elichtenberg): Move print functions to a custom logger class. Only
154 // log when debuggingEnabled is true.
155 /** 122 /**
156 * Print out details about a node. 123 * Move to the next sibling of the current node if it has one.
157 *
158 * @param {chrome.automation.AutomationNode} node
159 * @private
160 */
161 printNode_: function(node) {
162 if (node) {
163 console.log('Name = ' + node.name);
164 console.log('Role = ' + node.role);
165 console.log('Root role = ' + node.root.role);
166 if (!node.parent)
167 console.log('At index ' + node.indexInParent + ', has no parent');
168 else {
169 let numSiblings = node.parent.children.length;
170 console.log(
171 'At index ' + node.indexInParent + ', there are '
172 + numSiblings + ' siblings');
173 }
174 console.log('Has ' + node.children.length + ' children');
175 } else {
176 console.log('Node is null');
177 }
178 console.log(node);
179 console.log('\n');
180 },
181
182 /**
183 * Move to the next sibling of this.node_ if it has one.
184 * 124 *
185 * @override 125 * @override
186 */ 126 */
187 debugMoveToNext: function() { 127 debugMoveToNext: function() {
188 let next = this.treeWalker_.debugMoveToNext(this.node_); 128 this.automationManager_.debugMoveToNext();
189 if (next) {
190 this.node_ = next;
191 this.printNode_(this.node_);
192 chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
193 }
194 }, 129 },
195 130
196 /** 131 /**
197 * Move to the previous sibling of this.node_ if it has one. 132 * Move to the previous sibling of the current node if it has one.
198 * 133 *
199 * @override 134 * @override
200 */ 135 */
201 debugMoveToPrevious: function() { 136 debugMoveToPrevious: function() {
202 let prev = this.treeWalker_.debugMoveToPrevious(this.node_); 137 this.automationManager_.debugMoveToPrevious();
203 if (prev) {
204 this.node_ = prev;
205 this.printNode_(this.node_);
206 chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
207 }
208 }, 138 },
209 139
210 /** 140 /**
211 * Move to the first child of this.node_ if it has one. 141 * Move to the first child of the current node if it has one.
212 * 142 *
213 * @override 143 * @override
214 */ 144 */
215 debugMoveToFirstChild: function() { 145 debugMoveToFirstChild: function() {
216 let child = this.treeWalker_.debugMoveToFirstChild(this.node_); 146 this.automationManager_.debugMoveToFirstChild();
217 if (child) {
218 this.node_ = child;
219 this.printNode_(this.node_);
220 chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
221 }
222 }, 147 },
223 148
224 /** 149 /**
225 * Move to the parent of this.node_ if it has one. 150 * Move to the parent of the current node if it has one.
226 * 151 *
227 * @override 152 * @override
228 */ 153 */
229 debugMoveToParent: function() { 154 debugMoveToParent: function() {
230 let parent = this.treeWalker_.debugMoveToParent(this.node_); 155 this.automationManager_.debugMoveToParent();
231 if (parent) {
232 this.node_ = parent;
233 this.printNode_(this.node_);
234 chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
235 }
236 } 156 }
237 }; 157 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/switch_access/manifest.json.jinja2 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698