Commit 351f1e93 authored by dbeam@chromium.org's avatar dbeam@chromium.org

options: prettier fix for bug 281069 with a test.

R=estade@chromium.org
BUG=281069
TEST=bug repro steps

Review URL: https://codereview.chromium.org/168183002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251927 0039d316-1c4b-4281-b951-d872f2087c98
parent d0b23523
......@@ -425,14 +425,6 @@ cr.define('options', function() {
this.updateLanguageListInAddLanguageOverlay_();
},
/**
* Happens when a user changes back to the language they're currently using.
*/
currentLocaleWasReselected: function() {
this.updateUiLanguageButton_(
loadTimeData.getString('currentUiLanguageCode'));
},
/**
* Handles languageOptionsList's save event.
* @param {Event} e Save event.
......@@ -853,7 +845,12 @@ cr.define('options', function() {
this.savePreloadEnginesPref_();
},
handleAddLanguageOkButtonClick_: function() {
/**
* Handles clicks on the "OK" button of the "Add language" dialog.
* @param {Event} e Click event.
* @private
*/
handleAddLanguageOkButtonClick_: function(e) {
var languagesSelect = $('add-language-overlay-language-list');
var selectedIndex = languagesSelect.selectedIndex;
if (selectedIndex >= 0) {
......@@ -1192,6 +1189,39 @@ cr.define('options', function() {
delayedHide();
},
/**
* Chrome callback for when the UI language preference is saved.
* @param {string} languageCode The newly selected language to use.
* @private
*/
uiLanguageSaved_: function(languageCode) {
this.prospectiveUiLanguageCode_ = languageCode;
// If the user is no longer on the same language code, ignore.
if ($('language-options-list').getSelectedLanguageCode() != languageCode)
return;
// Special case for when a user changes to a different language, and
// changes back to the same language without having restarted Chrome or
// logged in/out of ChromeOS.
if (languageCode == loadTimeData.getString('currentUiLanguageCode')) {
this.updateUiLanguageButton_(languageCode);
return;
}
// Otherwise, show a notification telling the user that their changes will
// only take effect after restart.
showMutuallyExclusiveNodes([$('language-options-ui-language-button'),
$('language-options-ui-notification-bar')],
1);
},
/**
* A handler for when dictionary for |languageCode| begins downloading.
* @param {string} languageCode The language of the dictionary that just
* began downloading.
* @private
*/
onDictionaryDownloadBegin_: function(languageCode) {
this.spellcheckDictionaryDownloadStatus_[languageCode] =
DOWNLOAD_STATUS.IN_PROGRESS;
......@@ -1202,6 +1232,12 @@ cr.define('options', function() {
}
},
/**
* A handler for when dictionary for |languageCode| successfully downloaded.
* @param {string} languageCode The language of the dictionary that
* succeeded downloading.
* @private
*/
onDictionaryDownloadSuccess_: function(languageCode) {
delete this.spellcheckDictionaryDownloadStatus_[languageCode];
this.spellcheckDictionaryDownloadFailures_ = 0;
......@@ -1212,6 +1248,12 @@ cr.define('options', function() {
}
},
/**
* A handler for when dictionary for |languageCode| fails to download.
* @param {string} languageCode The language of the dictionary that failed
* to download.
* @private
*/
onDictionaryDownloadFailure_: function(languageCode) {
this.spellcheckDictionaryDownloadStatus_[languageCode] =
DOWNLOAD_STATUS.FAILED;
......@@ -1267,29 +1309,8 @@ cr.define('options', function() {
}
}
/**
* Chrome callback for when the UI language preference is saved.
* @param {string} languageCode The newly selected language to use.
*/
LanguageOptions.uiLanguageSaved = function(languageCode) {
this.getInstance().prospectiveUiLanguageCode_ = languageCode;
// If the user is no longer on the same language code, ignore.
if ($('language-options-list').getSelectedLanguageCode() != languageCode)
return;
// Special case for when a user changes to a different language, and changes
// back to the same language without having restarted Chrome or logged
// in/out of ChromeOS.
if (languageCode == loadTimeData.getString('currentUiLanguageCode')) {
LanguageOptions.getInstance().currentLocaleWasReselected();
return;
}
// Otherwise, show a notification telling the user that their changes will
// only take effect after restart.
showMutuallyExclusiveNodes([$('language-options-ui-language-button'),
$('language-options-ui-notification-bar')], 1);
LanguageOptions.getInstance().uiLanguageSaved_(languageCode);
};
LanguageOptions.onDictionaryDownloadBegin = function(languageCode) {
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* TestFixture for languages options WebUI testing.
* TestFixture for language options WebUI testing.
* @extends {testing.Test}
* @constructor
**/
function LanguagesOptionsWebUITest() {}
*/
function LanguageOptionsWebUITest() {}
LanguagesOptionsWebUITest.prototype = {
LanguageOptionsWebUITest.prototype = {
__proto__: testing.Test.prototype,
/**
* Browse to languages options.
**/
/** @override */
browsePreload: 'chrome://settings-frame/languages',
};
// Test opening languages options has correct location.
TEST_F('LanguagesOptionsWebUITest', 'testOpenLanguagesOptions', function() {
// Test opening language options has correct location.
TEST_F('LanguageOptionsWebUITest', 'testOpenLanguageOptions', function() {
assertEquals(this.browsePreload, document.location.href);
});
GEN('#if defined(OS_WIN) || defined(OS_CHROMEOS)');
// Test reselecting the same language as the current UI locale. This should show
// a "Chrome is displayed in this language" message rather than a restart banner
// or a [ Display Chrome in this language ] button.
TEST_F('LanguageOptionsWebUITest', 'reselectUILocale', function() {
var currentLang = loadTimeData.getString('currentUiLanguageCode');
LanguageOptions.uiLanguageSaved(currentLang);
expectTrue($('language-options-ui-language-button').hidden);
expectFalse($('language-options-ui-language-message').hidden);
expectTrue($('language-options-ui-notification-bar').hidden);
});
GEN('#endif'); // defined(OS_WIN) || defined(OS_CHROMEOS)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment