OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // TODO(kochi): Generalize the notification as a component and put it | 5 // TODO(kochi): Generalize the notification as a component and put it |
6 // in js/cr/ui/notification.js . | 6 // in js/cr/ui/notification.js . |
7 | 7 |
8 cr.define('options', function() { | 8 cr.define('options', function() { |
9 /** @const */ var Page = cr.ui.pageManager.Page; | 9 /** @const */ var Page = cr.ui.pageManager.Page; |
10 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 10 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 var ENABLED_EXTENSION_IME_PREF = 'settings.language.enabled_extension_imes'; | 45 var ENABLED_EXTENSION_IME_PREF = 'settings.language.enabled_extension_imes'; |
46 | 46 |
47 /** | 47 /** |
48 * The preference that lists the languages which are not translated. | 48 * The preference that lists the languages which are not translated. |
49 * @type {string} | 49 * @type {string} |
50 * @const | 50 * @const |
51 */ | 51 */ |
52 var TRANSLATE_BLOCKED_LANGUAGES_PREF = 'translate_blocked_languages'; | 52 var TRANSLATE_BLOCKED_LANGUAGES_PREF = 'translate_blocked_languages'; |
53 | 53 |
54 /** | 54 /** |
55 * The preference key that is a string that describes the spell check | 55 * The preference key that is a list of strings that describes the spellcheck |
56 * dictionary language, like "en-US". | 56 * dictionary language, like ["en-US", "fr"]. |
57 * @type {string} | 57 * @type {string} |
58 * @const | 58 * @const |
59 */ | 59 */ |
60 var SPELL_CHECK_DICTIONARIES_PREF = 'spellcheck.dictionaries'; | 60 var SPELL_CHECK_DICTIONARIES_PREF = 'spellcheck.dictionaries'; |
61 | 61 |
62 /** | 62 /** |
63 * The preference that indicates if the Translate feature is enabled. | 63 * The preference that indicates if the Translate feature is enabled. |
64 * @type {string} | 64 * @type {string} |
65 * @const | 65 * @const |
66 */ | 66 */ |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 translateBlockedLanguages_: [], | 129 translateBlockedLanguages_: [], |
130 | 130 |
131 /** | 131 /** |
132 * The list of the languages supported by Translate server | 132 * The list of the languages supported by Translate server |
133 * @type {Array} | 133 * @type {Array} |
134 * @private | 134 * @private |
135 */ | 135 */ |
136 translateSupportedLanguages_: [], | 136 translateSupportedLanguages_: [], |
137 | 137 |
138 /** | 138 /** |
139 * The preference is a string that describes the spell check dictionary | 139 * The dictionary of currently selected spellcheck dictionary languages, |
140 * language, like "en-US". | 140 * like {"en-US": true, "sl-SI": true}. |
141 * @type {string} | 141 * @type {Object} |
142 * @private | 142 * @private |
143 */ | 143 */ |
144 spellCheckDictionary_: '', | 144 spellCheckLanguages_: {}, |
145 | 145 |
146 /** | 146 /** |
147 * The map of language code to input method IDs, like: | 147 * The map of language code to input method IDs, like: |
148 * {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} | 148 * {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} |
149 * @type {Object} | 149 * @type {Object} |
150 * @private | 150 * @private |
151 */ | 151 */ |
152 languageCodeToInputMethodIdsMap_: {}, | 152 languageCodeToInputMethodIdsMap_: {}, |
153 | 153 |
154 /** | 154 /** |
(...skipping 26 matching lines...) Expand all Loading... |
181 } | 181 } |
182 | 182 |
183 var checkbox = $('offer-to-translate-in-this-language'); | 183 var checkbox = $('offer-to-translate-in-this-language'); |
184 checkbox.addEventListener('click', | 184 checkbox.addEventListener('click', |
185 this.handleOfferToTranslateCheckboxClick_.bind(this)); | 185 this.handleOfferToTranslateCheckboxClick_.bind(this)); |
186 | 186 |
187 Preferences.getInstance().addEventListener( | 187 Preferences.getInstance().addEventListener( |
188 TRANSLATE_BLOCKED_LANGUAGES_PREF, | 188 TRANSLATE_BLOCKED_LANGUAGES_PREF, |
189 this.handleTranslateBlockedLanguagesPrefChange_.bind(this)); | 189 this.handleTranslateBlockedLanguagesPrefChange_.bind(this)); |
190 Preferences.getInstance().addEventListener(SPELL_CHECK_DICTIONARIES_PREF, | 190 Preferences.getInstance().addEventListener(SPELL_CHECK_DICTIONARIES_PREF, |
191 this.handleSpellCheckDictionaryPrefChange_.bind(this)); | 191 this.handleSpellCheckDictionariesPrefChange_.bind(this)); |
192 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE, | 192 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE, |
193 this.handleEnableTranslatePrefChange_.bind(this)); | 193 this.handleEnableTranslatePrefChange_.bind(this)); |
194 this.translateSupportedLanguages_ = | 194 this.translateSupportedLanguages_ = |
195 loadTimeData.getValue('translateSupportedLanguages'); | 195 loadTimeData.getValue('translateSupportedLanguages'); |
196 | 196 |
197 // Set up add button. | 197 // Set up add button. |
198 var onclick = function(e) { | 198 var onclick = function(e) { |
199 // Add the language without showing the overlay if it's specified in | 199 // Add the language without showing the overlay if it's specified in |
200 // the URL hash (ex. lang_add=ja). Used for automated testing. | 200 // the URL hash (ex. lang_add=ja). Used for automated testing. |
201 var match = document.location.hash.match(/\blang_add=([\w-]+)/); | 201 var match = document.location.hash.match(/\blang_add=([\w-]+)/); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Handle spell check enable/disable. | 233 // Handle spell check enable/disable. |
234 if (!cr.isMac) { | 234 if (!cr.isMac) { |
235 Preferences.getInstance().addEventListener( | 235 Preferences.getInstance().addEventListener( |
236 ENABLE_SPELL_CHECK_PREF, | 236 ENABLE_SPELL_CHECK_PREF, |
237 this.updateEnableSpellCheck_.bind(this)); | 237 this.updateEnableSpellCheck_.bind(this)); |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 // Handle clicks on "Use this language for spell checking" button. | 241 // Handle clicks on "Use this language for spell checking" button. |
242 if (!cr.isMac) { | 242 if (!cr.isMac) { |
243 var spellCheckLanguageButton = getRequiredElement( | 243 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) { |
244 'language-options-spell-check-language-button'); | 244 $('spellcheck-language-checkbox').addEventListener( |
245 spellCheckLanguageButton.addEventListener( | 245 'change', |
246 'click', | 246 this.handleSpellCheckLanguageCheckboxClick_.bind(this)); |
247 this.handleSpellCheckLanguageButtonClick_.bind(this)); | 247 } else { |
| 248 $('spellcheck-language-button').addEventListener( |
| 249 'click', |
| 250 this.handleSpellCheckLanguageButtonClick_.bind(this)); |
| 251 } |
248 } | 252 } |
249 | 253 |
250 if (cr.isChromeOS) { | 254 if (cr.isChromeOS) { |
251 $('language-options-ui-restart-button').onclick = function() { | 255 $('language-options-ui-restart-button').onclick = function() { |
252 chrome.send('uiLanguageRestart'); | 256 chrome.send('uiLanguageRestart'); |
253 }; | 257 }; |
254 } | 258 } |
255 | 259 |
256 $('language-confirm').onclick = | 260 $('language-confirm').onclick = |
257 PageManager.closeOverlay.bind(PageManager); | 261 PageManager.closeOverlay.bind(PageManager); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 424 } |
421 | 425 |
422 this.updateOfferToTranslateCheckbox_(languageCode); | 426 this.updateOfferToTranslateCheckbox_(languageCode); |
423 | 427 |
424 if (cr.isWindows || cr.isChromeOS) | 428 if (cr.isWindows || cr.isChromeOS) |
425 this.updateUiLanguageButton_(languageCode); | 429 this.updateUiLanguageButton_(languageCode); |
426 | 430 |
427 this.updateSelectedLanguageName_(languageCode); | 431 this.updateSelectedLanguageName_(languageCode); |
428 | 432 |
429 if (!cr.isMac) | 433 if (!cr.isMac) |
430 this.updateSpellCheckLanguageButton_(languageCode); | 434 this.updateSpellCheckLanguageControls_(languageCode); |
431 | 435 |
432 if (cr.isChromeOS) | 436 if (cr.isChromeOS) |
433 this.updateInputMethodList_(languageCode); | 437 this.updateInputMethodList_(languageCode); |
434 | 438 |
435 this.updateLanguageListInAddLanguageOverlay_(); | 439 this.updateLanguageListInAddLanguageOverlay_(); |
436 }, | 440 }, |
437 | 441 |
438 /** | 442 /** |
439 * Handles languageOptionsList's save event. | 443 * Handles languageOptionsList's save event. |
440 * @param {Event} e Save event. | 444 * @param {Event} e Save event. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 showMutuallyExclusiveNodes( | 601 showMutuallyExclusiveNodes( |
598 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); | 602 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); |
599 } | 603 } |
600 }, | 604 }, |
601 | 605 |
602 /** | 606 /** |
603 * Updates the spell check language button. | 607 * Updates the spell check language button. |
604 * @param {string} languageCode Language code (ex. "fr"). | 608 * @param {string} languageCode Language code (ex. "fr"). |
605 * @private | 609 * @private |
606 */ | 610 */ |
607 updateSpellCheckLanguageButton_: function(languageCode) { | 611 updateSpellCheckLanguageControls_: function(languageCode) { |
| 612 assert(languageCode); |
608 var spellCheckLanguageSection = $('language-options-spellcheck'); | 613 var spellCheckLanguageSection = $('language-options-spellcheck'); |
609 var spellCheckLanguageButton = | 614 var spellCheckLanguageButton = $('spellcheck-language-button'); |
610 $('language-options-spell-check-language-button'); | 615 var spellCheckLanguageCheckboxContainer = |
611 var spellCheckLanguageMessage = | 616 $('spellcheck-language-checkbox-container'); |
612 $('language-options-spell-check-language-message'); | 617 var spellCheckLanguageCheckbox = $('spellcheck-language-checkbox'); |
| 618 var spellCheckLanguageMessage = $('spellcheck-language-message'); |
613 var dictionaryDownloadInProgress = | 619 var dictionaryDownloadInProgress = |
614 $('language-options-dictionary-downloading-message'); | 620 $('language-options-dictionary-downloading-message'); |
615 var dictionaryDownloadFailed = | 621 var dictionaryDownloadFailed = |
616 $('language-options-dictionary-download-failed-message'); | 622 $('language-options-dictionary-download-failed-message'); |
617 var dictionaryDownloadFailHelp = | 623 var dictionaryDownloadFailHelp = |
618 $('language-options-dictionary-download-fail-help-message'); | 624 $('language-options-dictionary-download-fail-help-message'); |
| 625 |
619 spellCheckLanguageSection.hidden = false; | 626 spellCheckLanguageSection.hidden = false; |
620 spellCheckLanguageMessage.hidden = true; | 627 spellCheckLanguageMessage.hidden = true; |
621 spellCheckLanguageButton.hidden = true; | 628 spellCheckLanguageButton.hidden = true; |
| 629 spellCheckLanguageCheckboxContainer.hidden = true; |
622 dictionaryDownloadInProgress.hidden = true; | 630 dictionaryDownloadInProgress.hidden = true; |
623 dictionaryDownloadFailed.hidden = true; | 631 dictionaryDownloadFailed.hidden = true; |
624 dictionaryDownloadFailHelp.hidden = true; | 632 dictionaryDownloadFailHelp.hidden = true; |
| 633 spellCheckLanguageCheckbox.checked = false; |
625 | 634 |
626 if (languageCode == this.spellCheckDictionary_) { | 635 var canBeUsedForSpellchecking = |
627 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) { | 636 languageCode in loadTimeData.getValue('spellCheckLanguageCodeSet'); |
| 637 |
| 638 if (!canBeUsedForSpellchecking) { |
| 639 spellCheckLanguageMessage.textContent = |
| 640 loadTimeData.getString('cannotBeUsedForSpellChecking'); |
| 641 spellCheckLanguageMessage.hidden = false; |
| 642 return; |
| 643 } |
| 644 |
| 645 var isUsedForSpellchecking = languageCode in this.spellCheckLanguages_; |
| 646 var isLanguageDownloaded = |
| 647 !(languageCode in this.spellcheckDictionaryDownloadStatus_); |
| 648 |
| 649 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) { |
| 650 spellCheckLanguageCheckbox.languageCode = languageCode; |
| 651 spellCheckLanguageCheckbox.checked = isUsedForSpellchecking; |
| 652 spellCheckLanguageCheckboxContainer.hidden = false; |
| 653 } else if (isUsedForSpellchecking) { |
| 654 if (isLanguageDownloaded) { |
628 spellCheckLanguageMessage.textContent = | 655 spellCheckLanguageMessage.textContent = |
629 loadTimeData.getString('isUsedForSpellChecking'); | 656 loadTimeData.getString('isUsedForSpellChecking'); |
| 657 spellCheckLanguageMessage.hidden = false; |
| 658 } |
| 659 } else { |
| 660 spellCheckLanguageButton.textContent = |
| 661 loadTimeData.getString('useThisForSpellChecking'); |
| 662 spellCheckLanguageButton.hidden = false; |
| 663 spellCheckLanguageButton.languageCode = languageCode; |
| 664 } |
| 665 |
| 666 switch (this.spellcheckDictionaryDownloadStatus_[languageCode]) { |
| 667 case DOWNLOAD_STATUS.IN_PROGRESS: |
| 668 dictionaryDownloadInProgress.hidden = false; |
| 669 break; |
| 670 case DOWNLOAD_STATUS.FAILED: |
630 showMutuallyExclusiveNodes( | 671 showMutuallyExclusiveNodes( |
631 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); | 672 [spellCheckLanguageSection, dictionaryDownloadFailed], 1); |
632 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == | |
633 DOWNLOAD_STATUS.IN_PROGRESS) { | |
634 dictionaryDownloadInProgress.hidden = false; | |
635 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == | |
636 DOWNLOAD_STATUS.FAILED) { | |
637 spellCheckLanguageSection.hidden = true; | |
638 dictionaryDownloadFailed.hidden = false; | |
639 if (this.spellcheckDictionaryDownloadFailures_ > 1) | 673 if (this.spellcheckDictionaryDownloadFailures_ > 1) |
640 dictionaryDownloadFailHelp.hidden = false; | 674 dictionaryDownloadFailHelp.hidden = false; |
641 } | 675 break; |
642 } else if (languageCode in | |
643 loadTimeData.getValue('spellCheckLanguageCodeSet')) { | |
644 spellCheckLanguageButton.textContent = | |
645 loadTimeData.getString('useThisForSpellChecking'); | |
646 showMutuallyExclusiveNodes( | |
647 [spellCheckLanguageButton, spellCheckLanguageMessage], 0); | |
648 spellCheckLanguageButton.languageCode = languageCode; | |
649 } else if (!languageCode) { | |
650 spellCheckLanguageButton.hidden = true; | |
651 spellCheckLanguageMessage.hidden = true; | |
652 } else { | |
653 spellCheckLanguageMessage.textContent = | |
654 loadTimeData.getString('cannotBeUsedForSpellChecking'); | |
655 showMutuallyExclusiveNodes( | |
656 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); | |
657 } | 676 } |
658 }, | 677 }, |
659 | 678 |
660 /** | 679 /** |
661 * Updates the checkbox for stopping translation. | 680 * Updates the checkbox for stopping translation. |
662 * @param {string} languageCode Language code (ex. "fr"). | 681 * @param {string} languageCode Language code (ex. "fr"). |
663 * @private | 682 * @private |
664 */ | 683 */ |
665 updateOfferToTranslateCheckbox_: function(languageCode) { | 684 updateOfferToTranslateCheckbox_: function(languageCode) { |
666 var div = $('language-options-offer-to-translate'); | 685 var div = $('language-options-offer-to-translate'); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 return (!cr.isChromeOS || | 931 return (!cr.isChromeOS || |
913 this.canDeleteLanguage_(languageCode)); | 932 this.canDeleteLanguage_(languageCode)); |
914 }, | 933 }, |
915 | 934 |
916 /** | 935 /** |
917 * Handles browse.enable_spellchecking change. | 936 * Handles browse.enable_spellchecking change. |
918 * @param {Event} e Change event. | 937 * @param {Event} e Change event. |
919 * @private | 938 * @private |
920 */ | 939 */ |
921 updateEnableSpellCheck_: function(e) { | 940 updateEnableSpellCheck_: function(e) { |
922 var value = !$('enable-spell-check').checked; | 941 var value = !$('enable-spellcheck').checked; |
923 $('language-options-spell-check-language-button').disabled = value; | 942 $('spellcheck-language-button').disabled = value; |
924 if (!cr.isMac) | 943 if (!cr.isMac) |
925 $('edit-dictionary-button').hidden = value; | 944 $('edit-dictionary-button').hidden = value; |
926 }, | 945 }, |
927 | 946 |
928 /** | 947 /** |
929 * Handles translateBlockedLanguagesPref change. | 948 * Handles translateBlockedLanguagesPref change. |
930 * @param {Event} e Change event. | 949 * @param {Event} e Change event. |
931 * @private | 950 * @private |
932 */ | 951 */ |
933 handleTranslateBlockedLanguagesPrefChange_: function(e) { | 952 handleTranslateBlockedLanguagesPrefChange_: function(e) { |
934 this.translateBlockedLanguages_ = e.value.value; | 953 this.translateBlockedLanguages_ = e.value.value; |
935 this.updateOfferToTranslateCheckbox_( | 954 this.updateOfferToTranslateCheckbox_( |
936 $('language-options-list').getSelectedLanguageCode()); | 955 $('language-options-list').getSelectedLanguageCode()); |
937 }, | 956 }, |
938 | 957 |
939 /** | 958 /** |
940 * Handles spellCheckDictionaryPref change. | 959 * Updates spellcheck dictionary UI (checkboxes, buttons, and labels) when |
941 * @param {Event} e Change event. | 960 * preferences change. |
| 961 * @param {Event} e Preference change event where e.value.value is the list |
| 962 * of languages currently used for spellchecking. |
942 * @private | 963 * @private |
943 */ | 964 */ |
944 handleSpellCheckDictionaryPrefChange_: function(e) { | 965 handleSpellCheckDictionariesPrefChange_: function(e) { |
945 var languageCode = e.value.value; | 966 if (cr.isMac) |
946 this.spellCheckDictionary_ = languageCode; | 967 return; |
947 if (!cr.isMac) { | 968 |
948 this.updateSpellCheckLanguageButton_( | 969 var languages = e.value.value; |
949 $('language-options-list').getSelectedLanguageCode()); | 970 this.spellCheckLanguages_ = {}; |
| 971 for (var i = 0; i < languages.length; i++) { |
| 972 this.spellCheckLanguages_[languages[i]] = true; |
950 } | 973 } |
| 974 this.updateSpellCheckLanguageControls_( |
| 975 $('language-options-list').getSelectedLanguageCode()); |
951 }, | 976 }, |
952 | 977 |
953 /** | 978 /** |
954 * Handles translate.enabled change. | 979 * Handles translate.enabled change. |
955 * @param {Event} e Change event. | 980 * @param {Event} e Change event. |
956 * @private | 981 * @private |
957 */ | 982 */ |
958 handleEnableTranslatePrefChange_: function(e) { | 983 handleEnableTranslatePrefChange_: function(e) { |
959 var enabled = e.value.value; | 984 var enabled = e.value.value; |
960 this.enableTranslate_ = enabled; | 985 this.enableTranslate_ = enabled; |
961 this.updateOfferToTranslateCheckbox_( | 986 this.updateOfferToTranslateCheckbox_( |
962 $('language-options-list').getSelectedLanguageCode()); | 987 $('language-options-list').getSelectedLanguageCode()); |
963 }, | 988 }, |
964 | 989 |
965 /** | 990 /** |
966 * Handles spellCheckLanguageButton click. | 991 * Handles spellCheckLanguageButton click. |
967 * @param {Event} e Click event. | 992 * @param {Event} e Click event. |
968 * @private | 993 * @private |
969 */ | 994 */ |
970 handleSpellCheckLanguageButtonClick_: function(e) { | 995 handleSpellCheckLanguageButtonClick_: function(e) { |
971 var languageCodes = [e.target.languageCode]; | 996 var languageCode = e.currentTarget.languageCode; |
972 // Save the preference. | 997 // Save the preference. |
973 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF, | 998 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF, |
| 999 [languageCode], true); |
| 1000 |
| 1001 // The spellCheckLanguageChange argument is only used for logging. |
| 1002 chrome.send('spellCheckLanguageChange', [languageCode]); |
| 1003 chrome.send('coreOptionsUserMetricsAction', |
| 1004 ['Options_Languages_SpellCheck']); |
| 1005 }, |
| 1006 |
| 1007 /** |
| 1008 * Updates the spellcheck.dictionaries preference with the currently |
| 1009 * selected language codes. |
| 1010 * @param {Event} e Click event. e.currentTarget represents the "Use this |
| 1011 * language for spellchecking" checkbox. |
| 1012 * @private |
| 1013 */ |
| 1014 handleSpellCheckLanguageCheckboxClick_: function(e) { |
| 1015 var languageCode = e.currentTarget.languageCode; |
| 1016 |
| 1017 if (e.currentTarget.checked) |
| 1018 this.spellCheckLanguages_[languageCode] = true; |
| 1019 else |
| 1020 delete this.spellCheckLanguages_[languageCode]; |
| 1021 |
| 1022 var languageCodes = Object.keys(this.spellCheckLanguages_); |
| 1023 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF, |
974 languageCodes, true); | 1024 languageCodes, true); |
| 1025 |
975 // The spellCheckLanguageChange argument is only used for logging. | 1026 // The spellCheckLanguageChange argument is only used for logging. |
976 chrome.send('spellCheckLanguageChange', [languageCodes.join(',')]); | 1027 chrome.send('spellCheckLanguageChange', [languageCodes.join(',')]); |
977 chrome.send('coreOptionsUserMetricsAction', | 1028 chrome.send('coreOptionsUserMetricsAction', |
978 ['Options_Languages_SpellCheck']); | 1029 ['Options_Languages_SpellCheck']); |
979 }, | 1030 }, |
980 | 1031 |
981 /** | 1032 /** |
982 * Checks whether it's possible to remove the language specified by | 1033 * Checks whether it's possible to remove the language specified by |
983 * languageCode and returns true if possible. This function returns false | 1034 * languageCode and returns true if possible. This function returns false |
984 * if the removal causes the number of preload engines to be zero. | 1035 * if the removal causes the number of preload engines to be zero. |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 * @param {string} languageCode The language of the dictionary that just | 1321 * @param {string} languageCode The language of the dictionary that just |
1271 * began downloading. | 1322 * began downloading. |
1272 * @private | 1323 * @private |
1273 */ | 1324 */ |
1274 onDictionaryDownloadBegin_: function(languageCode) { | 1325 onDictionaryDownloadBegin_: function(languageCode) { |
1275 this.spellcheckDictionaryDownloadStatus_[languageCode] = | 1326 this.spellcheckDictionaryDownloadStatus_[languageCode] = |
1276 DOWNLOAD_STATUS.IN_PROGRESS; | 1327 DOWNLOAD_STATUS.IN_PROGRESS; |
1277 if (!cr.isMac && | 1328 if (!cr.isMac && |
1278 languageCode == | 1329 languageCode == |
1279 $('language-options-list').getSelectedLanguageCode()) { | 1330 $('language-options-list').getSelectedLanguageCode()) { |
1280 this.updateSpellCheckLanguageButton_(languageCode); | 1331 this.updateSpellCheckLanguageControls_(languageCode); |
1281 } | 1332 } |
1282 }, | 1333 }, |
1283 | 1334 |
1284 /** | 1335 /** |
1285 * A handler for when dictionary for |languageCode| successfully downloaded. | 1336 * A handler for when dictionary for |languageCode| successfully downloaded. |
1286 * @param {string} languageCode The language of the dictionary that | 1337 * @param {string} languageCode The language of the dictionary that |
1287 * succeeded downloading. | 1338 * succeeded downloading. |
1288 * @private | 1339 * @private |
1289 */ | 1340 */ |
1290 onDictionaryDownloadSuccess_: function(languageCode) { | 1341 onDictionaryDownloadSuccess_: function(languageCode) { |
1291 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; | 1342 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; |
1292 this.spellcheckDictionaryDownloadFailures_ = 0; | 1343 this.spellcheckDictionaryDownloadFailures_ = 0; |
1293 if (!cr.isMac && | 1344 if (!cr.isMac && |
1294 languageCode == | 1345 languageCode == |
1295 $('language-options-list').getSelectedLanguageCode()) { | 1346 $('language-options-list').getSelectedLanguageCode()) { |
1296 this.updateSpellCheckLanguageButton_(languageCode); | 1347 this.updateSpellCheckLanguageControls_(languageCode); |
1297 } | 1348 } |
1298 }, | 1349 }, |
1299 | 1350 |
1300 /** | 1351 /** |
1301 * A handler for when dictionary for |languageCode| fails to download. | 1352 * A handler for when dictionary for |languageCode| fails to download. |
1302 * @param {string} languageCode The language of the dictionary that failed | 1353 * @param {string} languageCode The language of the dictionary that failed |
1303 * to download. | 1354 * to download. |
1304 * @private | 1355 * @private |
1305 */ | 1356 */ |
1306 onDictionaryDownloadFailure_: function(languageCode) { | 1357 onDictionaryDownloadFailure_: function(languageCode) { |
1307 this.spellcheckDictionaryDownloadStatus_[languageCode] = | 1358 this.spellcheckDictionaryDownloadStatus_[languageCode] = |
1308 DOWNLOAD_STATUS.FAILED; | 1359 DOWNLOAD_STATUS.FAILED; |
1309 this.spellcheckDictionaryDownloadFailures_++; | 1360 this.spellcheckDictionaryDownloadFailures_++; |
1310 if (!cr.isMac && | 1361 if (!cr.isMac && |
1311 languageCode == | 1362 languageCode == |
1312 $('language-options-list').getSelectedLanguageCode()) { | 1363 $('language-options-list').getSelectedLanguageCode()) { |
1313 this.updateSpellCheckLanguageButton_(languageCode); | 1364 this.updateSpellCheckLanguageControls_(languageCode); |
1314 } | 1365 } |
1315 }, | 1366 }, |
1316 | 1367 |
1317 /** | 1368 /** |
1318 * Converts the language code for Translation. There are some differences | 1369 * Converts the language code for Translation. There are some differences |
1319 * between the language set for Translation and that for Accept-Language. | 1370 * between the language set for Translation and that for Accept-Language. |
1320 * @param {string} languageCode The language code like 'fr'. | 1371 * @param {string} languageCode The language code like 'fr'. |
1321 * @return {string} The converted language code. | 1372 * @return {string} The converted language code. |
1322 * @private | 1373 * @private |
1323 */ | 1374 */ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 | 1426 |
1376 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { | 1427 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { |
1377 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); | 1428 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); |
1378 }; | 1429 }; |
1379 | 1430 |
1380 // Export | 1431 // Export |
1381 return { | 1432 return { |
1382 LanguageOptions: LanguageOptions | 1433 LanguageOptions: LanguageOptions |
1383 }; | 1434 }; |
1384 }); | 1435 }); |
OLD | NEW |