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

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, 4 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>
11 11
12 #include "base/memory/scoped_ptr.h"
12 #include "content/common/page_transition_types.h" 13 #include "content/common/page_transition_types.h"
13 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
14 15
15 class AutocompleteProvider; 16 class AutocompleteProvider;
16 class PageTransition; 17 class PageTransition;
17 class TemplateURL; 18 class TemplateURL;
18 19
19 // AutocompleteMatch ---------------------------------------------------------- 20 // AutocompleteMatch ----------------------------------------------------------
20 21
21 // A single result line with classified spans. The autocomplete popup displays 22 // A single result line with classified spans. The autocomplete popup displays
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 EXTENSION_APP, // An Extension App with a title/url that contains 81 EXTENSION_APP, // An Extension App with a title/url that contains
81 // the input. 82 // the input.
82 NUM_TYPES, 83 NUM_TYPES,
83 }; 84 };
84 85
85 AutocompleteMatch(); 86 AutocompleteMatch();
86 AutocompleteMatch(AutocompleteProvider* provider, 87 AutocompleteMatch(AutocompleteProvider* provider,
87 int relevance, 88 int relevance,
88 bool deletable, 89 bool deletable,
89 Type type); 90 Type type);
91 AutocompleteMatch(const AutocompleteMatch& match);
90 ~AutocompleteMatch(); 92 ~AutocompleteMatch();
91 93
94 AutocompleteMatch& operator=(const AutocompleteMatch& match);
95
92 // Converts |type| to a string representation. Used in logging. 96 // Converts |type| to a string representation. Used in logging.
93 static std::string TypeToString(Type type); 97 static std::string TypeToString(Type type);
94 98
95 // Converts |type| to a resource identifier for the appropriate icon for this 99 // Converts |type| to a resource identifier for the appropriate icon for this
96 // type. 100 // type.
97 static int TypeToIcon(Type type); 101 static int TypeToIcon(Type type);
98 102
99 // Comparison function for determining when one match is better than another. 103 // Comparison function for determining when one match is better than another.
100 static bool MoreRelevant(const AutocompleteMatch& elem1, 104 static bool MoreRelevant(const AutocompleteMatch& elem1,
101 const AutocompleteMatch& elem2); 105 const AutocompleteMatch& elem2);
102 106
103 // Comparison functions for removing matches with duplicate destinations. 107 // Comparison functions for removing matches with duplicate destinations.
108 // Destinations are compared using |stripped_destination_url|.
104 static bool DestinationSortFunc(const AutocompleteMatch& elem1, 109 static bool DestinationSortFunc(const AutocompleteMatch& elem1,
105 const AutocompleteMatch& elem2); 110 const AutocompleteMatch& elem2);
106 static bool DestinationsEqual(const AutocompleteMatch& elem1, 111 static bool DestinationsEqual(const AutocompleteMatch& elem1,
107 const AutocompleteMatch& elem2); 112 const AutocompleteMatch& elem2);
108 113
109 // Helper functions for classes creating matches: 114 // Helper functions for classes creating matches:
110 // Fills in the classifications for |text|, using |style| as the base style 115 // Fills in the classifications for |text|, using |style| as the base style
111 // and marking the first instance of |find_text| as a match. (This match 116 // and marking the first instance of |find_text| as a match. (This match
112 // will also not be dimmed, if |style| has DIM set.) 117 // will also not be dimmed, if |style| has DIM set.)
113 static void ClassifyMatchInString(const string16& find_text, 118 static void ClassifyMatchInString(const string16& find_text,
114 const string16& text, 119 const string16& text,
115 int style, 120 int style,
116 ACMatchClassifications* classifications); 121 ACMatchClassifications* classifications);
117 122
118 // Similar to ClassifyMatchInString(), but for cases where the range to mark 123 // Similar to ClassifyMatchInString(), but for cases where the range to mark
119 // as matching is already known (avoids calling find()). This can be helpful 124 // as matching is already known (avoids calling find()). This can be helpful
120 // when find() would be misleading (e.g. you want to mark the second match in 125 // when find() would be misleading (e.g. you want to mark the second match in
121 // a string instead of the first). 126 // a string instead of the first).
122 static void ClassifyLocationInString(size_t match_location, 127 static void ClassifyLocationInString(size_t match_location,
123 size_t match_length, 128 size_t match_length,
124 size_t overall_length, 129 size_t overall_length,
125 int style, 130 int style,
126 ACMatchClassifications* classifications); 131 ACMatchClassifications* classifications);
127 132
133 // Copies the destination_url with "www." stripped off to
134 // |stripped_destination_url|.
135 void ComputeStrippedDestinationURL();
sky 2011/08/09 00:32:51 nit: Can you mention this is invoked internally an
136
128 // The provider of this match, used to remember which provider the user had 137 // The provider of this match, used to remember which provider the user had
129 // selected when the input changes. This may be NULL, in which case there is 138 // selected when the input changes. This may be NULL, in which case there is
130 // no provider (or memory of the user's selection). 139 // no provider (or memory of the user's selection).
131 AutocompleteProvider* provider; 140 AutocompleteProvider* provider;
132 141
133 // The relevance of this match. See table in autocomplete.h for scores 142 // The relevance of this match. See table in autocomplete.h for scores
134 // returned by various providers. This is used to rank matches among all 143 // returned by various providers. This is used to rank matches among all
135 // responding providers, so different providers must be carefully tuned to 144 // responding providers, so different providers must be carefully tuned to
136 // supply matches with appropriate relevance. 145 // supply matches with appropriate relevance.
137 // 146 //
(...skipping 12 matching lines...) Expand all
150 // The position within fill_into_edit from which we'll display the inline 159 // The position within fill_into_edit from which we'll display the inline
151 // autocomplete string. This will be string16::npos if this match should 160 // autocomplete string. This will be string16::npos if this match should
152 // not be inline autocompleted. 161 // not be inline autocompleted.
153 size_t inline_autocomplete_offset; 162 size_t inline_autocomplete_offset;
154 163
155 // The URL to actually load when the autocomplete item is selected. This URL 164 // The URL to actually load when the autocomplete item is selected. This URL
156 // should be canonical so we can compare URLs with strcmp to avoid dupes. 165 // should be canonical so we can compare URLs with strcmp to avoid dupes.
157 // It may be empty if there is no possible navigation. 166 // It may be empty if there is no possible navigation.
158 GURL destination_url; 167 GURL destination_url;
159 168
169 // The destination URL with "www." stripped off for better dupe finding.
170 GURL stripped_destination_url;
171
160 // The main text displayed in the address bar dropdown. 172 // The main text displayed in the address bar dropdown.
161 string16 contents; 173 string16 contents;
162 ACMatchClassifications contents_class; 174 ACMatchClassifications contents_class;
163 175
164 // Additional helper text for each entry, such as a title or description. 176 // Additional helper text for each entry, such as a title or description.
165 string16 description; 177 string16 description;
166 ACMatchClassifications description_class; 178 ACMatchClassifications description_class;
167 179
168 // The transition type to use when the user opens this match. By default 180 // The transition type to use when the user opens this match. By default
169 // this is TYPED. Providers whose matches do not look like URLs should set 181 // this is TYPED. Providers whose matches do not look like URLs should set
170 // it to GENERATED. 182 // it to GENERATED.
171 PageTransition::Type transition; 183 PageTransition::Type transition;
172 184
173 // True when this match is the "what you typed" match from the history 185 // True when this match is the "what you typed" match from the history
174 // system. 186 // system.
175 bool is_history_what_you_typed_match; 187 bool is_history_what_you_typed_match;
176 188
177 // Type of this match. 189 // Type of this match.
178 Type type; 190 Type type;
179 191
192 // Set with a keyword provider match if this match can show a keyword hint.
193 // For example, if this is a SearchProvider match for "www.amazon.com",
194 // |associated_keyword| could be a KeywordProvider match for "amazon.com".
195 scoped_ptr<AutocompleteMatch> associated_keyword;
196
197 // For matches that correspond to valid substituting keywords ("search
198 // engines" that aren't the default engine, or extension keywords), this
199 // is the keyword. If this is set, then when displaying this match, the
200 // edit will use the "keyword mode" UI that shows a blue
201 // "Search <engine name>" chit before the user's typing. This should be
202 // set for any match that's an |associated_keyword| of a match in the main
203 // result list, as well as any other matches in the main result list that
204 // are direct keyword matches (e.g. if the user types in a keyword name and
205 // some search terms directly).
206 string16 keyword;
sky 2011/08/09 00:32:51 Since the matches you care about have TemplateURL
aaron.randolph 2011/08/16 17:52:43 The issue with |template_url| is it is only set on
207
180 // Indicates the TemplateURL the match originated from. This is set for 208 // Indicates the TemplateURL the match originated from. This is set for
181 // keywords as well as matches for the default search provider. 209 // keywords as well as matches for the default search provider.
182 const TemplateURL* template_url; 210 const TemplateURL* template_url;
183 211
184 // True if the user has starred the destination URL. 212 // True if the user has starred the destination URL.
185 bool starred; 213 bool starred;
186 214
187 // True if this match is from a previous result. 215 // True if this match is from a previous result.
188 bool from_previous; 216 bool from_previous;
189 217
190 #ifndef NDEBUG 218 #ifndef NDEBUG
191 // Does a data integrity check on this match. 219 // Does a data integrity check on this match.
192 void Validate() const; 220 void Validate() const;
193 221
194 // Checks one text/classifications pair for valid values. 222 // Checks one text/classifications pair for valid values.
195 void ValidateClassifications( 223 void ValidateClassifications(
196 const string16& text, 224 const string16& text,
197 const ACMatchClassifications& classifications) const; 225 const ACMatchClassifications& classifications) const;
198 #endif 226 #endif
199 }; 227 };
200 228
201 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; 229 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification;
202 typedef std::vector<ACMatchClassification> ACMatchClassifications; 230 typedef std::vector<ACMatchClassification> ACMatchClassifications;
203 231
204 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ 232 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698