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

Side by Side Diff: chrome/browser/resources/settings/languages_page/manage_input_methods_page.js

Issue 2658723002: MD Settings: Remove some ES6 leftovers from CrOS code that break uglify. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 var displayLanguage = languageState.language; 137 var displayLanguage = languageState.language;
138 if (languageFamilyCodes.length > 1) { 138 if (languageFamilyCodes.length > 1) {
139 var baseLanguage = this.languageHelper.getLanguage(baseLanguageCode); 139 var baseLanguage = this.languageHelper.getLanguage(baseLanguageCode);
140 if (baseLanguage) 140 if (baseLanguage)
141 displayLanguage = baseLanguage; 141 displayLanguage = baseLanguage;
142 } 142 }
143 languageList.push({ 143 languageList.push({
144 language: displayLanguage, 144 language: displayLanguage,
145 inputMethods: combinedInputMethods, 145 inputMethods: combinedInputMethods,
146 }); 146 });
147 for (var languageCode of languageFamilyCodes) 147 for (var k = 0; k < languageFamilyCodes.length; k++)
148 usedLanguages.add(languageCode); 148 usedLanguages.add(languageFamilyCodes[k]);
149 } 149 }
150 150
151 this.languageList_ = languageList; 151 this.languageList_ = languageList;
152 this.notifyInputMethodsChanged_(); 152 this.notifyInputMethodsChanged_();
153 }, 153 },
154 154
155 /** 155 /**
156 * Returns the input methods that support any of the given languages. 156 * Returns the input methods that support any of the given languages.
157 * @param {!Array<string>} languageCodes 157 * @param {!Array<string>} languageCodes
158 * @return {!Array<!chrome.languageSettingsPrivate.InputMethod>} 158 * @return {!Array<!chrome.languageSettingsPrivate.InputMethod>}
159 * @private 159 * @private
160 */ 160 */
161 getInputMethodsForLanguages: function(languageCodes) { 161 getInputMethodsForLanguages: function(languageCodes) {
162 // Input methods that have already been listed for this language. 162 // Input methods that have already been listed for this language.
163 var /** !Set<string> */ usedInputMethods = new Set(); 163 var /** !Set<string> */ usedInputMethods = new Set();
164 /** @type {!Array<chrome.languageSettingsPrivate.InputMethod>} */ 164 /** @type {!Array<chrome.languageSettingsPrivate.InputMethod>} */
165 var combinedInputMethods = []; 165 var combinedInputMethods = [];
166 for (var languageCode of languageCodes) { 166 for (var i = 0; i < languageCodes.length; i++) {
167 var inputMethods = this.languageHelper.getInputMethodsForLanguage( 167 var inputMethods = this.languageHelper.getInputMethodsForLanguage(
168 languageCode); 168 languageCodes[i]);
169 // Get the language's unused input methods and mark them as used. 169 // Get the language's unused input methods and mark them as used.
170 var newInputMethods = inputMethods.filter(function(inputMethod) { 170 var newInputMethods = inputMethods.filter(function(inputMethod) {
171 if (usedInputMethods.has(inputMethod.id)) 171 if (usedInputMethods.has(inputMethod.id))
172 return false; 172 return false;
173 usedInputMethods.add(inputMethod.id); 173 usedInputMethods.add(inputMethod.id);
174 return true; 174 return true;
175 }); 175 });
176 [].push.apply(combinedInputMethods, newInputMethods); 176 [].push.apply(combinedInputMethods, newInputMethods);
177 } 177 }
178 return combinedInputMethods; 178 return combinedInputMethods;
179 }, 179 },
180 180
181 // TODO(Polymer/polymer#3603): We have to notify Polymer of properties that 181 // 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 182 // may have changed on nested objects, even when the outer property itself
183 // is set to a new array. 183 // is set to a new array.
184 // TODO(michaelpg): Test this behavior. 184 // TODO(michaelpg): Test this behavior.
185 /** @private */ 185 /** @private */
186 notifyInputMethodsChanged_: function() { 186 notifyInputMethodsChanged_: function() {
187 for (var i = 0; i < this.languageList_.length; i++) { 187 for (var i = 0; i < this.languageList_.length; i++) {
188 for (var j = 0; j < this.languageList_[i].inputMethods.length; j++) { 188 for (var j = 0; j < this.languageList_[i].inputMethods.length; j++) {
189 this.notifyPath( 189 this.notifyPath(
190 'languageList_.' + i + '.inputMethods.' + j + '.enabled', 190 'languageList_.' + i + '.inputMethods.' + j + '.enabled',
191 this.languageList_[i].inputMethods[j].enabled); 191 this.languageList_[i].inputMethods[j].enabled);
192 } 192 }
193 } 193 }
194 }, 194 },
195 }); 195 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698