| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * The preference key that is a string that describes the spell check | 55 * The preference key that is a string that describes the spell check |
| 56 * dictionary language, like "en-US". | 56 * dictionary language, like "en-US". |
| 57 * @type {string} | 57 * @type {string} |
| 58 * @const | 58 * @const |
| 59 */ | 59 */ |
| 60 var SPELL_CHECK_DICTIONARY_PREF = 'spellcheck.dictionary'; | 60 var SPELL_CHECK_DICTIONARY_PREF = 'spellcheck.dictionary'; |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * The preference key that describes the spell check dictionary languages |
| 64 * currently selected (as a comma separated string, like "en-US,sl-SI"). |
| 65 * @type {string} |
| 66 * @const |
| 67 */ |
| 68 var SPELL_CHECK_DICTIONARIES_PREF = 'spellcheck.dictionaries'; |
| 69 |
| 70 /** |
| 63 * The preference that indicates if the Translate feature is enabled. | 71 * The preference that indicates if the Translate feature is enabled. |
| 64 * @type {string} | 72 * @type {string} |
| 65 * @const | 73 * @const |
| 66 */ | 74 */ |
| 67 var ENABLE_TRANSLATE = 'translate.enabled'; | 75 var ENABLE_TRANSLATE = 'translate.enabled'; |
| 68 | 76 |
| 69 ///////////////////////////////////////////////////////////////////////////// | 77 ///////////////////////////////////////////////////////////////////////////// |
| 70 // LanguageOptions class: | 78 // LanguageOptions class: |
| 71 | 79 |
| 72 /** | 80 /** |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 145 |
| 138 /** | 146 /** |
| 139 * The preference is a string that describes the spell check dictionary | 147 * The preference is a string that describes the spell check dictionary |
| 140 * language, like "en-US". | 148 * language, like "en-US". |
| 141 * @type {string} | 149 * @type {string} |
| 142 * @private | 150 * @private |
| 143 */ | 151 */ |
| 144 spellCheckDictionary_: '', | 152 spellCheckDictionary_: '', |
| 145 | 153 |
| 146 /** | 154 /** |
| 155 * The dictionary of currently selected spell check dictionary languages, |
| 156 * like "{"en-US": true, "sl-SI": true}". |
| 157 * @type {Object} |
| 158 * @private |
| 159 */ |
| 160 spellCheckDictionaries_: {}, |
| 161 |
| 162 /** |
| 147 * The map of language code to input method IDs, like: | 163 * The map of language code to input method IDs, like: |
| 148 * {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} | 164 * {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} |
| 149 * @type {Object} | 165 * @type {Object} |
| 150 * @private | 166 * @private |
| 151 */ | 167 */ |
| 152 languageCodeToInputMethodIdsMap_: {}, | 168 languageCodeToInputMethodIdsMap_: {}, |
| 153 | 169 |
| 154 /** | 170 /** |
| 155 * The value that indicates if Translate feature is enabled or not. | 171 * The value that indicates if Translate feature is enabled or not. |
| 156 * @type {boolean} | 172 * @type {boolean} |
| (...skipping 23 matching lines...) Expand all Loading... |
| 180 this.initializeLanguageCodeToInputMethodIdsMap_(); | 196 this.initializeLanguageCodeToInputMethodIdsMap_(); |
| 181 } | 197 } |
| 182 | 198 |
| 183 var checkbox = $('offer-to-translate-in-this-language'); | 199 var checkbox = $('offer-to-translate-in-this-language'); |
| 184 checkbox.addEventListener('click', | 200 checkbox.addEventListener('click', |
| 185 this.handleOfferToTranslateCheckboxClick_.bind(this)); | 201 this.handleOfferToTranslateCheckboxClick_.bind(this)); |
| 186 | 202 |
| 187 Preferences.getInstance().addEventListener( | 203 Preferences.getInstance().addEventListener( |
| 188 TRANSLATE_BLOCKED_LANGUAGES_PREF, | 204 TRANSLATE_BLOCKED_LANGUAGES_PREF, |
| 189 this.handleTranslateBlockedLanguagesPrefChange_.bind(this)); | 205 this.handleTranslateBlockedLanguagesPrefChange_.bind(this)); |
| 190 Preferences.getInstance().addEventListener(SPELL_CHECK_DICTIONARY_PREF, | 206 |
| 207 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) { |
| 208 Preferences.getInstance().addEventListener( |
| 209 SPELL_CHECK_DICTIONARIES_PREF, |
| 210 this.handleSpellCheckDictionariesPrefChange_.bind(this)); |
| 211 } else { |
| 212 Preferences.getInstance().addEventListener(SPELL_CHECK_DICTIONARY_PREF, |
| 191 this.handleSpellCheckDictionaryPrefChange_.bind(this)); | 213 this.handleSpellCheckDictionaryPrefChange_.bind(this)); |
| 214 } |
| 215 |
| 192 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE, | 216 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE, |
| 193 this.handleEnableTranslatePrefChange_.bind(this)); | 217 this.handleEnableTranslatePrefChange_.bind(this)); |
| 194 this.translateSupportedLanguages_ = | 218 this.translateSupportedLanguages_ = |
| 195 loadTimeData.getValue('translateSupportedLanguages'); | 219 loadTimeData.getValue('translateSupportedLanguages'); |
| 196 | 220 |
| 197 // Set up add button. | 221 // Set up add button. |
| 198 var onclick = function(e) { | 222 var onclick = function(e) { |
| 199 // Add the language without showing the overlay if it's specified in | 223 // Add the language without showing the overlay if it's specified in |
| 200 // the URL hash (ex. lang_add=ja). Used for automated testing. | 224 // the URL hash (ex. lang_add=ja). Used for automated testing. |
| 201 var match = document.location.hash.match(/\blang_add=([\w-]+)/); | 225 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. | 257 // Handle spell check enable/disable. |
| 234 if (!cr.isMac) { | 258 if (!cr.isMac) { |
| 235 Preferences.getInstance().addEventListener( | 259 Preferences.getInstance().addEventListener( |
| 236 ENABLE_SPELL_CHECK_PREF, | 260 ENABLE_SPELL_CHECK_PREF, |
| 237 this.updateEnableSpellCheck_.bind(this)); | 261 this.updateEnableSpellCheck_.bind(this)); |
| 238 } | 262 } |
| 239 } | 263 } |
| 240 | 264 |
| 241 // Handle clicks on "Use this language for spell checking" button. | 265 // Handle clicks on "Use this language for spell checking" button. |
| 242 if (!cr.isMac) { | 266 if (!cr.isMac) { |
| 243 var spellCheckLanguageButton = getRequiredElement( | 267 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) { |
| 244 'language-options-spell-check-language-button'); | 268 var spellCheckLanguageCheckbox = getRequiredElement( |
| 245 spellCheckLanguageButton.addEventListener( | 269 'language-options-spell-check-language-checkbox'); |
| 246 'click', | 270 spellCheckLanguageCheckbox.addEventListener( |
| 247 this.handleSpellCheckLanguageButtonClick_.bind(this)); | 271 'click', |
| 272 this.handleSpellCheckLanguageCheckboxClick_.bind(this)); |
| 273 } else { |
| 274 var spellCheckLanguageButton = getRequiredElement( |
| 275 'language-options-spell-check-language-button'); |
| 276 spellCheckLanguageButton.addEventListener( |
| 277 'click', |
| 278 this.handleSpellCheckLanguageButtonClick_.bind(this)); |
| 279 } |
| 248 } | 280 } |
| 249 | 281 |
| 250 if (cr.isChromeOS) { | 282 if (cr.isChromeOS) { |
| 251 $('language-options-ui-restart-button').onclick = function() { | 283 $('language-options-ui-restart-button').onclick = function() { |
| 252 chrome.send('uiLanguageRestart'); | 284 chrome.send('uiLanguageRestart'); |
| 253 }; | 285 }; |
| 254 } | 286 } |
| 255 | 287 |
| 256 $('language-confirm').onclick = | 288 $('language-confirm').onclick = |
| 257 PageManager.closeOverlay.bind(PageManager); | 289 PageManager.closeOverlay.bind(PageManager); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 452 } |
| 421 | 453 |
| 422 this.updateOfferToTranslateCheckbox_(languageCode); | 454 this.updateOfferToTranslateCheckbox_(languageCode); |
| 423 | 455 |
| 424 if (cr.isWindows || cr.isChromeOS) | 456 if (cr.isWindows || cr.isChromeOS) |
| 425 this.updateUiLanguageButton_(languageCode); | 457 this.updateUiLanguageButton_(languageCode); |
| 426 | 458 |
| 427 this.updateSelectedLanguageName_(languageCode); | 459 this.updateSelectedLanguageName_(languageCode); |
| 428 | 460 |
| 429 if (!cr.isMac) | 461 if (!cr.isMac) |
| 430 this.updateSpellCheckLanguageButton_(languageCode); | 462 this.updateSpellCheckLanguageControls_(languageCode); |
| 431 | 463 |
| 432 if (cr.isChromeOS) | 464 if (cr.isChromeOS) |
| 433 this.updateInputMethodList_(languageCode); | 465 this.updateInputMethodList_(languageCode); |
| 434 | 466 |
| 435 this.updateLanguageListInAddLanguageOverlay_(); | 467 this.updateLanguageListInAddLanguageOverlay_(); |
| 436 }, | 468 }, |
| 437 | 469 |
| 438 /** | 470 /** |
| 439 * Handles languageOptionsList's save event. | 471 * Handles languageOptionsList's save event. |
| 440 * @param {Event} e Save event. | 472 * @param {Event} e Save event. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 showMutuallyExclusiveNodes( | 629 showMutuallyExclusiveNodes( |
| 598 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); | 630 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); |
| 599 } | 631 } |
| 600 }, | 632 }, |
| 601 | 633 |
| 602 /** | 634 /** |
| 603 * Updates the spell check language button. | 635 * Updates the spell check language button. |
| 604 * @param {string} languageCode Language code (ex. "fr"). | 636 * @param {string} languageCode Language code (ex. "fr"). |
| 605 * @private | 637 * @private |
| 606 */ | 638 */ |
| 607 updateSpellCheckLanguageButton_: function(languageCode) { | 639 updateSpellCheckLanguageControls_: function(languageCode) { |
| 608 var spellCheckLanguageSection = $('language-options-spellcheck'); | 640 var spellCheckLanguageSection = $('language-options-spellcheck'); |
| 609 var spellCheckLanguageButton = | 641 var spellCheckLanguageButton = |
| 610 $('language-options-spell-check-language-button'); | 642 $('language-options-spell-check-language-button'); |
| 643 var spellCheckLanguageCheckboxDiv = |
| 644 $('language-options-spell-check-language-checkbox-div'); |
| 645 var spellCheckLanguageCheckbox = |
| 646 $('language-options-spell-check-language-checkbox'); |
| 611 var spellCheckLanguageMessage = | 647 var spellCheckLanguageMessage = |
| 612 $('language-options-spell-check-language-message'); | 648 $('language-options-spell-check-language-message'); |
| 613 var dictionaryDownloadInProgress = | 649 var dictionaryDownloadInProgress = |
| 614 $('language-options-dictionary-downloading-message'); | 650 $('language-options-dictionary-downloading-message'); |
| 615 var dictionaryDownloadFailed = | 651 var dictionaryDownloadFailed = |
| 616 $('language-options-dictionary-download-failed-message'); | 652 $('language-options-dictionary-download-failed-message'); |
| 617 var dictionaryDownloadFailHelp = | 653 var dictionaryDownloadFailHelp = |
| 618 $('language-options-dictionary-download-fail-help-message'); | 654 $('language-options-dictionary-download-fail-help-message'); |
| 655 |
| 619 spellCheckLanguageSection.hidden = false; | 656 spellCheckLanguageSection.hidden = false; |
| 620 spellCheckLanguageMessage.hidden = true; | 657 spellCheckLanguageMessage.hidden = true; |
| 621 spellCheckLanguageButton.hidden = true; | 658 spellCheckLanguageButton.hidden = true; |
| 659 spellCheckLanguageCheckboxDiv.hidden = true; |
| 622 dictionaryDownloadInProgress.hidden = true; | 660 dictionaryDownloadInProgress.hidden = true; |
| 623 dictionaryDownloadFailed.hidden = true; | 661 dictionaryDownloadFailed.hidden = true; |
| 624 dictionaryDownloadFailHelp.hidden = true; | 662 dictionaryDownloadFailHelp.hidden = true; |
| 625 | 663 |
| 626 if (languageCode == this.spellCheckDictionary_) { | 664 spellCheckLanguageCheckbox.checked = false; |
| 627 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) { | 665 |
| 628 spellCheckLanguageMessage.textContent = | 666 if (!languageCode) |
| 629 loadTimeData.getString('isUsedForSpellChecking'); | 667 return; |
| 630 showMutuallyExclusiveNodes( | 668 |
| 631 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); | 669 if (languageCode in loadTimeData.getValue('spellCheckLanguageCodeSet')) { |
| 632 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == | 670 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) { |
| 633 DOWNLOAD_STATUS.IN_PROGRESS) { | 671 spellCheckLanguageCheckbox.languageCode = languageCode; |
| 672 if (this.spellCheckDictionaries_.hasOwnProperty(languageCode)) |
| 673 spellCheckLanguageCheckbox.checked = true; |
| 674 |
| 675 spellCheckLanguageCheckboxDiv.hidden = false; |
| 676 } else if (languageCode == this.spellCheckDictionary_) { |
| 677 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) { |
| 678 spellCheckLanguageMessage.textContent = |
| 679 loadTimeData.getString('isUsedForSpellChecking'); |
| 680 spellCheckLanguageMessage.hidden = false; |
| 681 } |
| 682 } else { |
| 683 spellCheckLanguageButton.textContent = |
| 684 loadTimeData.getString('useThisForSpellChecking'); |
| 685 spellCheckLanguageButton.hidden = false; |
| 686 } |
| 687 |
| 688 if (this.spellcheckDictionaryDownloadStatus_[languageCode] == |
| 689 DOWNLOAD_STATUS.IN_PROGRESS) { |
| 634 dictionaryDownloadInProgress.hidden = false; | 690 dictionaryDownloadInProgress.hidden = false; |
| 635 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == | 691 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == |
| 636 DOWNLOAD_STATUS.FAILED) { | 692 DOWNLOAD_STATUS.FAILED) { |
| 637 spellCheckLanguageSection.hidden = true; | 693 showMutuallyExclusiveNodes( |
| 638 dictionaryDownloadFailed.hidden = false; | 694 [spellCheckLanguageSection, dictionaryDownloadFailed], 1); |
| 639 if (this.spellcheckDictionaryDownloadFailures_ > 1) | 695 if (this.spellcheckDictionaryDownloadFailures_ > 1) |
| 640 dictionaryDownloadFailHelp.hidden = false; | 696 dictionaryDownloadFailHelp.hidden = false; |
| 641 } | 697 } |
| 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 { | 698 } else { |
| 653 spellCheckLanguageMessage.textContent = | 699 spellCheckLanguageMessage.textContent = |
| 654 loadTimeData.getString('cannotBeUsedForSpellChecking'); | 700 loadTimeData.getString('cannotBeUsedForSpellChecking'); |
| 655 showMutuallyExclusiveNodes( | 701 spellCheckLanguageMessage.hidden = false; |
| 656 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); | |
| 657 } | 702 } |
| 658 }, | 703 }, |
| 659 | 704 |
| 660 /** | 705 /** |
| 661 * Updates the checkbox for stopping translation. | 706 * Updates the checkbox for stopping translation. |
| 662 * @param {string} languageCode Language code (ex. "fr"). | 707 * @param {string} languageCode Language code (ex. "fr"). |
| 663 * @private | 708 * @private |
| 664 */ | 709 */ |
| 665 updateOfferToTranslateCheckbox_: function(languageCode) { | 710 updateOfferToTranslateCheckbox_: function(languageCode) { |
| 666 var div = $('language-options-offer-to-translate'); | 711 var div = $('language-options-offer-to-translate'); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 | 983 |
| 939 /** | 984 /** |
| 940 * Handles spellCheckDictionaryPref change. | 985 * Handles spellCheckDictionaryPref change. |
| 941 * @param {Event} e Change event. | 986 * @param {Event} e Change event. |
| 942 * @private | 987 * @private |
| 943 */ | 988 */ |
| 944 handleSpellCheckDictionaryPrefChange_: function(e) { | 989 handleSpellCheckDictionaryPrefChange_: function(e) { |
| 945 var languageCode = e.value.value; | 990 var languageCode = e.value.value; |
| 946 this.spellCheckDictionary_ = languageCode; | 991 this.spellCheckDictionary_ = languageCode; |
| 947 if (!cr.isMac) { | 992 if (!cr.isMac) { |
| 948 this.updateSpellCheckLanguageButton_( | 993 this.updateSpellCheckLanguageControls_( |
| 949 $('language-options-list').getSelectedLanguageCode()); | 994 $('language-options-list').getSelectedLanguageCode()); |
| 950 } | 995 } |
| 951 }, | 996 }, |
| 952 | 997 |
| 953 /** | 998 /** |
| 999 * Updates spellcheck dictionary UI (checkboxes, buttons, and labels) when |
| 1000 * preferences change. |
| 1001 * @param {Event} e. Preference change event where e.value.value is the |
| 1002 * comma separated list of languages currently used for spellchecking. |
| 1003 * @private |
| 1004 */ |
| 1005 handleSpellCheckDictionariesPrefChange_: function(e) { |
| 1006 if (cr.isMac) |
| 1007 return; |
| 1008 |
| 1009 var commaSeparatedLanguageCodes = e.value.value; |
| 1010 var languageCodesSplit = commaSeparatedLanguageCodes.split(','); |
| 1011 |
| 1012 this.spellCheckDictionaries_ = {}; |
| 1013 for (var i = 0; i < languageCodesSplit.length; i++) |
| 1014 this.spellCheckDictionaries_[languageCodesSplit[i]] = true; |
| 1015 |
| 1016 this.updateSpellCheckLanguageControls_( |
| 1017 $('language-options-list').getSelectedLanguageCode()); |
| 1018 }, |
| 1019 |
| 1020 /** |
| 954 * Handles translate.enabled change. | 1021 * Handles translate.enabled change. |
| 955 * @param {Event} e Change event. | 1022 * @param {Event} e Change event. |
| 956 * @private | 1023 * @private |
| 957 */ | 1024 */ |
| 958 handleEnableTranslatePrefChange_: function(e) { | 1025 handleEnableTranslatePrefChange_: function(e) { |
| 959 var enabled = e.value.value; | 1026 var enabled = e.value.value; |
| 960 this.enableTranslate_ = enabled; | 1027 this.enableTranslate_ = enabled; |
| 961 this.updateOfferToTranslateCheckbox_( | 1028 this.updateOfferToTranslateCheckbox_( |
| 962 $('language-options-list').getSelectedLanguageCode()); | 1029 $('language-options-list').getSelectedLanguageCode()); |
| 963 }, | 1030 }, |
| 964 | 1031 |
| 965 /** | 1032 /** |
| 966 * Handles spellCheckLanguageButton click. | 1033 * Handles spellCheckLanguageButton click. |
| 967 * @param {Event} e Click event. | 1034 * @param {Event} e Click event. |
| 968 * @private | 1035 * @private |
| 969 */ | 1036 */ |
| 970 handleSpellCheckLanguageButtonClick_: function(e) { | 1037 handleSpellCheckLanguageButtonClick_: function(e) { |
| 971 var languageCode = e.target.languageCode; | 1038 var languageCode = e.target.languageCode; |
| 972 // Save the preference. | 1039 // Save the preference. |
| 973 Preferences.setStringPref(SPELL_CHECK_DICTIONARY_PREF, | 1040 Preferences.setStringPref(SPELL_CHECK_DICTIONARY_PREF, |
| 974 languageCode, true); | 1041 languageCode, true); |
| 975 chrome.send('spellCheckLanguageChange', [languageCode]); | 1042 chrome.send('spellCheckLanguageChange', [languageCode]); |
| 976 chrome.send('coreOptionsUserMetricsAction', | 1043 chrome.send('coreOptionsUserMetricsAction', |
| 977 ['Options_Languages_SpellCheck']); | 1044 ['Options_Languages_SpellCheck']); |
| 978 }, | 1045 }, |
| 979 | 1046 |
| 980 /** | 1047 /** |
| 1048 * Updates the spellcheck.dictionaries preference with the currently |
| 1049 * selected language codes. |
| 1050 * @param {Event} e Click event. e.target represents the "Use this language |
| 1051 * for spellchecking" |
| 1052 * @private |
| 1053 */ |
| 1054 handleSpellCheckLanguageCheckboxClick_: function(e) { |
| 1055 var languageCode = e.target.languageCode; |
| 1056 |
| 1057 if (e.target.checked) |
| 1058 this.spellCheckDictionaries_[languageCode] = true; |
| 1059 else |
| 1060 delete this.spellCheckDictionaries_[languageCode]; |
| 1061 |
| 1062 var languageCodes = []; |
| 1063 for (var currentLanguageCode in this.spellCheckDictionaries_) { |
| 1064 if (this.spellCheckDictionaries_.hasOwnProperty(currentLanguageCode)) |
| 1065 languageCodes.push(currentLanguageCode); |
| 1066 } |
| 1067 |
| 1068 Preferences.setStringPref(SPELL_CHECK_DICTIONARIES_PREF, |
| 1069 languageCodes.join(','), true); |
| 1070 }, |
| 1071 |
| 1072 /** |
| 981 * Checks whether it's possible to remove the language specified by | 1073 * Checks whether it's possible to remove the language specified by |
| 982 * languageCode and returns true if possible. This function returns false | 1074 * languageCode and returns true if possible. This function returns false |
| 983 * if the removal causes the number of preload engines to be zero. | 1075 * if the removal causes the number of preload engines to be zero. |
| 984 * | 1076 * |
| 985 * @param {string} languageCode Language code (ex. "fr"). | 1077 * @param {string} languageCode Language code (ex. "fr"). |
| 986 * @return {boolean} Returns true on success. | 1078 * @return {boolean} Returns true on success. |
| 987 * @private | 1079 * @private |
| 988 */ | 1080 */ |
| 989 canDeleteLanguage_: function(languageCode) { | 1081 canDeleteLanguage_: function(languageCode) { |
| 990 // First create the set of engines to be removed from input methods | 1082 // First create the set of engines to be removed from input methods |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 * @param {string} languageCode The language of the dictionary that just | 1361 * @param {string} languageCode The language of the dictionary that just |
| 1270 * began downloading. | 1362 * began downloading. |
| 1271 * @private | 1363 * @private |
| 1272 */ | 1364 */ |
| 1273 onDictionaryDownloadBegin_: function(languageCode) { | 1365 onDictionaryDownloadBegin_: function(languageCode) { |
| 1274 this.spellcheckDictionaryDownloadStatus_[languageCode] = | 1366 this.spellcheckDictionaryDownloadStatus_[languageCode] = |
| 1275 DOWNLOAD_STATUS.IN_PROGRESS; | 1367 DOWNLOAD_STATUS.IN_PROGRESS; |
| 1276 if (!cr.isMac && | 1368 if (!cr.isMac && |
| 1277 languageCode == | 1369 languageCode == |
| 1278 $('language-options-list').getSelectedLanguageCode()) { | 1370 $('language-options-list').getSelectedLanguageCode()) { |
| 1279 this.updateSpellCheckLanguageButton_(languageCode); | 1371 this.updateSpellCheckLanguageControls_(languageCode); |
| 1280 } | 1372 } |
| 1281 }, | 1373 }, |
| 1282 | 1374 |
| 1283 /** | 1375 /** |
| 1284 * A handler for when dictionary for |languageCode| successfully downloaded. | 1376 * A handler for when dictionary for |languageCode| successfully downloaded. |
| 1285 * @param {string} languageCode The language of the dictionary that | 1377 * @param {string} languageCode The language of the dictionary that |
| 1286 * succeeded downloading. | 1378 * succeeded downloading. |
| 1287 * @private | 1379 * @private |
| 1288 */ | 1380 */ |
| 1289 onDictionaryDownloadSuccess_: function(languageCode) { | 1381 onDictionaryDownloadSuccess_: function(languageCode) { |
| 1290 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; | 1382 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; |
| 1291 this.spellcheckDictionaryDownloadFailures_ = 0; | 1383 this.spellcheckDictionaryDownloadFailures_ = 0; |
| 1292 if (!cr.isMac && | 1384 if (!cr.isMac && |
| 1293 languageCode == | 1385 languageCode == |
| 1294 $('language-options-list').getSelectedLanguageCode()) { | 1386 $('language-options-list').getSelectedLanguageCode()) { |
| 1295 this.updateSpellCheckLanguageButton_(languageCode); | 1387 this.updateSpellCheckLanguageControls_(languageCode); |
| 1296 } | 1388 } |
| 1297 }, | 1389 }, |
| 1298 | 1390 |
| 1299 /** | 1391 /** |
| 1300 * A handler for when dictionary for |languageCode| fails to download. | 1392 * A handler for when dictionary for |languageCode| fails to download. |
| 1301 * @param {string} languageCode The language of the dictionary that failed | 1393 * @param {string} languageCode The language of the dictionary that failed |
| 1302 * to download. | 1394 * to download. |
| 1303 * @private | 1395 * @private |
| 1304 */ | 1396 */ |
| 1305 onDictionaryDownloadFailure_: function(languageCode) { | 1397 onDictionaryDownloadFailure_: function(languageCode) { |
| 1306 this.spellcheckDictionaryDownloadStatus_[languageCode] = | 1398 this.spellcheckDictionaryDownloadStatus_[languageCode] = |
| 1307 DOWNLOAD_STATUS.FAILED; | 1399 DOWNLOAD_STATUS.FAILED; |
| 1308 this.spellcheckDictionaryDownloadFailures_++; | 1400 this.spellcheckDictionaryDownloadFailures_++; |
| 1309 if (!cr.isMac && | 1401 if (!cr.isMac && |
| 1310 languageCode == | 1402 languageCode == |
| 1311 $('language-options-list').getSelectedLanguageCode()) { | 1403 $('language-options-list').getSelectedLanguageCode()) { |
| 1312 this.updateSpellCheckLanguageButton_(languageCode); | 1404 this.updateSpellCheckLanguageControls_(languageCode); |
| 1313 } | 1405 } |
| 1314 }, | 1406 }, |
| 1315 | 1407 |
| 1316 /** | 1408 /** |
| 1317 * Converts the language code for Translation. There are some differences | 1409 * Converts the language code for Translation. There are some differences |
| 1318 * between the language set for Translation and that for Accept-Language. | 1410 * between the language set for Translation and that for Accept-Language. |
| 1319 * @param {string} languageCode The language code like 'fr'. | 1411 * @param {string} languageCode The language code like 'fr'. |
| 1320 * @return {string} The converted language code. | 1412 * @return {string} The converted language code. |
| 1321 * @private | 1413 * @private |
| 1322 */ | 1414 */ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 | 1466 |
| 1375 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { | 1467 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { |
| 1376 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); | 1468 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); |
| 1377 }; | 1469 }; |
| 1378 | 1470 |
| 1379 // Export | 1471 // Export |
| 1380 return { | 1472 return { |
| 1381 LanguageOptions: LanguageOptions | 1473 LanguageOptions: LanguageOptions |
| 1382 }; | 1474 }; |
| 1383 }); | 1475 }); |
| OLD | NEW |