chromium/components/omnibox/browser/autocomplete_grouper_sections.h

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_GROUPER_SECTIONS_H_
#define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_GROUPER_SECTIONS_H_

#include <memory>
#include <vector>

#include "components/omnibox/browser/autocomplete_grouper_groups.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/suggestion_group_util.h"

class Section;
Groups;
PSections;

// `Section` class and subclasses used to implement the various autocomplete
// grouping algorithms.

// Section containing no `Groups` and, therefore, no matches.
class Section {};

// Base section for ZPS limits and grouping. Ensures that matches with higher
// relevance scores do not fill up the section if others with lower scores are
// expected to be placed earlier based on their `Group`'s position.
class ZpsSection : public Section {};

// A ZpsSection that automatically counts all MV Tiles as one suggestion when
// applying the total limit.
class ZpsSectionWithMVTiles : public ZpsSection {};

// Android prefixed section for Adaptive Suggestions grouping.
class AndroidNonZPSSection : public Section {};

// Section expressing the Android ZPS limits and grouping for the NTP.
// - up to 15 + `max_related_queries` + `max_trending_queries` suggestions
//   total.
//  - up to 1 clipboard suggestion.
//  - up to 15 personalized suggestions.
//  - up to 5 trending search suggestions.
class AndroidNTPZpsSection : public ZpsSection {};

// Section expressing the Android ZPS limits and grouping for the SRP.
// - up to 15 suggestions total.
//  - up to 1 verbatim suggestion.
//  - up to 1 clipboard suggestion.
//  - up to 1 most visited carousel.
//  - up to 15 previous search related suggestions.
//  - up to 15 personalized suggestions.
class AndroidSRPZpsSection : public ZpsSection {};

// Section expressing the Android ZPS limits and grouping for the Web.
// - up to 15 suggestions total.
//  - up to 1 verbatim suggestion.
//  - up to 1 clipboard suggestion.
//  - up to 1 most visited carousel.
//  - up to 8 page related suggestions.
//  - up to 15 personalized suggestions.
class AndroidWebZpsSection : public ZpsSectionWithMVTiles {};

// Section expressing the Desktop ZPS limits and grouping for the NTP.
// - up to 8 suggestions total or 7 total if the ZPS IPH is enabled (the 8th
// suggestion being the IPH).
//  - up to 8 personalized suggestions.
//  - up to 8 trending search suggestions.
class DesktopNTPZpsSection : public ZpsSection {};

// Section expressing the Desktop ZPS limits and grouping for the IPH suggestion
// on the NTP.
// - Up to 1 IPH suggestion total
class DesktopNTPZpsIPHSection : public ZpsSection {};

// Section expressing the Desktop secondary ZPS limits and grouping for the NTP.
// - up to 4 suggestions total.
//  - up to 3 previous search related suggestion chips.
// - up to 4 previous search related text suggestions.
// - up to 4 trending suggestions.
class DesktopSecondaryNTPZpsSection : public ZpsSection {};

// Section expressing the Desktop ZPS limits and grouping for the SRP.
// - up to 8 suggestions total.
//  - up to 8 previous search related suggestions.
//  - up to 8 personalized suggestions.
class DesktopSRPZpsSection : public ZpsSection {};

// Section expressing the Desktop ZPS limits and grouping for the Web.
// - up to 8 suggestions total.
//  - up to 8 page related suggestions.
//  - up to 8 personalized suggestions.
class DesktopWebZpsSection : public ZpsSection {};

// Section expressing the Desktop ZPS limits and grouping for the Lens
// contextual searchbox.
// - up to 8 suggestions total.
//  - up to 8 page related suggestions.
class DesktopLensContextualZpsSection : public ZpsSection {};

// Section expressing the Desktop ZPS limits and grouping for the Lens
// multimodal searchbox.
// - up to 8 suggestions total.
//  - up to 8 multimodal suggestions.
class DesktopLensMultimodalZpsSection : public ZpsSection {};

// Section expressing the Desktop, non-ZPS limits and grouping.
// - up to 10 suggestions total.
//  - up to 1 default, 10 starer packs, 10 search, 8 nav, and 1 history cluster
//   suggestions.
// - Only allow more than 8 suggestions if the section does not contain navs.
// - Only allow more than 7 navs if there are no non-navs to show.
// - The history cluster suggestion should count against the search limit.
// - The default suggestion should count against either the search or nav limit.
// - Group defaults 1st, then searches and history clusters, then navs.
class DesktopNonZpsSection : public Section {};

// Section expressing the iPhone ZPS limits and grouping for the NTP.
// - up to `total_count` suggestions total.
//  - up to 1 clipboard suggestion.
//  - up to `psuggest_count` personalized suggestions.
//  - up to `max_trending_queries` trending suggestions.
class IOSNTPZpsSection : public ZpsSection {};

// Section expressing the iPhone ZPS limits and grouping for the SRP.
// - up to 20 suggestions total (where all MV Tiles are counted for 1).
//  - up to 1 verbatim suggestion.
//  - up to 1 clipboard suggestion.
//  - up to 10 most visited in a carousel.
//  - up to 8 previous search related suggestions.
//  - up to 20 personalized suggestions.
class IOSSRPZpsSection : public ZpsSectionWithMVTiles {};

// Section expressing the iPhone ZPS limits and grouping for the Web.
// - up to 20 suggestions total (but all MV Tiles are counted for 1).
//  - up to 1 verbatim suggestion.
//  - up to 1 clipboard suggestion.
//  - up to 10 most visited in a carousel.
//  - up to 8 page related suggestions.
//  - up to 20 personalized suggestions.
class IOSWebZpsSection : public ZpsSectionWithMVTiles {};

// Section expressing the iPad ZPS limits and grouping for the NTP.
// - up to 10 suggestions total.
//  - up to 1 clipboard suggestion.
//  - up to 10 personalized suggestions.
class IOSIpadNTPZpsSection : public ZpsSection {};

// Section expressing the iPad ZPS limits and grouping for the SRP.
// - up to 10 suggestions total (but all MV Tiles are counted for 1).
//  - up to 1 verbatim suggestion.
//  - up to 1 clipboard suggestion.
//  - up to 10 most visited in a carousel.
//  - up to 8 previous search related suggestions.
//  - up to 10 personalized suggestions.
class IOSIpadSRPZpsSection : public ZpsSectionWithMVTiles {};

// Section expressing the iPad ZPS limits and grouping for the Web.
// - up to 10 suggestions total (but all MV Tiles are counted for 1).
//  - up to 1 verbatim suggestion.
//  - up to 1 clipboard suggestion.
//  - up to 10 most visited in a carousel.
//  - up to 8 page related suggestions.
//  - up to 10 personalized suggestions.
class IOSIpadWebZpsSection : public ZpsSectionWithMVTiles {};

#endif  // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_GROUPER_SECTIONS_H_