| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 6 /** |
| 7 * @fileoverview This class acts as the persistent store for all static data | 7 * @fileoverview This class acts as the persistent store for all static data |
| 8 * about commands. | 8 * about commands. |
| 9 * | 9 * |
| 10 * This store can safely be used within either a content or background script | 10 * This store can safely be used within either a content or background script |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 */ | 31 */ |
| 32 | 32 |
| 33 | 33 |
| 34 goog.provide('cvox.CommandStore'); | 34 goog.provide('cvox.CommandStore'); |
| 35 | 35 |
| 36 goog.require('cvox.PlatformFilter'); | 36 goog.require('cvox.PlatformFilter'); |
| 37 | 37 |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Returns all of the categories in the store as an array. | 40 * Returns all of the categories in the store as an array. |
| 41 * @return {Array.<string>} The collection of categories. | 41 * @return {Array<string>} The collection of categories. |
| 42 */ | 42 */ |
| 43 cvox.CommandStore.categories = function() { | 43 cvox.CommandStore.categories = function() { |
| 44 var categorySet = {}; | 44 var categorySet = {}; |
| 45 for (var cmd in cvox.CommandStore.CMD_WHITELIST) { | 45 for (var cmd in cvox.CommandStore.CMD_WHITELIST) { |
| 46 var struct = cvox.CommandStore.CMD_WHITELIST[cmd]; | 46 var struct = cvox.CommandStore.CMD_WHITELIST[cmd]; |
| 47 if (struct.category) { | 47 if (struct.category) { |
| 48 categorySet[struct.category] = true; | 48 categorySet[struct.category] = true; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 var ret = []; | 51 var ret = []; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 72 * @return {string|undefined} The command, if any. | 72 * @return {string|undefined} The command, if any. |
| 73 */ | 73 */ |
| 74 cvox.CommandStore.categoryForCommand = function(command) { | 74 cvox.CommandStore.categoryForCommand = function(command) { |
| 75 return (cvox.CommandStore.CMD_WHITELIST[command] || {}).category; | 75 return (cvox.CommandStore.CMD_WHITELIST[command] || {}).category; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * Gets all commands for a category. | 80 * Gets all commands for a category. |
| 81 * @param {string} category The category to query. | 81 * @param {string} category The category to query. |
| 82 * @return {Array.<string>} The commands, if any. | 82 * @return {Array<string>} The commands, if any. |
| 83 */ | 83 */ |
| 84 cvox.CommandStore.commandsForCategory = function(category) { | 84 cvox.CommandStore.commandsForCategory = function(category) { |
| 85 var ret = []; | 85 var ret = []; |
| 86 for (var cmd in cvox.CommandStore.CMD_WHITELIST) { | 86 for (var cmd in cvox.CommandStore.CMD_WHITELIST) { |
| 87 var struct = cvox.CommandStore.CMD_WHITELIST[cmd]; | 87 var struct = cvox.CommandStore.CMD_WHITELIST[cmd]; |
| 88 if (category == struct.category) { | 88 if (category == struct.category) { |
| 89 ret.push(cmd); | 89 ret.push(cmd); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 return ret; | 92 return ret; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * List of commands and their properties | 97 * List of commands and their properties |
| 98 * @type {Object.<string, {forward: (undefined|boolean), | 98 * @type {Object<string, {forward: (undefined|boolean), |
| 99 * backward: (undefined|boolean), | 99 * backward: (undefined|boolean), |
| 100 * announce: boolean, | 100 * announce: boolean, |
| 101 * category: (undefined|string), | 101 * category: (undefined|string), |
| 102 * findNext: (undefined|string), | 102 * findNext: (undefined|string), |
| 103 * doDefault: (undefined|boolean), | 103 * doDefault: (undefined|boolean), |
| 104 * msgId: (undefined|string), | 104 * msgId: (undefined|string), |
| 105 * nodeList: (undefined|string), | 105 * nodeList: (undefined|string), |
| 106 * platformFilter: (undefined|cvox.PlatformFilter), | 106 * platformFilter: (undefined|cvox.PlatformFilter), |
| 107 * skipInput: (undefined|boolean), | 107 * skipInput: (undefined|boolean), |
| 108 * allowEvents: (undefined|boolean), | 108 * allowEvents: (undefined|boolean), |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 'autorunner': {announce: false}, | 671 'autorunner': {announce: false}, |
| 672 | 672 |
| 673 'debug': {announce: false}, | 673 'debug': {announce: false}, |
| 674 | 674 |
| 675 'nop': {announce: false} | 675 'nop': {announce: false} |
| 676 }; | 676 }; |
| 677 | 677 |
| 678 | 678 |
| 679 /** | 679 /** |
| 680 * List of find next commands and their associated data. | 680 * List of find next commands and their associated data. |
| 681 * @type {Object.<string, {predicate: string, | 681 * @type {Object<string, {predicate: string, |
| 682 * forwardError: string, | 682 * forwardError: string, |
| 683 * backwardError: string}>} | 683 * backwardError: string}>} |
| 684 * predicate: The name of the predicate. This must be defined in DomPredicates. | 684 * predicate: The name of the predicate. This must be defined in DomPredicates. |
| 685 * forwardError: The message id of the error string when moving forward. | 685 * forwardError: The message id of the error string when moving forward. |
| 686 * backwardError: The message id of the error string when moving backward. | 686 * backwardError: The message id of the error string when moving backward. |
| 687 */ | 687 */ |
| 688 cvox.CommandStore.NODE_INFO_MAP = { | 688 cvox.CommandStore.NODE_INFO_MAP = { |
| 689 'checkbox': {predicate: 'checkboxPredicate', | 689 'checkbox': {predicate: 'checkboxPredicate', |
| 690 forwardError: 'no_next_checkbox', | 690 forwardError: 'no_next_checkbox', |
| 691 backwardError: 'no_previous_checkbox', | 691 backwardError: 'no_previous_checkbox', |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 'media': {predicate: 'mediaPredicate', | 776 'media': {predicate: 'mediaPredicate', |
| 777 forwardError: 'no_next_media_widget', | 777 forwardError: 'no_next_media_widget', |
| 778 backwardError: 'no_previous_media_widget'}, | 778 backwardError: 'no_previous_media_widget'}, |
| 779 'section': {predicate: 'sectionPredicate', | 779 'section': {predicate: 'sectionPredicate', |
| 780 forwardError: 'no_next_section', | 780 forwardError: 'no_next_section', |
| 781 backwardError: 'no_previous_section'}, | 781 backwardError: 'no_previous_section'}, |
| 782 'control': {predicate: 'controlPredicate', | 782 'control': {predicate: 'controlPredicate', |
| 783 forwardError: 'no_next_control', | 783 forwardError: 'no_next_control', |
| 784 backwardError: 'no_previous_control'} | 784 backwardError: 'no_previous_control'} |
| 785 }; | 785 }; |
| OLD | NEW |