Index: chrome/browser/autocomplete/history_quick_provider.cc |
diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc |
index 68cd805af91c950a9f5f13a6dfd9cf22509c1c02..1201efaa5a5f5bbd1608e96aa1ae6b1dba9796cb 100644 |
--- a/chrome/browser/autocomplete/history_quick_provider.cc |
+++ b/chrome/browser/autocomplete/history_quick_provider.cc |
@@ -257,20 +257,31 @@ AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch( |
SpansFromTermMatch(new_matches, match.contents.length(), true); |
// Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. |
+ // The second part of this test can happen if the only match(es) of the user's |
+ // term occur in places FormatUrl() decides to omit in the formatted url. |
+ // In these cases, it's impossible to set |inline_autocompletion| correctly |
+ // and hence the match cannot be the default match. I (mpearson@) do not |
+ // know under what circumstances this can occur. |
+ // See crbug.com/464926. |
if (history_match.can_inline) { |
- DCHECK(!new_matches.empty()); |
- size_t inline_autocomplete_offset = new_matches[0].offset + |
- new_matches[0].length; |
- // |inline_autocomplete_offset| may be beyond the end of the |
- // |fill_into_edit| if the user has typed an URL with a scheme and the |
- // last character typed is a slash. That slash is removed by the |
- // FormatURLWithOffsets call above. |
- if (inline_autocomplete_offset < match.fill_into_edit.length()) { |
- match.inline_autocompletion = |
- match.fill_into_edit.substr(inline_autocomplete_offset); |
+ DCHECK(!new_matches.empty()) << "url=" << info.url().spec() << " input=" |
+ << autocomplete_input_.text() << " history_match.url_matches.size=" |
+ << history_match.url_matches.size() << " offsets.size=" |
+ << offsets.size(); |
+ if (!new_matches.empty()) { |
+ size_t inline_autocomplete_offset = new_matches[0].offset + |
+ new_matches[0].length; |
+ // |inline_autocomplete_offset| may be beyond the end of the |
+ // |fill_into_edit| if the user has typed an URL with a scheme and the |
+ // last character typed is a slash. That slash is removed by the |
+ // FormatURLWithOffsets call above. |
+ if (inline_autocomplete_offset < match.fill_into_edit.length()) { |
+ match.inline_autocompletion = |
+ match.fill_into_edit.substr(inline_autocomplete_offset); |
+ } |
+ match.allowed_to_be_default_match = match.inline_autocompletion.empty() || |
+ !PreventInlineAutocomplete(autocomplete_input_); |
} |
- match.allowed_to_be_default_match = match.inline_autocompletion.empty() || |
- !PreventInlineAutocomplete(autocomplete_input_); |
} |
match.EnsureUWYTIsAllowedToBeDefault( |
autocomplete_input_.canonicalized_url(), |