Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 cr.define('extensions', function() { | 5 cr.define('extensions', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 // The UI to display and manage keyboard shortcuts set for extension commands. | 8 // The UI to display and manage keyboard shortcuts set for extension commands. |
| 9 var KeyboardShortcuts = Polymer({ | 9 var KeyboardShortcuts = Polymer({ |
| 10 is: 'extensions-keyboard-shortcuts', | 10 is: 'extensions-keyboard-shortcuts', |
| 11 | 11 |
| 12 behaviors: [Polymer.NeonAnimatableBehavior], | 12 behaviors: [Polymer.NeonAnimatableBehavior, I18nBehavior], |
| 13 | 13 |
| 14 properties: { | 14 properties: { |
| 15 /** @type {Array<!chrome.developerPrivate.ExtensionInfo>} */ | 15 /** @type {Array<!chrome.developerPrivate.ExtensionInfo>} */ |
| 16 items: Array, | 16 items: Array, |
| 17 }, | 17 }, |
| 18 | 18 |
| 19 /** @private {Array<Object>} */ | |
|
dpapad
2017/06/15 01:35:37
Can this be !Array<!Object> ?
scottchen
2017/06/15 23:50:51
This property is removed in the newest patch.
| |
| 20 scopes_: [], | |
| 21 | |
| 19 ready: function() { | 22 ready: function() { |
| 20 /** @type {!extensions.AnimationHelper} */ | 23 /** @type {!extensions.AnimationHelper} */ |
| 21 this.animationHelper = new extensions.AnimationHelper(this, this.$.main); | 24 this.animationHelper = new extensions.AnimationHelper(this, this.$.main); |
| 22 this.animationHelper.setEntryAnimations([extensions.Animation.FADE_IN]); | 25 this.animationHelper.setEntryAnimations([extensions.Animation.FADE_IN]); |
| 23 this.animationHelper.setExitAnimations([extensions.Animation.SCALE_DOWN]); | 26 this.animationHelper.setExitAnimations([extensions.Animation.SCALE_DOWN]); |
| 24 this.sharedElements = {hero: this.$.main}; | 27 this.sharedElements = {hero: this.$.main}; |
| 28 | |
| 29 // Preparing the options to be used easily by the html template. | |
| 30 this.scopes_ = [ | |
| 31 { | |
| 32 value: chrome.developerPrivate.CommandScope.CHROME, | |
| 33 label: this.i18n('shortcutScopeInChrome') | |
| 34 }, | |
| 35 { | |
| 36 value: chrome.developerPrivate.CommandScope.GLOBAL, | |
| 37 label: this.i18n('shortcutScopeGlobal') | |
| 38 }, | |
| 39 ]; | |
| 25 }, | 40 }, |
| 26 | 41 |
| 27 /** | 42 /** |
| 28 * @return {!Array<!chrome.developerPrivate.ExtensionInfo>} | 43 * @return {!Array<!chrome.developerPrivate.ExtensionInfo>} |
| 29 * @private | 44 * @private |
| 30 */ | 45 */ |
| 31 calculateShownItems_: function() { | 46 calculateShownItems_: function() { |
| 32 return this.items.filter(function(item) { | 47 return this.items.filter(function(item) { |
| 33 return item.commands.length > 0; | 48 return item.commands.length > 0; |
| 34 }); | 49 }); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 50 * Determines whether to disable the dropdown menu for the command's scope. | 65 * Determines whether to disable the dropdown menu for the command's scope. |
| 51 * @param {!chrome.developerPrivate.Command} command | 66 * @param {!chrome.developerPrivate.Command} command |
| 52 * @return {boolean} | 67 * @return {boolean} |
| 53 * @private | 68 * @private |
| 54 */ | 69 */ |
| 55 computeScopeDisabled_: function(command) { | 70 computeScopeDisabled_: function(command) { |
| 56 return command.isExtensionAction || !command.isActive; | 71 return command.isExtensionAction || !command.isActive; |
| 57 }, | 72 }, |
| 58 | 73 |
| 59 /** | 74 /** |
| 60 * Returns the scope index in the dropdown menu for the command's scope. | 75 * Helper to check if an option's scope value equals current command scope. |
| 61 * @param {chrome.developerPrivate.Command} command | 76 * @param {!string} commandScope the current command's scope value |
|
dpapad
2017/06/15 01:35:37
"!" not necessary with strings.
scottchen
2017/06/15 23:50:51
Acknowledged, though this function is removed in t
| |
| 62 * @return {number} | 77 * @param {!string} optionScopeValue scope value of options checked against |
| 78 * @return {boolean} | |
| 63 * @private | 79 * @private |
| 64 */ | 80 */ |
| 65 computeSelectedScope_: function(command) { | 81 isScopeEqual_: function(commandScope, optionScopeValue) { |
| 66 // These numbers match the indexes in the dropdown menu in the html. | 82 return commandScope == optionScopeValue; |
| 67 switch (command.scope) { | |
| 68 case chrome.developerPrivate.CommandScope.CHROME: | |
| 69 return 0; | |
| 70 case chrome.developerPrivate.CommandScope.GLOBAL: | |
| 71 return 1; | |
| 72 } | |
| 73 assertNotReached(); | |
| 74 }, | 83 }, |
| 75 | 84 |
| 76 /** @private */ | 85 /** @private */ |
| 77 onCloseButtonClick_: function() { | 86 onCloseButtonClick_: function() { |
| 78 this.fire('close'); | 87 this.fire('close'); |
| 79 }, | 88 }, |
| 89 | |
| 90 /** @private */ | |
| 91 onScopeChanged_: function(e) { | |
| 92 e.model.set('command.scope', e.target.value); | |
| 93 }, | |
| 80 }); | 94 }); |
| 81 | 95 |
| 82 return {KeyboardShortcuts: KeyboardShortcuts}; | 96 return {KeyboardShortcuts: KeyboardShortcuts}; |
| 83 }); | 97 }); |
| OLD | NEW |