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, ...@@ -215,6 +215,10 @@ std::string ChromeSearchResult::TagsDebugStringForTest(const std::string& text,
return result; return result;
} }
int ChromeSearchResult::GetSubType() const {
return -1;
}
app_list::AppContextMenu* ChromeSearchResult::GetAppContextMenu() { app_list::AppContextMenu* ChromeSearchResult::GetAppContextMenu() {
return nullptr; return nullptr;
} }
...@@ -121,6 +121,11 @@ class ChromeSearchResult { ...@@ -121,6 +121,11 @@ class ChromeSearchResult {
static std::string TagsDebugStringForTest(const std::string& text, static std::string TagsDebugStringForTest(const std::string& text,
const Tags& tags); 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: protected:
// These id setters should be called in derived class constructors only. // These id setters should be called in derived class constructors only.
void set_id(const std::string& id) { metadata_->id = id; } void set_id(const std::string& id) { metadata_->id = id; }
......
...@@ -187,8 +187,8 @@ void OmniboxResult::InvokeAction(int action_index, int event_flags) { ...@@ -187,8 +187,8 @@ void OmniboxResult::InvokeAction(int action_index, int event_flags) {
} }
} }
AutocompleteMatch::Type OmniboxResult::type() const { int OmniboxResult::GetSubType() const {
return match_.type; return static_cast<int>(match_.type);
} }
void OmniboxResult::UpdateIcon() { void OmniboxResult::UpdateIcon() {
......
...@@ -38,9 +38,7 @@ class OmniboxResult : public ChromeSearchResult { ...@@ -38,9 +38,7 @@ class OmniboxResult : public ChromeSearchResult {
// ChromeSearchResult overrides: // ChromeSearchResult overrides:
void Open(int event_flags) override; void Open(int event_flags) override;
void InvokeAction(int action_index, int event_flags) override; void InvokeAction(int action_index, int event_flags) override;
int GetSubType() const override;
// Returns type of the matched result as a string.
AutocompleteMatch::Type type() const;
private: private:
void UpdateIcon(); 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