| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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-languages' provides convenient access to | 6 * @fileoverview 'settings-languages' provides convenient access to |
| 7 * Chrome's language and input method settings. | 7 * Chrome's language and input method settings. |
| 8 * | 8 * |
| 9 * Instances of this element have a 'languages' property, which reflects the | 9 * Instances of this element have a 'languages' property, which reflects the |
| 10 * current language settings. The 'languages' property is read-only, meaning | 10 * current language settings. The 'languages' property is read-only, meaning |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 disableLanguage: function(languageCode) { | 481 disableLanguage: function(languageCode) { |
| 482 if (!CrSettingsPrefs.isInitialized) | 482 if (!CrSettingsPrefs.isInitialized) |
| 483 return; | 483 return; |
| 484 | 484 |
| 485 assert(this.canDisableLanguage(languageCode)); | 485 assert(this.canDisableLanguage(languageCode)); |
| 486 | 486 |
| 487 // Remove the language from spell check. | 487 // Remove the language from spell check. |
| 488 this.deletePrefListItem('spellcheck.dictionaries', languageCode); | 488 this.deletePrefListItem('spellcheck.dictionaries', languageCode); |
| 489 | 489 |
| 490 if (cr.isChromeOS) { | 490 if (cr.isChromeOS) { |
| 491 // Remove input methods that don't support any other enabled language. |
| 491 var inputMethods = this.languageInputMethods_.get(languageCode) || []; | 492 var inputMethods = this.languageInputMethods_.get(languageCode) || []; |
| 492 for (var inputMethod of inputMethods) { | 493 for (var inputMethod of inputMethods) { |
| 493 var supportsOtherEnabledLanguages = inputMethod.languageCodes.some( | 494 var supportsOtherEnabledLanguages = inputMethod.languageCodes.some( |
| 494 function(inputMethodLanguageCode) { | 495 function(otherLanguageCode) { |
| 495 return inputMethodLanguageCode != languageCode && | 496 return otherLanguageCode != languageCode && |
| 496 this.isLanguageEnabled(languageCode); | 497 this.isLanguageEnabled(otherLanguageCode); |
| 497 }.bind(this)); | 498 }.bind(this)); |
| 498 if (!supportsOtherEnabledLanguages) | 499 if (!supportsOtherEnabledLanguages) |
| 499 this.removeInputMethod(inputMethod.id); | 500 this.removeInputMethod(inputMethod.id); |
| 500 } | 501 } |
| 501 } | 502 } |
| 502 | 503 |
| 503 // Remove the language from preferred languages. | 504 // Remove the language from preferred languages. |
| 504 var languageCodes = | 505 var languageCodes = |
| 505 this.getPref(preferredLanguagesPrefName).value.split(','); | 506 this.getPref(preferredLanguagesPrefName).value.split(','); |
| 506 var languageIndex = languageCodes.indexOf(languageCode); | 507 var languageIndex = languageCodes.indexOf(languageCode); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 * manually sending a change notification for our 'languages' property (since | 773 * manually sending a change notification for our 'languages' property (since |
| 773 * it's the same object as the singleton's property, but isn't bound by | 774 * it's the same object as the singleton's property, but isn't bound by |
| 774 * Polymer). | 775 * Polymer). |
| 775 * @private | 776 * @private |
| 776 */ | 777 */ |
| 777 singletonLanguagesChanged_: function(e) { | 778 singletonLanguagesChanged_: function(e) { |
| 778 // Forward the change notification to the host. | 779 // Forward the change notification to the host. |
| 779 this.fire(e.type, e.detail, {bubbles: false}); | 780 this.fire(e.type, e.detail, {bubbles: false}); |
| 780 }, | 781 }, |
| 781 }); | 782 }); |
| OLD | NEW |