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

Unified Diff: chrome/browser/resources/chromeos/switch_access/switch_access.js

Issue 2939133004: Added to options page to let users change keyboard mappings. (Closed)
Patch Set: Fixed merge conflict and formatting error Created 3 years, 6 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/switch_access.js
diff --git a/chrome/browser/resources/chromeos/switch_access/switch_access.js b/chrome/browser/resources/chromeos/switch_access/switch_access.js
index eccde6e55f52e950a17664d416647383d876f95d..c32af336563ed1f2862e2acfc27f706fdc027bb1 100644
--- a/chrome/browser/resources/chromeos/switch_access/switch_access.js
+++ b/chrome/browser/resources/chromeos/switch_access/switch_access.js
@@ -11,12 +11,19 @@
function SwitchAccess() {
console.log('Switch access is enabled');
+ /**
+ * User commands.
+ *
+ * @private {Commands}
+ */
+ this.commands_ = null;
+
/**
* User preferences.
*
- * @type {SwitchAccessPrefs}
+ * @private {SwitchAccessPrefs}
*/
- this.switchAccessPrefs = null;
+ this.switchAccessPrefs_ = null;
/**
* Handles changes to auto-scan.
@@ -50,7 +57,8 @@ SwitchAccess.prototype = {
* @private
*/
init_: function() {
- this.switchAccessPrefs = new SwitchAccessPrefs();
+ this.commands_ = new Commands(this);
+ this.switchAccessPrefs_ = new SwitchAccessPrefs(this);
this.autoScanManager_ = new AutoScanManager(this);
this.keyboardHandler_ = new KeyboardHandler(this);
@@ -94,6 +102,37 @@ SwitchAccess.prototype = {
chrome.tabs.create(optionsPage);
},
+ /**
+ * Return a list of the names of all user commands.
+ *
+ * @override
+ * @return {!Array<string>}
+ */
+ getCommands: function() {
+ return this.commands_.getCommands();
+ },
+
+ /**
+ * Return the default key code for a command.
+ *
+ * @override
+ * @param {string} command
+ * @return {number}
+ */
+ getDefaultKeyCodeFor: function(command) {
+ return this.commands_.getDefaultKeyCodeFor(command);
+ },
+
+ /**
+ * Run the function binding for the specified command.
+ *
+ * @override
+ * @param {string} command
+ */
+ runCommand: function(command) {
+ this.commands_.runCommand(command);
+ },
+
/**
* Perform actions as the result of actions by the user. Currently, restarts
* auto-scan if it is enabled.
@@ -120,10 +159,73 @@ SwitchAccess.prototype = {
case 'autoScanTime':
this.autoScanManager_.setScanTime(updatedPrefs[key]);
break;
+ default:
+ if (this.commands_.getCommands().includes(key))
+ this.keyboardHandler_.updateSwitchAccessKeys();
}
}
},
+ /**
+ * Set the value of the preference |key| to |value| in chrome.storage.sync.
+ * this.prefs_ is not set until handleStorageChange_.
+ *
+ * @override
+ * @param {string} key
+ * @param {boolean|string|number} value
+ */
+ setPref: function(key, value) {
+ this.switchAccessPrefs_.setPref(key, value);
+ },
+
+ /**
+ * Get the value of type 'boolean' of the preference |key|. Will throw a type
+ * error if the value of |key| is not 'boolean'.
+ *
+ * @override
+ * @param {string} key
+ * @return {boolean}
+ */
+ getBooleanPref: function(key) {
+ return this.switchAccessPrefs_.getBooleanPref(key);
+ },
+
+ /**
+ * Get the value of type 'number' of the preference |key|. Will throw a type
+ * error if the value of |key| is not 'number'.
+ *
+ * @override
+ * @param {string} key
+ * @return {number}
+ */
+ getNumberPref: function(key) {
+ return this.switchAccessPrefs_.getNumberPref(key);
+ },
+
+ /**
+ * Get the value of type 'string' of the preference |key|. Will throw a type
+ * error if the value of |key| is not 'string'.
+ *
+ * @override
+ * @param {string} key
+ * @return {string}
+ */
+ getStringPref: function(key) {
+ return this.switchAccessPrefs_.getStringPref(key);
+ },
+
+ /**
+ * Returns true if |keyCode| is already used to run a command from the
+ * keyboard.
+ *
+ * @override
+ * @param {number} keyCode
+ * @return {boolean}
+ */
+ keyCodeIsUsed: function(keyCode) {
+ return this.switchAccessPrefs_.keyCodeIsUsed(keyCode);
+ },
+
/**
* Move to the next sibling of the current node if it has one.
*

Powered by Google App Engine
This is Rietveld 408576698