| 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 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-language-detail-page', | 10 is: 'settings-language-detail-page', |
| 11 | 11 |
| 12 properties: { | 12 properties: { |
| 13 /** | 13 /** |
| 14 * Preferences state. | 14 * Preferences state. |
| 15 */ | 15 */ |
| 16 prefs: { | 16 prefs: { |
| 17 type: Object, | 17 type: Object, |
| 18 notify: true, | 18 notify: true, |
| 19 }, | 19 }, |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Read-only reference to the languages model provided by the | 22 * Read-only reference to the languages model provided by the |
| 23 * 'settings-languages' instance. | 23 * 'settings-languages' instance. |
| 24 * @type {LanguagesModel|undefined} | 24 * @type {!LanguagesModel|undefined} |
| 25 */ | 25 */ |
| 26 languages: Object, | 26 languages: Object, |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * The language to display the details for. | 29 * The language to display the details for. |
| 30 * @type {LanguageInfo|undefined} | 30 * @type {!LanguageState|undefined} |
| 31 */ | 31 */ |
| 32 detail: Object, | 32 detail: Object, |
| 33 | 33 |
| 34 /** @private {!LanguageHelper} */ | 34 /** @private {!LanguageHelper} */ |
| 35 languageHelper_: Object, | 35 languageHelper_: Object, |
| 36 }, | 36 }, |
| 37 | 37 |
| 38 /** @override */ | 38 /** @override */ |
| 39 created: function() { | 39 created: function() { |
| 40 this.languageHelper_ = LanguageHelperImpl.getInstance(); | 40 this.languageHelper_ = LanguageHelperImpl.getInstance(); |
| 41 }, | 41 }, |
| 42 | 42 |
| 43 /** @override */ | 43 /** @override */ |
| 44 ready: function() { | 44 ready: function() { |
| 45 // In a CrOS multi-user session, the primary user controls the UI language. | 45 // In a CrOS multi-user session, the primary user controls the UI language. |
| 46 if (this.isSecondaryUser_()) { | 46 if (this.isSecondaryUser_()) { |
| 47 var indicator = this.$.policyIndicator; | 47 var indicator = this.$.policyIndicator; |
| 48 indicator.indicatorType = CrPolicyIndicatorType.PRIMARY_USER; | 48 indicator.indicatorType = CrPolicyIndicatorType.PRIMARY_USER; |
| 49 indicator.controllingUser = loadTimeData.getString('primaryUserEmail'); | 49 indicator.controllingUser = loadTimeData.getString('primaryUserEmail'); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // The UI language choice doesn't persist for guests. | 52 // The UI language choice doesn't persist for guests. |
| 53 if (cr.isChromeOS && | 53 if (cr.isChromeOS && |
| 54 (uiAccountTweaks.UIAccountTweaks.loggedInAsGuest() || | 54 (uiAccountTweaks.UIAccountTweaks.loggedInAsGuest() || |
| 55 uiAccountTweaks.UIAccountTweaks.loggedInAsPublicAccount())) { | 55 uiAccountTweaks.UIAccountTweaks.loggedInAsPublicAccount())) { |
| 56 this.$.languageSettings.hidden = true; | 56 this.$.languageSettings.hidden = true; |
| 57 } | 57 } |
| 58 }, | 58 }, |
| 59 | 59 |
| 60 <if expr="chromeos or is_win"> | |
| 61 /** | 60 /** |
| 62 * Checks whether the prospective UI language (the pref that indicates what | 61 * Checks whether the prospective UI language (the pref that indicates what |
| 63 * language to use in Chrome) matches the current language. This pref is only | 62 * language to use in Chrome) matches the current language. This pref is only |
| 64 * on Chrome OS and Windows; we don't control the UI language elsewhere. | 63 * on Chrome OS and Windows; we don't control the UI language elsewhere. |
| 65 * @param {string} languageCode The language code identifying a language. | 64 * @param {string} languageCode The language code identifying a language. |
| 66 * @param {string} prospectiveUILanguage The prospective UI language. | 65 * @param {string} prospectiveUILanguage The prospective UI language. |
| 67 * @return {boolean} True if the given language matches the prospective UI | 66 * @return {boolean} True if the given language matches the prospective UI |
| 68 * pref (which may be different from the actual UI language). | 67 * pref (which may be different from the actual UI language). |
| 69 * @private | 68 * @private |
| 70 */ | 69 */ |
| 71 isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) { | 70 isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) { |
| 71 assert(cr.isChromeOS || cr.isWindows); |
| 72 return languageCode == this.languageHelper_.getProspectiveUILanguage(); | 72 return languageCode == this.languageHelper_.getProspectiveUILanguage(); |
| 73 }, | 73 }, |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * @param {string} languageCode The language code identifying a language. | 76 * @param {string} languageCode The language code identifying a language. |
| 77 * @param {string} prospectiveUILanguage The prospective UI language. | 77 * @param {string} prospectiveUILanguage The prospective UI language. |
| 78 * @return {boolean} True if the the given language, the prospective UI | 78 * @return {boolean} True if the the given language, the prospective UI |
| 79 * language and the actual language all the same. | 79 * language and the actual language all the same. |
| 80 * @private | 80 * @private |
| 81 */ | 81 */ |
| 82 isCurrentUILanguage_: function(languageCode, prospectiveUILanguage) { | 82 isCurrentUILanguage_: function(languageCode, prospectiveUILanguage) { |
| 83 assert(cr.isChromeOS || cr.isWindows); |
| 83 return languageCode == prospectiveUILanguage && | 84 return languageCode == prospectiveUILanguage && |
| 84 languageCode == navigator.language; | 85 languageCode == navigator.language; |
| 85 }, | 86 }, |
| 86 </if> | |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @param {string} languageCode The language code identifying a language. | 89 * @param {string} languageCode The language code identifying a language. |
| 90 * @param {string} targetLanguageCode The default translate target language. | 90 * @param {string} targetLanguageCode The default translate target language. |
| 91 * @return {boolean} True if the language code matches the target language. | 91 * @return {boolean} True if the language code matches the target language. |
| 92 * @private | 92 * @private |
| 93 */ | 93 */ |
| 94 isTranslateDisabled_: function(languageCode, targetLanguageCode) { | 94 isTranslateDisabled_: function(languageCode, targetLanguageCode) { |
| 95 return this.languageHelper_.convertLanguageCodeForTranslate(languageCode) == | 95 return this.languageHelper_.convertLanguageCodeForTranslate(languageCode) == |
| 96 targetLanguageCode; | 96 targetLanguageCode; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 }, | 171 }, |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * Handler for the restart button. | 174 * Handler for the restart button. |
| 175 * @private | 175 * @private |
| 176 */ | 176 */ |
| 177 onRestartTap_: function() { | 177 onRestartTap_: function() { |
| 178 chrome.send('restart'); | 178 chrome.send('restart'); |
| 179 }, | 179 }, |
| 180 }); | 180 }); |
| OLD | NEW |