Commit 4e56b141 authored by Gang Wu's avatar Gang Wu Committed by Commit Bot

[Omnibox] Change isUrlSuggestion->isSearchSuggestion

Change-Id: I9966644225507f51d5d22189b5e391491ed03587
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153569Reviewed-by: default avatarEnder <ender@google.com>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Gang Wu <gangwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760130}
parent fb8b9055
......@@ -234,7 +234,7 @@ public class LocationBarTablet extends LocationBarLayout {
super.onSuggestionsChanged(autocompleteText);
mStatusViewCoordinator.setFirstSuggestionIsSearchType(
mAutocompleteCoordinator.getSuggestionCount() > 0
&& !mAutocompleteCoordinator.getSuggestionAt(0).isUrlSuggestion());
&& mAutocompleteCoordinator.getSuggestionAt(0).isSearchSuggestion());
}
@Override
......
......@@ -684,17 +684,17 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
*/
private void onRefineSuggestion(OmniboxSuggestion suggestion) {
stopAutocomplete(false);
boolean isUrlSuggestion = suggestion.isUrlSuggestion();
boolean isSearchSuggestion = suggestion.isSearchSuggestion();
String refineText = suggestion.getFillIntoEdit();
if (!isUrlSuggestion) refineText = TextUtils.concat(refineText, " ").toString();
if (isSearchSuggestion) refineText = TextUtils.concat(refineText, " ").toString();
mDelegate.setOmniboxEditingText(refineText);
onTextChanged(mUrlBarEditingTextProvider.getTextWithoutAutocomplete(),
mUrlBarEditingTextProvider.getTextWithAutocomplete());
if (isUrlSuggestion) {
RecordUserAction.record("MobileOmniboxRefineSuggestion.Url");
} else {
if (isSearchSuggestion) {
RecordUserAction.record("MobileOmniboxRefineSuggestion.Search");
} else {
RecordUserAction.record("MobileOmniboxRefineSuggestion.Url");
}
}
......
......@@ -165,10 +165,10 @@ public class OmniboxSuggestion {
}
/**
* @return Whether the suggestion is a URL.
* @return Whether the suggestion is a search suggestion.
*/
public boolean isUrlSuggestion() {
return !mIsSearchType;
public boolean isSearchSuggestion() {
return mIsSearchType;
}
/**
......@@ -247,7 +247,7 @@ public class OmniboxSuggestion {
.putString(KEY_PREFIX_ZERO_SUGGEST_DESCRIPTION + i, suggestion.getDescription())
.putInt(KEY_PREFIX_ZERO_SUGGEST_NATIVE_TYPE + i, suggestion.getType())
.putBoolean(KEY_PREFIX_ZERO_SUGGEST_IS_SEARCH_TYPE + i,
!suggestion.isUrlSuggestion())
suggestion.isSearchSuggestion())
.putBoolean(KEY_PREFIX_ZERO_SUGGEST_IS_DELETABLE + i, suggestion.isDeletable())
.putBoolean(KEY_PREFIX_ZERO_SUGGEST_IS_STARRED + i, suggestion.isStarred())
.putString(KEY_PREFIX_ZERO_SUGGEST_POST_CONTENT_TYPE + i,
......
......@@ -97,13 +97,7 @@ public class BasicSuggestionProcessor extends BaseSuggestionViewProcessor {
* when we know we have a valid and large enough site favicon to present.
*/
private @SuggestionIcon int getSuggestionIconType(OmniboxSuggestion suggestion) {
if (suggestion.isUrlSuggestion()) {
if (suggestion.isStarred()) {
return SuggestionIcon.BOOKMARK;
} else {
return SuggestionIcon.GLOBE;
}
} else /* Search suggestion */ {
if (suggestion.isSearchSuggestion()) {
switch (suggestion.getType()) {
case OmniboxSuggestionType.VOICE_SUGGEST:
return SuggestionIcon.VOICE;
......@@ -115,6 +109,12 @@ public class BasicSuggestionProcessor extends BaseSuggestionViewProcessor {
default:
return SuggestionIcon.MAGNIFIER;
}
} else {
if (suggestion.isStarred()) {
return SuggestionIcon.BOOKMARK;
} else {
return SuggestionIcon.GLOBE;
}
}
}
......@@ -164,7 +164,7 @@ public class BasicSuggestionProcessor extends BaseSuggestionViewProcessor {
SuggestionSpannable textLine2 = null;
boolean urlHighlighted = false;
if (suggestion.isUrlSuggestion()) {
if (!suggestion.isSearchSuggestion()) {
if (!TextUtils.isEmpty(suggestion.getUrl())) {
SuggestionSpannable str = new SuggestionSpannable(suggestion.getDisplayText());
urlHighlighted = applyHighlightToMatchRegions(
......@@ -176,10 +176,10 @@ public class BasicSuggestionProcessor extends BaseSuggestionViewProcessor {
}
final SuggestionSpannable textLine1 =
getSuggestedQuery(suggestion, suggestion.isUrlSuggestion(), !urlHighlighted);
getSuggestedQuery(suggestion, !suggestion.isSearchSuggestion(), !urlHighlighted);
updateSuggestionIcon(suggestion, model);
model.set(SuggestionViewProperties.IS_SEARCH_SUGGESTION, !suggestion.isUrlSuggestion());
model.set(SuggestionViewProperties.IS_SEARCH_SUGGESTION, suggestion.isSearchSuggestion());
model.set(SuggestionViewProperties.TEXT_LINE_1_TEXT, textLine1);
model.set(SuggestionViewProperties.TEXT_LINE_2_TEXT, textLine2);
fetchSuggestionFavicon(model, suggestion.getUrl(), mIconBridgeSupplier.get(), () -> {
......
......@@ -46,7 +46,7 @@ public class OmniboxSuggestionUnitTest {
&& TextUtils.equals(suggestion1.getDisplayText(), suggestion2.getDisplayText())
&& TextUtils.equals(suggestion1.getDescription(), suggestion2.getDescription())
&& TextUtils.equals(suggestion1.getUrl(), suggestion2.getUrl())
&& suggestion1.isUrlSuggestion() == suggestion2.isUrlSuggestion()
&& suggestion1.isSearchSuggestion() == suggestion2.isSearchSuggestion()
&& suggestion1.isStarred() == suggestion2.isStarred()
&& suggestion1.isDeletable() == suggestion2.isDeletable()
&& TextUtils.equals(
......
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