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

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: Addressed comments. Created 5 years, 10 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}
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 list of currently selected spell check dictionary languages, like
156 * "en-US, sl-SI".
please use gerrit instead 2015/02/24 23:38:38 Since this is a list of strings instead of a comma
Klemen Forstnerič 2015/02/25 09:48:23 Actually it's a dictionary. I forgot to change the
please use gerrit instead 2015/02/25 18:16:15 I'm not sure why this is a dictionary instead of a
Klemen Forstnerič 2015/02/26 15:37:42 I figured that since we're determining whether som
please use gerrit instead 2015/02/26 16:03:12 Dan, what's the best JS collection data structure
Dan Beam 2015/02/26 18:49:50 yeah, an object (see: hash map) is good for this.
157 * @type {array}
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 (languageCode in this.spellCheckDictionaries_)
673 spellCheckLanguageCheckbox.checked = true;
please use gerrit instead 2015/02/24 23:38:38 We usually put a newline after an if-statement to
Klemen Forstnerič 2015/02/25 09:48:23 Done.
674 spellCheckLanguageCheckboxDiv.hidden = false;
675 } else if (languageCode == this.spellCheckDictionary_) {
676 if (!(languageCode in this.spellcheckDictionaryDownloadStatus_)) {
677 spellCheckLanguageMessage.textContent =
678 loadTimeData.getString('isUsedForSpellChecking');
679 spellCheckLanguageMessage.hidden = false;
680 }
681 } else {
682 spellCheckLanguageButton.textContent =
683 loadTimeData.getString('useThisForSpellChecking');
684 spellCheckLanguageButton.hidden = false;
685 }
686
687 if (this.spellcheckDictionaryDownloadStatus_[languageCode] ==
688 DOWNLOAD_STATUS_IN_PROGRESS) {
634 dictionaryDownloadInProgress.hidden = false; 689 dictionaryDownloadInProgress.hidden = false;
635 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] == 690 } else if (this.spellcheckDictionaryDownloadStatus_[languageCode] ==
636 DOWNLOAD_STATUS.FAILED) { 691 DOWNLOAD_STATUS.FAILED) {
637 spellCheckLanguageSection.hidden = true; 692 showMutuallyExclusiveNodes(
638 dictionaryDownloadFailed.hidden = false; 693 [spellCheckLanguageSection, dictionaryDownloadFailed], 1);
639 if (this.spellcheckDictionaryDownloadFailures_ > 1) 694 if (this.spellcheckDictionaryDownloadFailures_ > 1)
640 dictionaryDownloadFailHelp.hidden = false; 695 dictionaryDownloadFailHelp.hidden = false;
641 } 696 }
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 { 697 } else {
653 spellCheckLanguageMessage.textContent = 698 spellCheckLanguageMessage.textContent =
654 loadTimeData.getString('cannotBeUsedForSpellChecking'); 699 loadTimeData.getString('cannotBeUsedForSpellChecking');
655 showMutuallyExclusiveNodes( 700 spellCheckLanguageMessage.hidden = false;
656 [spellCheckLanguageButton, spellCheckLanguageMessage], 1);
657 } 701 }
658 }, 702 },
659 703
660 /** 704 /**
661 * Updates the checkbox for stopping translation. 705 * Updates the checkbox for stopping translation.
662 * @param {string} languageCode Language code (ex. "fr"). 706 * @param {string} languageCode Language code (ex. "fr").
663 * @private 707 * @private
664 */ 708 */
665 updateOfferToTranslateCheckbox_: function(languageCode) { 709 updateOfferToTranslateCheckbox_: function(languageCode) {
666 var div = $('language-options-offer-to-translate'); 710 var div = $('language-options-offer-to-translate');
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 982
939 /** 983 /**
940 * Handles spellCheckDictionaryPref change. 984 * Handles spellCheckDictionaryPref change.
941 * @param {Event} e Change event. 985 * @param {Event} e Change event.
942 * @private 986 * @private
943 */ 987 */
944 handleSpellCheckDictionaryPrefChange_: function(e) { 988 handleSpellCheckDictionaryPrefChange_: function(e) {
945 var languageCode = e.value.value; 989 var languageCode = e.value.value;
946 this.spellCheckDictionary_ = languageCode; 990 this.spellCheckDictionary_ = languageCode;
947 if (!cr.isMac) { 991 if (!cr.isMac) {
948 this.updateSpellCheckLanguageButton_( 992 this.updateSpellCheckLanguageControls_(
949 $('language-options-list').getSelectedLanguageCode()); 993 $('language-options-list').getSelectedLanguageCode());
950 } 994 }
951 }, 995 },
952 996
997 handleSpellCheckDictionariesPrefChange_: function(e) {
please use gerrit instead 2015/02/24 23:38:38 Add a comment please.
Klemen Forstnerič 2015/02/25 09:48:23 Done.
998 if (cr.isMac)
999 return;
1000
1001 var commaSeparatedLanguageCodes = e.value.value;
1002 var languageCodesSplit = commaSeparatedLanguageCodes.split(',');
1003
1004 this.spellCheckDictionaries_ = {};
1005 for (var i = 0; i < languageCodesSplit.length; i++)
1006 this.spellCheckDictionaries_[languageCodesSplit[i]] = true;
1007
1008 this.updateSpellCheckLanguageControls_(
1009 $('language-options-list').getSelectedLanguageCode());
1010 },
1011
953 /** 1012 /**
954 * Handles translate.enabled change. 1013 * Handles translate.enabled change.
955 * @param {Event} e Change event. 1014 * @param {Event} e Change event.
956 * @private 1015 * @private
957 */ 1016 */
958 handleEnableTranslatePrefChange_: function(e) { 1017 handleEnableTranslatePrefChange_: function(e) {
959 var enabled = e.value.value; 1018 var enabled = e.value.value;
960 this.enableTranslate_ = enabled; 1019 this.enableTranslate_ = enabled;
961 this.updateOfferToTranslateCheckbox_( 1020 this.updateOfferToTranslateCheckbox_(
962 $('language-options-list').getSelectedLanguageCode()); 1021 $('language-options-list').getSelectedLanguageCode());
963 }, 1022 },
964 1023
965 /** 1024 /**
966 * Handles spellCheckLanguageButton click. 1025 * Handles spellCheckLanguageButton click.
967 * @param {Event} e Click event. 1026 * @param {Event} e Click event.
968 * @private 1027 * @private
969 */ 1028 */
970 handleSpellCheckLanguageButtonClick_: function(e) { 1029 handleSpellCheckLanguageButtonClick_: function(e) {
971 var languageCode = e.target.languageCode; 1030 var languageCode = e.target.languageCode;
972 // Save the preference. 1031 // Save the preference.
973 Preferences.setStringPref(SPELL_CHECK_DICTIONARY_PREF, 1032 Preferences.setStringPref(SPELL_CHECK_DICTIONARY_PREF,
974 languageCode, true); 1033 languageCode, true);
975 chrome.send('spellCheckLanguageChange', [languageCode]); 1034 chrome.send('spellCheckLanguageChange', [languageCode]);
976 chrome.send('coreOptionsUserMetricsAction', 1035 chrome.send('coreOptionsUserMetricsAction',
977 ['Options_Languages_SpellCheck']); 1036 ['Options_Languages_SpellCheck']);
978 }, 1037 },
979 1038
980 /** 1039 /**
1040 * Handles spellCheckLanguageCheckbox click.
1041 * @param {Event} e Click event.
1042 * @private
1043 */
1044 handleSpellCheckLanguageCheckboxClick_: function(e) {
1045 var languageCode = e.target.languageCode;
1046
1047 if (e.target.checked)
1048 this.spellCheckDictionaries_[languageCode] = true;
1049 else
1050 delete this.spellCheckDictionaries_[languageCode];
1051
1052 var languageCodes = [];
1053 for (var currentLanguageCode in this.spellCheckDictionaries_) {
1054 if (this.spellCheckDictionaries_.hasOwnProperty(currentLanguageCode))
1055 languageCodes.push(currentLanguageCode);
1056 }
1057
1058 Preferences.setStringPref(SPELL_CHECK_DICTIONARIES_PREF,
1059 languageCodes.join(','), true);
1060 },
1061
1062 /**
981 * Checks whether it's possible to remove the language specified by 1063 * Checks whether it's possible to remove the language specified by
982 * languageCode and returns true if possible. This function returns false 1064 * languageCode and returns true if possible. This function returns false
983 * if the removal causes the number of preload engines to be zero. 1065 * if the removal causes the number of preload engines to be zero.
984 * 1066 *
985 * @param {string} languageCode Language code (ex. "fr"). 1067 * @param {string} languageCode Language code (ex. "fr").
986 * @return {boolean} Returns true on success. 1068 * @return {boolean} Returns true on success.
987 * @private 1069 * @private
988 */ 1070 */
989 canDeleteLanguage_: function(languageCode) { 1071 canDeleteLanguage_: function(languageCode) {
990 // First create the set of engines to be removed from input methods 1072 // 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 1351 * @param {string} languageCode The language of the dictionary that just
1270 * began downloading. 1352 * began downloading.
1271 * @private 1353 * @private
1272 */ 1354 */
1273 onDictionaryDownloadBegin_: function(languageCode) { 1355 onDictionaryDownloadBegin_: function(languageCode) {
1274 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1356 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1275 DOWNLOAD_STATUS.IN_PROGRESS; 1357 DOWNLOAD_STATUS.IN_PROGRESS;
1276 if (!cr.isMac && 1358 if (!cr.isMac &&
1277 languageCode == 1359 languageCode ==
1278 $('language-options-list').getSelectedLanguageCode()) { 1360 $('language-options-list').getSelectedLanguageCode()) {
1279 this.updateSpellCheckLanguageButton_(languageCode); 1361 this.updateSpellCheckLanguageControls_(languageCode);
1280 } 1362 }
1281 }, 1363 },
1282 1364
1283 /** 1365 /**
1284 * A handler for when dictionary for |languageCode| successfully downloaded. 1366 * A handler for when dictionary for |languageCode| successfully downloaded.
1285 * @param {string} languageCode The language of the dictionary that 1367 * @param {string} languageCode The language of the dictionary that
1286 * succeeded downloading. 1368 * succeeded downloading.
1287 * @private 1369 * @private
1288 */ 1370 */
1289 onDictionaryDownloadSuccess_: function(languageCode) { 1371 onDictionaryDownloadSuccess_: function(languageCode) {
1290 delete this.spellcheckDictionaryDownloadStatus_[languageCode]; 1372 delete this.spellcheckDictionaryDownloadStatus_[languageCode];
1291 this.spellcheckDictionaryDownloadFailures_ = 0; 1373 this.spellcheckDictionaryDownloadFailures_ = 0;
1292 if (!cr.isMac && 1374 if (!cr.isMac &&
1293 languageCode == 1375 languageCode ==
1294 $('language-options-list').getSelectedLanguageCode()) { 1376 $('language-options-list').getSelectedLanguageCode()) {
1295 this.updateSpellCheckLanguageButton_(languageCode); 1377 this.updateSpellCheckLanguageControls_(languageCode);
1296 } 1378 }
1297 }, 1379 },
1298 1380
1299 /** 1381 /**
1300 * A handler for when dictionary for |languageCode| fails to download. 1382 * A handler for when dictionary for |languageCode| fails to download.
1301 * @param {string} languageCode The language of the dictionary that failed 1383 * @param {string} languageCode The language of the dictionary that failed
1302 * to download. 1384 * to download.
1303 * @private 1385 * @private
1304 */ 1386 */
1305 onDictionaryDownloadFailure_: function(languageCode) { 1387 onDictionaryDownloadFailure_: function(languageCode) {
1306 this.spellcheckDictionaryDownloadStatus_[languageCode] = 1388 this.spellcheckDictionaryDownloadStatus_[languageCode] =
1307 DOWNLOAD_STATUS.FAILED; 1389 DOWNLOAD_STATUS.FAILED;
1308 this.spellcheckDictionaryDownloadFailures_++; 1390 this.spellcheckDictionaryDownloadFailures_++;
1309 if (!cr.isMac && 1391 if (!cr.isMac &&
1310 languageCode == 1392 languageCode ==
1311 $('language-options-list').getSelectedLanguageCode()) { 1393 $('language-options-list').getSelectedLanguageCode()) {
1312 this.updateSpellCheckLanguageButton_(languageCode); 1394 this.updateSpellCheckLanguageControls_(languageCode);
1313 } 1395 }
1314 }, 1396 },
1315 1397
1316 /** 1398 /**
1317 * Converts the language code for Translation. There are some differences 1399 * Converts the language code for Translation. There are some differences
1318 * between the language set for Translation and that for Accept-Language. 1400 * between the language set for Translation and that for Accept-Language.
1319 * @param {string} languageCode The language code like 'fr'. 1401 * @param {string} languageCode The language code like 'fr'.
1320 * @return {string} The converted language code. 1402 * @return {string} The converted language code.
1321 * @private 1403 * @private
1322 */ 1404 */
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 1456
1375 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) { 1457 LanguageOptions.onDictionaryDownloadFailure = function(languageCode) {
1376 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode); 1458 LanguageOptions.getInstance().onDictionaryDownloadFailure_(languageCode);
1377 }; 1459 };
1378 1460
1379 // Export 1461 // Export
1380 return { 1462 return {
1381 LanguageOptions: LanguageOptions 1463 LanguageOptions: LanguageOptions
1382 }; 1464 };
1383 }); 1465 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698