0

Add placeholder search box string for cloud gaming.

Bug: 1325360
Change-Id: Ia15d8f2f51de9aa38b56900fc98aafdb4cb2264a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3645240
Reviewed-by: Matthew Mourgos <mmourgos@chromium.org>
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Auto-Submit: Yulun Wu <yulunwu@chromium.org>
Commit-Queue: Yulun Wu <yulunwu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1004017}
This commit is contained in:
Yulun Wu
2022-05-17 00:02:19 +00:00
committed by Chromium LUCI CQ
parent a05c2a1434
commit 2996998d10
4 changed files with 48 additions and 12 deletions

@ -81,12 +81,36 @@ constexpr auto kBorderInsetsForAppListBubble = gfx::Insets::TLBR(4, 4, 4, 0);
constexpr auto kTextFieldMarginsForAppListBubble =
gfx::Insets::TLBR(8, 0, 0, 0);
// The default PlaceholderTextTypes used for productivity launcher. Randomly
// selected when placeholder text would be shown.
constexpr SearchBoxView::PlaceholderTextType kDefaultPlaceholders[3] = {
SearchBoxView::PlaceholderTextType::kShortcuts,
SearchBoxView::PlaceholderTextType::kTabs,
SearchBoxView::PlaceholderTextType::kSettings,
};
// PlaceholderTextTypes used for productivity launcher for cloud gaming devices.
// Randomly selected when placeholder text would be shown.
constexpr SearchBoxView::PlaceholderTextType kGamingPlaceholders[4] = {
SearchBoxView::PlaceholderTextType::kShortcuts,
SearchBoxView::PlaceholderTextType::kTabs,
SearchBoxView::PlaceholderTextType::kSettings,
SearchBoxView::PlaceholderTextType::kGames,
};
bool IsTrimmedQueryEmpty(const std::u16string& query) {
std::u16string trimmed_query;
base::TrimWhitespace(query, base::TrimPositions::TRIM_ALL, &trimmed_query);
return trimmed_query.empty();
}
SearchBoxView::PlaceholderTextType SelectPlaceholderText() {
if (features::IsCloudGamingDevice()) {
return kGamingPlaceholders[rand() % std::size(kGamingPlaceholders)];
}
return kDefaultPlaceholders[rand() % std::size(kDefaultPlaceholders)];
}
} // namespace
class SearchBoxView::FocusRingLayer : public ui::Layer, ui::LayerDelegate {
@ -717,11 +741,7 @@ void SearchBoxView::UpdateTextColor() {
void SearchBoxView::UpdatePlaceholderTextAndAccessibleName() {
if (features::IsProductivityLauncherEnabled()) {
// Randomly select a placeholder text.
const PlaceholderTextType placeholder_type = PlaceholderTextType(
base::RandInt(0, static_cast<int>(PlaceholderTextType::kMaxValue)));
switch (placeholder_type) {
switch (SelectPlaceholderText()) {
case PlaceholderTextType::kShortcuts:
search_box()->SetPlaceholderText(l10n_util::GetStringFUTF16(
IDS_APP_LIST_SEARCH_BOX_PLACEHOLDER_TEMPLATE,
@ -758,6 +778,18 @@ void SearchBoxView::UpdatePlaceholderTextAndAccessibleName() {
l10n_util::GetStringUTF16(
IDS_APP_LIST_SEARCH_BOX_PLACEHOLDER_SETTINGS)));
break;
case PlaceholderTextType::kGames:
search_box()->SetPlaceholderText(l10n_util::GetStringFUTF16(
IDS_APP_LIST_SEARCH_BOX_PLACEHOLDER_TEMPLATE,
l10n_util::GetStringUTF16(
IDS_APP_LIST_SEARCH_BOX_PLACEHOLDER_GAMES)));
search_box()->SetAccessibleName(l10n_util::GetStringFUTF16(
is_tablet_mode_
? IDS_APP_LIST_SEARCH_BOX_PLACEHOLDER_TEMPLATE_ACCESSIBILITY_NAME_TABLET
: IDS_APP_LIST_SEARCH_BOX_PLACEHOLDER_TEMPLATE_ACCESSIBILITY_NAME_CLAMSHELL,
l10n_util::GetStringUTF16(
IDS_APP_LIST_SEARCH_BOX_PLACEHOLDER_GAMES)));
break;
}
} else {
search_box()->SetPlaceholderText(

@ -42,6 +42,13 @@ class ASH_EXPORT SearchBoxView : public SearchBoxViewBase,
public AppListModelProvider::Observer,
public SearchBoxModelObserver {
public:
enum class PlaceholderTextType {
kShortcuts = 0,
kTabs = 1,
kSettings = 2,
kGames = 3
};
SearchBoxView(SearchBoxViewDelegate* delegate,
AppListViewDelegate* view_delegate,
AppListView* app_list_view = nullptr);
@ -163,13 +170,6 @@ class ASH_EXPORT SearchBoxView : public SearchBoxViewBase,
private:
class FocusRingLayer;
enum class PlaceholderTextType {
kShortcuts = 0,
kTabs = 1,
kSettings = 2,
kMaxValue = kSettings
};
// Updates the text field text color.
void UpdateTextColor();

@ -4810,6 +4810,9 @@ New install
<message name="IDS_APP_LIST_SEARCH_BOX_PLACEHOLDER_SETTINGS" desc="One of possible rotating providers listed in the placeholder text for the search box shown within the ChromeOS launcher. The provider is injected into string 'Search your $1, files, apps, and more...'">
settings
</message>
<message name="IDS_APP_LIST_SEARCH_BOX_PLACEHOLDER_GAMES" desc="One of possible rotating providers listed in the placeholder text for the search box shown within the ChromeOS launcher. The provider is injected into string 'Search your $1, files, apps, and more...'">
games
</message>
<!-- WM -->
<message name="IDS_ENTER_PIP_A11Y_NOTIFICATION" is_accessibility_with_no_ui="true" desc="Accessibility text read by chromevox when a window starts picture-in-picture mode.">

@ -0,0 +1 @@
48c6c426910ab6f241a5d73fc8371aad3f83ad90