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

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

Issue 1902893003: MD Settings: simplify language model and data binding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment based on other CL feedback Created 4 years, 8 months 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_page.js
diff --git a/chrome/browser/resources/settings/languages_page/languages_page.js b/chrome/browser/resources/settings/languages_page/languages_page.js
index 169db1bbb48e6007b1d8f2d7494aa25bfba52cc8..10c4fc490a033b7603f024052eca3bf5b6fad4a0 100644
--- a/chrome/browser/resources/settings/languages_page/languages_page.js
+++ b/chrome/browser/resources/settings/languages_page/languages_page.js
@@ -32,7 +32,7 @@ Polymer({
/**
* Read-only reference to the languages model provided by the
* 'settings-languages' instance.
- * @type {LanguagesModel|undefined}
+ * @type {!LanguagesModel|undefined}
*/
languages: {
type: Object,
@@ -53,7 +53,7 @@ Polymer({
/**
* The language to display the details for.
- * @type {!LanguageInfo|undefined}
+ * @type {!LanguageState|undefined}
* @private
*/
detailLanguage_: Object,
@@ -64,13 +64,13 @@ Polymer({
/** @override */
created: function() {
- this.languageHelper_ = LanguageHelperImpl.getInstance();
+ this.languageHelper_ = LanguageHelperImpl.getInstance();
},
/**
* Handler for clicking a language on the main page, which selects the
* language as the prospective UI language on Chrome OS and Windows.
- * @param {!{model: !{item: !LanguageInfo}}} e
+ * @param {!{model: !{item: !LanguageState}}} e
*/
onLanguageTap_: function(e) {
// Only change the UI language on platforms that allow it.
@@ -88,7 +88,7 @@ Polymer({
/**
* Handler for enabling or disabling spell check.
- * @param {!{target: Element, model: !{item: !LanguageInfo}}} e
+ * @param {!{target: Element, model: !{item: !LanguageState}}} e
*/
onSpellCheckChange_: function(e) {
this.languageHelper_.toggleSpellCheck(e.model.item.language.code,
@@ -111,7 +111,7 @@ Polymer({
/**
* Opens the Language Detail page for the language.
- * @param {!{model: !{item: !LanguageInfo}}} e
+ * @param {!{model: !{item: !LanguageState}}} e
* @private
*/
onShowLanguageDetailTap_: function(e) {
@@ -119,14 +119,15 @@ Polymer({
this.$.pages.setSubpageChain(['language-detail']);
},
-<if expr="not is_macosx">
/**
* Returns the enabled languages which support spell check.
+ * @return {!Array<!LanguageState>}
* @private
*/
spellCheckLanguages_: function() {
- return this.languages.enabledLanguages.filter(function(languageInfo) {
- return languageInfo.language.supportsSpellcheck;
+ assert(!cr.isMac);
+ return this.languages.enabled.filter(function(languageState) {
+ return languageState.language.supportsSpellcheck;
});
},
@@ -135,12 +136,11 @@ Polymer({
* @private
*/
onEditDictionaryTap_: function() {
+ assert(!cr.isMac);
this.$.pages.setSubpageChain(['edit-dictionary']);
this.forceRenderList_('settings-edit-dictionary-page');
},
-</if>
-<if expr="chromeos or is_win">
/**
* Checks whether the prospective UI language (the pref that indicates what
* language to use in Chrome) matches the current language. This pref is only
@@ -152,9 +152,9 @@ Polymer({
* @private
*/
isProspectiveUILanguage_: function(languageCode, prospectiveUILanguage) {
+ assert(cr.isChromeOS || cr.isWindows);
return languageCode == this.languageHelper_.getProspectiveUILanguage();
},
-</if>
/**
* @return {string}
@@ -175,14 +175,13 @@ Polymer({
* @private
*/
getLanguageItemClass_: function(languageCode, prospectiveUILanguage) {
-<if expr="chromeos or is_win">
- if (this.isProspectiveUILanguage_(languageCode, prospectiveUILanguage))
+ if ((cr.isChromeOS || cr.isWindows) &&
+ this.isProspectiveUILanguage_(languageCode, prospectiveUILanguage)) {
return 'selected';
-</if>
+ }
return '';
},
-<if expr="chromeos">
/**
* @param {string} id The input method ID.
* @param {string} currentId The ID of the currently enabled input method.
@@ -201,9 +200,9 @@ Polymer({
* @private
*/
getInputMethodItemClass_: function(id, currentId) {
+ assert(cr.isChromeOS);
return this.isCurrentInputMethod_(id, currentId) ? 'selected' : '';
},
-</if>
/**
* HACK(michaelpg): This is necessary to show the list when navigating to

Powered by Google App Engine
This is Rietveld 408576698