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

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

Issue 654653002: Enables the user to select multiple languages for spellchecking (UI) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a regression. Created 5 years, 9 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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}
Dan Beam 2015/03/02 22:40:08 nit: @const {string} is shorter (and a newer synta
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
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}".
Dan Beam 2015/03/02 22:40:08 nit: remove quotes around the dictionary, e.g.
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
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
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
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
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;
Dan Beam 2015/03/02 22:40:08 nit: spellCheckLanguageCheckbox.checked =
674
675 spellCheckLanguageCheckboxDiv.hidden = false;
676 } else if (languageCode == this.spellCheckDictionary_) {
Dan Beam 2015/03/02 22:40:08 how will a string ever be equal to a dictionary?
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 spellCheckLanguageButton.languageCode = languageCode;
687 }
688
Dan Beam 2015/03/02 22:40:08 var status = this.spellcheckDictionaryDownloadStat
689 if (this.spellcheckDictionaryDownloadStatus_[languageCode] ==
690 DOWNLOAD_STATUS.IN_PROGRESS) {
634 dictionaryDownloadInProgress.hidden = false; 691 dictionaryDownloadInProgress.hidden = false;
635 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == 692 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] ==
636 DOWNLOAD_STATUS.FAILED) { 693 DOWNLOAD_STATUS.FAILED) {
637 spellCheckLanguageSection.hidden = true; 694 showMutuallyExclusiveNodes(
638 dictionaryDownloadFailed.hidden = false; 695 [spellCheckLanguageSection, dictionaryDownloadFailed], 1);
639 if (this.spellcheckDictionaryDownloadFailures_ > 1) 696 if (this.spellcheckDictionaryDownloadFailures_ > 1)
640 dictionaryDownloadFailHelp.hidden = false; 697 dictionaryDownloadFailHelp.hidden = false;
641 } 698 }
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 { 699 } else {
653 spellCheckLanguageMessage.textContent = 700 spellCheckLanguageMessage.textContent =
654 loadTimeData.getString('cannotBeUsedForSpellChecking'); 701 loadTimeData.getString('cannotBeUsedForSpellChecking');
655 showMutuallyExclusiveNodes( 702 spellCheckLanguageMessage.hidden = false;
656 [spellCheckLanguageButton, spellCheckLanguageMessage], 1);
657 } 703 }
658 }, 704 },
659 705
660 /** 706 /**
661 * Updates the checkbox for stopping translation. 707 * Updates the checkbox for stopping translation.
662 * @param {string} languageCode Language code (ex. "fr"). 708 * @param {string} languageCode Language code (ex. "fr").
663 * @private 709 * @private
664 */ 710 */
665 updateOfferToTranslateCheckbox_: function(languageCode) { 711 updateOfferToTranslateCheckbox_: function(languageCode) {
666 var div = $('language-options-offer-to-translate'); 712 var div = $('language-options-offer-to-translate');
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 984
939 /** 985 /**
940 * Handles spellCheckDictionaryPref change. 986 * Handles spellCheckDictionaryPref change.
941 * @param {Event} e Change event. 987 * @param {Event} e Change event.
942 * @private 988 * @private
943 */ 989 */
944 handleSpellCheckDictionaryPrefChange_: function(e) { 990 handleSpellCheckDictionaryPrefChange_: function(e) {
945 var languageCode = e.value.value; 991 var languageCode = e.value.value;
946 this.spellCheckDictionary_ = languageCode; 992 this.spellCheckDictionary_ = languageCode;
947 if (!cr.isMac) { 993 if (!cr.isMac) {
948 this.updateSpellCheckLanguageButton_( 994 this.updateSpellCheckLanguageControls_(
949 $('language-options-list').getSelectedLanguageCode()); 995 $('language-options-list').getSelectedLanguageCode());
950 } 996 }
951 }, 997 },
952 998
953 /** 999 /**
1000 * Updates spellcheck dictionary UI (checkboxes, buttons, and labels) when
1001 * preferences change.
1002 * @param {Event} e. Preference change event where e.value.value is the
1003 * comma separated list of languages currently used for spellchecking.
1004 * @private
1005 */
1006 handleSpellCheckDictionariesPrefChange_: function(e) {
1007 if (cr.isMac)
1008 return;
1009
1010 var commaSeparatedLanguageCodes = e.value.value;
1011 var languageCodesSplit = commaSeparatedLanguageCodes.split(',');
1012
1013 this.spellCheckDictionaries_ = {};
1014 for (var i = 0; i < languageCodesSplit.length; i++)
1015 this.spellCheckDictionaries_[languageCodesSplit[i]] = true;
1016
1017 this.updateSpellCheckLanguageControls_(
1018 $('language-options-list').getSelectedLanguageCode());
1019 },
1020
1021 /**
954 * Handles translate.enabled change. 1022 * Handles translate.enabled change.
955 * @param {Event} e Change event. 1023 * @param {Event} e Change event.
956 * @private 1024 * @private
957 */ 1025 */
958 handleEnableTranslatePrefChange_: function(e) { 1026 handleEnableTranslatePrefChange_: function(e) {
959 var enabled = e.value.value; 1027 var enabled = e.value.value;
960 this.enableTranslate_ = enabled; 1028 this.enableTranslate_ = enabled;
961 this.updateOfferToTranslateCheckbox_( 1029 this.updateOfferToTranslateCheckbox_(
962 $('language-options-list').getSelectedLanguageCode()); 1030 $('language-options-list').getSelectedLanguageCode());
963 }, 1031 },
964 1032
965 /** 1033 /**
966 * Handles spellCheckLanguageButton click. 1034 * Handles spellCheckLanguageButton click.
967 * @param {Event} e Click event. 1035 * @param {Event} e Click event.
968 * @private 1036 * @private
969 */ 1037 */
970 handleSpellCheckLanguageButtonClick_: function(e) { 1038 handleSpellCheckLanguageButtonClick_: function(e) {
971 var languageCode = e.target.languageCode; 1039 var languageCode = e.target.languageCode;
972 // Save the preference. 1040 // Save the preference.
973 Preferences.setStringPref(SPELL_CHECK_DICTIONARY_PREF, 1041 Preferences.setStringPref(SPELL_CHECK_DICTIONARY_PREF,
974 languageCode, true); 1042 languageCode, true);
975 chrome.send('spellCheckLanguageChange', [languageCode]); 1043 chrome.send('spellCheckLanguageChange', [languageCode]);
976 chrome.send('coreOptionsUserMetricsAction', 1044 chrome.send('coreOptionsUserMetricsAction',
977 ['Options_Languages_SpellCheck']); 1045 ['Options_Languages_SpellCheck']);
978 }, 1046 },
979 1047
980 /** 1048 /**
1049 * Updates the spellcheck.dictionaries preference with the currently
1050 * selected language codes.
1051 * @param {Event} e Click event. e.target represents the "Use this language
1052 * for spellchecking"
1053 * @private
1054 */
1055 handleSpellCheckLanguageCheckboxClick_: function(e) {
1056 var languageCode = e.target.languageCode;
1057
1058 if (e.target.checked)
1059 this.spellCheckDictionaries_[languageCode] = true;
1060 else
1061 delete this.spellCheckDictionaries_[languageCode];
1062
1063 var languageCodes = [];
1064 for (var currentLanguageCode in this.spellCheckDictionaries_) {
1065 if (this.spellCheckDictionaries_.hasOwnProperty(currentLanguageCode))
1066 languageCodes.push(currentLanguageCode);
1067 }
1068
1069 Preferences.setStringPref(SPELL_CHECK_DICTIONARIES_PREF,
1070 languageCodes.join(','), true);
1071 },
1072
1073 /**
981 * Checks whether it's possible to remove the language specified by 1074 * Checks whether it's possible to remove the language specified by
982 * languageCode and returns true if possible. This function returns false 1075 * languageCode and returns true if possible. This function returns false
983 * if the removal causes the number of preload engines to be zero. 1076 * if the removal causes the number of preload engines to be zero.
984 * 1077 *
985 * @param {string} languageCode Language code (ex. "fr"). 1078 * @param {string} languageCode Language code (ex. "fr").
986 * @return {boolean} Returns true on success. 1079 * @return {boolean} Returns true on success.
987 * @private 1080 * @private
988 */ 1081 */
989 canDeleteLanguage_: function(languageCode) { 1082 canDeleteLanguage_: function(languageCode) {
990 // First create the set of engines to be removed from input methods 1083 // First create the set of engines to be removed from input methods
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 * @param {string} languageCode The language of the dictionary that just 1362 * @param {string} languageCode The language of the dictionary that just
1270 * began downloading. 1363 * began downloading.
1271 * @private 1364 * @private
1272 */ 1365 */
1273 onDictionaryDownloadBegin_: function(languageCode) { 1366 onDictionaryDownloadBegin_: function(languageCode) {
1274 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1367 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1275 DOWNLOAD_STATUS.IN_PROGRESS; 1368 DOWNLOAD_STATUS.IN_PROGRESS;
1276 if (!cr.isMac && 1369 if (!cr.isMac &&
1277 languageCode == 1370 languageCode ==
1278 $('language-options-list').getSelectedLanguageCode()) { 1371 $('language-options-list').getSelectedLanguageCode()) {
1279 this.updateSpellCheckLanguageButton_(languageCode); 1372 this.updateSpellCheckLanguageControls_(languageCode);
1280 } 1373 }
1281 }, 1374 },
1282 1375
1283 /** 1376 /**
1284 * A handler for when dictionary for |languageCode| successfully downloaded. 1377 * A handler for when dictionary for |languageCode| successfully downloaded.
1285 * @param {string} languageCode The language of the dictionary that 1378 * @param {string} languageCode The language of the dictionary that
1286 * succeeded downloading. 1379 * succeeded downloading.
1287 * @private 1380 * @private
1288 */ 1381 */
1289 onDictionaryDownloadSuccess_: function(languageCode) { 1382 onDictionaryDownloadSuccess_: function(languageCode) {
1290 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; 1383 delete this.spellcheckDictionaryDownloadStatus_[languageCode];
1291 this.spellcheckDictionaryDownloadFailures_ = 0; 1384 this.spellcheckDictionaryDownloadFailures_ = 0;
1292 if (!cr.isMac && 1385 if (!cr.isMac &&
1293 languageCode == 1386 languageCode ==
1294 $('language-options-list').getSelectedLanguageCode()) { 1387 $('language-options-list').getSelectedLanguageCode()) {
1295 this.updateSpellCheckLanguageButton_(languageCode); 1388 this.updateSpellCheckLanguageControls_(languageCode);
1296 } 1389 }
1297 }, 1390 },
1298 1391
1299 /** 1392 /**
1300 * A handler for when dictionary for |languageCode| fails to download. 1393 * A handler for when dictionary for |languageCode| fails to download.
1301 * @param {string} languageCode The language of the dictionary that failed 1394 * @param {string} languageCode The language of the dictionary that failed
1302 * to download. 1395 * to download.
1303 * @private 1396 * @private
1304 */ 1397 */
1305 onDictionaryDownloadFailure_: function(languageCode) { 1398 onDictionaryDownloadFailure_: function(languageCode) {
1306 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1399 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1307 DOWNLOAD_STATUS.FAILED; 1400 DOWNLOAD_STATUS.FAILED;
1308 this.spellcheckDictionaryDownloadFailures_++; 1401 this.spellcheckDictionaryDownloadFailures_++;
1309 if (!cr.isMac && 1402 if (!cr.isMac &&
1310 languageCode == 1403 languageCode ==
1311 $('language-options-list').getSelectedLanguageCode()) { 1404 $('language-options-list').getSelectedLanguageCode()) {
1312 this.updateSpellCheckLanguageButton_(languageCode); 1405 this.updateSpellCheckLanguageControls_(languageCode);
1313 } 1406 }
1314 }, 1407 },
1315 1408
1316 /** 1409 /**
1317 * Converts the language code for Translation. There are some differences 1410 * Converts the language code for Translation. There are some differences
1318 * between the language set for Translation and that for Accept-Language. 1411 * between the language set for Translation and that for Accept-Language.
1319 * @param {string} languageCode The language code like 'fr'. 1412 * @param {string} languageCode The language code like 'fr'.
1320 * @return {string} The converted language code. 1413 * @return {string} The converted language code.
1321 * @private 1414 * @private
1322 */ 1415 */
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 1467
1375 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { 1468 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) {
1376 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); 1469 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode);
1377 }; 1470 };
1378 1471
1379 // Export 1472 // Export
1380 return { 1473 return {
1381 LanguageOptions: LanguageOptions 1474 LanguageOptions: LanguageOptions
1382 }; 1475 };
1383 }); 1476 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698