Index: components/omnibox/browser/shortcut_match.cc |
diff --git a/components/omnibox/browser/shortcut_match.cc b/components/omnibox/browser/shortcut_match.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b96aab9970f1ecaa7a296c32aff3e7b02f2a9204 |
--- /dev/null |
+++ b/components/omnibox/browser/shortcut_match.cc |
@@ -0,0 +1,35 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/omnibox/browser/shortcut_match.h" |
+ |
+#include <algorithm> |
+ |
+ShortcutMatch::ShortcutMatch(int relevance, |
+ const GURL& stripped_destination_url, |
+ const ShortcutsDatabase::Shortcut* shortcut) : |
+ relevance(relevance), |
+ stripped_destination_url(stripped_destination_url), |
+ shortcut(shortcut), |
+ contents(shortcut->match_core.contents), |
+ type(static_cast<AutocompleteMatch::Type>(shortcut->match_core.type)) {} |
+ |
+// static |
+bool ShortcutMatch::DestinationsEqual(const ShortcutMatch& elem1, |
+ const ShortcutMatch& elem2) { |
+ if (elem1.stripped_destination_url.is_empty() && |
+ elem2.stripped_destination_url.is_empty()) |
+ return false; |
+ return elem1.stripped_destination_url == elem2.stripped_destination_url; |
Peter Kasting
2016/04/12 23:29:50
Nit: Simpler:
return (elem1.stripped_destinatio
Alexander Yashkin
2016/04/13 09:29:36
Replaced here and in autocomplete_match.cc with
|
+} |
+ |
+// static |
+bool ShortcutMatch::MoreRelevant(const ShortcutMatch& elem1, |
+ const ShortcutMatch& elem2) { |
+ // For equal-relevance matches, we sort alphabetically, so that providers |
+ // who return multiple elements at the same priority get a "stable" sort |
+ // across multiple updates. |
+ return (elem1.relevance == elem2.relevance) ? |
+ (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); |
+} |