Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: chrome/browser/autocomplete/history_url_provider.cc

Issue 353010: Better handling of UNKNOWN versus QUERY in a couple ways.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/history_url_provider.cc
===================================================================
--- chrome/browser/autocomplete/history_url_provider.cc (revision 30723)
+++ chrome/browser/autocomplete/history_url_provider.cc (working copy)
@@ -127,10 +127,21 @@
history::URLDatabase* db,
HistoryURLProviderParams* params) {
// Create a What You Typed match, which we'll need below.
+ //
+ // We display this to the user when there's a reasonable chance they actually
+ // care:
+ // * Their input can be opened as a URL, and
+ // * They hit ctrl-enter, or we parsed the input as a URL, or it starts with
+ // an explicit "http:" or "https:".
+ // Otherwise, this is just low-quality noise. In the cases where we've parsed
+ // as UNKNOWN, we'll still show an accidental search infobar if need be.
bool have_what_you_typed_match =
params->input.canonicalized_url().is_valid() &&
- (params->input.type() != AutocompleteInput::UNKNOWN) &&
- (params->input.type() != AutocompleteInput::QUERY);
+ (params->input.type() != AutocompleteInput::QUERY) &&
+ ((params->input.type() != AutocompleteInput::UNKNOWN) ||
+ !params->trim_http ||
+ url_util::FindAndCompareScheme(WideToUTF8(params->input.text()),
+ chrome::kHttpsScheme, NULL));
AutocompleteMatch what_you_typed_match(SuggestExactInput(params->input,
params->trim_http));
@@ -141,7 +152,7 @@
for (Prefixes::const_iterator i(prefixes_.begin()); i != prefixes_.end();
++i) {
if (params->cancel)
- return; // canceled in the middle of a query, give up
+ return; // Canceled in the middle of a query, give up.
// We only need max_matches results in the end, but before we get there we
// need to promote lower-quality matches that are prefixes of
// higher-quality matches, and remove lower-quality redirects. So we ask
@@ -184,7 +195,7 @@
history_matches.empty() ||
!PromoteMatchForInlineAutocomplete(params, history_matches.front())) {
// Failed to promote any URLs for inline autocompletion. Use the What You
- // Typed match, if we have it and the input looked like a URL.
+ // Typed match, if we have it.
first_match = 0;
if (have_what_you_typed_match)
params->matches.push_back(what_you_typed_match);

Powered by Google App Engine
This is Rietveld 408576698