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

Unified Diff: components/omnibox/browser/autocomplete_result.cc

Issue 2266083002: Avoid DCHECK failure for chrome:// URLs in autocomplete suggestions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes for pkasting@ Created 4 years, 3 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
Index: components/omnibox/browser/autocomplete_result.cc
diff --git a/components/omnibox/browser/autocomplete_result.cc b/components/omnibox/browser/autocomplete_result.cc
index 14f084337e980300abdaf7d6df4ba3b249b8374d..9aa9815358303c2b6d6aeef42b3c658805c943e1 100644
--- a/components/omnibox/browser/autocomplete_result.cc
+++ b/components/omnibox/browser/autocomplete_result.cc
@@ -166,11 +166,20 @@ void AutocompleteResult::SortAndCull(
: base::string16()) +
base::ASCIIToUTF16(", input=") +
input.text();
- DCHECK(default_match_->allowed_to_be_default_match) << debug_info;
- // If the default match is valid (i.e., not a prompt/placeholder), make
- // sure the type of destination is what the user would expect given the
- // input.
- if (default_match_->destination_url.is_valid()) {
+
+ // We should only get here with an empty omnibox for automatic suggestions
+ // on focus on the NTP; in these cases hitting enter should do nothing, so
+ // there should be no default match. Otherwise, we're doing automatic
+ // suggestions for the currently visible URL (and hitting enter should
+ // reload it), or the user is typing; in either of these cases, there should
+ // be a default match.
+ DCHECK_NE(input.text().empty(), default_match_->allowed_to_be_default_match)
+ << debug_info;
+
+ // For navigable default matches, make sure the destination type is what the
+ // user would expect given the input.
+ if (default_match_->allowed_to_be_default_match &&
+ default_match_->destination_url.is_valid()) {
if (AutocompleteMatch::IsSearchType(default_match_->type)) {
// We shouldn't get query matches for URL inputs.
DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info;
« no previous file with comments | « components/omnibox/browser/autocomplete_controller.cc ('k') | components/omnibox/browser/autocomplete_result_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698