Chromium Code Reviews| 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 #ifndef COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 5 #ifndef COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
| 6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 const std::string& serialized_classifications); | 146 const std::string& serialized_classifications); |
| 147 | 147 |
| 148 // Adds a classification to the end of |classifications| iff its style is | 148 // Adds a classification to the end of |classifications| iff its style is |
| 149 // different from the last existing classification. |offset| must be larger | 149 // different from the last existing classification. |offset| must be larger |
| 150 // than the offset of the last classification in |classifications|. | 150 // than the offset of the last classification in |classifications|. |
| 151 static void AddLastClassificationIfNecessary( | 151 static void AddLastClassificationIfNecessary( |
| 152 ACMatchClassifications* classifications, | 152 ACMatchClassifications* classifications, |
| 153 size_t offset, | 153 size_t offset, |
| 154 int style); | 154 int style); |
| 155 | 155 |
| 156 // Returns true if at least one style in |classifications| is of type MATCH. | |
| 157 static bool HasMatch(const ACMatchClassifications& classifications); | |
|
Peter Kasting
2015/06/23 22:57:05
Nit: HasMatchStyle() would be slightly clearer.
Mark P
2015/06/24 03:52:45
Done.
| |
| 158 | |
| 156 // Removes invalid characters from |text|. Should be called on strings coming | 159 // Removes invalid characters from |text|. Should be called on strings coming |
| 157 // from external sources (such as extensions) before assigning to |contents| | 160 // from external sources (such as extensions) before assigning to |contents| |
| 158 // or |description|. | 161 // or |description|. |
| 159 static base::string16 SanitizeString(const base::string16& text); | 162 static base::string16 SanitizeString(const base::string16& text); |
| 160 | 163 |
| 161 // Convenience function to check if |type| is a search (as opposed to a URL or | 164 // Convenience function to check if |type| is a search (as opposed to a URL or |
| 162 // an extension). | 165 // an extension). |
| 163 static bool IsSearchType(Type type); | 166 static bool IsSearchType(Type type); |
| 164 | 167 |
| 165 // Convenience function to check if |type| is a special search suggest type - | 168 // Convenience function to check if |type| is a special search suggest type - |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 // is not shown. | 259 // is not shown. |
| 257 bool IsVerbatimType() const; | 260 bool IsVerbatimType() const; |
| 258 | 261 |
| 259 // Returns whether this match or any duplicate of this match can be deleted. | 262 // Returns whether this match or any duplicate of this match can be deleted. |
| 260 // This is used to decide whether we should call DeleteMatch(). | 263 // This is used to decide whether we should call DeleteMatch(). |
| 261 bool SupportsDeletion() const; | 264 bool SupportsDeletion() const; |
| 262 | 265 |
| 263 // Swaps the contents and description fields, and their associated | 266 // Swaps the contents and description fields, and their associated |
| 264 // classifications, if this is a match for which we should emphasize the | 267 // classifications, if this is a match for which we should emphasize the |
| 265 // title (stored in the description field) over the URL (in the contents | 268 // title (stored in the description field) over the URL (in the contents |
| 266 // field). See the implementation for the conditions under which this is | 269 // field). Intended to only be used at the UI level before displaying, lest |
| 267 // true. | 270 // other omnibox systems get confused about which is which. See the code |
| 268 void PossiblySwapContentsAndDescriptionForURLSuggestion( | 271 // that sets |swap_contents_and_description| for conditions under which |
| 269 const AutocompleteInput& input); | 272 // it is true. |
| 273 void PossiblySwapContentsAndDescriptionForDisplay(); | |
| 270 | 274 |
| 271 // The provider of this match, used to remember which provider the user had | 275 // The provider of this match, used to remember which provider the user had |
| 272 // selected when the input changes. This may be NULL, in which case there is | 276 // selected when the input changes. This may be NULL, in which case there is |
| 273 // no provider (or memory of the user's selection). | 277 // no provider (or memory of the user's selection). |
| 274 AutocompleteProvider* provider; | 278 AutocompleteProvider* provider; |
| 275 | 279 |
| 276 // The relevance of this match. See table in autocomplete.h for scores | 280 // The relevance of this match. See table in autocomplete.h for scores |
| 277 // returned by various providers. This is used to rank matches among all | 281 // returned by various providers. This is used to rank matches among all |
| 278 // responding providers, so different providers must be carefully tuned to | 282 // responding providers, so different providers must be carefully tuned to |
| 279 // supply matches with appropriate relevance. | 283 // supply matches with appropriate relevance. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 GURL stripped_destination_url; | 324 GURL stripped_destination_url; |
| 321 | 325 |
| 322 // The main text displayed in the address bar dropdown. | 326 // The main text displayed in the address bar dropdown. |
| 323 base::string16 contents; | 327 base::string16 contents; |
| 324 ACMatchClassifications contents_class; | 328 ACMatchClassifications contents_class; |
| 325 | 329 |
| 326 // Additional helper text for each entry, such as a title or description. | 330 // Additional helper text for each entry, such as a title or description. |
| 327 base::string16 description; | 331 base::string16 description; |
| 328 ACMatchClassifications description_class; | 332 ACMatchClassifications description_class; |
| 329 | 333 |
| 334 // If true, UI-level code should swap the contents and description fields | |
| 335 // before displaying. | |
| 336 bool swap_contents_and_description; | |
| 337 | |
| 330 // TODO(jdonnelly): Remove the first two properties once the downstream | 338 // TODO(jdonnelly): Remove the first two properties once the downstream |
| 331 // clients are using the SuggestionAnswer. | 339 // clients are using the SuggestionAnswer. |
| 332 // A rich-format version of the display for the dropdown. | 340 // A rich-format version of the display for the dropdown. |
| 333 base::string16 answer_contents; | 341 base::string16 answer_contents; |
| 334 base::string16 answer_type; | 342 base::string16 answer_type; |
| 335 scoped_ptr<SuggestionAnswer> answer; | 343 scoped_ptr<SuggestionAnswer> answer; |
| 336 | 344 |
| 337 // The transition type to use when the user opens this match. By default | 345 // The transition type to use when the user opens this match. By default |
| 338 // this is TYPED. Providers whose matches do not look like URLs should set | 346 // this is TYPED. Providers whose matches do not look like URLs should set |
| 339 // it to GENERATED. | 347 // it to GENERATED. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 const base::string16& text, | 402 const base::string16& text, |
| 395 const ACMatchClassifications& classifications) const; | 403 const ACMatchClassifications& classifications) const; |
| 396 #endif | 404 #endif |
| 397 }; | 405 }; |
| 398 | 406 |
| 399 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 407 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
| 400 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 408 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
| 401 typedef std::vector<AutocompleteMatch> ACMatches; | 409 typedef std::vector<AutocompleteMatch> ACMatches; |
| 402 | 410 |
| 403 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 411 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
| OLD | NEW |