0

coral: Properly set coral chip title

The correct title logic for coral chip is that a placeholder title would
be set, then the actual title would be fetched from the group when
initing the chip (because it could be nullopt). Loading animation / real
title / placeholder title would show accordingly. But that logic was
accidentally removed in https://crrev.com/c/6150035, to that the group
title from request would be used directly, if provided. This introduces
a bug that if the backend returns an empty title (which is intended,
when we want to use placeholder title instead), the group will be
filtered by birch model and not shown.

This CL makes the group use placeholder title if the returned title is
empty or null.

Bug: b:405906928
Test: CQ
Test: On device, test that title will be set correctly
Change-Id: If4beffb9bab741be1f2f95b103c1945c7b7c795a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6381619
Reviewed-by: Xiaodan Zhu <zxdan@chromium.org>
Commit-Queue: Howard Yang <hcyang@google.com>
Cr-Commit-Position: refs/heads/main@{#1437835}
This commit is contained in:
Howard Yang
2025-03-25 16:46:36 -07:00
committed by Chromium LUCI CQ
parent e9574ae6cc
commit 6e35926697

@ -811,9 +811,11 @@ void BirchCoralProvider::HandleCoralResponse(
NOTREACHED() << "Unknown response type.";
}
// If the group title is null/empty, we use a placeholder title.
bool is_non_empty = group->title.has_value() && !group->title->empty();
items.emplace_back(
group->title
? base::UTF8ToUTF16(*(group->title))
is_non_empty
? base::UTF8ToUTF16(*group->title)
: l10n_util::GetStringUTF16(IDS_ASH_BIRCH_CORAL_SUGGESTION_NAME),
l10n_util::GetStringUTF16(subtitle_id), response_->source(), group->id);
}