| 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 OptionsPage = options.OptionsPage; | 9 /** @const */ var OptionsPage = options.OptionsPage; |
| 10 /** @const */ var LanguageList = options.LanguageList; | 10 /** @const */ var LanguageList = options.LanguageList; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 ///////////////////////////////////////////////////////////////////////////// | 24 ///////////////////////////////////////////////////////////////////////////// |
| 25 // LanguageOptions class: | 25 // LanguageOptions class: |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Encapsulated handling of ChromeOS language options page. | 28 * Encapsulated handling of ChromeOS language options page. |
| 29 * @constructor | 29 * @constructor |
| 30 */ | 30 */ |
| 31 function LanguageOptions(model) { | 31 function LanguageOptions(model) { |
| 32 OptionsPage.call(this, 'languages', templateData.languagePageTabTitle, | 32 OptionsPage.call(this, 'languages', |
| 33 loadTimeData.getString('languagePageTabTitle'), |
| 33 'languagePage'); | 34 'languagePage'); |
| 34 } | 35 } |
| 35 | 36 |
| 36 cr.addSingletonGetter(LanguageOptions); | 37 cr.addSingletonGetter(LanguageOptions); |
| 37 | 38 |
| 38 // Inherit LanguageOptions from OptionsPage. | 39 // Inherit LanguageOptions from OptionsPage. |
| 39 LanguageOptions.prototype = { | 40 LanguageOptions.prototype = { |
| 40 __proto__: OptionsPage.prototype, | 41 __proto__: OptionsPage.prototype, |
| 41 | 42 |
| 42 /** | 43 /** |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 var addLanguageList = $('add-language-overlay-language-list'); | 87 var addLanguageList = $('add-language-overlay-language-list'); |
| 87 addLanguageList.addEventListener('click', | 88 addLanguageList.addEventListener('click', |
| 88 this.handleAddLanguageListClick_.bind(this)); | 89 this.handleAddLanguageListClick_.bind(this)); |
| 89 } else { | 90 } else { |
| 90 // Listen to add language dialog ok button. | 91 // Listen to add language dialog ok button. |
| 91 var addLanguageOkButton = $('add-language-overlay-ok-button'); | 92 var addLanguageOkButton = $('add-language-overlay-ok-button'); |
| 92 addLanguageOkButton.addEventListener('click', | 93 addLanguageOkButton.addEventListener('click', |
| 93 this.handleAddLanguageOkButtonClick_.bind(this)); | 94 this.handleAddLanguageOkButtonClick_.bind(this)); |
| 94 | 95 |
| 95 // Show experimental features if enabled. | 96 // Show experimental features if enabled. |
| 96 if (templateData.experimentalSpellCheckFeatures == 'true') | 97 if (loadTimeData.getBoolean('experimentalSpellCheckFeatures')) |
| 97 $('auto-spell-correction-option').hidden = false; | 98 $('auto-spell-correction-option').hidden = false; |
| 98 | 99 |
| 99 // Handle spell check enable/disable. | 100 // Handle spell check enable/disable. |
| 100 if (!cr.isMac) { | 101 if (!cr.isMac) { |
| 101 Preferences.getInstance().addEventListener( | 102 Preferences.getInstance().addEventListener( |
| 102 this.enableSpellCheckPref, | 103 this.enableSpellCheckPref, |
| 103 this.updateEnableSpellCheck_.bind(this)); | 104 this.updateEnableSpellCheck_.bind(this)); |
| 104 | 105 |
| 105 var spellCheckLanguageButton = getRequiredElement( | 106 var spellCheckLanguageButton = getRequiredElement( |
| 106 'language-options-spell-check-language-button'); | 107 'language-options-spell-check-language-button'); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 spellCheckDictionary_: '', | 144 spellCheckDictionary_: '', |
| 144 // The map of language code to input method IDs, like: | 145 // The map of language code to input method IDs, like: |
| 145 // {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} | 146 // {'ja': ['mozc', 'mozc-jp'], 'zh-CN': ['pinyin'], ...} |
| 146 languageCodeToInputMethodIdsMap_: {}, | 147 languageCodeToInputMethodIdsMap_: {}, |
| 147 | 148 |
| 148 /** | 149 /** |
| 149 * Initializes the input method list. | 150 * Initializes the input method list. |
| 150 */ | 151 */ |
| 151 initializeInputMethodList_: function() { | 152 initializeInputMethodList_: function() { |
| 152 var inputMethodList = $('language-options-input-method-list'); | 153 var inputMethodList = $('language-options-input-method-list'); |
| 153 var inputMethodListData = templateData.inputMethodList; | 154 var inputMethodListData = loadTimeData.getValue('inputMethodList'); |
| 154 var inputMethodPrototype = $('language-options-input-method-proto'); | 155 var inputMethodPrototype = $('language-options-input-method-proto'); |
| 155 | 156 |
| 156 // Add all input methods, but make all of them invisible here. We'll | 157 // Add all input methods, but make all of them invisible here. We'll |
| 157 // change the visibility in handleLanguageOptionsListChange_() based | 158 // change the visibility in handleLanguageOptionsListChange_() based |
| 158 // on the selected language. Note that we only have less than 100 | 159 // on the selected language. Note that we only have less than 100 |
| 159 // input methods, so creating DOM nodes at once here should be ok. | 160 // input methods, so creating DOM nodes at once here should be ok. |
| 160 for (var i = 0; i < inputMethodListData.length; i++) { | 161 for (var i = 0; i < inputMethodListData.length; i++) { |
| 161 var inputMethod = inputMethodListData[i]; | 162 var inputMethod = inputMethodListData[i]; |
| 162 var element = inputMethodPrototype.cloneNode(true); | 163 var element = inputMethodPrototype.cloneNode(true); |
| 163 element.id = ''; | 164 element.id = ''; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 187 }, | 188 }, |
| 188 | 189 |
| 189 /** | 190 /** |
| 190 * Creates a configure button for the given input method ID. | 191 * Creates a configure button for the given input method ID. |
| 191 * @param {string} inputMethodId Input method ID (ex. "pinyin"). | 192 * @param {string} inputMethodId Input method ID (ex. "pinyin"). |
| 192 * @param {string} pageName Name of the config page (ex. "languagePinyin"). | 193 * @param {string} pageName Name of the config page (ex. "languagePinyin"). |
| 193 * @private | 194 * @private |
| 194 */ | 195 */ |
| 195 createConfigureInputMethodButton_: function(inputMethodId, pageName) { | 196 createConfigureInputMethodButton_: function(inputMethodId, pageName) { |
| 196 var button = document.createElement('button'); | 197 var button = document.createElement('button'); |
| 197 button.textContent = localStrings.getString('configure'); | 198 button.textContent = loadTimeData.getString('configure'); |
| 198 button.onclick = function(e) { | 199 button.onclick = function(e) { |
| 199 // Prevent the default action (i.e. changing the checked property | 200 // Prevent the default action (i.e. changing the checked property |
| 200 // of the checkbox). The button click here should not be handled | 201 // of the checkbox). The button click here should not be handled |
| 201 // as checkbox click. | 202 // as checkbox click. |
| 202 e.preventDefault(); | 203 e.preventDefault(); |
| 203 chrome.send('inputMethodOptionsOpen', [inputMethodId]); | 204 chrome.send('inputMethodOptionsOpen', [inputMethodId]); |
| 204 OptionsPage.navigateToPage(pageName); | 205 OptionsPage.navigateToPage(pageName); |
| 205 }; | 206 }; |
| 206 return button; | 207 return button; |
| 207 }, | 208 }, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (cr.isChromeOS) | 249 if (cr.isChromeOS) |
| 249 this.updateInputMethodList_(languageCode); | 250 this.updateInputMethodList_(languageCode); |
| 250 | 251 |
| 251 this.updateLanguageListInAddLanguageOverlay_(); | 252 this.updateLanguageListInAddLanguageOverlay_(); |
| 252 }, | 253 }, |
| 253 | 254 |
| 254 /** | 255 /** |
| 255 * Happens when a user changes back to the language they're currently using. | 256 * Happens when a user changes back to the language they're currently using. |
| 256 */ | 257 */ |
| 257 currentLocaleWasReselected: function() { | 258 currentLocaleWasReselected: function() { |
| 258 this.updateUiLanguageButton_(templateData.currentUiLanguageCode); | 259 this.updateUiLanguageButton_( |
| 260 loadTimeData.getString('currentUiLanguageCode')); |
| 259 }, | 261 }, |
| 260 | 262 |
| 261 /** | 263 /** |
| 262 * Handles languageOptionsList's save event. | 264 * Handles languageOptionsList's save event. |
| 263 * @param {Event} e Save event. | 265 * @param {Event} e Save event. |
| 264 * @private | 266 * @private |
| 265 */ | 267 */ |
| 266 handleLanguageOptionsListSave_: function(e) { | 268 handleLanguageOptionsListSave_: function(e) { |
| 267 if (cr.isChromeOS) { | 269 if (cr.isChromeOS) { |
| 268 // Sort the preload engines per the saved languages before save. | 270 // Sort the preload engines per the saved languages before save. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 319 } |
| 318 | 320 |
| 319 return newPreloadEngines; | 321 return newPreloadEngines; |
| 320 }, | 322 }, |
| 321 | 323 |
| 322 /** | 324 /** |
| 323 * Initializes the map of language code to input method IDs. | 325 * Initializes the map of language code to input method IDs. |
| 324 * @private | 326 * @private |
| 325 */ | 327 */ |
| 326 initializeLanguageCodeToInputMethodIdsMap_: function() { | 328 initializeLanguageCodeToInputMethodIdsMap_: function() { |
| 327 var inputMethodList = templateData.inputMethodList; | 329 var inputMethodList = loadTimeData.getValue('inputMethodList'); |
| 328 for (var i = 0; i < inputMethodList.length; i++) { | 330 for (var i = 0; i < inputMethodList.length; i++) { |
| 329 var inputMethod = inputMethodList[i]; | 331 var inputMethod = inputMethodList[i]; |
| 330 for (var languageCode in inputMethod.languageCodeSet) { | 332 for (var languageCode in inputMethod.languageCodeSet) { |
| 331 if (languageCode in this.languageCodeToInputMethodIdsMap_) { | 333 if (languageCode in this.languageCodeToInputMethodIdsMap_) { |
| 332 this.languageCodeToInputMethodIdsMap_[languageCode].push( | 334 this.languageCodeToInputMethodIdsMap_[languageCode].push( |
| 333 inputMethod.id); | 335 inputMethod.id); |
| 334 } else { | 336 } else { |
| 335 this.languageCodeToInputMethodIdsMap_[languageCode] = | 337 this.languageCodeToInputMethodIdsMap_[languageCode] = |
| 336 [inputMethod.id]; | 338 [inputMethod.id]; |
| 337 } | 339 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 var uiLanguageMessage = $('language-options-ui-language-message'); | 374 var uiLanguageMessage = $('language-options-ui-language-message'); |
| 373 var uiLanguageNotification = $('language-options-ui-notification-bar'); | 375 var uiLanguageNotification = $('language-options-ui-notification-bar'); |
| 374 | 376 |
| 375 // Remove the event listener and add it back if useful. | 377 // Remove the event listener and add it back if useful. |
| 376 uiLanguageButton.onclick = null; | 378 uiLanguageButton.onclick = null; |
| 377 | 379 |
| 378 // Unhide the language button every time, as it could've been previously | 380 // Unhide the language button every time, as it could've been previously |
| 379 // hidden by a language change. | 381 // hidden by a language change. |
| 380 uiLanguageButton.hidden = false; | 382 uiLanguageButton.hidden = false; |
| 381 | 383 |
| 382 if (languageCode == templateData.prospectiveUiLanguageCode) { | 384 if (languageCode == loadTimeData.getString('prospectiveUiLanguageCode')) { |
| 383 uiLanguageMessage.textContent = | 385 uiLanguageMessage.textContent = |
| 384 localStrings.getString('is_displayed_in_this_language'); | 386 loadTimeData.getString('is_displayed_in_this_language'); |
| 385 showMutuallyExclusiveNodes( | 387 showMutuallyExclusiveNodes( |
| 386 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); | 388 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); |
| 387 } else if (languageCode in templateData.uiLanguageCodeSet) { | 389 } else if (languageCode in loadTimeData.getValue('uiLanguageCodeSet')) { |
| 388 if (cr.isChromeOS && UIAccountTweaks.loggedInAsGuest()) { | 390 if (cr.isChromeOS && UIAccountTweaks.loggedInAsGuest()) { |
| 389 // In the guest mode for ChromeOS, changing UI language does not make | 391 // In the guest mode for ChromeOS, changing UI language does not make |
| 390 // sense because it does not take effect after browser restart. | 392 // sense because it does not take effect after browser restart. |
| 391 uiLanguageButton.hidden = true; | 393 uiLanguageButton.hidden = true; |
| 392 uiLanguageMessage.hidden = true; | 394 uiLanguageMessage.hidden = true; |
| 393 } else { | 395 } else { |
| 394 uiLanguageButton.textContent = | 396 uiLanguageButton.textContent = |
| 395 localStrings.getString('display_in_this_language'); | 397 loadTimeData.getString('display_in_this_language'); |
| 396 showMutuallyExclusiveNodes( | 398 showMutuallyExclusiveNodes( |
| 397 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 0); | 399 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 0); |
| 398 uiLanguageButton.onclick = function(e) { | 400 uiLanguageButton.onclick = function(e) { |
| 399 chrome.send('uiLanguageChange', [languageCode]); | 401 chrome.send('uiLanguageChange', [languageCode]); |
| 400 }; | 402 }; |
| 401 } | 403 } |
| 402 } else { | 404 } else { |
| 403 uiLanguageMessage.textContent = | 405 uiLanguageMessage.textContent = |
| 404 localStrings.getString('cannot_be_displayed_in_this_language'); | 406 loadTimeData.getString('cannot_be_displayed_in_this_language'); |
| 405 showMutuallyExclusiveNodes( | 407 showMutuallyExclusiveNodes( |
| 406 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); | 408 [uiLanguageButton, uiLanguageMessage, uiLanguageNotification], 1); |
| 407 } | 409 } |
| 408 }, | 410 }, |
| 409 | 411 |
| 410 /** | 412 /** |
| 411 * Updates the spell check language button. | 413 * Updates the spell check language button. |
| 412 * @param {string} languageCode Language code (ex. "fr"). | 414 * @param {string} languageCode Language code (ex. "fr"). |
| 413 * @private | 415 * @private |
| 414 */ | 416 */ |
| 415 updateSpellCheckLanguageButton_: function(languageCode) { | 417 updateSpellCheckLanguageButton_: function(languageCode) { |
| 416 var spellCheckLanguageButton = | 418 var spellCheckLanguageButton = |
| 417 $('language-options-spell-check-language-button'); | 419 $('language-options-spell-check-language-button'); |
| 418 var spellCheckLanguageMessage = | 420 var spellCheckLanguageMessage = |
| 419 $('language-options-spell-check-language-message'); | 421 $('language-options-spell-check-language-message'); |
| 420 | 422 |
| 421 if (languageCode == this.spellCheckDictionary_) { | 423 if (languageCode == this.spellCheckDictionary_) { |
| 422 spellCheckLanguageMessage.textContent = | 424 spellCheckLanguageMessage.textContent = |
| 423 localStrings.getString('is_used_for_spell_checking'); | 425 loadTimeData.getString('is_used_for_spell_checking'); |
| 424 showMutuallyExclusiveNodes( | 426 showMutuallyExclusiveNodes( |
| 425 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); | 427 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); |
| 426 } else if (languageCode in templateData.spellCheckLanguageCodeSet) { | 428 } else if (languageCode in |
| 429 loadTimeData.getValue('spellCheckLanguageCodeSet')) { |
| 427 spellCheckLanguageButton.textContent = | 430 spellCheckLanguageButton.textContent = |
| 428 localStrings.getString('use_this_for_spell_checking'); | 431 loadTimeData.getString('use_this_for_spell_checking'); |
| 429 showMutuallyExclusiveNodes( | 432 showMutuallyExclusiveNodes( |
| 430 [spellCheckLanguageButton, spellCheckLanguageMessage], 0); | 433 [spellCheckLanguageButton, spellCheckLanguageMessage], 0); |
| 431 spellCheckLanguageButton.languageCode = languageCode; | 434 spellCheckLanguageButton.languageCode = languageCode; |
| 432 } else if (!languageCode) { | 435 } else if (!languageCode) { |
| 433 spellCheckLanguageButton.hidden = true; | 436 spellCheckLanguageButton.hidden = true; |
| 434 spellCheckLanguageMessage.hidden = true; | 437 spellCheckLanguageMessage.hidden = true; |
| 435 } else { | 438 } else { |
| 436 spellCheckLanguageMessage.textContent = | 439 spellCheckLanguageMessage.textContent = |
| 437 localStrings.getString('cannot_be_used_for_spell_checking'); | 440 loadTimeData.getString('cannot_be_used_for_spell_checking'); |
| 438 showMutuallyExclusiveNodes( | 441 showMutuallyExclusiveNodes( |
| 439 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); | 442 [spellCheckLanguageButton, spellCheckLanguageMessage], 1); |
| 440 } | 443 } |
| 441 }, | 444 }, |
| 442 | 445 |
| 443 /** | 446 /** |
| 444 * Updates the input method list. | 447 * Updates the input method list. |
| 445 * @param {string} languageCode Language code (ex. "fr"). | 448 * @param {string} languageCode Language code (ex. "fr"). |
| 446 * @private | 449 * @private |
| 447 */ | 450 */ |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 /** | 522 /** |
| 520 * Handles input method checkbox's click event. | 523 * Handles input method checkbox's click event. |
| 521 * @param {Event} e Click event. | 524 * @param {Event} e Click event. |
| 522 * @private | 525 * @private |
| 523 */ | 526 */ |
| 524 handleCheckboxClick_: function(e) { | 527 handleCheckboxClick_: function(e) { |
| 525 var checkbox = e.target; | 528 var checkbox = e.target; |
| 526 if (this.preloadEngines_.length == 1 && !checkbox.checked) { | 529 if (this.preloadEngines_.length == 1 && !checkbox.checked) { |
| 527 // Don't allow disabling the last input method. | 530 // Don't allow disabling the last input method. |
| 528 this.showNotification_( | 531 this.showNotification_( |
| 529 localStrings.getString('please_add_another_input_method'), | 532 loadTimeData.getString('please_add_another_input_method'), |
| 530 localStrings.getString('ok_button')); | 533 loadTimeData.getString('ok_button')); |
| 531 checkbox.checked = true; | 534 checkbox.checked = true; |
| 532 return; | 535 return; |
| 533 } | 536 } |
| 534 if (checkbox.checked) { | 537 if (checkbox.checked) { |
| 535 chrome.send('inputMethodEnable', [checkbox.inputMethodId]); | 538 chrome.send('inputMethodEnable', [checkbox.inputMethodId]); |
| 536 } else { | 539 } else { |
| 537 chrome.send('inputMethodDisable', [checkbox.inputMethodId]); | 540 chrome.send('inputMethodDisable', [checkbox.inputMethodId]); |
| 538 } | 541 } |
| 539 this.updatePreloadEnginesFromCheckboxes_(); | 542 this.updatePreloadEnginesFromCheckboxes_(); |
| 540 this.preloadEngines_ = this.sortPreloadEngines_(this.preloadEngines_); | 543 this.preloadEngines_ = this.sortPreloadEngines_(this.preloadEngines_); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 OptionsPage.closeOverlay(); | 584 OptionsPage.closeOverlay(); |
| 582 } | 585 } |
| 583 }, | 586 }, |
| 584 | 587 |
| 585 /** | 588 /** |
| 586 * Checks if languageCode is deletable or not. | 589 * Checks if languageCode is deletable or not. |
| 587 * @param {String} languageCode the languageCode to check for deletability. | 590 * @param {String} languageCode the languageCode to check for deletability. |
| 588 */ | 591 */ |
| 589 languageIsDeletable: function(languageCode) { | 592 languageIsDeletable: function(languageCode) { |
| 590 // Don't allow removing the language if it's a UI language. | 593 // Don't allow removing the language if it's a UI language. |
| 591 if (languageCode == templateData.prospectiveUiLanguageCode) | 594 if (languageCode == loadTimeData.getString('prospectiveUiLanguageCode')) |
| 592 return false; | 595 return false; |
| 593 return (!cr.isChromeOS || | 596 return (!cr.isChromeOS || |
| 594 this.canDeleteLanguage_(languageCode)); | 597 this.canDeleteLanguage_(languageCode)); |
| 595 }, | 598 }, |
| 596 | 599 |
| 597 /** | 600 /** |
| 598 * Handles browse.enable_spellchecking change. | 601 * Handles browse.enable_spellchecking change. |
| 599 * @param {Event} e Change event. | 602 * @param {Event} e Change event. |
| 600 * @private | 603 * @private |
| 601 */ | 604 */ |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 734 |
| 732 /** | 735 /** |
| 733 * Filters bad preload engines in case bad preload engines are | 736 * Filters bad preload engines in case bad preload engines are |
| 734 * stored in the preference. Removes duplicates as well. | 737 * stored in the preference. Removes duplicates as well. |
| 735 * @param {Array} preloadEngines List of preload engines. | 738 * @param {Array} preloadEngines List of preload engines. |
| 736 * @private | 739 * @private |
| 737 */ | 740 */ |
| 738 filterBadPreloadEngines_: function(preloadEngines) { | 741 filterBadPreloadEngines_: function(preloadEngines) { |
| 739 // Convert the list into a dictonary for simpler lookup. | 742 // Convert the list into a dictonary for simpler lookup. |
| 740 var dictionary = {}; | 743 var dictionary = {}; |
| 741 for (var i = 0; i < templateData.inputMethodList.length; i++) { | 744 var list = loadTimeData.getValue('inputMethodList'); |
| 742 dictionary[templateData.inputMethodList[i].id] = true; | 745 for (var i = 0; i < list.length; i++) { |
| 746 dictionary[list[i].id] = true; |
| 743 } | 747 } |
| 744 | 748 |
| 745 var filteredPreloadEngines = []; | 749 var filteredPreloadEngines = []; |
| 746 var seen = {}; | 750 var seen = {}; |
| 747 for (var i = 0; i < preloadEngines.length; i++) { | 751 for (var i = 0; i < preloadEngines.length; i++) { |
| 748 // Check if the preload engine is present in the | 752 // Check if the preload engine is present in the |
| 749 // dictionary, and not duplicate. Otherwise, skip it. | 753 // dictionary, and not duplicate. Otherwise, skip it. |
| 750 if (preloadEngines[i] in dictionary && !(preloadEngines[i] in seen)) { | 754 if (preloadEngines[i] in dictionary && !(preloadEngines[i] in seen)) { |
| 751 filteredPreloadEngines.push(preloadEngines[i]); | 755 filteredPreloadEngines.push(preloadEngines[i]); |
| 752 seen[preloadEngines[i]] = true; | 756 seen[preloadEngines[i]] = true; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 assert(nodes[i] instanceof HTMLElement); // TODO(dbeam): Ignore null? | 828 assert(nodes[i] instanceof HTMLElement); // TODO(dbeam): Ignore null? |
| 825 nodes[i].hidden = i != index; | 829 nodes[i].hidden = i != index; |
| 826 } | 830 } |
| 827 } | 831 } |
| 828 | 832 |
| 829 /** | 833 /** |
| 830 * Chrome callback for when the UI language preference is saved. | 834 * Chrome callback for when the UI language preference is saved. |
| 831 * @param {string} languageCode The newly selected language to use. | 835 * @param {string} languageCode The newly selected language to use. |
| 832 */ | 836 */ |
| 833 LanguageOptions.uiLanguageSaved = function(languageCode) { | 837 LanguageOptions.uiLanguageSaved = function(languageCode) { |
| 834 templateData.prospectiveUiLanguageCode = languageCode; | 838 loadTimeData.getString('prospectiveUiLanguageCode') = languageCode; |
| 835 | 839 |
| 836 // If the user is no longer on the same language code, ignore. | 840 // If the user is no longer on the same language code, ignore. |
| 837 if ($('language-options-list').getSelectedLanguageCode() != languageCode) | 841 if ($('language-options-list').getSelectedLanguageCode() != languageCode) |
| 838 return; | 842 return; |
| 839 | 843 |
| 840 // Special case for when a user changes to a different language, and changes | 844 // Special case for when a user changes to a different language, and changes |
| 841 // back to the same language without having restarted Chrome or logged | 845 // back to the same language without having restarted Chrome or logged |
| 842 // in/out of ChromeOS. | 846 // in/out of ChromeOS. |
| 843 if (languageCode == templateData.currentUiLanguageCode) { | 847 if (languageCode == loadTimeData.getString('currentUiLanguageCode')) { |
| 844 LanguageOptions.getInstance().currentLocaleWasReselected(); | 848 LanguageOptions.getInstance().currentLocaleWasReselected(); |
| 845 return; | 849 return; |
| 846 } | 850 } |
| 847 | 851 |
| 848 // Otherwise, show a notification telling the user that their changes will | 852 // Otherwise, show a notification telling the user that their changes will |
| 849 // only take effect after restart. | 853 // only take effect after restart. |
| 850 showMutuallyExclusiveNodes([$('language-options-ui-language-button'), | 854 showMutuallyExclusiveNodes([$('language-options-ui-language-button'), |
| 851 $('language-options-ui-notification-bar')], 1); | 855 $('language-options-ui-notification-bar')], 1); |
| 852 }; | 856 }; |
| 853 | 857 |
| 854 // Export | 858 // Export |
| 855 return { | 859 return { |
| 856 LanguageOptions: LanguageOptions | 860 LanguageOptions: LanguageOptions |
| 857 }; | 861 }; |
| 858 }); | 862 }); |
| OLD | NEW |