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

Unified Diff: chrome/browser/resources/chromeos/switch_access/automation_manager.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/switch_access/automation_manager.js
diff --git a/chrome/browser/resources/chromeos/switch_access/switch_access.js b/chrome/browser/resources/chromeos/switch_access/automation_manager.js
similarity index 62%
copy from chrome/browser/resources/chromeos/switch_access/switch_access.js
copy to chrome/browser/resources/chromeos/switch_access/automation_manager.js
index 58bcb3a7b0c2c8ccf72ccda79a5f617f95ae4da9..855539dae6706fb34f3e20fc1de1df08d3610dfe 100644
--- a/chrome/browser/resources/chromeos/switch_access/switch_access.js
+++ b/chrome/browser/resources/chromeos/switch_access/automation_manager.js
@@ -3,34 +3,25 @@
// found in the LICENSE file.
/**
- * Class to manage SwitchAccess and interact with other controllers.
+ * Class to manage interactions with the accessibility tree, including moving
+ * to and selecting nodes.
*
* @constructor
- * @implements {SwitchAccessInterface}
*/
-function SwitchAccess() {
- console.log('Switch access is enabled');
-
+function AutomationManager() {
/**
- * User preferences.
- *
- * @type {SwitchAccessPrefs}
- */
- this.switchAccessPrefs = null;
-
- /**
- * Handles changes to auto-scan.
+ * Currently selected node.
*
- * @private {AutoScanManager}
+ * @private {chrome.automation.AutomationNode}
*/
- this.autoScanManager_ = null;
+ this.node_ = null;
/**
- * Handles keyboard input.
+ * Root node (i.e., the desktop).
*
- * @private {KeyboardHandler}
+ * @private {chrome.automation.AutomationNode}
*/
- this.keyboardHandler_ = null;
+ this.root_ = null;
/**
* Moves to the appropriate node in the accessibility tree.
@@ -39,34 +30,17 @@ function SwitchAccess() {
*/
this.treeWalker_ = null;
- /**
- * Currently selected node.
- *
- * @private {chrome.automation.AutomationNode}
- */
- this.node_ = null;
-
- /**
- * Root node (i.e., the desktop).
- *
- * @private {chrome.automation.AutomationNode}
- */
- this.root_ = null;
-
this.init_();
};
-SwitchAccess.prototype = {
+AutomationManager.prototype = {
/**
- * Set this.node_ and this.root_ to the desktop node, and set up preferences,
- * controllers, and event listeners.
+ * Set this.node_ and this.root_ to the desktop node, and initialize the
+ * tree walker.
*
* @private
*/
init_: function() {
- this.switchAccessPrefs = new SwitchAccessPrefs();
- this.autoScanManager_ = new AutoScanManager(this);
- this.keyboardHandler_ = new KeyboardHandler(this);
this.treeWalker_ = new AutomationTreeWalker();
chrome.automation.getDesktop(function(desktop) {
@@ -75,19 +49,15 @@ SwitchAccess.prototype = {
console.log('AutomationNode for desktop is loaded');
this.printNode_(this.node_);
}.bind(this));
-
- document.addEventListener(
- 'prefsUpdate', this.handlePrefsUpdate_.bind(this));
},
/**
- * Set this.node_ to the next/previous interesting node. If no interesting
- * node is found, set this.node_ to the first/last interesting node. If
- * |doNext| is true, will search for next node. Otherwise, will search for
- * previous node.
+ * Set this.node_ to the next/previous interesting node, and then highlight
+ * it on the screen. If no interesting node is found, set this.node_ to the
+ * first/last interesting node. If |doNext| is true, will search for next
+ * node. Otherwise, will search for previous node.
*
* @param {boolean} doNext
- * @override
*/
moveToNode: function(doNext) {
let node = this.treeWalker_.moveToNode(this.node_, this.root_, doNext);
@@ -100,8 +70,6 @@ SwitchAccess.prototype = {
/**
* Perform the default action on the currently selected node.
- *
- * @override
*/
doDefault: function() {
if (!this.node_)
@@ -110,46 +78,6 @@ SwitchAccess.prototype = {
this.node_.doDefault();
},
- /**
- * Open the options page in a new tab.
- *
- * @override
- */
- showOptionsPage: function() {
- let optionsPage = {url: 'options.html'};
- chrome.tabs.create(optionsPage);
- },
-
- /**
- * Perform actions as the result of actions by the user. Currently, restarts
- * auto-scan if it is enabled.
- *
- * @override
- */
- performedUserAction: function() {
- this.autoScanManager_.restartIfRunning();
- },
-
- /**
- * Handle a change in user preferences.
- *
- * @param {!Event} event
- * @private
- */
- handlePrefsUpdate_: function(event) {
- let updatedPrefs = event.detail;
- for (let key of Object.keys(updatedPrefs)) {
- switch (key) {
- case 'enableAutoScan':
- this.autoScanManager_.setEnabled(updatedPrefs[key]);
- break;
- case 'autoScanTime':
- this.autoScanManager_.setScanTime(updatedPrefs[key]);
- break;
- }
- }
- },
-
// TODO(elichtenberg): Move print functions to a custom logger class. Only
// log when debuggingEnabled is true.
/**
@@ -181,8 +109,6 @@ SwitchAccess.prototype = {
/**
* Move to the next sibling of this.node_ if it has one.
- *
- * @override
*/
debugMoveToNext: function() {
let next = this.treeWalker_.debugMoveToNext(this.node_);
@@ -195,8 +121,6 @@ SwitchAccess.prototype = {
/**
* Move to the previous sibling of this.node_ if it has one.
- *
- * @override
*/
debugMoveToPrevious: function() {
let prev = this.treeWalker_.debugMoveToPrevious(this.node_);
@@ -209,8 +133,6 @@ SwitchAccess.prototype = {
/**
* Move to the first child of this.node_ if it has one.
- *
- * @override
*/
debugMoveToFirstChild: function() {
let child = this.treeWalker_.debugMoveToFirstChild(this.node_);
@@ -223,8 +145,6 @@ SwitchAccess.prototype = {
/**
* Move to the parent of this.node_ if it has one.
- *
- * @override
*/
debugMoveToParent: function() {
let parent = this.treeWalker_.debugMoveToParent(this.node_);

Powered by Google App Engine
This is Rietveld 408576698