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/autocomplete_result.h" | 5 #include "components/omnibox/autocomplete_result.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 const AutocompleteMatch& AutocompleteResult::match_at(size_t index) const { | 287 const AutocompleteMatch& AutocompleteResult::match_at(size_t index) const { |
288 DCHECK_LT(index, matches_.size()); | 288 DCHECK_LT(index, matches_.size()); |
289 return matches_[index]; | 289 return matches_[index]; |
290 } | 290 } |
291 | 291 |
292 AutocompleteMatch* AutocompleteResult::match_at(size_t index) { | 292 AutocompleteMatch* AutocompleteResult::match_at(size_t index) { |
293 DCHECK_LT(index, matches_.size()); | 293 DCHECK_LT(index, matches_.size()); |
294 return &matches_[index]; | 294 return &matches_[index]; |
295 } | 295 } |
296 | 296 |
297 bool AutocompleteResult::ShouldHideTopMatch() const { | |
298 return chrome::ShouldHideTopVerbatimMatch() && | |
299 TopMatchIsStandaloneVerbatimMatch(); | |
300 } | |
301 | |
302 bool AutocompleteResult::TopMatchIsStandaloneVerbatimMatch() const { | 297 bool AutocompleteResult::TopMatchIsStandaloneVerbatimMatch() const { |
303 if (empty() || !match_at(0).IsVerbatimType()) | 298 if (empty() || !match_at(0).IsVerbatimType()) |
304 return false; | 299 return false; |
305 | 300 |
306 // Skip any copied matches, under the assumption that they'll be expired and | 301 // Skip any copied matches, under the assumption that they'll be expired and |
307 // disappear. We don't want this disappearance to cause the visibility of the | 302 // disappear. We don't want this disappearance to cause the visibility of the |
308 // top match to change. | 303 // top match to change. |
309 for (const_iterator i(begin() + 1); i != end(); ++i) { | 304 for (const_iterator i(begin() + 1); i != end(); ++i) { |
310 if (!i->from_previous) | 305 if (!i->from_previous) |
311 return !i->IsVerbatimType(); | 306 return !i->IsVerbatimType(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 i != old_matches.rend() && delta > 0; ++i) { | 437 i != old_matches.rend() && delta > 0; ++i) { |
443 if (!HasMatchByDestination(*i, new_matches)) { | 438 if (!HasMatchByDestination(*i, new_matches)) { |
444 AutocompleteMatch match = *i; | 439 AutocompleteMatch match = *i; |
445 match.relevance = std::min(max_relevance, match.relevance); | 440 match.relevance = std::min(max_relevance, match.relevance); |
446 match.from_previous = true; | 441 match.from_previous = true; |
447 matches_.push_back(match); | 442 matches_.push_back(match); |
448 delta--; | 443 delta--; |
449 } | 444 } |
450 } | 445 } |
451 } | 446 } |
OLD | NEW |