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

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

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 #include <string> 10 #include <string>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 // Converts |type| to a resource identifier for the appropriate icon for this 93 // Converts |type| to a resource identifier for the appropriate icon for this
94 // type. 94 // type.
95 static int TypeToIcon(Type type); 95 static int TypeToIcon(Type type);
96 96
97 // Comparison function for determining when one match is better than another. 97 // Comparison function for determining when one match is better than another.
98 static bool MoreRelevant(const AutocompleteMatch& elem1, 98 static bool MoreRelevant(const AutocompleteMatch& elem1,
99 const AutocompleteMatch& elem2); 99 const AutocompleteMatch& elem2);
100 100
101 // Comparison functions for removing matches with duplicate destinations. 101 // Comparison functions for removing matches with duplicate destinations.
102 // Destinations are compared using |stripped_destination_url|.
102 static bool DestinationSortFunc(const AutocompleteMatch& elem1, 103 static bool DestinationSortFunc(const AutocompleteMatch& elem1,
103 const AutocompleteMatch& elem2); 104 const AutocompleteMatch& elem2);
104 static bool DestinationsEqual(const AutocompleteMatch& elem1, 105 static bool DestinationsEqual(const AutocompleteMatch& elem1,
105 const AutocompleteMatch& elem2); 106 const AutocompleteMatch& elem2);
106 107
107 // Helper functions for classes creating matches: 108 // Helper functions for classes creating matches:
108 // Fills in the classifications for |text|, using |style| as the base style 109 // Fills in the classifications for |text|, using |style| as the base style
109 // and marking the first instance of |find_text| as a match. (This match 110 // and marking the first instance of |find_text| as a match. (This match
110 // will also not be dimmed, if |style| has DIM set.) 111 // will also not be dimmed, if |style| has DIM set.)
111 static void ClassifyMatchInString(const string16& find_text, 112 static void ClassifyMatchInString(const string16& find_text,
112 const string16& text, 113 const string16& text,
113 int style, 114 int style,
114 ACMatchClassifications* classifications); 115 ACMatchClassifications* classifications);
115 116
116 // Similar to ClassifyMatchInString(), but for cases where the range to mark 117 // Similar to ClassifyMatchInString(), but for cases where the range to mark
117 // as matching is already known (avoids calling find()). This can be helpful 118 // as matching is already known (avoids calling find()). This can be helpful
118 // when find() would be misleading (e.g. you want to mark the second match in 119 // when find() would be misleading (e.g. you want to mark the second match in
119 // a string instead of the first). 120 // a string instead of the first).
120 static void ClassifyLocationInString(size_t match_location, 121 static void ClassifyLocationInString(size_t match_location,
121 size_t match_length, 122 size_t match_length,
122 size_t overall_length, 123 size_t overall_length,
123 int style, 124 int style,
124 ACMatchClassifications* classifications); 125 ACMatchClassifications* classifications);
125 126
127 // Copies the destination_url with "www." stripped off to
128 // |stripped_destination_url|.
129 void ComputeStrippedDestinationURL();
130
131 bool has_keyword_hint() const {
132 return keyword_state == DUAL_SHOWING_KEYWORD ||
Peter Kasting 2011/04/13 21:06:59 This isn't right. DUAL_SHOWING_NON_KEYWORD is the
133 keyword_state == DUAL_SHOWING_NON_KEYWORD;
134 }
135
126 // The provider of this match, used to remember which provider the user had 136 // The provider of this match, used to remember which provider the user had
127 // selected when the input changes. This may be NULL, in which case there is 137 // selected when the input changes. This may be NULL, in which case there is
128 // no provider (or memory of the user's selection). 138 // no provider (or memory of the user's selection).
129 AutocompleteProvider* provider; 139 AutocompleteProvider* provider;
130 140
131 // The relevance of this match. See table in autocomplete.h for scores 141 // The relevance of this match. See table in autocomplete.h for scores
132 // returned by various providers. This is used to rank matches among all 142 // returned by various providers. This is used to rank matches among all
133 // responding providers, so different providers must be carefully tuned to 143 // responding providers, so different providers must be carefully tuned to
134 // supply matches with appropriate relevance. 144 // supply matches with appropriate relevance.
135 // 145 //
(...skipping 12 matching lines...) Expand all
148 // The position within fill_into_edit from which we'll display the inline 158 // The position within fill_into_edit from which we'll display the inline
149 // autocomplete string. This will be string16::npos if this match should 159 // autocomplete string. This will be string16::npos if this match should
150 // not be inline autocompleted. 160 // not be inline autocompleted.
151 size_t inline_autocomplete_offset; 161 size_t inline_autocomplete_offset;
152 162
153 // The URL to actually load when the autocomplete item is selected. This URL 163 // The URL to actually load when the autocomplete item is selected. This URL
154 // should be canonical so we can compare URLs with strcmp to avoid dupes. 164 // should be canonical so we can compare URLs with strcmp to avoid dupes.
155 // It may be empty if there is no possible navigation. 165 // It may be empty if there is no possible navigation.
156 GURL destination_url; 166 GURL destination_url;
157 167
168 // The destination URL with "www." stripped off for better dupe finding.
169 GURL stripped_destination_url;
170
158 // The main text displayed in the address bar dropdown. 171 // The main text displayed in the address bar dropdown.
159 string16 contents; 172 string16 contents;
160 ACMatchClassifications contents_class; 173 ACMatchClassifications contents_class;
161 174
162 // Additional helper text for each entry, such as a title or description. 175 // Additional helper text for each entry, such as a title or description.
163 string16 description; 176 string16 description;
164 ACMatchClassifications description_class; 177 ACMatchClassifications description_class;
165 178
166 // The transition type to use when the user opens this match. By default 179 // The transition type to use when the user opens this match. By default
167 // this is TYPED. Providers whose matches do not look like URLs should set 180 // this is TYPED. Providers whose matches do not look like URLs should set
168 // it to GENERATED. 181 // it to GENERATED.
169 PageTransition::Type transition; 182 PageTransition::Type transition;
170 183
171 // True when this match is the "what you typed" match from the history 184 // True when this match is the "what you typed" match from the history
172 // system. 185 // system.
173 bool is_history_what_you_typed_match; 186 bool is_history_what_you_typed_match;
174 187
175 // Type of this match. 188 // Type of this match.
176 Type type; 189 Type type;
177 190
191 enum KeywordState {
Peter Kasting 2011/04/13 21:06:59 Nit: Probably want to document these.
192 NO_KEYWORD,
193 KEYWORD,
194 DUAL_SHOWING_NON_KEYWORD,
195 DUAL_SHOWING_KEYWORD,
196 };
197
198 KeywordState keyword_state;
199
200 // Keyword for this match.
201 string16 keyword;
202
178 // If this match corresponds to a keyword, this is the TemplateURL the 203 // If this match corresponds to a keyword, this is the TemplateURL the
179 // keyword was obtained from. 204 // keyword was obtained from. If this match has a keyword hint, this is
180 const TemplateURL* template_url; 205 // the TemplateURL for the keyword.
206 const TemplateURL* keyword_url;
181 207
182 // True if the user has starred the destination URL. 208 // True if the user has starred the destination URL.
183 bool starred; 209 bool starred;
184 210
185 // True if this match is from a previous result. 211 // True if this match is from a previous result.
186 bool from_previous; 212 bool from_previous;
187 213
188 #ifndef NDEBUG 214 #ifndef NDEBUG
189 // Does a data integrity check on this match. 215 // Does a data integrity check on this match.
190 void Validate() const; 216 void Validate() const;
191 217
192 // Checks one text/classifications pair for valid values. 218 // Checks one text/classifications pair for valid values.
193 void ValidateClassifications( 219 void ValidateClassifications(
194 const string16& text, 220 const string16& text,
195 const ACMatchClassifications& classifications) const; 221 const ACMatchClassifications& classifications) const;
196 #endif 222 #endif
197 }; 223 };
198 224
199 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; 225 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification;
200 typedef std::vector<ACMatchClassification> ACMatchClassifications; 226 typedef std::vector<ACMatchClassification> ACMatchClassifications;
201 227
202 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ 228 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698