Commit 88e526bb authored by My Nguyen's avatar My Nguyen Committed by Commit Bot

[OsSettingsLanguages] Add blank edit dictionary subpage

Mock: http://go/cros-lang-settings-ux-slide#slide=28
Current view: http://screen/5u7jNdndrP3bHcz
Drive-by:
- LanguagesSection::IsEmojiSuggestionAllowed to be
consistent with header.
- Add correct paddings for download error in input_page.html
(accidentally removed earlier, added a comment to remind myself)

Bug: 1113439
Change-Id: Ib63f44905db3b93f73c0be814b0fca37ee21f0c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2394878Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Reviewed-by: default avatarRegan Hsu <hsuregan@chromium.org>
Commit-Queue: My Nguyen <myy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806510}
parent 11f96149
......@@ -889,6 +889,9 @@
<message name="IDS_OS_SETTINGS_TAG_LANGUAGES_SPELL_CHECK" translateable="false" desc="Text for search result item which, when clicked, navigates the user to input settings, with all the options for spell check settings">
Spell check
</message>
<message name="IDS_OS_SETTINGS_TAG_LANGUAGES_EDIT_DICTIONARY" translateable="false" desc="Text for search result item which, when clicked, navigates the user to edit dictionary page.">
Customize spell check
</message>
<message name="IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_METHODS" desc="Text for search result item which, when clicked, navigates the user to input settings, with the option to enable/disable input in supported languages.">
Manage input methods
</message>
......
......@@ -16,6 +16,7 @@ js_type_check("closure_compile") {
":languages_metrics_proxy",
":manage_input_methods_page",
":os_add_languages_dialog",
":os_edit_dictionary_page",
":os_languages_page",
":os_languages_page_v2",
":os_languages_section",
......@@ -79,6 +80,9 @@ js_library("manage_input_methods_page") {
externs_list = [ "$externs_path/language_settings_private.js" ]
}
js_library("os_edit_dictionary_page") {
}
js_library("os_languages_section") {
deps = [
":input_method_options_page",
......@@ -172,6 +176,7 @@ js_type_check("closure_compile_module") {
":languages_metrics_proxy.m",
":manage_input_methods_page.m",
":os_add_languages_dialog.m",
":os_edit_dictionary_page.m",
":os_languages_page.m",
":os_languages_page_v2.m",
":os_languages_section.m",
......@@ -219,6 +224,7 @@ js_library("input_page.m") {
":add_input_methods_dialog.m",
":input_method_util.m",
":languages_metrics_proxy.m",
":os_edit_dictionary_page.m",
"..:deep_linking_behavior.m",
"..:os_route.m",
"../..:i18n_setup",
......@@ -256,6 +262,11 @@ js_library("os_add_languages_dialog.m") {
extra_deps = [ ":os_add_languages_dialog_module" ]
}
js_library("os_edit_dictionary_page.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_languages_page/os_edit_dictionary_page.m.js" ]
extra_deps = [ ":os_edit_dictionary_page_module" ]
}
js_library("os_languages_page.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_languages_page/os_languages_page.m.js" ]
deps = [
......@@ -348,6 +359,7 @@ group("polymer3_elements") {
":manage_input_methods_page_module",
":modulize",
":os_add_languages_dialog_module",
":os_edit_dictionary_page_module",
":os_languages_page_module",
":os_languages_page_v2_module",
":os_languages_section_module",
......@@ -394,6 +406,15 @@ polymer_modulizer("os_add_languages_dialog") {
auto_imports = os_settings_auto_imports
}
polymer_modulizer("os_edit_dictionary_page") {
js_file = "os_edit_dictionary_page.js"
html_file = "os_edit_dictionary_page.html"
html_type = "dom-module"
migrated_imports = settings_migrated_imports
namespace_rewrites = os_settings_namespace_rewrites
auto_imports = os_settings_auto_imports
}
polymer_modulizer("os_languages_page") {
js_file = "os_languages_page.js"
html_file = "os_languages_page.html"
......
......@@ -10,6 +10,7 @@
<link rel="import" href="add_input_methods_dialog.html">
<link rel="import" href="input_method_util.html">
<link rel="import" href="languages_metrics_proxy.html">
<link rel="import" href="os_edit_dictionary_page.html">
<link rel="import" href="remove_input_method_dialog.html">
<link rel="import" href="../deep_linking_behavior.html">
<link rel="import" href="../os_route.html">
......@@ -18,6 +19,7 @@
<link rel="import" href="../../i18n_setup.html">
<link rel="import" href="../../router.html">
<link rel="import" href="../../settings_shared_css.html">
<link rel="import" href="../../settings_page/settings_animated_pages.html">
<dom-module id="os-settings-input-page">
<template>
......@@ -42,6 +44,11 @@
pointer-events: none;
}
/* Paddings when showing download error */
.name-with-error {
padding: 14px 0;
}
.name-with-error div {
color: var(--settings-error-color);
margin-top: 8px;
......@@ -111,7 +118,7 @@
<div class$="list-item [[getInputMethodItemClass_(
item.id, languages.inputMethods.currentId)]]"
actionable on-click="onInputMethodClick_"
on-keypress="onInputMethodKeyPress_"
on-keypress="onInputMethodKeyPress_"
tabindex$="[[getInputMethodTabIndex_(
item.id, languages.inputMethods.currentId)]]"
aria-labelledby$="language-[[index]]" role="button">
......@@ -226,6 +233,7 @@
disabled="[[!prefs.browser.enable_spellchecking.value]]">
</settings-toggle-button>
<cr-link-row class="hr" label="$i18n{editDictionaryLabel}"
on-click="onEditDictionaryClick_"
id="editDictionarySubpageTrigger"
disabled="[[!prefs.browser.enable_spellchecking.value]]"
role-description="$i18n{subpageArrowRoleDescription}">
......
......@@ -23,6 +23,12 @@ Polymer({
notify: true,
},
/** @type {!Map<string, (string|Function)>} */
focusConfig: {
type: Object,
observer: 'focusConfigChanged_',
},
/**
* Read-only reference to the languages model provided by the
* 'os-settings-languages' instance.
......@@ -97,6 +103,20 @@ Polymer({
this.attemptDeepLink();
},
/**
* @param {!Map<string, (string|Function)>} newConfig
* @param {?Map<string, (string|Function)>} oldConfig
* @private
*/
focusConfigChanged_(newConfig, oldConfig) {
// focusConfig is set only once on the parent, so this observer should
// only fire once.
assert(!oldConfig);
this.focusConfig.set(
settings.routes.OS_LANGUAGES_EDIT_DICTIONARY.path,
() => cr.ui.focusWithoutInk(this.$.editDictionarySubpageTrigger));
},
/**
* @param {!Event} e
* @private
......@@ -365,5 +385,16 @@ Polymer({
return this.i18n(
'languagesDictionaryDownloadRetryDescription',
item.language.displayName);
},
/**
* Opens the Custom Dictionary page.
* @private
*/
onEditDictionaryClick_() {
this.languagesMetricsProxy_.recordInteraction(
settings.LanguagesPageInteraction.OPEN_CUSTOM_SPELL_CHECK);
settings.Router.getInstance().navigateTo(
settings.routes.OS_LANGUAGES_EDIT_DICTIONARY);
}
});
<link rel="import" href="chrome://resources/html/polymer.html">
<dom-module id="os-settings-edit-dictionary-page">
<template>
</template>
<script src="os_edit_dictionary_page.js"></script>
</dom-module>
\ No newline at end of file
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview 'os-settings-edit-dictionary-page' is a sub-page for editing
* the "dictionary" of custom words used for spell check.
*/
Polymer({
is: 'os-settings-edit-dictionary-page',
});
......@@ -99,7 +99,8 @@
associated-control="[[$$('#inputPageTrigger')]]"
page-title="$i18n{inputPageTitle}">
<os-settings-input-page language-helper="[[languageHelper]]"
languages="[[languages]]" prefs="{{prefs}}">
languages="[[languages]]" prefs="{{prefs}}"
focus-config="[[focusConfig_]]">
</os-settings-input-page>
</settings-subpage>
</template>
......@@ -141,6 +142,15 @@
</settings-input-method-options-page>
</settings-subpage>
</template>
<!-- "Customize spell check" sub-sub-page. -->
<template is="dom-if" route-path="/osLanguages/editDictionary">
<settings-subpage
associated-control="[[$$('#editDictionarySubpageTrigger')]]"
page-title="$i18n{editDictionaryLabel}">
<os-settings-edit-dictionary-page></os-settings-edit-dictionary-page>
</settings-subpage>
</template>
</settings-animated-pages>
</template>
<script src="os_languages_section.js"></script>
......
......@@ -235,6 +235,9 @@ cr.define('settings', function() {
r.OS_LANGUAGES_INPUT_METHOD_OPTIONS = createSubpage(
r.OS_LANGUAGES_INPUT, mojom.INPUT_METHOD_OPTIONS_SUBPAGE_PATH,
Subpage.kInputMethodOptions);
r.OS_LANGUAGES_EDIT_DICTIONARY = createSubpage(
r.OS_LANGUAGES_INPUT, mojom.EDIT_DICTIONARY_SUBPAGE_PATH,
Subpage.kEditDictionary);
} else {
r.OS_LANGUAGES_DETAILS = createSubpage(
r.OS_LANGUAGES, mojom.LANGUAGES_AND_INPUT_DETAILS_SUBPAGE_PATH,
......
......@@ -129,6 +129,11 @@
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_LANGUAGES_PAGE_OS_EDIT_DICTIONARY_PAGE_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_languages_page/os_edit_dictionary_page.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_LANGUAGES_PAGE_OS_LANGUAGES_PAGE_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_languages_page/os_languages_page.m.js"
use_base_dir="false"
......
......@@ -59,6 +59,7 @@
* OS_ACCESSIBILITY: !settings.Route,
* OS_LANGUAGES: !settings.Route,
* OS_LANGUAGES_DETAILS: !settings.Route,
* OS_LANGUAGES_EDIT_DICTIONARY: !settings.Route,
* OS_LANGUAGES_INPUT: !settings.Route,
* OS_LANGUAGES_INPUT_METHODS: !settings.Route,
* OS_LANGUAGES_INPUT_METHOD_OPTIONS: !settings.Route,
......
......@@ -743,6 +743,12 @@
<structure name="IDR_OS_SETTINGS_LANGUAGES_PAGE_INPUT_PAGE_JS"
file="chromeos/os_languages_page/input_page.js"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_LANGUAGES_PAGE_OS_EDIT_DICTIONARY_PAGE_HTML"
file="chromeos/os_languages_page/os_edit_dictionary_page.html"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_LANGUAGES_PAGE_OS_EDIT_DICTIONARY_PAGE_JS"
file="chromeos/os_languages_page/os_edit_dictionary_page.js"
compress="false" type="chrome_html" />
<structure name="IDR_OS_SETTINGS_LANGUAGES_PAGE_OS_LANGUAGES_PAGE_V2_HTML"
file="chromeos/os_languages_page/os_languages_page_v2.html"
compress="false" type="chrome_html" />
......
......@@ -131,6 +131,8 @@ constexpr std::pair<arc::mojom::ChromePage, const char*> kOSSettingsMapping[] =
chromeos::settings::mojom::kLanguagesAndInputSectionPath},
{ChromePage::OSLANGUAGESDETAILS,
chromeos::settings::mojom::kLanguagesAndInputDetailsSubpagePath},
{ChromePage::OSLANGUAGESEDITDICTIONARY,
chromeos::settings::mojom::kEditDictionarySubpagePath},
{ChromePage::OSLANGUAGESINPUT,
chromeos::settings::mojom::kInputSubpagePath},
{ChromePage::OSLANGUAGESINPUTMETHODS,
......
......@@ -293,6 +293,9 @@ void TestAllOSSettingPages(const GURL& base_url) {
ChromePage::OSLANGUAGESDETAILS,
base_url.Resolve(
chromeos::settings::mojom::kLanguagesAndInputDetailsSubpagePath));
TestOpenChromePage(
ChromePage::OSLANGUAGESEDITDICTIONARY,
base_url.Resolve(chromeos::settings::mojom::kEditDictionarySubpagePath));
TestOpenChromePage(
ChromePage::OSLANGUAGESINPUT,
base_url.Resolve(chromeos::settings::mojom::kInputSubpagePath));
......
......@@ -111,6 +111,7 @@ enum Subpage {
kInputMethodOptions = 1203,
kLanguages = 1204,
kInput = 1205,
kEditDictionary = 1206,
// Files section.
kNetworkFileShares = 1300,
......@@ -220,6 +221,7 @@ const string kSmartInputsSubpagePath = "osLanguages/smartInputs";
const string kInputMethodOptionsSubpagePath = "osLanguages/inputMethodOptions";
const string kLanguagesSubpagePath = "osLanguages/languages";
const string kInputSubpagePath = "osLanguages/input";
const string kEditDictionarySubpagePath = "osLanguages/editDictionary";
// Files section.
const string kFilesSectionPath = "files";
......
......@@ -98,6 +98,7 @@ bool IsOSSettingsSubPage(const std::string& sub_page) {
chromeos::settings::mojom::kInputMethodOptionsSubpagePath,
chromeos::settings::mojom::kLanguagesSubpagePath,
chromeos::settings::mojom::kInputSubpagePath,
chromeos::settings::mojom::kEditDictionarySubpagePath,
// Files section.
chromeos::settings::mojom::kFilesSectionPath,
......
......@@ -17,6 +17,7 @@
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/chromeos_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/spellcheck/browser/pref_names.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
......@@ -119,6 +120,18 @@ const std::vector<SearchConcept>& GetInputPageSearchConceptsV2() {
return *tags;
}
const std::vector<SearchConcept>& GetEditDictionarySearchConceptsV2() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_LANGUAGES_EDIT_DICTIONARY,
mojom::kEditDictionarySubpagePath,
mojom::SearchResultIcon::kGlobe,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSubpage,
{.subpage = mojom::Subpage::kEditDictionary}},
});
return *tags;
}
bool IsLanguageSettingsV2Enabled() {
return base::FeatureList::IsEnabled(
::chromeos::features::kLanguageSettingsUpdate);
......@@ -309,12 +322,21 @@ void AddInputPageStringsV2(content::WebUIDataSource* html_source) {
} // namespace
LanguagesSection::LanguagesSection(Profile* profile,
SearchTagRegistry* search_tag_registry)
: OsSettingsSection(profile, search_tag_registry) {
SearchTagRegistry* search_tag_registry,
PrefService* pref_service)
: OsSettingsSection(profile, search_tag_registry),
pref_service_(pref_service) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
if (IsLanguageSettingsV2Enabled()) {
pref_change_registrar_.Init(pref_service_);
pref_change_registrar_.Add(
spellcheck::prefs::kSpellCheckEnable,
base::BindRepeating(&LanguagesSection::UpdateSpellCheckSearchTags,
base::Unretained(this)));
updater.AddSearchTags(GetLanguagesPageSearchConceptsV2());
updater.AddSearchTags(GetInputPageSearchConceptsV2());
UpdateSpellCheckSearchTags();
} else {
updater.AddSearchTags(GetLanguagesSearchConceptsV1());
}
......@@ -402,13 +424,6 @@ std::string LanguagesSection::GetSectionPath() const {
return mojom::kLanguagesAndInputSectionPath;
}
bool LanguagesSection::IsEmojiSuggestionAllowed() const {
return base::FeatureList::IsEnabled(
::chromeos::features::kEmojiSuggestAddition) &&
profile()->GetPrefs()->GetBoolean(
::chromeos::prefs::kEmojiSuggestionEnterpriseAllowed);
}
void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
// Languages.
generator->RegisterTopLevelSubpage(
......@@ -434,6 +449,13 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
RegisterNestedSettingBulk(mojom::Subpage::kInput, kInputPageSettings,
generator);
// Edit dictionary.
generator->RegisterNestedSubpage(
IDS_OS_SETTINGS_LANGUAGES_EDIT_DICTIONARY_LABEL,
mojom::Subpage::kEditDictionary, mojom::Subpage::kInput,
mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium,
mojom::kEditDictionarySubpagePath);
// Languages and input details.
generator->RegisterTopLevelSubpage(
IDS_OS_SETTINGS_LANGUAGES_AND_INPUT_PAGE_TITLE,
......@@ -494,5 +516,24 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
kSmartInputsFeaturesSettings, generator);
}
bool LanguagesSection::IsEmojiSuggestionAllowed() const {
return base::FeatureList::IsEnabled(
::chromeos::features::kEmojiSuggestAddition) &&
pref_service_->GetBoolean(
::chromeos::prefs::kEmojiSuggestionEnterpriseAllowed);
}
bool LanguagesSection::IsSpellCheckEnabled() const {
return pref_service_->GetBoolean(spellcheck::prefs::kSpellCheckEnable);
}
void LanguagesSection::UpdateSpellCheckSearchTags() {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetEditDictionarySearchConceptsV2());
if (IsSpellCheckEnabled()) {
updater.AddSearchTags(GetEditDictionarySearchConceptsV2());
}
}
} // namespace settings
} // namespace chromeos
......@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_LANGUAGES_SECTION_H_
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "components/prefs/pref_change_registrar.h"
namespace content {
class WebUIDataSource;
......@@ -21,7 +22,9 @@ class SearchTagRegistry;
// the relevant features are enabled.
class LanguagesSection : public OsSettingsSection {
public:
LanguagesSection(Profile* profile, SearchTagRegistry* search_tag_registry);
LanguagesSection(Profile* profile,
SearchTagRegistry* search_tag_registry,
PrefService* pref_service);
~LanguagesSection() override;
private:
......@@ -35,6 +38,11 @@ class LanguagesSection : public OsSettingsSection {
void RegisterHierarchy(HierarchyGenerator* generator) const override;
bool IsEmojiSuggestionAllowed() const;
bool IsSpellCheckEnabled() const;
void UpdateSpellCheckSearchTags();
PrefService* pref_service_;
PrefChangeRegistrar pref_change_registrar_;
};
} // namespace settings
......
......@@ -103,8 +103,8 @@ OsSettingsSections::OsSettingsSections(
sections_map_[mojom::Section::kPrivacyAndSecurity] = privacy_section.get();
sections_.push_back(std::move(privacy_section));
auto language_section =
std::make_unique<LanguagesSection>(profile, search_tag_registry);
auto language_section = std::make_unique<LanguagesSection>(
profile, search_tag_registry, profile->GetPrefs());
sections_map_[mojom::Section::kLanguagesAndInput] = language_section.get();
sections_.push_back(std::move(language_section));
......
......@@ -459,5 +459,15 @@ suite('input page', () => {
assertTrue(editDictionarySubpageTrigger.disabled);
});
test('opens edit dictionary page', () => {
const editDictionarySubpageTrigger =
inputPage.$$('#editDictionarySubpageTrigger');
editDictionarySubpageTrigger.click();
const router = settings.Router.getInstance();
assertEquals(
router.getCurrentRoute().getAbsolutePath(),
'chrome://os-settings/osLanguages/editDictionary');
});
});
});
......@@ -196,8 +196,9 @@ enum ChromePage {
DEPRECATED_DOWNLOADEDCONTENT,
OSLANGUAGESINPUT,
OSLANGUAGESLANGUAGES,
OSLANGUAGESEDITDICTIONARY,
LAST = OSLANGUAGESLANGUAGES
LAST = OSLANGUAGESEDITDICTIONARY
};
// Describes an unique chrome app.
......
......@@ -53437,6 +53437,7 @@ Called by update_net_trust_anchors.py.-->
<int value="1203" label="Input Method Options"/>
<int value="1204" label="Languages"/>
<int value="1205" label="Input"/>
<int value="1206" label="Customize spell check"/>
<int value="1300" label="Network File Shares"/>
<int value="1400" label="Printing Details"/>
<int value="1500" label="Manage Accessibility"/>
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