0

Create a new section type for examples.

Bug: b:358007869
Change-Id: I1fed8274c7d3331d8080bafa416741f66f267732
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5771812
Reviewed-by: Michelle Chen <michellegc@google.com>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1339422}
This commit is contained in:
Darren Shen
2024-08-09 01:33:10 +00:00
committed by Chromium LUCI CQ
parent 0c96e104bb
commit 794b6e51be
6 changed files with 20 additions and 4 deletions

@ -7482,6 +7482,10 @@ New install
desc="This string appears as the heading text of a section. This section contains several selectable menu items. This section is the last section on page, and contains menu items that do not belong to the previous sections.">
More
</message>
<message name="IDS_PICKER_EXAMPLES_CATEGORY_TYPE_SECTION_TITLE"
desc="This string appears as the heading text of a section. This section contains a list of example queries that the user can do.">
A few things to try
</message>
<message name="IDS_PICKER_EDIT_TEXT_CATEGORY_TYPE_SECTION_TITLE"
desc="This string appears as the heading text of a section. This section contains several selectable menu items related to editing the user's selected text, such as changing the capitalization of the text.">
Edit text

@ -0,0 +1 @@
032634196e4ad6e759b0d37fb8216d2cbf7c4c4c

@ -16,6 +16,7 @@ namespace ash {
enum class ASH_EXPORT PickerSectionType {
kNone,
kClipboard,
kExamples,
kLinks,
kLocalFiles,
kDriveFiles,

@ -216,13 +216,13 @@ InsertionContent GetInsertionContentForResult(
}
std::vector<PickerSearchResultsSection> CreateSingleSectionForCategoryResults(
PickerSectionType section_type,
std::vector<PickerSearchResult> results) {
if (results.empty()) {
return {};
}
return {PickerSearchResultsSection(PickerSectionType::kNone,
std::move(results),
/*has_more_results*/ false)};
return {PickerSearchResultsSection(section_type, std::move(results),
/*has_more_results=*/false)};
}
std::u16string TransformText(std::u16string_view text,
@ -390,9 +390,15 @@ void PickerController::GetZeroStateSuggestedResults(
void PickerController::GetResultsForCategory(PickerCategory category,
SearchResultsCallback callback) {
const PickerSectionType section_type =
(category == PickerCategory::kUnitsMaths ||
category == PickerCategory::kDatesTimes)
? PickerSectionType::kExamples
: PickerSectionType::kNone;
suggestions_controller_->GetSuggestionsForCategory(
*model_, category,
base::BindRepeating(CreateSingleSectionForCategoryResults)
base::BindRepeating(CreateSingleSectionForCategoryResults, section_type)
.Then(std::move(callback)));
}

@ -118,6 +118,9 @@ std::u16string GetSectionTitleForPickerSectionType(
return u"";
case PickerSectionType::kClipboard:
return l10n_util::GetStringUTF16(IDS_PICKER_CLIPBOARD_CATEGORY_LABEL);
case PickerSectionType::kExamples:
return l10n_util::GetStringUTF16(
IDS_PICKER_EXAMPLES_CATEGORY_TYPE_SECTION_TITLE);
case PickerSectionType::kEditorWrite:
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
return l10n_util::GetStringUTF16(

@ -184,6 +184,7 @@ PickerCategory GetCategoryForMoreResults(PickerSectionType type) {
case PickerSectionType::kNone:
case PickerSectionType::kEditorWrite:
case PickerSectionType::kEditorRewrite:
case PickerSectionType::kExamples:
NOTREACHED_NORETURN();
case PickerSectionType::kClipboard:
return PickerCategory::kClipboard;