summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/history_url_provider.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-11 21:37:43 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-11 21:37:43 +0000
commit3247d92f87ba0ad4c8afe0ee1f482f1b4442eca5 (patch)
tree45de6fd1e3e3d900ac5389a5e9500caae5fb5abf /chrome/browser/autocomplete/history_url_provider.cc
parent5ef8453ec790c7b2a1e3efff42d4c2cebcecfd6f (diff)
downloadchromium_src-3247d92f87ba0ad4c8afe0ee1f482f1b4442eca5.zip
chromium_src-3247d92f87ba0ad4c8afe0ee1f482f1b4442eca5.tar.gz
chromium_src-3247d92f87ba0ad4c8afe0ee1f482f1b4442eca5.tar.bz2
Fix regression where exact-match URLs could fail to be promoted when longer URLs were typed more.
We should alwys look up whether we have an exact match, regardless of the input type, and use it if we have it. My change to not add the "exact match" entry for UNKNOWN input should have only affected the case where that match doesn't, in fact, exist. BUG=1844093 Review URL: http://codereview.chromium.org/113223 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15786 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/history_url_provider.cc')
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc56
1 files changed, 29 insertions, 27 deletions
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index d623748..0083bfe 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -131,8 +131,7 @@ void HistoryURLProvider::ExecuteWithDB(history::HistoryBackend* backend,
void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend,
history::URLDatabase* db,
HistoryURLProviderParams* params) {
- // For non-UNKNOWN input, create a What You Typed match, which we'll need
- // below.
+ // Create a What You Typed match, which we'll need below.
bool have_what_you_typed_match =
params->input.canonicalized_url().is_valid() &&
(params->input.type() != AutocompleteInput::UNKNOWN);
@@ -176,16 +175,23 @@ void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend,
// converting the rest of the matches.
size_t first_match = 1;
size_t exact_suggestion = 0;
- if (params->input.prevent_inline_autocomplete() || history_matches.empty() ||
+ // Checking |is_history_what_you_typed_match| tells us whether
+ // SuggestExactInput() succeeded in constructing a valid match.
+ if (what_you_typed_match.is_history_what_you_typed_match &&
+ FixupExactSuggestion(db, params->input, &what_you_typed_match,
+ &history_matches)) {
+ // Got an exact match for the user's input. Treat is as the best match
+ // regardless of the input type.
+ exact_suggestion = 1;
+ params->matches.push_back(what_you_typed_match);
+ } else if (params->input.prevent_inline_autocomplete() ||
+ history_matches.empty() ||
!PromoteMatchForInlineAutocomplete(params, history_matches.front())) {
- // Failed to promote for inline autocompletion. Use the What You Typed
- // match, if we have it.
+ // Failed to promote any URLs for inline autocompletion. Use the What You
+ // Typed match, if we have it and the input wasn't UNKNOWN.
first_match = 0;
- if (have_what_you_typed_match) {
+ if (have_what_you_typed_match)
params->matches.push_back(what_you_typed_match);
- if (FixupExactSuggestion(db, params, &history_matches))
- first_match = exact_suggestion = 1;
- }
}
// This is the end of the synchronous pass.
@@ -269,12 +275,11 @@ AutocompleteMatch HistoryURLProvider::SuggestExactInput(
}
bool HistoryURLProvider::FixupExactSuggestion(history::URLDatabase* db,
- HistoryURLProviderParams* params,
+ const AutocompleteInput& input,
+ AutocompleteMatch* match,
HistoryMatches* matches) const {
- DCHECK(!params->matches.empty());
-
- history::URLRow info;
- AutocompleteMatch& match = params->matches.front();
+ DCHECK(match != NULL);
+ DCHECK(matches != NULL);
// Tricky corner case: The user has visited intranet site "foo", but not
// internet site "www.foo.com". He types in foo (getting an exact match),
@@ -291,27 +296,24 @@ bool HistoryURLProvider::FixupExactSuggestion(history::URLDatabase* db,
// * and the input _without_ the TLD _is_ in the history DB,
// * ...then just before pressing "ctrl" the best match we supplied was the
// what-you-typed match, so stick with it by promoting this.
- if (!db->GetRowForURL(match.destination_url, &info)) {
- if (params->input.desired_tld().empty())
+ history::URLRow info;
+ if (!db->GetRowForURL(match->destination_url, &info)) {
+ if (input.desired_tld().empty())
return false;
- GURL destination_url(
- URLFixerUpper::FixupURL(WideToUTF8(params->input.text()),
- std::string()));
+ GURL destination_url(URLFixerUpper::FixupURL(WideToUTF8(input.text()),
+ std::string()));
if (!db->GetRowForURL(destination_url, &info))
return false;
} else {
// We have data for this match, use it.
- match.deletable = true;
- match.description = info.title();
- AutocompleteMatch::ClassifyMatchInString(params->input.text(),
- info.title(),
- ACMatchClassification::NONE,
- &match.description_class);
+ match->deletable = true;
+ match->description = info.title();
+ AutocompleteMatch::ClassifyMatchInString(input.text(), info.title(),
+ ACMatchClassification::NONE, &match->description_class);
}
// Promote as an exact match.
- match.relevance = CalculateRelevance(params->input.type(),
- INLINE_AUTOCOMPLETE, 0);
+ match->relevance = CalculateRelevance(input.type(), INLINE_AUTOCOMPLETE, 0);
// Put it on the front of the HistoryMatches for redirect culling.
EnsureMatchPresent(info, std::wstring::npos, false, matches, true);