Commit 49168a47 authored by Zach Helfinstein's avatar Zach Helfinstein Committed by Commit Bot

Rename AutomationManager to NavigationManager

Improves the clarity of the codebase, as the AutomationManager's primary
responsibility is to handle navigation around the page.

Bug: None
Change-Id: I897cbab60abdd081a6cb687476c57ff294f9e127
Reviewed-on: https://chromium-review.googlesource.com/c/1294516Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Zach Helfinstein <zhelfins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601793}
parent 0238c6b5
......@@ -31,12 +31,12 @@ run_jsbundler("switch_access_copied_files") {
"../select_to_speak/closure_shim.js",
"//third_party/chromevox/third_party/closure-library/closure/goog/base.js",
"auto_scan_manager.js",
"automation_manager.js",
"background.js",
"commands.js",
"context_menu_manager.js",
"keyboard_handler.js",
"message_handler.js",
"navigation_manager.js",
"options.css",
"options.html",
"options.js",
......@@ -120,12 +120,12 @@ manifest("switch_access_guest_manifest") {
js_type_check("closure_compile") {
deps = [
":auto_scan_manager",
":automation_manager",
":background",
":commands",
":context_menu_manager",
":keyboard_handler",
":message_handler",
":navigation_manager",
":options",
":prefs",
":switch_access_predicate",
......@@ -144,7 +144,7 @@ js_library("auto_scan_manager") {
]
}
js_library("automation_manager") {
js_library("navigation_manager") {
deps = [
":switch_access_predicate",
"../chromevox:constants",
......@@ -203,10 +203,10 @@ js_library("prefs") {
js_library("switch_access") {
deps = [
":auto_scan_manager",
":automation_manager",
":commands",
":keyboard_handler",
":message_handler",
":navigation_manager",
":prefs",
]
externs_list = [
......
......@@ -9,10 +9,10 @@
class ContextMenuManager {
/**
* @param {!AutomationManager} automationManager
* @param {!NavigationManager} navigationManager
* @param {!chrome.automation.AutomationNode} desktop
*/
constructor(automationManager, desktop) {
constructor(navigationManager, desktop) {
/**
* A list of the ContextMenu actions that are currently enabled.
* @private {!Array<ContextMenuManager.Action>}
......@@ -21,9 +21,9 @@ class ContextMenuManager {
/**
* The parent automation manager.
* @private {!AutomationManager}
* @private {!NavigationManager}
*/
this.automationManager_ = automationManager;
this.navigationManager_ = navigationManager;
/**
* The root node of the screen.
......@@ -193,7 +193,7 @@ class ContextMenuManager {
this.exit();
if (event.data === ContextMenuManager.Action.CLICK)
this.automationManager_.selectCurrentNode();
this.navigationManager_.selectCurrentNode();
else if (event.data === ContextMenuManager.Action.DICTATION)
chrome.accessibilityPrivate.toggleDictation();
else if (event.data === ContextMenuManager.Action.OPTIONS)
......@@ -203,7 +203,7 @@ class ContextMenuManager {
event.data === ContextMenuManager.Action.SCROLL_UP ||
event.data === ContextMenuManager.Action.SCROLL_LEFT ||
event.data === ContextMenuManager.Action.SCROLL_RIGHT)
this.automationManager_.scroll(event.data);
this.navigationManager_.scroll(event.data);
}
/**
......
......@@ -6,7 +6,7 @@
* Class to manage interactions with the accessibility tree, including moving
* to and selecting nodes.
*/
class AutomationManager {
class NavigationManager {
/**
* @param {!chrome.automation.AutomationNode} desktop
*/
......@@ -348,7 +348,7 @@ class AutomationManager {
this.node_ = this.scope_;
this.visitingScopeAsActionable_ = true;
this.updateFocusRing_(AutomationManager.Color.LEAF);
this.updateFocusRing_(NavigationManager.Color.LEAF);
}
/**
......@@ -381,17 +381,17 @@ class AutomationManager {
/**
* Set the focus ring for the current node and determine the color for it.
*
* @param {AutomationManager.Color=} opt_color
* @param {NavigationManager.Color=} opt_color
* @private
*/
updateFocusRing_(opt_color) {
let color;
if (this.node_ === this.scope_)
color = AutomationManager.Color.SCOPE;
color = NavigationManager.Color.SCOPE;
else if (SwitchAccessPredicate.isGroup(this.node_, this.scope_))
color = AutomationManager.Color.GROUP;
color = NavigationManager.Color.GROUP;
else
color = AutomationManager.Color.LEAF;
color = NavigationManager.Color.LEAF;
color = opt_color || color;
chrome.accessibilityPrivate.setFocusRing([this.node_.location], color);
......@@ -448,18 +448,18 @@ class AutomationManager {
* To use, got to the console for SwitchAccess and run
* switchAccess.automationManager_.printDebugSwitchAccessTree()
*
* @param {AutomationManager.DisplayMode} opt_displayMode - an optional
* @param {NavigationManager.DisplayMode} opt_displayMode - an optional
* parameter that controls which nodes are printed. Default is
* INTERESTING_NODE.
* @return {SwitchAccessDebugNode|undefined}
*/
printDebugSwitchAccessTree(
opt_displayMode = AutomationManager.DisplayMode.INTERESTING_NODE) {
let allNodes = opt_displayMode === AutomationManager.DisplayMode.ALL;
opt_displayMode = NavigationManager.DisplayMode.INTERESTING_NODE) {
let allNodes = opt_displayMode === NavigationManager.DisplayMode.ALL;
let debugRoot =
AutomationManager.switchAccessDebugTree_(this.desktop_, allNodes);
NavigationManager.switchAccessDebugTree_(this.desktop_, allNodes);
if (debugRoot)
AutomationManager.printDebugNode_(debugRoot, 0, opt_displayMode);
NavigationManager.printDebugNode_(debugRoot, 0, opt_displayMode);
return debugRoot;
}
/**
......@@ -518,7 +518,7 @@ class AutomationManager {
*
* @param {SwitchAccessDebugNode} node
* @param {!number} indent
* @param {AutomationManager.DisplayMode} displayMode
* @param {NavigationManager.DisplayMode} displayMode
* @private
*/
static printDebugNode_(node, indent, displayMode) {
......@@ -535,14 +535,14 @@ class AutomationManager {
result += ', isInterestingSubtree? ' + node.isInterestingSubtree;
switch (displayMode) {
case AutomationManager.DisplayMode.ALL:
case NavigationManager.DisplayMode.ALL:
console.log(result);
break;
case AutomationManager.DisplayMode.INTERESTING_SUBTREE:
case NavigationManager.DisplayMode.INTERESTING_SUBTREE:
if (node.isInterestingSubtree)
console.log(result);
break;
case AutomationManager.DisplayMode.INTERESTING_NODE:
case NavigationManager.DisplayMode.INTERESTING_NODE:
default:
if (node.isActionable || node.isGroup)
console.log(result);
......@@ -562,7 +562,7 @@ class AutomationManager {
* @enum {string}
* @const
*/
AutomationManager.Color = {
NavigationManager.Color = {
SCOPE: '#de742f', // dark orange
GROUP: '#ffbb33', // light orange
LEAF: '#78e428' // light green
......@@ -574,7 +574,7 @@ AutomationManager.Color = {
* @enum {string}
* @const
*/
AutomationManager.DisplayMode = {
NavigationManager.DisplayMode = {
ALL: 'all',
INTERESTING_SUBTREE: 'interestingSubtree',
INTERESTING_NODE: 'interestingNode'
......
......@@ -37,9 +37,9 @@ class SwitchAccess {
/**
* Handles interactions with the accessibility tree, including moving to and
* selecting nodes.
* @private {AutomationManager}
* @private {NavigationManager}
*/
this.automationManager_ = null;
this.navigationManager_ = null;
this.init_();
}
......@@ -55,7 +55,7 @@ class SwitchAccess {
this.keyboardHandler_ = new KeyboardHandler(this);
chrome.automation.getDesktop(function(desktop) {
this.automationManager_ = new AutomationManager(desktop);
this.navigationManager_ = new NavigationManager(desktop);
}.bind(this));
document.addEventListener(
......@@ -67,8 +67,8 @@ class SwitchAccess {
* @override
*/
enterContextMenu() {
if (this.automationManager_)
this.automationManager_.enterContextMenu();
if (this.navigationManager_)
this.navigationManager_.enterContextMenu();
}
/**
......@@ -76,8 +76,8 @@ class SwitchAccess {
* @override
*/
moveForward() {
if (this.automationManager_)
this.automationManager_.moveForward();
if (this.navigationManager_)
this.navigationManager_.moveForward();
}
/**
......@@ -85,8 +85,8 @@ class SwitchAccess {
* @override
*/
moveBackward() {
if (this.automationManager_)
this.automationManager_.moveBackward();
if (this.navigationManager_)
this.navigationManager_.moveBackward();
}
/**
......@@ -94,8 +94,8 @@ class SwitchAccess {
* @override
*/
selectCurrentNode() {
if (this.automationManager_)
this.automationManager_.selectCurrentNode();
if (this.navigationManager_)
this.navigationManager_.selectCurrentNode();
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment