| 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..b942fffdfc940ca2a56f2c3a7116b51c23373206 100644
|
| --- a/components/omnibox/browser/autocomplete_result.cc
|
| +++ b/components/omnibox/browser/autocomplete_result.cc
|
| @@ -166,24 +166,35 @@ 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()) {
|
| - if (AutocompleteMatch::IsSearchType(default_match_->type)) {
|
| - // We shouldn't get query matches for URL inputs.
|
| - DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info;
|
| - } else {
|
| - // If the user explicitly typed a scheme, the default match should
|
| - // have the same scheme.
|
| - if ((input.type() == metrics::OmniboxInputType::URL) &&
|
| - input.parts().scheme.is_nonempty()) {
|
| - const std::string& in_scheme = base::UTF16ToUTF8(input.scheme());
|
| - const std::string& dest_scheme =
|
| - default_match_->destination_url.scheme();
|
| - DCHECK(url_formatter::IsEquivalentScheme(in_scheme, dest_scheme))
|
| - << debug_info;
|
| +
|
| + // Ensure there is a default match if (and only if) the omnibox is not
|
| + // empty. Typically, the omnibox will never be empty because it is filled
|
| + // with the current page URL when the omnibox is focused. The zero-suggest
|
| + // default match, if any, should navigate to this URL. However, on some
|
| + // WebUI pages (eg: chrome://newtab) the URL is not auto-filled. In this
|
| + // case, there should be no default match.
|
| + if (input.text().empty()) {
|
| + DCHECK(!default_match_->allowed_to_be_default_match) << debug_info;
|
| + } else {
|
| + 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()) {
|
| + if (AutocompleteMatch::IsSearchType(default_match_->type)) {
|
| + // We shouldn't get query matches for URL inputs.
|
| + DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info;
|
| + } else {
|
| + // If the user explicitly typed a scheme, the default match should
|
| + // have the same scheme.
|
| + if ((input.type() == metrics::OmniboxInputType::URL) &&
|
| + input.parts().scheme.is_nonempty()) {
|
| + const std::string& in_scheme = base::UTF16ToUTF8(input.scheme());
|
| + const std::string& dest_scheme =
|
| + default_match_->destination_url.scheme();
|
| + DCHECK(url_formatter::IsEquivalentScheme(in_scheme, dest_scheme))
|
| + << debug_info;
|
| + }
|
| }
|
| }
|
| }
|
|
|