OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/omnibox/browser/autocomplete_result.h" | 5 #include "components/omnibox/browser/autocomplete_result.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ((default_match_->provider != NULL) | 164 ((default_match_->provider != NULL) |
165 ? base::ASCIIToUTF16(default_match_->provider->GetName()) | 165 ? base::ASCIIToUTF16(default_match_->provider->GetName()) |
166 : base::string16()) + | 166 : base::string16()) + |
167 base::ASCIIToUTF16(", input=") + | 167 base::ASCIIToUTF16(", input=") + |
168 input.text(); | 168 input.text(); |
169 DCHECK(default_match_->allowed_to_be_default_match) << debug_info; | 169 DCHECK(default_match_->allowed_to_be_default_match) << debug_info; |
170 // If the default match is valid (i.e., not a prompt/placeholder), make | 170 // If the default match is valid (i.e., not a prompt/placeholder), make |
171 // sure the type of destination is what the user would expect given the | 171 // sure the type of destination is what the user would expect given the |
172 // input. | 172 // input. |
173 if (default_match_->destination_url.is_valid()) { | 173 if (default_match_->destination_url.is_valid()) { |
174 // We shouldn't get query matches for URL inputs, or non-query matches | |
175 // for query inputs. | |
176 if (AutocompleteMatch::IsSearchType(default_match_->type)) { | 174 if (AutocompleteMatch::IsSearchType(default_match_->type)) { |
| 175 // We shouldn't get query matches for URL inputs. |
177 DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info; | 176 DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info; |
178 } else { | 177 } else { |
179 DCHECK_NE(metrics::OmniboxInputType::FORCED_QUERY, input.type()) | |
180 << debug_info; | |
181 // If the user explicitly typed a scheme, the default match should | 178 // If the user explicitly typed a scheme, the default match should |
182 // have the same scheme. | 179 // have the same scheme. |
183 if ((input.type() == metrics::OmniboxInputType::URL) && | 180 if ((input.type() == metrics::OmniboxInputType::URL) && |
184 input.parts().scheme.is_nonempty()) { | 181 input.parts().scheme.is_nonempty()) { |
185 const std::string& in_scheme = base::UTF16ToUTF8(input.scheme()); | 182 const std::string& in_scheme = base::UTF16ToUTF8(input.scheme()); |
186 const std::string& dest_scheme = | 183 const std::string& dest_scheme = |
187 default_match_->destination_url.scheme(); | 184 default_match_->destination_url.scheme(); |
188 DCHECK(url_formatter::IsEquivalentScheme(in_scheme, dest_scheme)) | 185 DCHECK(url_formatter::IsEquivalentScheme(in_scheme, dest_scheme)) |
189 << debug_info; | 186 << debug_info; |
190 } | 187 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 i != old_matches.rend() && delta > 0; ++i) { | 378 i != old_matches.rend() && delta > 0; ++i) { |
382 if (!HasMatchByDestination(*i, new_matches)) { | 379 if (!HasMatchByDestination(*i, new_matches)) { |
383 AutocompleteMatch match = *i; | 380 AutocompleteMatch match = *i; |
384 match.relevance = std::min(max_relevance, match.relevance); | 381 match.relevance = std::min(max_relevance, match.relevance); |
385 match.from_previous = true; | 382 match.from_previous = true; |
386 matches_.push_back(match); | 383 matches_.push_back(match); |
387 delta--; | 384 delta--; |
388 } | 385 } |
389 } | 386 } |
390 } | 387 } |
OLD | NEW |