Commit fc03fa21 authored by manukh's avatar manukh Committed by Commit Bot

[omnibox] [rich-autocomplete] Add AutocompleteMatch::EmptyAutocompletion

Just a helper to check if both suffix and prefix autocompletion are
empty. This is in preparation for the potential introduction of a 3rd
autocompletion field.

Bug: 1062446
Change-Id: I58aecb9cffb690618bb835ed97e1cb69cfdae635
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426964
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810248}
parent 5f9d80d4
...@@ -1040,7 +1040,7 @@ AutocompleteMatch::GetMatchWithContentsAndDescriptionPossiblySwapped() const { ...@@ -1040,7 +1040,7 @@ AutocompleteMatch::GetMatchWithContentsAndDescriptionPossiblySwapped() const {
} }
void AutocompleteMatch::SetAllowedToBeDefault(const AutocompleteInput& input) { void AutocompleteMatch::SetAllowedToBeDefault(const AutocompleteInput& input) {
if (inline_autocompletion.empty() && prefix_autocompletion.empty()) if (IsEmptyAutocompletion())
allowed_to_be_default_match = true; allowed_to_be_default_match = true;
else if (input.prevent_inline_autocomplete()) else if (input.prevent_inline_autocomplete())
allowed_to_be_default_match = false; allowed_to_be_default_match = false;
...@@ -1129,7 +1129,7 @@ void AutocompleteMatch::UpgradeMatchWithPropertiesFrom( ...@@ -1129,7 +1129,7 @@ void AutocompleteMatch::UpgradeMatchWithPropertiesFrom(
fill_into_edit == duplicate_match.fill_into_edit && fill_into_edit == duplicate_match.fill_into_edit &&
duplicate_match.allowed_to_be_default_match) { duplicate_match.allowed_to_be_default_match) {
allowed_to_be_default_match = true; allowed_to_be_default_match = true;
if (inline_autocompletion.empty() && prefix_autocompletion.empty()) { if (IsEmptyAutocompletion()) {
inline_autocompletion = duplicate_match.inline_autocompletion; inline_autocompletion = duplicate_match.inline_autocompletion;
prefix_autocompletion = duplicate_match.prefix_autocompletion; prefix_autocompletion = duplicate_match.prefix_autocompletion;
} }
...@@ -1254,6 +1254,10 @@ bool AutocompleteMatch::TryRichAutocompletion( ...@@ -1254,6 +1254,10 @@ bool AutocompleteMatch::TryRichAutocompletion(
return false; return false;
} }
bool AutocompleteMatch::IsEmptyAutocompletion() const {
return inline_autocompletion.empty() && prefix_autocompletion.empty();
}
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
void AutocompleteMatch::Validate() const { void AutocompleteMatch::Validate() const {
std::string provider_name = provider ? provider->GetName() : "None"; std::string provider_name = provider ? provider->GetName() : "None";
......
...@@ -446,6 +446,9 @@ struct AutocompleteMatch { ...@@ -446,6 +446,9 @@ struct AutocompleteMatch {
const AutocompleteInput& input, const AutocompleteInput& input,
bool shortcut_provider = false); bool shortcut_provider = false);
// True if both |inline_autocompletion| & |prefix_autocompletion| are empty.
bool IsEmptyAutocompletion() const;
// The provider of this match, used to remember which provider the user had // The provider of this match, used to remember which provider the user had
// selected when the input changes. This may be NULL, in which case there is // selected when the input changes. This may be NULL, in which case there is
// no provider (or memory of the user's selection). // no provider (or memory of the user's selection).
......
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