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

Side by Side Diff: chrome/browser/resources/options/language_options.js

Issue 1156473007: Enables the user to select multiple languages for spellchecking (UI) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replied to old comments and fixed small issues. Created 5 years, 5 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 (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
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
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 spell check 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
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
192 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE, 193 Preferences.getInstance().addEventListener(ENABLE_TRANSLATE,
193 this.handleEnableTranslatePrefChange_.bind(this)); 194 this.handleEnableTranslatePrefChange_.bind(this));
194 this.translateSupportedLanguages_ = 195 this.translateSupportedLanguages_ =
195 loadTimeData.getValue('translateSupportedLanguages'); 196 loadTimeData.getValue('translateSupportedLanguages');
196 197
197 // Set up add button. 198 // Set up add button.
198 var onclick = function(e) { 199 var onclick = function(e) {
199 // Add the language without showing the overlay if it's specified in 200 // Add the language without showing the overlay if it's specified in
200 // the URL hash (ex. lang_add=ja). Used for automated testing. 201 // the URL hash (ex. lang_add=ja). Used for automated testing.
201 var match = document.location.hash.match(/\blang_add=([\w-]+)/); 202 var match = document.location.hash.match(/\blang_add=([\w-]+)/);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Handle spell check enable/disable. 234 // Handle spell check enable/disable.
234 if (!cr.isMac) { 235 if (!cr.isMac) {
235 Preferences.getInstance().addEventListener( 236 Preferences.getInstance().addEventListener(
236 ENABLE_SPELL_CHECK_PREF, 237 ENABLE_SPELL_CHECK_PREF,
237 this.updateEnableSpellCheck_.bind(this)); 238 this.updateEnableSpellCheck_.bind(this));
238 } 239 }
239 } 240 }
240 241
241 // Handle clicks on "Use this language for spell checking" button. 242 // Handle clicks on "Use this language for spell checking" button.
242 if (!cr.isMac) { 243 if (!cr.isMac) {
243 var spellCheckLanguageButton = getRequiredElement( 244 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) {
244 'language-options-spell-check-language-button'); 245 $('spellcheck-language-checkbox').addEventListener(
245 spellCheckLanguageButton.addEventListener( 246 'change',
246 'click', 247 this.handleSpellCheckLanguageCheckboxClick_.bind(this));
247 this.handleSpellCheckLanguageButtonClick_.bind(this)); 248 } else {
249 $('spellcheck-language-button').addEventListener(
250 'click',
251 this.handleSpellCheckLanguageButtonClick_.bind(this));
252 }
248 } 253 }
249 254
250 if (cr.isChromeOS) { 255 if (cr.isChromeOS) {
251 $('language-options-ui-restart-button').onclick = function() { 256 $('language-options-ui-restart-button').onclick = function() {
252 chrome.send('uiLanguageRestart'); 257 chrome.send('uiLanguageRestart');
253 }; 258 };
254 } 259 }
255 260
256 $('language-confirm').onclick = 261 $('language-confirm').onclick =
257 PageManager.closeOverlay.bind(PageManager); 262 PageManager.closeOverlay.bind(PageManager);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 425 }
421 426
422 this.updateOfferToTranslateCheckbox_(languageCode); 427 this.updateOfferToTranslateCheckbox_(languageCode);
423 428
424 if (cr.isWindows || cr.isChromeOS) 429 if (cr.isWindows || cr.isChromeOS)
425 this.updateUiLanguageButton_(languageCode); 430 this.updateUiLanguageButton_(languageCode);
426 431
427 this.updateSelectedLanguageName_(languageCode); 432 this.updateSelectedLanguageName_(languageCode);
428 433
429 if (!cr.isMac) 434 if (!cr.isMac)
430 this.updateSpellCheckLanguageButton_(languageCode); 435 this.updateSpellCheckLanguageControls_(languageCode);
431 436
432 if (cr.isChromeOS) 437 if (cr.isChromeOS)
433 this.updateInputMethodList_(languageCode); 438 this.updateInputMethodList_(languageCode);
434 439
435 this.updateLanguageListInAddLanguageOverlay_(); 440 this.updateLanguageListInAddLanguageOverlay_();
436 }, 441 },
437 442
438 /** 443 /**
439 * Handles languageOptionsList's save event. 444 * Handles languageOptionsList's save event.
440 * @param {Event} e Save event. 445 * @param {Event} e Save event.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 showMutuallyExclusiveNodes( 602 showMutuallyExclusiveNodes(
598 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); 603 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1);
599 } 604 }
600 }, 605 },
601 606
602 /** 607 /**
603 * Updates the spell check language button. 608 * Updates the spell check language button.
604 * @param {string} languageCode Language code (ex. "fr"). 609 * @param {string} languageCode Language code (ex. "fr").
605 * @private 610 * @private
606 */ 611 */
607 updateSpellCheckLanguageButton_: function(languageCode) { 612 updateSpellCheckLanguageControls_: function(languageCode) {
613 assert(languageCode);
608 var spellCheckLanguageSection = $('language-options-spellcheck'); 614 var spellCheckLanguageSection = $('language-options-spellcheck');
609 var spellCheckLanguageButton = 615 var spellCheckLanguageButton =
610 $('language-options-spell-check-language-button'); 616 $('spellcheck-language-button');
Dan Beam 2015/07/06 23:30:28 fits on one line
Julius 2015/07/07 01:14:21 Done.
617 var spellCheckLanguageCheckboxDiv =
618 $('spellcheck-language-checkbox-container');
619 var spellCheckLanguageCheckbox =
620 $('spellcheck-language-checkbox');
611 var spellCheckLanguageMessage = 621 var spellCheckLanguageMessage =
612 $('language-options-spell-check-language-message'); 622 $('spellcheck-language-message');
613 var dictionaryDownloadInProgress = 623 var dictionaryDownloadInProgress =
614 $('language-options-dictionary-downloading-message'); 624 $('language-options-dictionary-downloading-message');
615 var dictionaryDownloadFailed = 625 var dictionaryDownloadFailed =
616 $('language-options-dictionary-download-failed-message'); 626 $('language-options-dictionary-download-failed-message');
617 var dictionaryDownloadFailHelp = 627 var dictionaryDownloadFailHelp =
618 $('language-options-dictionary-download-fail-help-message'); 628 $('language-options-dictionary-download-fail-help-message');
629
619 spellCheckLanguageSection.hidden = false; 630 spellCheckLanguageSection.hidden = false;
620 spellCheckLanguageMessage.hidden = true; 631 spellCheckLanguageMessage.hidden = true;
621 spellCheckLanguageButton.hidden = true; 632 spellCheckLanguageButton.hidden = true;
633 spellCheckLanguageCheckboxDiv.hidden = true;
622 dictionaryDownloadInProgress.hidden = true; 634 dictionaryDownloadInProgress.hidden = true;
623 dictionaryDownloadFailed.hidden = true; 635 dictionaryDownloadFailed.hidden = true;
624 dictionaryDownloadFailHelp.hidden = true; 636 dictionaryDownloadFailHelp.hidden = true;
637 spellCheckLanguageCheckbox.checked = false;
625 638
626 if (languageCode == this.spellCheckDictionary_) { 639 if (languageCode in loadTimeData.getValue('spellCheckLanguageCodeSet')) {
Dan Beam 2015/07/06 23:30:28 if (!(languageCode in loadTimeData.getValue('spell
Julius 2015/07/07 01:14:21 Done.
627 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) { 640 if (loadTimeData.getBoolean('enableMultilingualSpellChecker')) {
628 spellCheckLanguageMessage.textContent = 641 spellCheckLanguageCheckbox.languageCode = languageCode;
629 loadTimeData.getString('isUsedForSpellChecking'); 642 spellCheckLanguageCheckbox.checked =
630 showMutuallyExclusiveNodes( 643 this.spellCheckLanguages_.hasOwnProperty(languageCode);
Dan Beam 2015/07/06 23:30:28 use "key in obj" or "obj.hasOwnProperty(key)", don
Julius 2015/07/07 01:14:21 I'll use "key in obj" because that's what's used t
631 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); 644 spellCheckLanguageCheckboxDiv.hidden = false;
632 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == 645 } else if (this.spellCheckLanguages_.hasOwnProperty(languageCode)) {
633 DOWNLOAD_STATUS.IN_PROGRESS) { 646 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) {
Dan Beam 2015/07/06 23:30:28 nit: this code would really benefit from things li
Julius 2015/07/07 01:14:21 Done.
634 dictionaryDownloadInProgress.hidden = false; 647 spellCheckLanguageMessage.textContent =
635 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == 648 loadTimeData.getString('isUsedForSpellChecking');
636 DOWNLOAD_STATUS.FAILED) { 649 spellCheckLanguageMessage.hidden = false;
637 spellCheckLanguageSection.hidden = true; 650 }
638 dictionaryDownloadFailed.hidden = false; 651 } else {
639 if (this.spellcheckDictionaryDownloadFailures_ > 1) 652 spellCheckLanguageButton.textContent =
640 dictionaryDownloadFailHelp.hidden = false; 653 loadTimeData.getString('useThisForSpellChecking');
654 spellCheckLanguageButton.hidden = false;
655 spellCheckLanguageButton.languageCode = languageCode;
641 } 656 }
642 } else if (languageCode in 657
643 loadTimeData.getValue('spellCheckLanguageCodeSet')) { 658 switch (this.spellcheckDictionaryDownloadStatus_[languageCode]) {
644 spellCheckLanguageButton.textContent = 659 case DOWNLOAD_STATUS.IN_PROGRESS:
645 loadTimeData.getString('useThisForSpellChecking'); 660 dictionaryDownloadInProgress.hidden = false;
646 showMutuallyExclusiveNodes( 661 break;
647 [spellCheckLanguageButton, spellCheckLanguageMessage], 0); 662 case DOWNLOAD_STATUS.FAILED:
648 spellCheckLanguageButton.languageCode = languageCode; 663 showMutuallyExclusiveNodes(
649 } else if (!languageCode) { 664 [spellCheckLanguageSection, dictionaryDownloadFailed], 1);
650 spellCheckLanguageButton.hidden = true; 665 if (this.spellcheckDictionaryDownloadFailures_ > 1)
651 spellCheckLanguageMessage.hidden = true; 666 dictionaryDownloadFailHelp.hidden = false;
667 break;
668 }
652 } else { 669 } else {
653 spellCheckLanguageMessage.textContent = 670 spellCheckLanguageMessage.textContent =
654 loadTimeData.getString('cannotBeUsedForSpellChecking'); 671 loadTimeData.getString('cannotBeUsedForSpellChecking');
655 showMutuallyExclusiveNodes( 672 spellCheckLanguageMessage.hidden = false;
656 [spellCheckLanguageButton, spellCheckLanguageMessage], 1);
657 } 673 }
658 }, 674 },
659 675
660 /** 676 /**
661 * Updates the checkbox for stopping translation. 677 * Updates the checkbox for stopping translation.
662 * @param {string} languageCode Language code (ex. "fr"). 678 * @param {string} languageCode Language code (ex. "fr").
663 * @private 679 * @private
664 */ 680 */
665 updateOfferToTranslateCheckbox_: function(languageCode) { 681 updateOfferToTranslateCheckbox_: function(languageCode) {
666 var div = $('language-options-offer-to-translate'); 682 var div = $('language-options-offer-to-translate');
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 return (!cr.isChromeOS || 928 return (!cr.isChromeOS ||
913 this.canDeleteLanguage_(languageCode)); 929 this.canDeleteLanguage_(languageCode));
914 }, 930 },
915 931
916 /** 932 /**
917 * Handles browse.enable_spellchecking change. 933 * Handles browse.enable_spellchecking change.
918 * @param {Event} e Change event. 934 * @param {Event} e Change event.
919 * @private 935 * @private
920 */ 936 */
921 updateEnableSpellCheck_: function(e) { 937 updateEnableSpellCheck_: function(e) {
922 var value = !$('enable-spell-check').checked; 938 var value = !$('enable-spellcheck').checked;
923 $('language-options-spell-check-language-button').disabled = value; 939 $('spellcheck-language-button').disabled = value;
924 if (!cr.isMac) 940 if (!cr.isMac)
925 $('edit-dictionary-button').hidden = value; 941 $('edit-dictionary-button').hidden = value;
926 }, 942 },
927 943
928 /** 944 /**
929 * Handles translateBlockedLanguagesPref change. 945 * Handles translateBlockedLanguagesPref change.
930 * @param {Event} e Change event. 946 * @param {Event} e Change event.
931 * @private 947 * @private
932 */ 948 */
933 handleTranslateBlockedLanguagesPrefChange_: function(e) { 949 handleTranslateBlockedLanguagesPrefChange_: function(e) {
934 this.translateBlockedLanguages_ = e.value.value; 950 this.translateBlockedLanguages_ = e.value.value;
935 this.updateOfferToTranslateCheckbox_( 951 this.updateOfferToTranslateCheckbox_(
936 $('language-options-list').getSelectedLanguageCode()); 952 $('language-options-list').getSelectedLanguageCode());
937 }, 953 },
938 954
939 /** 955 /**
940 * Handles spellCheckDictionaryPref change. 956 * Updates spellcheck dictionary UI (checkboxes, buttons, and labels) when
941 * @param {Event} e Change event. 957 * preferences change.
958 * @param {Event} e Preference change event where e.value.value is the list
959 * of languages currently used for spellchecking.
942 * @private 960 * @private
943 */ 961 */
944 handleSpellCheckDictionaryPrefChange_: function(e) { 962 handleSpellCheckDictionariesPrefChange_: function(e) {
945 var languageCode = e.value.value; 963 if (cr.isMac)
946 this.spellCheckDictionary_ = languageCode; 964 return;
947 if (!cr.isMac) { 965
948 this.updateSpellCheckLanguageButton_( 966 var languages = e.value.value;
949 $('language-options-list').getSelectedLanguageCode()); 967 this.spellCheckLanguages_ = {};
950 } 968 for (var i = 0; i < languages.length; i++)
969 this.spellCheckLanguages_[languages[i]] = true;
Dan Beam 2015/07/06 23:30:28 curlies
Julius 2015/07/07 01:14:20 Done.
970 this.updateSpellCheckLanguageControls_(
971 $('language-options-list').getSelectedLanguageCode());
951 }, 972 },
952 973
953 /** 974 /**
954 * Handles translate.enabled change. 975 * Handles translate.enabled change.
955 * @param {Event} e Change event. 976 * @param {Event} e Change event.
956 * @private 977 * @private
957 */ 978 */
958 handleEnableTranslatePrefChange_: function(e) { 979 handleEnableTranslatePrefChange_: function(e) {
959 var enabled = e.value.value; 980 var enabled = e.value.value;
960 this.enableTranslate_ = enabled; 981 this.enableTranslate_ = enabled;
961 this.updateOfferToTranslateCheckbox_( 982 this.updateOfferToTranslateCheckbox_(
962 $('language-options-list').getSelectedLanguageCode()); 983 $('language-options-list').getSelectedLanguageCode());
963 }, 984 },
964 985
965 /** 986 /**
966 * Handles spellCheckLanguageButton click. 987 * Handles spellCheckLanguageButton click.
967 * @param {Event} e Click event. 988 * @param {Event} e Click event.
968 * @private 989 * @private
969 */ 990 */
970 handleSpellCheckLanguageButtonClick_: function(e) { 991 handleSpellCheckLanguageButtonClick_: function(e) {
971 var languageCodes = [e.target.languageCode]; 992 var languageCode = e.target.languageCode;
972 // Save the preference. 993 // Save the preference.
973 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF, 994 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF,
995 [languageCode], true);
996
997 // The spellCheckLanguageChange argument is only used for logging.
998 chrome.send('spellCheckLanguageChange', [languageCode]);
999 chrome.send('coreOptionsUserMetricsAction',
1000 ['Options_Languages_SpellCheck']);
1001 },
1002
1003 /**
1004 * Updates the spellcheck.dictionaries preference with the currently
1005 * selected language codes.
1006 * @param {Event} e Click event. e.target represents the "Use this language
1007 * for spellchecking"
1008 * @private
1009 */
1010 handleSpellCheckLanguageCheckboxClick_: function(e) {
1011 var languageCode = e.target.languageCode;
Dan Beam 2015/07/06 23:30:28 target -> currentTarget
Julius 2015/07/07 01:14:20 Done.
1012
1013 if (e.target.checked)
1014 this.spellCheckLanguages_[languageCode] = true;
1015 else
1016 delete this.spellCheckLanguages_[languageCode];
1017
1018 var languageCodes = Object.keys(this.spellCheckLanguages_);
1019 Preferences.setListPref(SPELL_CHECK_DICTIONARIES_PREF,
974 languageCodes, true); 1020 languageCodes, true);
1021
975 // The spellCheckLanguageChange argument is only used for logging. 1022 // The spellCheckLanguageChange argument is only used for logging.
976 chrome.send('spellCheckLanguageChange', [languageCodes.join(',')]); 1023 chrome.send('spellCheckLanguageChange', [languageCodes.join(',')]);
977 chrome.send('coreOptionsUserMetricsAction', 1024 chrome.send('coreOptionsUserMetricsAction',
978 ['Options_Languages_SpellCheck']); 1025 ['Options_Languages_SpellCheck']);
979 }, 1026 },
980 1027
981 /** 1028 /**
982 * Checks whether it's possible to remove the language specified by 1029 * Checks whether it's possible to remove the language specified by
983 * languageCode and returns true if possible. This function returns false 1030 * languageCode and returns true if possible. This function returns false
984 * if the removal causes the number of preload engines to be zero. 1031 * if the removal causes the number of preload engines to be zero.
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 * @param {string} languageCode The language of the dictionary that just 1317 * @param {string} languageCode The language of the dictionary that just
1271 * began downloading. 1318 * began downloading.
1272 * @private 1319 * @private
1273 */ 1320 */
1274 onDictionaryDownloadBegin_: function(languageCode) { 1321 onDictionaryDownloadBegin_: function(languageCode) {
1275 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1322 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1276 DOWNLOAD_STATUS.IN_PROGRESS; 1323 DOWNLOAD_STATUS.IN_PROGRESS;
1277 if (!cr.isMac && 1324 if (!cr.isMac &&
1278 languageCode == 1325 languageCode ==
1279 $('language-options-list').getSelectedLanguageCode()) { 1326 $('language-options-list').getSelectedLanguageCode()) {
1280 this.updateSpellCheckLanguageButton_(languageCode); 1327 this.updateSpellCheckLanguageControls_(languageCode);
1281 } 1328 }
1282 }, 1329 },
1283 1330
1284 /** 1331 /**
1285 * A handler for when dictionary for |languageCode| successfully downloaded. 1332 * A handler for when dictionary for |languageCode| successfully downloaded.
1286 * @param {string} languageCode The language of the dictionary that 1333 * @param {string} languageCode The language of the dictionary that
1287 * succeeded downloading. 1334 * succeeded downloading.
1288 * @private 1335 * @private
1289 */ 1336 */
1290 onDictionaryDownloadSuccess_: function(languageCode) { 1337 onDictionaryDownloadSuccess_: function(languageCode) {
1291 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; 1338 delete this.spellcheckDictionaryDownloadStatus_[languageCode];
1292 this.spellcheckDictionaryDownloadFailures_ = 0; 1339 this.spellcheckDictionaryDownloadFailures_ = 0;
1293 if (!cr.isMac && 1340 if (!cr.isMac &&
1294 languageCode == 1341 languageCode ==
1295 $('language-options-list').getSelectedLanguageCode()) { 1342 $('language-options-list').getSelectedLanguageCode()) {
1296 this.updateSpellCheckLanguageButton_(languageCode); 1343 this.updateSpellCheckLanguageControls_(languageCode);
1297 } 1344 }
1298 }, 1345 },
1299 1346
1300 /** 1347 /**
1301 * A handler for when dictionary for |languageCode| fails to download. 1348 * A handler for when dictionary for |languageCode| fails to download.
1302 * @param {string} languageCode The language of the dictionary that failed 1349 * @param {string} languageCode The language of the dictionary that failed
1303 * to download. 1350 * to download.
1304 * @private 1351 * @private
1305 */ 1352 */
1306 onDictionaryDownloadFailure_: function(languageCode) { 1353 onDictionaryDownloadFailure_: function(languageCode) {
1307 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1354 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1308 DOWNLOAD_STATUS.FAILED; 1355 DOWNLOAD_STATUS.FAILED;
1309 this.spellcheckDictionaryDownloadFailures_++; 1356 this.spellcheckDictionaryDownloadFailures_++;
1310 if (!cr.isMac && 1357 if (!cr.isMac &&
1311 languageCode == 1358 languageCode ==
1312 $('language-options-list').getSelectedLanguageCode()) { 1359 $('language-options-list').getSelectedLanguageCode()) {
1313 this.updateSpellCheckLanguageButton_(languageCode); 1360 this.updateSpellCheckLanguageControls_(languageCode);
1314 } 1361 }
1315 }, 1362 },
1316 1363
1317 /** 1364 /**
1318 * Converts the language code for Translation. There are some differences 1365 * Converts the language code for Translation. There are some differences
1319 * between the language set for Translation and that for Accept-Language. 1366 * between the language set for Translation and that for Accept-Language.
1320 * @param {string} languageCode The language code like 'fr'. 1367 * @param {string} languageCode The language code like 'fr'.
1321 * @return {string} The converted language code. 1368 * @return {string} The converted language code.
1322 * @private 1369 * @private
1323 */ 1370 */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 }; 1417 };
1371 1418
1372 LanguageOptions.onDictionaryDownloadSuccess = function(languageCode) { 1419 LanguageOptions.onDictionaryDownloadSuccess = function(languageCode) {
1373 LanguageOptions.getInstance().onDictionaryDownloadSuccess_(languageCode); 1420 LanguageOptions.getInstance().onDictionaryDownloadSuccess_(languageCode);
1374 }; 1421 };
1375 1422
1376 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { 1423 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) {
1377 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); 1424 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode);
1378 }; 1425 };
1379 1426
1427 LanguageOptions.updateSpellCheckLanguageControls = function(languageCode) {
1428 var instance = LanguageOptions.getInstance();
1429 instance.updateSpellCheckLanguageControls_(languageCode);
1430 };
1380 // Export 1431 // Export
1381 return { 1432 return {
1382 LanguageOptions: LanguageOptions 1433 LanguageOptions: LanguageOptions
1383 }; 1434 };
1384 }); 1435 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698