Commit 1a762995 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[unified-consent] Hide spellcheck toggle when there is no dict

When there is no spellcheck dictionary, the
"Enhanced spellcheck" toggle is hidden.

TBR=jochen@chromium.org

Bug: 855945
Change-Id: I490abeba215382853462d092937f7e8607c84439
Reviewed-on: https://chromium-review.googlesource.com/c/1297140
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602931}
parent 207744f4
...@@ -2491,12 +2491,6 @@ ...@@ -2491,12 +2491,6 @@
<message name="IDS_SETTINGS_SPELLING_PREF_UNIFIED_CONSENT" desc="The documentation string of the 'Use Spelling' preference"> <message name="IDS_SETTINGS_SPELLING_PREF_UNIFIED_CONSENT" desc="The documentation string of the 'Use Spelling' preference">
Enhanced spell check Enhanced spell check
</message> </message>
<message name="IDS_SETTINGS_SPELLING_TURN_ON_HINT_UNIFIED_CONSENT" desc="Informs user how to change their settings to be able to turn on spell check.">
To turn this on, first turn on spell check in <ph name="BEGIN_LINK">&lt;a href="$1" target=&quot;_blank&quot;&gt;<ex>&lt;a href="$1" target=&quot;_blank&quot;&gt;</ex></ph>Languages and input<ph name="END_LINK">&lt;/a&gt;<ex>&lt;/a&gt;</ex></ph>
</message>
<message name="IDS_SETTINGS_SPELLING_TURN_ON_HINT_UNIFIED_CONSENT_MAC" desc="Informs user how to change their settings on Mac to be able to turn on spell check.">
To turn this on, first select Check Spelling While Typing in the Edit menu
</message>
<message name="IDS_SETTINGS_ENABLE_LOGGING" desc="The label of the checkbox to enable/disable crash and user metrics logging"> <message name="IDS_SETTINGS_ENABLE_LOGGING" desc="The label of the checkbox to enable/disable crash and user metrics logging">
Automatically send usage statistics and crash reports to Google Automatically send usage statistics and crash reports to Google
</message> </message>
......
...@@ -83,11 +83,12 @@ ...@@ -83,11 +83,12 @@
</settings-toggle-button> </settings-toggle-button>
</template> </template>
<if expr="_google_chrome"> <if expr="_google_chrome">
<settings-toggle-button <settings-toggle-button id="spellCheckControl"
pref="{{prefs.spellcheck.use_spelling_service}}" pref="{{prefs.spellcheck.use_spelling_service}}"
label="$i18n{spellingPref}" label="$i18n{spellingPref}"
sub-label="$i18n{spellingDescription}" sub-label="$i18n{spellingDescription}"
disabled="[[unifiedConsentGiven]]"> disabled="[[unifiedConsentGiven]]"
hidden="[[!showSpellCheckControl_(prefs.spellcheck.dictionaries)]]">
</settings-toggle-button> </settings-toggle-button>
</if><!-- _google_chrome --> </if><!-- _google_chrome -->
</template> </template>
......
...@@ -83,18 +83,6 @@ Polymer({ ...@@ -83,18 +83,6 @@ Polymer({
// </if> // </if>
}, },
/**
* TODO(crbug.com/855945): Use this function for the spell check error hint
* @param {!Event} e
* @private
*/
onLanguageLinkBoxClick_: function(e) {
if (e.target.tagName === 'A') {
e.preventDefault();
settings.navigateTo(settings.routes.LANGUAGES);
}
},
// <if expr="_google_chrome and not chromeos"> // <if expr="_google_chrome and not chromeos">
/** @private */ /** @private */
onMetricsReportingChange_: function() { onMetricsReportingChange_: function() {
...@@ -138,5 +126,15 @@ Polymer({ ...@@ -138,5 +126,15 @@ Polymer({
settings.LifetimeBrowserProxyImpl.getInstance().restart(); settings.LifetimeBrowserProxyImpl.getInstance().restart();
}, },
// </if> // </if>
/**
* @return {boolean}
* @private
*/
showSpellCheckControl_: function() {
return !!this.prefs.spellcheck &&
/** @type {!Array<string>} */
(this.prefs.spellcheck.dictionaries.value).length > 0;
},
}); });
})(); })();
...@@ -34,5 +34,16 @@ cr.define('settings_personalization_options', function() { ...@@ -34,5 +34,16 @@ cr.define('settings_personalization_options', function() {
8, 8,
testElement.root.querySelectorAll('settings-toggle-button').length); testElement.root.querySelectorAll('settings-toggle-button').length);
}); });
test('hide spellcheck toggle when there is no dictionary', function() {
testElement.unifiedConsentEnabled = true;
testElement.prefs = {spellcheck: {dictionaries: {value: ['en-US']}}};
Polymer.dom.flush();
assertFalse(testElement.$.spellCheckControl.hidden);
testElement.prefs = {spellcheck: {dictionaries: {value: []}}};
Polymer.dom.flush();
assertTrue(testElement.$.spellCheckControl.hidden);
});
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment