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_match.h" | 5 #include "components/omnibox/browser/autocomplete_match.h" |
6 | 6 |
7 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 // For equal-relevance matches, we sort alphabetically, so that providers | 265 // For equal-relevance matches, we sort alphabetically, so that providers |
266 // who return multiple elements at the same priority get a "stable" sort | 266 // who return multiple elements at the same priority get a "stable" sort |
267 // across multiple updates. | 267 // across multiple updates. |
268 return (elem1.relevance == elem2.relevance) ? | 268 return (elem1.relevance == elem2.relevance) ? |
269 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); | 269 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); |
270 } | 270 } |
271 | 271 |
272 // static | 272 // static |
273 bool AutocompleteMatch::DestinationsEqual(const AutocompleteMatch& elem1, | 273 bool AutocompleteMatch::DestinationsEqual(const AutocompleteMatch& elem1, |
274 const AutocompleteMatch& elem2) { | 274 const AutocompleteMatch& elem2) { |
275 if (elem1.stripped_destination_url.is_empty() && | 275 return !elem1.stripped_destination_url.is_empty() && |
276 elem2.stripped_destination_url.is_empty()) | 276 (elem1.stripped_destination_url == elem2.stripped_destination_url); |
277 return false; | |
278 return elem1.stripped_destination_url == elem2.stripped_destination_url; | |
279 } | 277 } |
280 | 278 |
281 // static | 279 // static |
282 void AutocompleteMatch::ClassifyMatchInString( | 280 void AutocompleteMatch::ClassifyMatchInString( |
283 const base::string16& find_text, | 281 const base::string16& find_text, |
284 const base::string16& text, | 282 const base::string16& text, |
285 int style, | 283 int style, |
286 ACMatchClassifications* classification) { | 284 ACMatchClassifications* classification) { |
287 ClassifyLocationInString(text.find(find_text), find_text.length(), | 285 ClassifyLocationInString(text.find(find_text), find_text.length(), |
288 text.length(), style, classification); | 286 text.length(), style, classification); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 << " is unsorted in relation to last offset of " << last_offset | 662 << " is unsorted in relation to last offset of " << last_offset |
665 << ". Provider: " << provider_name << "."; | 663 << ". Provider: " << provider_name << "."; |
666 DCHECK_LT(i->offset, text.length()) | 664 DCHECK_LT(i->offset, text.length()) |
667 << " Classification of [" << i->offset << "," << text.length() | 665 << " Classification of [" << i->offset << "," << text.length() |
668 << "] is out of bounds for \"" << text << "\". Provider: " | 666 << "] is out of bounds for \"" << text << "\". Provider: " |
669 << provider_name << "."; | 667 << provider_name << "."; |
670 last_offset = i->offset; | 668 last_offset = i->offset; |
671 } | 669 } |
672 } | 670 } |
673 #endif | 671 #endif |
OLD | NEW |