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

Unified Diff: chrome/browser/resources/settings/languages_page/languages.js

Issue 2573643005: Language settings: Fix Restart and Remove buttons shown at wrong times (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/languages_page/languages.js
diff --git a/chrome/browser/resources/settings/languages_page/languages.js b/chrome/browser/resources/settings/languages_page/languages.js
index 790a45fba91d763cbad5c548833d0bc05dae1fdb..dc54735a4dbb90a3de07c02b77e377630a05aee3 100644
--- a/chrome/browser/resources/settings/languages_page/languages.js
+++ b/chrome/browser/resources/settings/languages_page/languages.js
@@ -121,9 +121,13 @@ Polymer({
type: Object,
value: function() { return new Map(); },
},
+
+ /** @private Prospective UI language when the page was loaded. */
+ originalProspectiveUILanguage_: String,
},
observers: [
+ 'prospectiveUILanguageChanged_(prefs.intl.app_locale.value)',
'preferredLanguagesPrefChanged_(' +
'prefs.' + preferredLanguagesPrefName + '.value, languages)',
'spellCheckDictionariesPrefChanged_(' +
@@ -178,6 +182,16 @@ Polymer({
}.bind(this));
}
+ if (cr.isWindows || cr.isChromeOS) {
+ // Fetch the starting UI language, which affects which actions should be
+ // enabled.
+ promises.push(cr.sendWithPromise('getProspectiveUILanguage').then(
+ function(prospectiveUILanguage) {
+ this.originalProspectiveUILanguage_ =
+ prospectiveUILanguage || navigator.language;
+ }.bind(this)));
+ }
+
Promise.all(promises).then(function(results) {
this.createModel_(results[1], results[2], results[3], results[4]);
this.resolver_.resolve();
@@ -190,6 +204,19 @@ Polymer({
},
/**
+ * Updates the prospective UI languages based on the new pref value.
+ * @param {string} prospectiveUILanguage
+ * @private
+ */
+ prospectiveUILanguageChanged_: function(prospectiveUILanguage) {
+ if (!this.languages)
+ return;
+
+ this.set('languages.prospectiveUILanguage',
+ prospectiveUILanguage || this.originalProspectiveUILanguage_);
+ },
+
+ /**
* Updates the list of enabled languages from the preferred languages pref.
* @private
*/
@@ -288,6 +315,11 @@ Polymer({
enabled: enabledLanguageStates,
translateTarget: translateTarget,
});
+ if (cr.isChromeOS || cr.isWindows) {
+ model.prospectiveUILanguage =
+ /** @type {string} */(this.getPref('intl.app_locale').value) ||
+ this.originalProspectiveUILanguage_;
+ }
if (cr.isChromeOS) {
model.inputMethods = /** @type {!InputMethodsModel} */({
supported: supportedInputMethods,
@@ -426,26 +458,25 @@ Polymer({
* the actual UI language until a restart.
* @param {string} languageCode
*/
- setUILanguage: function(languageCode) {
+ setProspectiveUILanguage: function(languageCode) {
assert(cr.isChromeOS || cr.isWindows);
- chrome.send('setUILanguage', [languageCode]);
+ chrome.send('setProspectiveUILanguage', [languageCode]);
},
/** Resets the prospective UI language back to the actual UI language. */
- resetUILanguage: function() {
+ resetProspectiveUILanguage: function() {
assert(cr.isChromeOS || cr.isWindows);
- chrome.send('setUILanguage', [navigator.language]);
+ chrome.send(
+ 'setProspectiveUILanguage', [this.originalProspectiveUILanguage_]);
},
/**
- * Returns the "prospective" UI language, i.e. the one to be used on next
- * restart. If the pref is not set, the current UI language is also the
- * "prospective" language.
- * @return {string} Language code of the prospective UI language.
+ * True if the prospective UI language was changed from its starting value.
+ * @return {boolean}
*/
- getProspectiveUILanguage: function() {
- return /** @type {string} */(this.getPref('intl.app_locale').value) ||
- navigator.language;
+ requiresRestart: function() {
+ return this.originalProspectiveUILanguage_ !=
+ this.languages.prospectiveUILanguage;
},
/**
@@ -506,7 +537,7 @@ Polymer({
*/
canDisableLanguage: function(languageCode) {
// Cannot disable the prospective UI language.
- if (languageCode == this.getProspectiveUILanguage())
+ if (languageCode == this.languages.prospectiveUILanguage)
return false;
// Cannot disable the only enabled language.

Powered by Google App Engine
This is Rietveld 408576698