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

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

Issue 1124033003: Omnibox - Fix Rare HQP Crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698