Commit 5b8c84cf authored by tby's avatar tby Committed by Commit Bot

[Search ranking] Clean up ranking_item_util.

We have a lot of dead code behind unused feature flags from past
experiments in the search ranking codebase, so I'm going to do some
clean up CLs.

This one removes the utility code for expanding omnibox result
subtypes, used for the original cat model.

Bug: 1028447
Change-Id: I2f88c68e08505edbc559b7bae63310c2b850c8a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1935629Reviewed-by: default avatarThanh Nguyen <thanhdng@chromium.org>
Commit-Queue: Tony Yeoman <tby@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719486}
parent bf802924
......@@ -15,62 +15,13 @@
namespace app_list {
// Given a ChromeSearchResult representing an omnibox result, convert it based
// on the subtype specified by ChromeSearchResult::result_subtype. Any
// unanticipated subtypes are converted into RankingItemType::kOmniboxGeneric.
RankingItemType ExpandOmniboxType(const ChromeSearchResult& result) {
if (result.result_type() != ash::AppListSearchResultType::kOmnibox) {
NOTREACHED();
return RankingItemType::kUnknown;
}
switch (static_cast<AutocompleteMatchType::Type>(result.result_subtype())) {
case AutocompleteMatchType::Type::HISTORY_URL:
case AutocompleteMatchType::Type::HISTORY_TITLE:
case AutocompleteMatchType::Type::HISTORY_BODY:
case AutocompleteMatchType::Type::HISTORY_KEYWORD:
return RankingItemType::kOmniboxHistory;
case AutocompleteMatchType::Type::NAVSUGGEST:
case AutocompleteMatchType::Type::NAVSUGGEST_PERSONALIZED:
return RankingItemType::kOmniboxNavSuggest;
case AutocompleteMatchType::Type::SEARCH_HISTORY:
case AutocompleteMatchType::Type::SEARCH_SUGGEST:
case AutocompleteMatchType::Type::SEARCH_SUGGEST_ENTITY:
case AutocompleteMatchType::Type::SEARCH_SUGGEST_TAIL:
case AutocompleteMatchType::Type::SEARCH_SUGGEST_PERSONALIZED:
case AutocompleteMatchType::Type::SEARCH_SUGGEST_PROFILE:
case AutocompleteMatchType::Type::SEARCH_OTHER_ENGINE:
return RankingItemType::kOmniboxSearch;
case AutocompleteMatchType::Type::BOOKMARK_TITLE:
return RankingItemType::kOmniboxBookmark;
case AutocompleteMatchType::Type::DOCUMENT_SUGGESTION:
return RankingItemType::kOmniboxDocument;
case AutocompleteMatchType::Type::EXTENSION_APP_DEPRECATED:
case AutocompleteMatchType::Type::CONTACT_DEPRECATED:
case AutocompleteMatchType::Type::PHYSICAL_WEB_DEPRECATED:
case AutocompleteMatchType::Type::PHYSICAL_WEB_OVERFLOW_DEPRECATED:
case AutocompleteMatchType::Type::TAB_SEARCH_DEPRECATED:
return RankingItemType::kOmniboxDeprecated;
default:
return RankingItemType::kOmniboxGeneric;
}
}
RankingItemType RankingItemTypeFromSearchResult(
const ChromeSearchResult& result) {
// We don't want or expect the expand_omnibox_types parameter to change during
// the execution of chrome, so make it static.
static bool expand_omnibox_types = base::GetFieldTrialParamByFeatureAsBool(
app_list_features::kEnableQueryBasedMixedTypesRanker,
"expand_omnibox_types", false);
switch (result.result_type()) {
case ash::AppListSearchResultType::kInstalledApp:
case ash::AppListSearchResultType::kInternalApp:
return RankingItemType::kApp;
case ash::AppListSearchResultType::kOmnibox:
if (expand_omnibox_types)
return ExpandOmniboxType(result);
return RankingItemType::kOmniboxGeneric;
case ash::AppListSearchResultType::kLauncher:
return RankingItemType::kFile;
......
......@@ -58,14 +58,6 @@ class RankingItemUtilTest : public AppListTestBase {
std::unique_ptr<TestAppListControllerDelegate> app_list_controller_delegate_;
};
TEST_F(RankingItemUtilTest, OmniboxSubtypeReturnedWithFinchParameterOn) {
SetAdaptiveRankerParams({{"expand_omnibox_types", "true"}});
std::unique_ptr<OmniboxResult> result =
MakeOmniboxResult(AutocompleteMatchType::HISTORY_URL);
RankingItemType type = RankingItemTypeFromSearchResult(*result.get());
EXPECT_EQ(type, RankingItemType::kOmniboxHistory);
}
TEST_F(RankingItemUtilTest, SimplifyUrlId) {
// Test handling different kinds of scheme, domain, and path. These should all
// be no-ops.
......
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