Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_match.cc

Issue 6268005: Removes the link in the omnibox for searching history. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "chrome/browser/autocomplete/autocomplete_match.h" 6 #include "chrome/browser/autocomplete/autocomplete_match.h"
7 #include "grit/theme_resources.h" 7 #include "grit/theme_resources.h"
8 8
9 // AutocompleteMatch ---------------------------------------------------------- 9 // AutocompleteMatch ----------------------------------------------------------
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 "url-what-you-typed", 44 "url-what-you-typed",
45 "history-url", 45 "history-url",
46 "history-title", 46 "history-title",
47 "history-body", 47 "history-body",
48 "history-keyword", 48 "history-keyword",
49 "navsuggest", 49 "navsuggest",
50 "search-what-you-typed", 50 "search-what-you-typed",
51 "search-history", 51 "search-history",
52 "search-suggest", 52 "search-suggest",
53 "search-other-engine", 53 "search-other-engine",
54 "open-history-page",
55 }; 54 };
56 DCHECK(arraysize(strings) == NUM_TYPES); 55 DCHECK(arraysize(strings) == NUM_TYPES);
57 return strings[type]; 56 return strings[type];
58 } 57 }
59 58
60 // static 59 // static
61 int AutocompleteMatch::TypeToIcon(Type type) { 60 int AutocompleteMatch::TypeToIcon(Type type) {
62 int icons[NUM_TYPES] = { 61 int icons[NUM_TYPES] = {
63 IDR_OMNIBOX_HTTP, 62 IDR_OMNIBOX_HTTP,
64 IDR_OMNIBOX_HTTP, 63 IDR_OMNIBOX_HTTP,
65 IDR_OMNIBOX_HISTORY, 64 IDR_OMNIBOX_HISTORY,
66 IDR_OMNIBOX_HISTORY, 65 IDR_OMNIBOX_HISTORY,
67 IDR_OMNIBOX_HISTORY, 66 IDR_OMNIBOX_HISTORY,
68 IDR_OMNIBOX_HTTP, 67 IDR_OMNIBOX_HTTP,
69 IDR_OMNIBOX_SEARCH, 68 IDR_OMNIBOX_SEARCH,
70 IDR_OMNIBOX_SEARCH, 69 IDR_OMNIBOX_SEARCH,
71 IDR_OMNIBOX_SEARCH, 70 IDR_OMNIBOX_SEARCH,
72 IDR_OMNIBOX_SEARCH, 71 IDR_OMNIBOX_SEARCH,
73 IDR_OMNIBOX_MORE,
74 }; 72 };
75 DCHECK(arraysize(icons) == NUM_TYPES); 73 DCHECK(arraysize(icons) == NUM_TYPES);
76 return icons[type]; 74 return icons[type];
77 } 75 }
78 76
79 // static 77 // static
80 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, 78 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1,
81 const AutocompleteMatch& elem2) { 79 const AutocompleteMatch& elem2) {
82 // For equal-relevance matches, we sort alphabetically, so that providers 80 // For equal-relevance matches, we sort alphabetically, so that providers
83 // who return multiple elements at the same priority get a "stable" sort 81 // who return multiple elements at the same priority get a "stable" sort
84 // across multiple updates. 82 // across multiple updates.
85 if (elem1.relevance == elem2.relevance) 83 if (elem1.relevance == elem2.relevance)
86 return elem1.contents > elem2.contents; 84 return elem1.contents > elem2.contents;
87 85
88 // A negative relevance indicates the real relevance can be determined by 86 return elem1.relevance > elem2.relevance;
89 // negating the value. If both relevances are negative, negate the result
90 // so that we end up with positive relevances, then negative relevances with
91 // the negative relevances sorted by absolute values.
92 const bool result = elem1.relevance > elem2.relevance;
93 return (elem1.relevance < 0 && elem2.relevance < 0) ? !result : result;
94 } 87 }
95 88
96 // static 89 // static
97 bool AutocompleteMatch::DestinationSortFunc(const AutocompleteMatch& elem1, 90 bool AutocompleteMatch::DestinationSortFunc(const AutocompleteMatch& elem1,
98 const AutocompleteMatch& elem2) { 91 const AutocompleteMatch& elem2) {
99 // Sort identical destination_urls together. Place the most relevant matches 92 // Sort identical destination_urls together. Place the most relevant matches
100 // first, so that when we call std::unique(), these are the ones that get 93 // first, so that when we call std::unique(), these are the ones that get
101 // preserved. 94 // preserved.
102 return (elem1.destination_url != elem2.destination_url) ? 95 return (elem1.destination_url != elem2.destination_url) ?
103 (elem1.destination_url < elem2.destination_url) : 96 (elem1.destination_url < elem2.destination_url) :
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // The classifications should always be sorted. 172 // The classifications should always be sorted.
180 size_t last_offset = classifications[0].offset; 173 size_t last_offset = classifications[0].offset;
181 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); 174 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1);
182 i != classifications.end(); ++i) { 175 i != classifications.end(); ++i) {
183 DCHECK(i->offset > last_offset) << "Classification unsorted"; 176 DCHECK(i->offset > last_offset) << "Classification unsorted";
184 DCHECK(i->offset < text.length()) << "Classification out of bounds"; 177 DCHECK(i->offset < text.length()) << "Classification out of bounds";
185 last_offset = i->offset; 178 last_offset = i->offset;
186 } 179 }
187 } 180 }
188 #endif 181 #endif
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_match.h ('k') | chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698