Chromium Code Reviews| 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-languages-page' is the settings page | 6 * @fileoverview 'settings-languages-page' is the settings page |
| 7 * for language and input method settings. | 7 * for language and input method settings. |
| 8 * | 8 * |
| 9 * @group Chrome Settings Elements | 9 * @group Chrome Settings Elements |
| 10 * @element settings-languages-page | 10 * @element settings-languages-page |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 * Read-only reference to the languages model provided by the | 36 * Read-only reference to the languages model provided by the |
| 37 * 'settings-languages' instance. | 37 * 'settings-languages' instance. |
| 38 * @type {LanguagesModel|undefined} | 38 * @type {LanguagesModel|undefined} |
| 39 */ | 39 */ |
| 40 languages: { | 40 languages: { |
| 41 type: Object, | 41 type: Object, |
| 42 notify: true, | 42 notify: true, |
| 43 }, | 43 }, |
| 44 }, | 44 }, |
| 45 | 45 |
| 46 /** @private {!LanguageHelper} */ | |
| 47 languageHelper_: LanguageHelperImpl.getInstance(), | |
| 48 | |
| 46 /** | 49 /** |
| 47 * Handler for clicking a language on the main page, which selects the | 50 * Handler for clicking a language on the main page, which selects the |
| 48 * language as the prospective UI language on Chrome OS and Windows. | 51 * language as the prospective UI language on Chrome OS and Windows. |
| 49 * @param {!{model: !{item: !LanguageInfo}}} e | 52 * @param {!{model: !{item: !LanguageInfo}}} e |
| 50 */ | 53 */ |
| 51 onLanguageTap_: function(e) { | 54 onLanguageTap_: function(e) { |
| 55 // Only change the UI language on platforms that allow it. | |
| 56 if (!cr.isChromeOS && !cr.isWindows) | |
|
Dan Beam
2015/12/01 04:17:44
is there a rhyme or reason as to when we use cr.is
michaelpg
2015/12/02 21:06:06
yeah, i use <if> to exclude whole functions that d
Dan Beam
2015/12/02 22:21:15
fwiw:
void DoThing() {
#if defined(OS_CHROME)
| |
| 57 return; | |
| 58 | |
| 52 // Taps on the paper-icon-button are handled in onShowLanguageDetailTap_. | 59 // Taps on the paper-icon-button are handled in onShowLanguageDetailTap_. |
| 53 if (e.target.tagName == 'PAPER-ICON-BUTTON') | 60 if (e.target.tagName == 'PAPER-ICON-BUTTON') |
| 54 return; | 61 return; |
| 55 | 62 |
| 56 // Set the prospective UI language. This won't take effect until a restart. | 63 // Set the prospective UI language. This won't take effect until a restart. |
| 57 if (e.model.item.language.supportsUI) | 64 if (e.model.item.language.supportsUI) |
| 58 this.$.languages.setUILanguage(e.model.item.language.code); | 65 this.languageHelper_.setUILanguage(e.model.item.language.code); |
| 59 }, | 66 }, |
| 60 | 67 |
| 61 /** | 68 /** |
| 62 * Handler for enabling or disabling spell check. | 69 * Handler for enabling or disabling spell check. |
| 63 * @param {!{target: Element, model: !{item: !LanguageInfo}}} e | 70 * @param {!{target: Element, model: !{item: !LanguageInfo}}} e |
| 64 */ | 71 */ |
| 65 onSpellCheckChange_: function(e) { | 72 onSpellCheckChange_: function(e) { |
| 66 this.$.languages.toggleSpellCheck(e.model.item.language.code, | 73 this.languageHelper_.toggleSpellCheck(e.model.item.language.code, |
| 67 e.target.checked); | 74 e.target.checked); |
| 68 }, | 75 }, |
| 69 | 76 |
| 70 /** @private */ | 77 /** @private */ |
| 71 onBackTap_: function() { | 78 onBackTap_: function() { |
| 72 this.$.pages.back(); | 79 this.$.pages.back(); |
| 73 }, | 80 }, |
| 74 | 81 |
| 75 /** | 82 /** |
| 76 * Opens the Manage Languages page. | 83 * Opens the Manage Languages page. |
| 77 * @private | 84 * @private |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 95 /** | 102 /** |
| 96 * Opens the Custom Dictionary page. | 103 * Opens the Custom Dictionary page. |
| 97 * @private | 104 * @private |
| 98 */ | 105 */ |
| 99 onEditDictionaryTap_: function() { | 106 onEditDictionaryTap_: function() { |
| 100 this.$.pages.setSubpageChain(['edit-dictionary']); | 107 this.$.pages.setSubpageChain(['edit-dictionary']); |
| 101 this.forceRenderList_('settings-edit-dictionary-page'); | 108 this.forceRenderList_('settings-edit-dictionary-page'); |
| 102 }, | 109 }, |
| 103 </if> | 110 </if> |
| 104 | 111 |
| 112 <if expr="chromeos or is_win"> | |
| 105 /** | 113 /** |
| 114 * Checks whether the prospective UI language (the pref that indicates what | |
| 115 * language to use in Chrome) matches the current language. This pref is only | |
| 116 * on Chrome OS and Windows; we don't control the UI language elsewhere. | |
| 106 * @param {string} languageCode The language code identifying a language. | 117 * @param {string} languageCode The language code identifying a language. |
| 107 * @param {string} prospectiveUILanguage The prospective UI language. | 118 * @param {string} prospectiveUILanguage The prospective UI language. |
| 108 * @return {boolean} True if the given language matches the prospective UI | 119 * @return {boolean} True if the given language matches the prospective UI |
| 109 * pref (which may be different from the actual UI language). | 120 * pref (which may be different from the actual UI language). |
| 110 * @private | 121 * @private |
| 111 */ | 122 */ |
| 112 isUILanguage_: function(languageCode, prospectiveUILanguage) { | 123 isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) { |
| 113 return languageCode == this.$.languages.getProspectiveUILanguage(); | 124 return languageCode == this.languageHelper_.getProspectiveUILanguage(); |
| 114 }, | 125 }, |
| 126 </if> | |
| 115 | 127 |
| 116 /** | 128 /** |
| 117 * @param {string} id The input method ID. | 129 * @param {string} id The input method ID. |
| 118 * @param {string} currentId The ID of the currently enabled input method. | 130 * @param {string} currentId The ID of the currently enabled input method. |
| 119 * @return {boolean} True if the IDs match. | 131 * @return {boolean} True if the IDs match. |
| 120 * @private | 132 * @private |
| 121 */ | 133 */ |
| 122 isCurrentInputMethod_: function(id, currentId) { | 134 isCurrentInputMethod_: function(id, currentId) { |
| 123 assert(cr.isChromeOS); | 135 assert(cr.isChromeOS); |
| 124 return id == currentId; | 136 return id == currentId; |
| 125 }, | 137 }, |
| 126 | 138 |
| 127 /** | 139 /** |
| 128 * HACK(michaelpg): This is necessary to show the list when navigating to | 140 * HACK(michaelpg): This is necessary to show the list when navigating to |
| 129 * the sub-page. Remove this function when PolymerElements/neon-animation#60 | 141 * the sub-page. Remove this function when PolymerElements/neon-animation#60 |
| 130 * is fixed. | 142 * is fixed. |
| 131 * @param {string} tagName Name of the element containing the <iron-list>. | 143 * @param {string} tagName Name of the element containing the <iron-list>. |
| 132 */ | 144 */ |
| 133 forceRenderList_: function(tagName) { | 145 forceRenderList_: function(tagName) { |
| 134 this.$$(tagName).$$('iron-list').fire('iron-resize'); | 146 this.$$(tagName).$$('iron-list').fire('iron-resize'); |
| 135 }, | 147 }, |
| 136 }); | 148 }); |
| 137 })(); | 149 })(); |
| OLD | NEW |