Commit e2e3514d authored by My Nguyen's avatar My Nguyen Committed by Commit Bot

Add emoji suggestions section in setting page

Mock screenshot: https://screenshot.googleplex.com/n6jPyLOGHoZ
Actual view: https://screenshot.googleplex.com/xho3q7phQr8

Note the actual view is because emoji suggestion can be managed
by enterprise policy

Bug: 1093650
Change-Id: Ie9bf4b4bdc1a51b44b60cf76feebe479334243a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2237835
Commit-Queue: My Nguyen <myy@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779700}
parent a7636356
...@@ -850,6 +850,9 @@ ...@@ -850,6 +850,9 @@
<message name="IDS_OS_SETTINGS_TAG_LANGUAGES_PERSONAL_INFORMATION_SUGGESTIONS" desc="Text for search result item which, when clicked, navigates the user to smart input settings, which with a toggle to enable/disable showing personal information suggestions."> <message name="IDS_OS_SETTINGS_TAG_LANGUAGES_PERSONAL_INFORMATION_SUGGESTIONS" desc="Text for search result item which, when clicked, navigates the user to smart input settings, which with a toggle to enable/disable showing personal information suggestions.">
Personal information suggestions Personal information suggestions
</message> </message>
<message name="IDS_OS_SETTINGS_TAG_LANGUAGES_EMOJI_SUGGESTIONS" desc="Text for search result item which, when clicked, navigates the user to smart input settings, with a section having a toggle to enable/disable showing emoji suggestions after an user types a word.">
Emoji suggestions
</message>
<!-- Files section. --> <!-- Files section. -->
<message name="IDS_OS_SETTINGS_TAG_FILES" desc="Text for search result item which, when clicked, navigates the user to files settings."> <message name="IDS_OS_SETTINGS_TAG_FILES" desc="Text for search result item which, when clicked, navigates the user to files settings.">
......
...@@ -290,6 +290,12 @@ ...@@ -290,6 +290,12 @@
<message name="IDS_SETTINGS_SMART_INPUTS_MANAGE_PERSONAL_INFO" desc="The label for opening Chrome's browser settings page for managing personal addresses"> <message name="IDS_SETTINGS_SMART_INPUTS_MANAGE_PERSONAL_INFO" desc="The label for opening Chrome's browser settings page for managing personal addresses">
Manage personal information Manage personal information
</message> </message>
<message name="IDS_SETTINGS_SMART_INPUTS_EMOJI_SUGGESTION_TITLE" desc="The label for emoji suggestion (when an user types a word, some emojis might be suggested for the user to insert after) section.">
Emoji suggestions
</message>
<message name="IDS_SETTINGS_SMART_INPUTS_SHOW_EMOJI_SUGGESTION" desc="The label for the toggle button controlling showing emoji suggestions (when an user types a word, some emojis might be suggested for the user to insert after).">
Show emoji suggestions
</message>
<!-- Device Page (OS Settings) --> <!-- Device Page (OS Settings) -->
<message name="IDS_OS_SETTINGS_TOUCHPAD_REVERSE_SCROLL_LABEL"> <message name="IDS_OS_SETTINGS_TOUCHPAD_REVERSE_SCROLL_LABEL">
......
0c1b85346a644a73e81f31987e4fb26599704212
\ No newline at end of file
1eb98dd458e3fafcc3dd67920d1c7c5029101a09
\ No newline at end of file
...@@ -290,6 +290,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() { ...@@ -290,6 +290,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
settings_api::PrefType::PREF_TYPE_BOOLEAN; settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[chromeos::prefs::kAssistPersonalInfoEnabled] = (*s_whitelist)[chromeos::prefs::kAssistPersonalInfoEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN; settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[chromeos::prefs::kEmojiSuggestionEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
#endif #endif
// Nearby Share. // Nearby Share.
......
...@@ -48,7 +48,8 @@ Polymer({ ...@@ -48,7 +48,8 @@ Polymer({
smartInputsEnabled_: { smartInputsEnabled_: {
type: Boolean, type: Boolean,
value() { value() {
return loadTimeData.getBoolean('allowAssistivePersonalInfo'); return loadTimeData.getBoolean('allowAssistivePersonalInfo') ||
loadTimeData.getBoolean('allowEmojiSuggestion');
}, },
} }
}, },
......
...@@ -37,6 +37,19 @@ ...@@ -37,6 +37,19 @@
</div> </div>
</div> </div>
</template> </template>
<template is="dom-if" if="[[allowEmojiSuggestion_]]">
<div id="emojiSuggestion">
<h2 aria-hidden="true">
$i18n{emojiSuggestionTitle}
</h2>
<div class="list-frame vertical-list">
<settings-toggle-button class="list-item first"
pref="{{prefs.assistive_input.emoji_suggestion_enabled}}"
label="$i18n{showEmojiSuggestion}">
</settings-toggle-button>
</div>
</div>
</template>
</div> </div>
</template> </template>
<script src="smart_inputs_page.js"></script> <script src="smart_inputs_page.js"></script>
......
...@@ -28,6 +28,14 @@ Polymer({ ...@@ -28,6 +28,14 @@ Polymer({
value() { value() {
return loadTimeData.getBoolean('allowAssistivePersonalInfo'); return loadTimeData.getBoolean('allowAssistivePersonalInfo');
}, },
},
/** @private */
allowEmojiSuggestion_: {
type: Boolean,
value() {
return loadTimeData.getBoolean('allowEmojiSuggestion');
},
} }
}, },
......
...@@ -151,6 +151,7 @@ enum Setting { ...@@ -151,6 +151,7 @@ enum Setting {
kAddLanguage = 1200, kAddLanguage = 1200,
kShowInputOptionsInShelf = 1201, kShowInputOptionsInShelf = 1201,
kShowPersonalInformationSuggestions = 1202, kShowPersonalInformationSuggestions = 1202,
kShowEmojiSuggestions = 1203,
// Files section. // Files section.
kGoogleDriveConnection = 1300, kGoogleDriveConnection = 1300,
......
...@@ -78,12 +78,29 @@ const std::vector<SearchConcept>& GetAssistivePersonalInfoSearchConcepts() { ...@@ -78,12 +78,29 @@ const std::vector<SearchConcept>& GetAssistivePersonalInfoSearchConcepts() {
return *tags; return *tags;
} }
const std::vector<SearchConcept>& GetEmojiSuggestionSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_LANGUAGES_EMOJI_SUGGESTIONS,
mojom::kSmartInputsSubpagePath,
mojom::SearchResultIcon::kGlobe,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kShowEmojiSuggestions}},
});
return *tags;
}
bool IsAssistivePersonalInfoAllowed() { bool IsAssistivePersonalInfoAllowed() {
return !features::IsGuestModeActive() && return !features::IsGuestModeActive() &&
base::FeatureList::IsEnabled( base::FeatureList::IsEnabled(
::chromeos::features::kAssistPersonalInfo); ::chromeos::features::kAssistPersonalInfo);
} }
bool IsEmojiSuggestionAllowed() {
return base::FeatureList::IsEnabled(
::chromeos::features::kEmojiSuggestAddition);
}
void AddSmartInputsStrings(content::WebUIDataSource* html_source) { void AddSmartInputsStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = { static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"smartInputsTitle", IDS_SETTINGS_SMART_INPUTS_TITLE}, {"smartInputsTitle", IDS_SETTINGS_SMART_INPUTS_TITLE},
...@@ -94,11 +111,15 @@ void AddSmartInputsStrings(content::WebUIDataSource* html_source) { ...@@ -94,11 +111,15 @@ void AddSmartInputsStrings(content::WebUIDataSource* html_source) {
{"showPersonalInfoSuggestion", {"showPersonalInfoSuggestion",
IDS_SETTINGS_SMART_INPUTS_SHOW_PERSONAL_INFO}, IDS_SETTINGS_SMART_INPUTS_SHOW_PERSONAL_INFO},
{"managePersonalInfo", IDS_SETTINGS_SMART_INPUTS_MANAGE_PERSONAL_INFO}, {"managePersonalInfo", IDS_SETTINGS_SMART_INPUTS_MANAGE_PERSONAL_INFO},
{"emojiSuggestionTitle",
IDS_SETTINGS_SMART_INPUTS_EMOJI_SUGGESTION_TITLE},
{"showEmojiSuggestion", IDS_SETTINGS_SMART_INPUTS_SHOW_EMOJI_SUGGESTION},
}; };
AddLocalizedStringsBulk(html_source, kLocalizedStrings); AddLocalizedStringsBulk(html_source, kLocalizedStrings);
html_source->AddBoolean("allowAssistivePersonalInfo", html_source->AddBoolean("allowAssistivePersonalInfo",
IsAssistivePersonalInfoAllowed()); IsAssistivePersonalInfoAllowed());
html_source->AddBoolean("allowEmojiSuggestion", IsEmojiSuggestionAllowed());
} }
} // namespace } // namespace
...@@ -108,9 +129,12 @@ LanguagesSection::LanguagesSection(Profile* profile, ...@@ -108,9 +129,12 @@ LanguagesSection::LanguagesSection(Profile* profile,
: OsSettingsSection(profile, search_tag_registry) { : OsSettingsSection(profile, search_tag_registry) {
registry()->AddSearchTags(GetLanguagesSearchConcepts()); registry()->AddSearchTags(GetLanguagesSearchConcepts());
if (IsAssistivePersonalInfoAllowed()) { if (IsAssistivePersonalInfoAllowed() || IsEmojiSuggestionAllowed()) {
registry()->AddSearchTags(GetSmartInputsSearchConcepts()); registry()->AddSearchTags(GetSmartInputsSearchConcepts());
registry()->AddSearchTags(GetAssistivePersonalInfoSearchConcepts()); if (IsAssistivePersonalInfoAllowed())
registry()->AddSearchTags(GetAssistivePersonalInfoSearchConcepts());
if (IsEmojiSuggestionAllowed())
registry()->AddSearchTags(GetEmojiSuggestionSearchConcepts());
} }
} }
...@@ -215,9 +239,12 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const { ...@@ -215,9 +239,12 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
IDS_SETTINGS_SMART_INPUTS_TITLE, mojom::Subpage::kSmartInputs, IDS_SETTINGS_SMART_INPUTS_TITLE, mojom::Subpage::kSmartInputs,
mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium, mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium,
mojom::kSmartInputsSubpagePath); mojom::kSmartInputsSubpagePath);
generator->RegisterNestedSetting( static constexpr mojom::Setting kSmartInputsFeaturesSettings[] = {
mojom::Setting::kShowPersonalInformationSuggestions, mojom::Setting::kShowPersonalInformationSuggestions,
mojom::Subpage::kSmartInputs); mojom::Setting::kShowEmojiSuggestions,
};
RegisterNestedSettingBulk(mojom::Subpage::kSmartInputs,
kSmartInputsFeaturesSettings, generator);
} }
} // namespace settings } // namespace settings
......
...@@ -30,4 +30,16 @@ suite('SmartInputsPage', function() { ...@@ -30,4 +30,16 @@ suite('SmartInputsPage', function() {
createSmartInputsPage(); createSmartInputsPage();
assertFalse(!!smartInputsPage.$$('#assistPersonalInfo')); assertFalse(!!smartInputsPage.$$('#assistPersonalInfo'));
}); });
test('emojiSuggestAdditionNotNullWhenAllowEmojiSuggestionIsTrue', function() {
loadTimeData.overrideValues({allowEmojiSuggestion: true});
createSmartInputsPage();
assertTrue(!!smartInputsPage.$$('#emojiSuggestion'));
});
test('emojiSuggestAdditionNullWhenAllowEmojiSuggestionIsFalse', function() {
loadTimeData.overrideValues({allowEmojiSuggestion: false});
createSmartInputsPage();
assertFalse(!!smartInputsPage.$$('#emojiSuggestion'));
});
}); });
...@@ -51210,6 +51210,7 @@ Called by update_net_trust_anchors.py.--> ...@@ -51210,6 +51210,7 @@ Called by update_net_trust_anchors.py.-->
<int value="1200" label="Add Language"/> <int value="1200" label="Add Language"/>
<int value="1201" label="Show Input Options In Shelf"/> <int value="1201" label="Show Input Options In Shelf"/>
<int value="1202" label="Show Personal Information Suggestions"/> <int value="1202" label="Show Personal Information Suggestions"/>
<int value="1203" label="Show Emoji Suggestions"/>
<int value="1300" label="Google Drive Connection"/> <int value="1300" label="Google Drive Connection"/>
<int value="1400" label="Add Printer"/> <int value="1400" label="Add Printer"/>
<int value="1401" label="Saved Printers"/> <int value="1401" label="Saved Printers"/>
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