| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // For equal-relevance matches, we sort alphabetically, so that providers | 263 // For equal-relevance matches, we sort alphabetically, so that providers |
| 264 // who return multiple elements at the same priority get a "stable" sort | 264 // who return multiple elements at the same priority get a "stable" sort |
| 265 // across multiple updates. | 265 // across multiple updates. |
| 266 return (elem1.relevance == elem2.relevance) ? | 266 return (elem1.relevance == elem2.relevance) ? |
| 267 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); | 267 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); |
| 268 } | 268 } |
| 269 | 269 |
| 270 // static | 270 // static |
| 271 bool AutocompleteMatch::DestinationsEqual(const AutocompleteMatch& elem1, | 271 bool AutocompleteMatch::DestinationsEqual(const AutocompleteMatch& elem1, |
| 272 const AutocompleteMatch& elem2) { | 272 const AutocompleteMatch& elem2) { |
| 273 if (elem1.stripped_destination_url.is_empty() && | 273 return !elem1.stripped_destination_url.is_empty() && |
| 274 elem2.stripped_destination_url.is_empty()) | 274 (elem1.stripped_destination_url == elem2.stripped_destination_url); |
| 275 return false; | |
| 276 return elem1.stripped_destination_url == elem2.stripped_destination_url; | |
| 277 } | 275 } |
| 278 | 276 |
| 279 // static | 277 // static |
| 280 void AutocompleteMatch::ClassifyMatchInString( | 278 void AutocompleteMatch::ClassifyMatchInString( |
| 281 const base::string16& find_text, | 279 const base::string16& find_text, |
| 282 const base::string16& text, | 280 const base::string16& text, |
| 283 int style, | 281 int style, |
| 284 ACMatchClassifications* classification) { | 282 ACMatchClassifications* classification) { |
| 285 ClassifyLocationInString(text.find(find_text), find_text.length(), | 283 ClassifyLocationInString(text.find(find_text), find_text.length(), |
| 286 text.length(), style, classification); | 284 text.length(), style, classification); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 << " is unsorted in relation to last offset of " << last_offset | 657 << " is unsorted in relation to last offset of " << last_offset |
| 660 << ". Provider: " << provider_name << "."; | 658 << ". Provider: " << provider_name << "."; |
| 661 DCHECK_LT(i->offset, text.length()) | 659 DCHECK_LT(i->offset, text.length()) |
| 662 << " Classification of [" << i->offset << "," << text.length() | 660 << " Classification of [" << i->offset << "," << text.length() |
| 663 << "] is out of bounds for \"" << text << "\". Provider: " | 661 << "] is out of bounds for \"" << text << "\". Provider: " |
| 664 << provider_name << "."; | 662 << provider_name << "."; |
| 665 last_offset = i->offset; | 663 last_offset = i->offset; |
| 666 } | 664 } |
| 667 } | 665 } |
| 668 #endif | 666 #endif |
| OLD | NEW |