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

Omnibox: Slight optimization for OmniboxEditModel::CurrentTextIsURL

Previously, we skipped the match classification process if
user_input_in_progress_ was false and we were not in Query in Omnibox
mode.

Actually, we can always skip the classification process if
user_input_in_progress_ is false.

This CL implements that slight optimization.

Bug: NONE
Change-Id: Iabde52481e199b60874434f034733f7275af8f92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1534282Reviewed-by: default avatarKevin Bailey <krb@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644477}
parent 668b9493
...@@ -342,14 +342,17 @@ void OmniboxEditModel::GetDataForURLExport(GURL* url, ...@@ -342,14 +342,17 @@ void OmniboxEditModel::GetDataForURLExport(GURL* url,
} }
bool OmniboxEditModel::CurrentTextIsURL() const { bool OmniboxEditModel::CurrentTextIsURL() const {
// If !user_input_in_progress_ and we are not showing a Query in Omnibox, // If !user_input_in_progress_, we can determine if the text is a URL without
// then the URL is showing as the permanent display text, and no further // starting the autocomplete system. This speeds browser startup.
// checking is needed. By avoiding checking in this case, we avoid calling if (!user_input_in_progress_) {
// into the autocomplete providers, and thus initializing the history system, // If we are displaying Query in Omnibox, and the user has not clicked
// as long as possible, which speeds startup. // "Show URL", then the text must be search terms, and not a URL.
LocationBarModel* location_bar_model = controller()->GetLocationBarModel(); if (controller()->GetLocationBarModel()->GetDisplaySearchTerms(nullptr) &&
if (!user_input_in_progress_ && view_->GetText() == display_text_) {
!location_bar_model->GetDisplaySearchTerms(nullptr)) { return false;
}
// In all other cases, the text must be a URL.
return true; return true;
} }
......
...@@ -286,6 +286,7 @@ TEST_F(OmniboxEditModelTest, CurrentMatch) { ...@@ -286,6 +286,7 @@ TEST_F(OmniboxEditModelTest, CurrentMatch) {
location_bar_model()->set_url(GURL("http://localhost/")); location_bar_model()->set_url(GURL("http://localhost/"));
location_bar_model()->set_url_for_display(base::ASCIIToUTF16("localhost")); location_bar_model()->set_url_for_display(base::ASCIIToUTF16("localhost"));
model()->ResetDisplayTexts(); model()->ResetDisplayTexts();
model()->Revert();
// Tests that we use the formatted full URL instead of the elided URL to // Tests that we use the formatted full URL instead of the elided URL to
// generate matches. // generate matches.
...@@ -299,6 +300,7 @@ TEST_F(OmniboxEditModelTest, CurrentMatch) { ...@@ -299,6 +300,7 @@ TEST_F(OmniboxEditModelTest, CurrentMatch) {
// query, instead of the full formatted URL. // query, instead of the full formatted URL.
location_bar_model()->set_display_search_terms(base::ASCIIToUTF16("foobar")); location_bar_model()->set_display_search_terms(base::ASCIIToUTF16("foobar"));
model()->ResetDisplayTexts(); model()->ResetDisplayTexts();
model()->Revert();
{ {
AutocompleteMatch match = model()->CurrentMatch(nullptr); AutocompleteMatch match = model()->CurrentMatch(nullptr);
......
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