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

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

Issue 222783006: Omnibox: Fix HQP Crash on Bad FormatURL and can_inline Interaction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: peter's comment Created 6 years, 8 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 64a3d27a13d1e1992d7946952f9b08a7badcd59e..d94b7db734f89c020846bff5103b8940fd2652bf 100644
--- a/chrome/browser/autocomplete/history_quick_provider.cc
+++ b/chrome/browser/autocomplete/history_quick_provider.cc
@@ -262,8 +262,18 @@ AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch(
match.contents_class =
SpansFromTermMatch(new_matches, match.contents.length(), true);
- if (history_match.can_inline()) {
- DCHECK(!new_matches.empty());
+ // 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@) believe
+ // this is likely caused by the mismatch that offsets are originally
+ // computed with respect to the cleaned-up URL yet then applied and
+ // updated by FormatUrl() as if they applied to the original string.
+ // See crbug.com/252630.
+ // TODO(mpearson): replacing the second clause with a DCHECK after fixing
+ // 252630.
+ if (history_match.can_inline() && !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
« 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