| OLD | NEW |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 SwitchAccess.prototype = { | 46 SwitchAccess.prototype = { |
| 47 /** | 47 /** |
| 48 * Set up preferences, controllers, and event listeners. | 48 * Set up preferences, controllers, and event listeners. |
| 49 * | 49 * |
| 50 * @private | 50 * @private |
| 51 */ | 51 */ |
| 52 init_: function() { | 52 init_: function() { |
| 53 this.switchAccessPrefs = new SwitchAccessPrefs(); | 53 this.switchAccessPrefs = new SwitchAccessPrefs(); |
| 54 this.autoScanManager_ = new AutoScanManager(this); | 54 this.autoScanManager_ = new AutoScanManager(this); |
| 55 this.keyboardHandler_ = new KeyboardHandler(this); | 55 this.keyboardHandler_ = new KeyboardHandler(this); |
| 56 this.automationManager_ = new AutomationManager(); | 56 |
| 57 chrome.automation.getDesktop(function(desktop) { |
| 58 this.automationManager_ = new AutomationManager(desktop); |
| 59 }.bind(this)); |
| 57 | 60 |
| 58 document.addEventListener( | 61 document.addEventListener( |
| 59 'prefsUpdate', this.handlePrefsUpdate_.bind(this)); | 62 'prefsUpdate', this.handlePrefsUpdate_.bind(this)); |
| 60 }, | 63 }, |
| 61 | 64 |
| 62 /** | 65 /** |
| 63 * Move to the next/previous interesting node. If |doNext| is true, move to | 66 * Move to the next/previous interesting node. If |doNext| is true, move to |
| 64 * the next node. Otherwise, move to the previous node. | 67 * the next node. Otherwise, move to the previous node. |
| 65 * | 68 * |
| 66 * @param {boolean} doNext | 69 * @param {boolean} doNext |
| 67 * @override | 70 * @override |
| 68 */ | 71 */ |
| 69 moveToNode: function(doNext) { | 72 moveToNode: function(doNext) { |
| 70 this.automationManager_.moveToNode(doNext); | 73 if (this.automationManager_) |
| 74 this.automationManager_.moveToNode(doNext); |
| 71 }, | 75 }, |
| 72 | 76 |
| 73 /** | 77 /** |
| 74 * Perform the default action on the current node. | 78 * Perform the default action on the current node. |
| 75 * | 79 * |
| 76 * @override | 80 * @override |
| 77 */ | 81 */ |
| 78 selectCurrentNode: function() { | 82 selectCurrentNode: function() { |
| 79 this.automationManager_.selectCurrentNode(); | 83 if (this.automationManager_) |
| 84 this.automationManager_.selectCurrentNode(); |
| 80 }, | 85 }, |
| 81 | 86 |
| 82 /** | 87 /** |
| 83 * Open the options page in a new tab. | 88 * Open the options page in a new tab. |
| 84 * | 89 * |
| 85 * @override | 90 * @override |
| 86 */ | 91 */ |
| 87 showOptionsPage: function() { | 92 showOptionsPage: function() { |
| 88 let optionsPage = {url: 'options.html'}; | 93 let optionsPage = {url: 'options.html'}; |
| 89 chrome.tabs.create(optionsPage); | 94 chrome.tabs.create(optionsPage); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 118 } | 123 } |
| 119 } | 124 } |
| 120 }, | 125 }, |
| 121 | 126 |
| 122 /** | 127 /** |
| 123 * Move to the next sibling of the current node if it has one. | 128 * Move to the next sibling of the current node if it has one. |
| 124 * | 129 * |
| 125 * @override | 130 * @override |
| 126 */ | 131 */ |
| 127 debugMoveToNext: function() { | 132 debugMoveToNext: function() { |
| 128 this.automationManager_.debugMoveToNext(); | 133 if (this.automationManager_) |
| 134 this.automationManager_.debugMoveToNext(); |
| 129 }, | 135 }, |
| 130 | 136 |
| 131 /** | 137 /** |
| 132 * Move to the previous sibling of the current node if it has one. | 138 * Move to the previous sibling of the current node if it has one. |
| 133 * | 139 * |
| 134 * @override | 140 * @override |
| 135 */ | 141 */ |
| 136 debugMoveToPrevious: function() { | 142 debugMoveToPrevious: function() { |
| 137 this.automationManager_.debugMoveToPrevious(); | 143 if (this.automationManager_) |
| 144 this.automationManager_.debugMoveToPrevious(); |
| 138 }, | 145 }, |
| 139 | 146 |
| 140 /** | 147 /** |
| 141 * Move to the first child of the current node if it has one. | 148 * Move to the first child of the current node if it has one. |
| 142 * | 149 * |
| 143 * @override | 150 * @override |
| 144 */ | 151 */ |
| 145 debugMoveToFirstChild: function() { | 152 debugMoveToFirstChild: function() { |
| 146 this.automationManager_.debugMoveToFirstChild(); | 153 if (this.automationManager_) |
| 154 this.automationManager_.debugMoveToFirstChild(); |
| 147 }, | 155 }, |
| 148 | 156 |
| 149 /** | 157 /** |
| 150 * Move to the parent of the current node if it has one. | 158 * Move to the parent of the current node if it has one. |
| 151 * | 159 * |
| 152 * @override | 160 * @override |
| 153 */ | 161 */ |
| 154 debugMoveToParent: function() { | 162 debugMoveToParent: function() { |
| 155 this.automationManager_.debugMoveToParent(); | 163 if (this.automationManager_) |
| 164 this.automationManager_.debugMoveToParent(); |
| 156 } | 165 } |
| 157 }; | 166 }; |
| OLD | NEW |