| 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 /** | 5 /** |
| 6 * @fileoverview 'settings-manage-input-methods-page' is a sub-page for enabling | 6 * @fileoverview 'settings-manage-input-methods-page' is a sub-page for enabling |
| 7 * and disabling input methods. Input methods are grouped by base languages to | 7 * and disabling input methods. Input methods are grouped by base languages to |
| 8 * avoid showing duplicate or ambiguous input methods. | 8 * avoid showing duplicate or ambiguous input methods. |
| 9 * | 9 * |
| 10 * @group Chrome Settings Elements | 10 * @group Chrome Settings Elements |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * List of enabled languages with the input methods to show. | 27 * List of enabled languages with the input methods to show. |
| 28 * @private {!Array< | 28 * @private {!Array< |
| 29 * !{language: !chrome.languageSettingsPrivate.Language, | 29 * !{language: !chrome.languageSettingsPrivate.Language, |
| 30 * inputMethods: !Array<!chrome.languageSettingsPrivate.InputMethod> | 30 * inputMethods: !Array<!chrome.languageSettingsPrivate.InputMethod> |
| 31 * }>} | 31 * }>} |
| 32 */ | 32 */ |
| 33 languageList_: { | 33 languageList_: { |
| 34 type: Array, | 34 type: Array, |
| 35 value: function() { return []; }, | 35 value: function() { |
| 36 return []; |
| 37 }, |
| 36 }, | 38 }, |
| 37 }, | 39 }, |
| 38 | 40 |
| 39 observers: [ | 41 observers: [ |
| 40 'availableInputMethodsChanged_(languages.enabled.*,' + | 42 'availableInputMethodsChanged_(languages.enabled.*,' + |
| 41 'languages.inputMethods.supported.*)', | 43 'languages.inputMethods.supported.*)', |
| 42 'enabledInputMethodsChanged_(languages.inputMethods.enabled.*)', | 44 'enabledInputMethodsChanged_(languages.inputMethods.enabled.*)', |
| 43 ], | 45 ], |
| 44 | 46 |
| 45 /** @private */ | 47 /** @private */ |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 * @param {!Array<string>} languageCodes | 159 * @param {!Array<string>} languageCodes |
| 158 * @return {!Array<!chrome.languageSettingsPrivate.InputMethod>} | 160 * @return {!Array<!chrome.languageSettingsPrivate.InputMethod>} |
| 159 * @private | 161 * @private |
| 160 */ | 162 */ |
| 161 getInputMethodsForLanguages: function(languageCodes) { | 163 getInputMethodsForLanguages: function(languageCodes) { |
| 162 // Input methods that have already been listed for this language. | 164 // Input methods that have already been listed for this language. |
| 163 var /** !Set<string> */ usedInputMethods = new Set(); | 165 var /** !Set<string> */ usedInputMethods = new Set(); |
| 164 /** @type {!Array<chrome.languageSettingsPrivate.InputMethod>} */ | 166 /** @type {!Array<chrome.languageSettingsPrivate.InputMethod>} */ |
| 165 var combinedInputMethods = []; | 167 var combinedInputMethods = []; |
| 166 for (var i = 0; i < languageCodes.length; i++) { | 168 for (var i = 0; i < languageCodes.length; i++) { |
| 167 var inputMethods = this.languageHelper.getInputMethodsForLanguage( | 169 var inputMethods = |
| 168 languageCodes[i]); | 170 this.languageHelper.getInputMethodsForLanguage(languageCodes[i]); |
| 169 // Get the language's unused input methods and mark them as used. | 171 // Get the language's unused input methods and mark them as used. |
| 170 var newInputMethods = inputMethods.filter(function(inputMethod) { | 172 var newInputMethods = inputMethods.filter(function(inputMethod) { |
| 171 if (usedInputMethods.has(inputMethod.id)) | 173 if (usedInputMethods.has(inputMethod.id)) |
| 172 return false; | 174 return false; |
| 173 usedInputMethods.add(inputMethod.id); | 175 usedInputMethods.add(inputMethod.id); |
| 174 return true; | 176 return true; |
| 175 }); | 177 }); |
| 176 [].push.apply(combinedInputMethods, newInputMethods); | 178 [].push.apply(combinedInputMethods, newInputMethods); |
| 177 } | 179 } |
| 178 return combinedInputMethods; | 180 return combinedInputMethods; |
| 179 }, | 181 }, |
| 180 | 182 |
| 181 // TODO(Polymer/polymer#3603): We have to notify Polymer of properties that | 183 // TODO(Polymer/polymer#3603): We have to notify Polymer of properties that |
| 182 // may have changed on nested objects, even when the outer property itself | 184 // may have changed on nested objects, even when the outer property itself |
| 183 // is set to a new array. | 185 // is set to a new array. |
| 184 // TODO(michaelpg): Test this behavior. | 186 // TODO(michaelpg): Test this behavior. |
| 185 /** @private */ | 187 /** @private */ |
| 186 notifyInputMethodsChanged_: function() { | 188 notifyInputMethodsChanged_: function() { |
| 187 for (var i = 0; i < this.languageList_.length; i++) { | 189 for (var i = 0; i < this.languageList_.length; i++) { |
| 188 for (var j = 0; j < this.languageList_[i].inputMethods.length; j++) { | 190 for (var j = 0; j < this.languageList_[i].inputMethods.length; j++) { |
| 189 this.notifyPath( | 191 this.notifyPath( |
| 190 'languageList_.' + i + '.inputMethods.' + j + '.enabled', | 192 'languageList_.' + i + '.inputMethods.' + j + '.enabled', |
| 191 this.languageList_[i].inputMethods[j].enabled); | 193 this.languageList_[i].inputMethods[j].enabled); |
| 192 } | 194 } |
| 193 } | 195 } |
| 194 }, | 196 }, |
| 195 }); | 197 }); |
| OLD | NEW |