| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 ((default_match_->provider != NULL) | 245 ((default_match_->provider != NULL) |
| 246 ? base::ASCIIToUTF16(default_match_->provider->GetName()) | 246 ? base::ASCIIToUTF16(default_match_->provider->GetName()) |
| 247 : base::string16()) + | 247 : base::string16()) + |
| 248 base::ASCIIToUTF16(", input=") + | 248 base::ASCIIToUTF16(", input=") + |
| 249 input.text(); | 249 input.text(); |
| 250 DCHECK(default_match_->allowed_to_be_default_match) << debug_info; | 250 DCHECK(default_match_->allowed_to_be_default_match) << debug_info; |
| 251 // If the default match is valid (i.e., not a prompt/placeholder), make | 251 // If the default match is valid (i.e., not a prompt/placeholder), make |
| 252 // sure the type of destination is what the user would expect given the | 252 // sure the type of destination is what the user would expect given the |
| 253 // input. | 253 // input. |
| 254 if (default_match_->destination_url.is_valid()) { | 254 if (default_match_->destination_url.is_valid()) { |
| 255 // We shouldn't get query matches for URL inputs, or non-query matches | |
| 256 // for query inputs. | |
| 257 if (AutocompleteMatch::IsSearchType(default_match_->type)) { | 255 if (AutocompleteMatch::IsSearchType(default_match_->type)) { |
| 256 // We shouldn't get query matches for URL inputs. |
| 258 DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info; | 257 DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info; |
| 259 } else { | 258 } else { |
| 260 DCHECK_NE(metrics::OmniboxInputType::FORCED_QUERY, input.type()) | |
| 261 << debug_info; | |
| 262 // If the user explicitly typed a scheme, the default match should | 259 // If the user explicitly typed a scheme, the default match should |
| 263 // have the same scheme. | 260 // have the same scheme. |
| 264 if ((input.type() == metrics::OmniboxInputType::URL) && | 261 if ((input.type() == metrics::OmniboxInputType::URL) && |
| 265 input.parts().scheme.is_nonempty()) { | 262 input.parts().scheme.is_nonempty()) { |
| 266 const std::string& in_scheme = base::UTF16ToUTF8(input.scheme()); | 263 const std::string& in_scheme = base::UTF16ToUTF8(input.scheme()); |
| 267 const std::string& dest_scheme = | 264 const std::string& dest_scheme = |
| 268 default_match_->destination_url.scheme(); | 265 default_match_->destination_url.scheme(); |
| 269 DCHECK(url_formatter::IsEquivalentScheme(in_scheme, dest_scheme)) | 266 DCHECK(url_formatter::IsEquivalentScheme(in_scheme, dest_scheme)) |
| 270 << debug_info; | 267 << debug_info; |
| 271 } | 268 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 i != old_matches.rend() && delta > 0; ++i) { | 461 i != old_matches.rend() && delta > 0; ++i) { |
| 465 if (!HasMatchByDestination(*i, new_matches)) { | 462 if (!HasMatchByDestination(*i, new_matches)) { |
| 466 AutocompleteMatch match = *i; | 463 AutocompleteMatch match = *i; |
| 467 match.relevance = std::min(max_relevance, match.relevance); | 464 match.relevance = std::min(max_relevance, match.relevance); |
| 468 match.from_previous = true; | 465 match.from_previous = true; |
| 469 matches_.push_back(match); | 466 matches_.push_back(match); |
| 470 delta--; | 467 delta--; |
| 471 } | 468 } |
| 472 } | 469 } |
| 473 } | 470 } |
| OLD | NEW |