| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
| 6 * @fileoverview 'settings-language-detail-page' is a sub-page for editing | 6 * @fileoverview 'settings-language-detail-page' is a sub-page for editing |
| 7 * an individual language's settings. | 7 * an individual language's settings. |
| 8 * | 8 * |
| 9 * @group Chrome Settings Elements | 9 * @group Chrome Settings Elements |
| 10 * @element settings-language-detail-page | 10 * @element settings-language-detail-page |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 */ | 28 */ |
| 29 languages: Object, | 29 languages: Object, |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * The language to display the details for. | 32 * The language to display the details for. |
| 33 * @type {LanguageInfo|undefined} | 33 * @type {LanguageInfo|undefined} |
| 34 */ | 34 */ |
| 35 detail: Object, | 35 detail: Object, |
| 36 }, | 36 }, |
| 37 | 37 |
| 38 /** @private {!LanguageHelper} */ |
| 39 languageHelper_: LanguageHelperImpl.getInstance(), |
| 40 |
| 38 ready: function() { | 41 ready: function() { |
| 39 // In a CrOS multi-user session, the primary user controls the UI language. | 42 // In a CrOS multi-user session, the primary user controls the UI language. |
| 40 if (this.isSecondaryUser_()) { | 43 if (this.isSecondaryUser_()) { |
| 41 var indicator = this.$.policyIndicator; | 44 var indicator = this.$.policyIndicator; |
| 42 indicator.indicatorType = CrPolicyIndicatorType.PRIMARY_USER; | 45 indicator.indicatorType = CrPolicyIndicatorType.PRIMARY_USER; |
| 43 indicator.controllingUser = loadTimeData.getString('primaryUserEmail'); | 46 indicator.controllingUser = loadTimeData.getString('primaryUserEmail'); |
| 44 } | 47 } |
| 45 | 48 |
| 46 // The UI language choice doesn't persist for guests. | 49 // The UI language choice doesn't persist for guests. |
| 47 if (cr.isChromeOS && | 50 if (cr.isChromeOS && |
| 48 (uiAccountTweaks.UIAccountTweaks.loggedInAsGuest() || | 51 (uiAccountTweaks.UIAccountTweaks.loggedInAsGuest() || |
| 49 uiAccountTweaks.UIAccountTweaks.loggedInAsPublicAccount())) { | 52 uiAccountTweaks.UIAccountTweaks.loggedInAsPublicAccount())) { |
| 50 this.$.languageSettings.hidden = true; | 53 this.$.languageSettings.hidden = true; |
| 51 } | 54 } |
| 52 }, | 55 }, |
| 53 | 56 |
| 57 <if expr="chromeos or is_win"> |
| 54 /** | 58 /** |
| 59 * Checks whether the prospective UI language (the pref that indicates what |
| 60 * language to use in Chrome) matches the current language. This pref is only |
| 61 * on Chrome OS and Windows; we don't control the UI language elsewhere. |
| 55 * @param {string} languageCode The language code identifying a language. | 62 * @param {string} languageCode The language code identifying a language. |
| 56 * @param {string} prospectiveUILanguage The chosen UI language. | 63 * @param {string} prospectiveUILanguage The prospective UI language. |
| 57 * @return {boolean} True if the given language matches the chosen UI language | 64 * @return {boolean} True if the given language matches the prospective UI |
| 58 * (which may be different from the actual UI language). | 65 * pref (which may be different from the actual UI language). |
| 59 * @private | 66 * @private |
| 60 */ | 67 */ |
| 61 isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) { | 68 isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) { |
| 62 return languageCode == this.$.languages.getProspectiveUILanguage(); | 69 return languageCode == this.languageHelper_.getProspectiveUILanguage(); |
| 63 }, | 70 }, |
| 64 | 71 |
| 65 /** | 72 /** |
| 66 * @param {string} languageCode The language code identifying a language. | 73 * @param {string} languageCode The language code identifying a language. |
| 67 * @param {string} prospectiveUILanguage The prospective UI language. | 74 * @param {string} prospectiveUILanguage The prospective UI language. |
| 68 * @return {boolean} True if the the given language, the prospective UI | 75 * @return {boolean} True if the the given language, the prospective UI |
| 69 * language and the actual language all the same. | 76 * language and the actual language all the same. |
| 70 * @private | 77 * @private |
| 71 */ | 78 */ |
| 72 isCurrentUILanguage_: function(languageCode, prospectiveUILanguage) { | 79 isCurrentUILanguage_: function(languageCode, prospectiveUILanguage) { |
| 73 return languageCode == prospectiveUILanguage && | 80 return languageCode == prospectiveUILanguage && |
| 74 languageCode == navigator.language; | 81 languageCode == navigator.language; |
| 75 }, | 82 }, |
| 83 </if> |
| 76 | 84 |
| 77 /** | 85 /** |
| 78 * @param {string} languageCode The language code identifying a language. | 86 * @param {string} languageCode The language code identifying a language. |
| 79 * @param {string} targetLanguageCode The default translate target language. | 87 * @param {string} targetLanguageCode The default translate target language. |
| 80 * @return {boolean} True if the language code matches the target language. | 88 * @return {boolean} True if the language code matches the target language. |
| 81 * @private | 89 * @private |
| 82 */ | 90 */ |
| 83 isTranslateDisabled_: function(languageCode, targetLanguageCode) { | 91 isTranslateDisabled_: function(languageCode, targetLanguageCode) { |
| 84 return this.$.languages.convertLanguageCodeForTranslate(languageCode) == | 92 return this.languageHelper_.convertLanguageCodeForTranslate(languageCode) == |
| 85 targetLanguageCode; | 93 targetLanguageCode; |
| 86 }, | 94 }, |
| 87 | 95 |
| 88 /** | 96 /** |
| 89 * @param {string} languageCode The language code identifying a language. | 97 * @param {string} languageCode The language code identifying a language. |
| 90 * @param {string} prospectiveUILanguage The prospective UI language. | 98 * @param {string} prospectiveUILanguage The prospective UI language. |
| 91 * @return {boolean} True if the prospective UI language is set to | 99 * @return {boolean} True if the prospective UI language is set to |
| 92 * |languageCode| but requires a restart to take effect. | 100 * |languageCode| but requires a restart to take effect. |
| 93 * @private | 101 * @private |
| 94 */ | 102 */ |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return !translateEnabled || languageCode == 'zh'; | 141 return !translateEnabled || languageCode == 'zh'; |
| 134 }, | 142 }, |
| 135 | 143 |
| 136 /** | 144 /** |
| 137 * Handler for changes to the translate checkbox. | 145 * Handler for changes to the translate checkbox. |
| 138 * @param {!{target: !{checked: boolean}}} e | 146 * @param {!{target: !{checked: boolean}}} e |
| 139 * @private | 147 * @private |
| 140 */ | 148 */ |
| 141 onTranslateEnabledChange_: function(e) { | 149 onTranslateEnabledChange_: function(e) { |
| 142 if (e.target.checked) | 150 if (e.target.checked) |
| 143 this.$.languages.enableTranslateLanguage(this.detail.language.code); | 151 this.languageHelper_.enableTranslateLanguage(this.detail.language.code); |
| 144 else | 152 else |
| 145 this.$.languages.disableTranslateLanguage(this.detail.language.code); | 153 this.languageHelper_.disableTranslateLanguage(this.detail.language.code); |
| 146 }, | 154 }, |
| 147 | 155 |
| 148 /** | 156 /** |
| 149 * Handler for changes to the UI language toggle button. | 157 * Handler for changes to the UI language toggle button. |
| 150 * @param {!{target: !{checked: boolean}}} e | 158 * @param {!{target: !{checked: boolean}}} e |
| 151 * @private | 159 * @private |
| 152 */ | 160 */ |
| 153 onUILanguageChange_: function(e) { | 161 onUILanguageChange_: function(e) { |
| 154 if (e.target.checked) { | 162 if (e.target.checked) { |
| 155 this.$.languages.setUILanguage(this.detail.language.code); | 163 this.languageHelper_.setUILanguage(this.detail.language.code); |
| 156 } else { | 164 } else { |
| 157 // Reset the chosen UI language to the actual UI language. | 165 // Reset the chosen UI language to the actual UI language. |
| 158 this.$.languages.resetUILanguage(); | 166 this.languageHelper_.resetUILanguage(); |
| 159 } | 167 } |
| 160 }, | 168 }, |
| 161 | 169 |
| 162 /** | 170 /** |
| 163 * Handler for the restart button. | 171 * Handler for the restart button. |
| 164 * @private | 172 * @private |
| 165 */ | 173 */ |
| 166 onRestartTap_: function() { | 174 onRestartTap_: function() { |
| 167 chrome.send('restart'); | 175 chrome.send('restart'); |
| 168 }, | 176 }, |
| 169 }); | 177 }); |
| OLD | NEW |