Commit 76fa453c authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

[omnibox] Support showing group ID and header text in chrome://omnibox.

This records the group ID and header text of suggestions in the
additional_info field of AutocompleteMatch.

That way, we can show this extended metadata in chrome://omnibox
in a lightweight way (without adding a whole new column or something).

This will be useful for Moe and I (and others) to debug the header
text feature as we are developing it.

I really like the extensible additional_info dictionary by the way.

Bug: 1052519, 1052522
Change-Id: I1409b6e6fd775149f6ca9c67e793f49c031c7251
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132958
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755861}
parent a4ef653f
......@@ -756,14 +756,28 @@ void AutocompleteController::UpdateAssociatedKeywords(
}
void AutocompleteController::UpdateHeaders(AutocompleteResult* result) {
DCHECK(result);
// Set the suggestion group ID to header mapping information.
result->set_headers_map(zero_suggest_provider_->headers_map());
// Move all grouped matches to the bottom while maintaining the current order.
std::stable_sort(result->begin(), result->end(),
[](const auto& a, const auto& b) {
return !a.suggestion_group_id && b.suggestion_group_id;
return !a.suggestion_group_id.has_value() &&
b.suggestion_group_id.has_value();
});
// Record header data into the additional_info field for chrome://omnibox.
for (AutocompleteMatch& match : *result) {
if (match.suggestion_group_id.has_value()) {
int group_id = match.suggestion_group_id.value();
match.RecordAdditionalInfo("suggestion_group_id", group_id);
match.RecordAdditionalInfo(
"header string",
base::UTF16ToUTF8(result->GetHeaderForGroupId(group_id)));
}
}
}
void AutocompleteController::UpdateKeywordDescriptions(
......
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