Commit f2827420 authored by Jia's avatar Jia Committed by Commit Bot

[Cros SR] Add GetSubType method to ChromeSearchResult.

This method's default impl is to return -1. The subclasses overriding it are
expected to return a meaningful +ve value.

Bug: 931149
Change-Id: I6c91e8d92b5c3bfca8a4ccd3a2223d928fe13eb7
Reviewed-on: https://chromium-review.googlesource.com/c/1481277
Commit-Queue: Jia Meng <jiameng@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634400}
parent 3b39b4ae
......@@ -215,6 +215,10 @@ std::string ChromeSearchResult::TagsDebugStringForTest(const std::string& text,
return result;
}
int ChromeSearchResult::GetSubType() const {
return -1;
}
app_list::AppContextMenu* ChromeSearchResult::GetAppContextMenu() {
return nullptr;
}
......@@ -121,6 +121,11 @@ class ChromeSearchResult {
static std::string TagsDebugStringForTest(const std::string& text,
const Tags& tags);
// Subtype of a search result. -1 means no sub type. Derived class
// can use this to return useful values for rankers etc. Currently,
// OmniboxResult overrides it to return AutocompleteMatch::Type.
virtual int GetSubType() const;
protected:
// These id setters should be called in derived class constructors only.
void set_id(const std::string& id) { metadata_->id = id; }
......
......@@ -187,8 +187,8 @@ void OmniboxResult::InvokeAction(int action_index, int event_flags) {
}
}
AutocompleteMatch::Type OmniboxResult::type() const {
return match_.type;
int OmniboxResult::GetSubType() const {
return static_cast<int>(match_.type);
}
void OmniboxResult::UpdateIcon() {
......
......@@ -38,9 +38,7 @@ class OmniboxResult : public ChromeSearchResult {
// ChromeSearchResult overrides:
void Open(int event_flags) override;
void InvokeAction(int action_index, int event_flags) override;
// Returns type of the matched result as a string.
AutocompleteMatch::Type type() const;
int GetSubType() const override;
private:
void UpdateIcon();
......
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