Commit f9115e6c authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

Omnibox UI: Don't use the display URL to generate matches

Previously, when the autocomplete engine did not provide any matches,
the OmniboxEditModel would generate a current match from the text
contents of the View.

This would lead to bad behavior when Steady State Elisions was on. For
example, if the user was at the full URL https://router/, and the
elided display text was simply "router", this would trigger a search
when the user pressed Ctrl+L, and then Enter.

This CL fixes that by only using the View text if user input is in
progress, and using the full formatted URL otherwise (if in display
mode).

This bug doesn't have an impact unless the Steady State Elisions flag
is on, so this doesn't require a merge.

This CL also adds a test.

Bug: 797354
Change-Id: Id27913f567313333e8a171a8040bf906a7a1cc52
Reviewed-on: https://chromium-review.googlesource.com/1013694Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551509}
parent c92fdcdd
...@@ -1346,8 +1346,9 @@ void OmniboxEditModel::GetInfoForCurrentText(AutocompleteMatch* match, ...@@ -1346,8 +1346,9 @@ void OmniboxEditModel::GetInfoForCurrentText(AutocompleteMatch* match,
*alternate_nav_url = result().alternate_nav_url(); *alternate_nav_url = result().alternate_nav_url();
} else { } else {
client_->GetAutocompleteClassifier()->Classify( client_->GetAutocompleteClassifier()->Classify(
MaybePrependKeyword(view_->GetText()), is_keyword_selected(), true, MaybePrependKeyword(user_input_in_progress_ ? view_->GetText()
ClassifyPage(), match, alternate_nav_url); : url_for_editing_),
is_keyword_selected(), true, ClassifyPage(), match, alternate_nav_url);
} }
} }
......
...@@ -231,3 +231,14 @@ TEST_F(OmniboxEditModelTest, AlternateNavHasHTTP) { ...@@ -231,3 +231,14 @@ TEST_F(OmniboxEditModelTest, AlternateNavHasHTTP) {
EXPECT_TRUE(AutocompleteInput::HasHTTPScheme( EXPECT_TRUE(AutocompleteInput::HasHTTPScheme(
client->alternate_nav_match().fill_into_edit)); client->alternate_nav_match().fill_into_edit));
} }
TEST_F(OmniboxEditModelTest, GenerateMatchesFromFullFormattedUrl) {
toolbar_model()->set_formatted_full_url(
base::ASCIIToUTF16("http://localhost/"));
toolbar_model()->set_url_for_display(base::ASCIIToUTF16("localhost"));
model()->ResetDisplayUrls();
// Bypass the test class's mock method to test the real behavior.
AutocompleteMatch match = model()->OmniboxEditModel::CurrentMatch(nullptr);
EXPECT_EQ(AutocompleteMatchType::URL_WHAT_YOU_TYPED, match.type);
}
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