OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // engine). | 74 // engine). |
75 SEARCH_HISTORY, // A past search (with the default engine) | 75 SEARCH_HISTORY, // A past search (with the default engine) |
76 // containing the input. | 76 // containing the input. |
77 SEARCH_SUGGEST, // A suggested search (with the default engine). | 77 SEARCH_SUGGEST, // A suggested search (with the default engine). |
78 SEARCH_OTHER_ENGINE, // A search with a non-default engine. | 78 SEARCH_OTHER_ENGINE, // A search with a non-default engine. |
79 EXTENSION_APP, // An Extension App with a title/url that contains | 79 EXTENSION_APP, // An Extension App with a title/url that contains |
80 // the input. | 80 // the input. |
81 NUM_TYPES, | 81 NUM_TYPES, |
82 }; | 82 }; |
83 | 83 |
| 84 // Null-terminated array of characters that are not valid within |contents| |
| 85 // and |description| strings. |
| 86 static const char16 kInvalidChars[]; |
| 87 |
84 AutocompleteMatch(); | 88 AutocompleteMatch(); |
85 AutocompleteMatch(AutocompleteProvider* provider, | 89 AutocompleteMatch(AutocompleteProvider* provider, |
86 int relevance, | 90 int relevance, |
87 bool deletable, | 91 bool deletable, |
88 Type type); | 92 Type type); |
89 ~AutocompleteMatch(); | 93 ~AutocompleteMatch(); |
90 | 94 |
91 // Converts |type| to a string representation. Used in logging. | 95 // Converts |type| to a string representation. Used in logging. |
92 static std::string TypeToString(Type type); | 96 static std::string TypeToString(Type type); |
93 | 97 |
(...skipping 23 matching lines...) Expand all Loading... |
117 // Similar to ClassifyMatchInString(), but for cases where the range to mark | 121 // Similar to ClassifyMatchInString(), but for cases where the range to mark |
118 // as matching is already known (avoids calling find()). This can be helpful | 122 // as matching is already known (avoids calling find()). This can be helpful |
119 // when find() would be misleading (e.g. you want to mark the second match in | 123 // when find() would be misleading (e.g. you want to mark the second match in |
120 // a string instead of the first). | 124 // a string instead of the first). |
121 static void ClassifyLocationInString(size_t match_location, | 125 static void ClassifyLocationInString(size_t match_location, |
122 size_t match_length, | 126 size_t match_length, |
123 size_t overall_length, | 127 size_t overall_length, |
124 int style, | 128 int style, |
125 ACMatchClassifications* classifications); | 129 ACMatchClassifications* classifications); |
126 | 130 |
127 // Removes invalid characters from |str|. Should be called on strings coming | 131 // Removes invalid characters from |text|. Should be called on strings coming |
128 // from external sources (such as extensions) before assigning to |contents| | 132 // from external sources (such as extensions) before assigning to |contents| |
129 // or |description|. | 133 // or |description|. |
130 static string16 SanitizeString(const string16& text); | 134 static string16 SanitizeString(const string16& text); |
131 | 135 |
132 // 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 |
133 // 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 |
134 // no provider (or memory of the user's selection). | 138 // no provider (or memory of the user's selection). |
135 AutocompleteProvider* provider; | 139 AutocompleteProvider* provider; |
136 | 140 |
137 // 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 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 void ValidateClassifications( | 203 void ValidateClassifications( |
200 const string16& text, | 204 const string16& text, |
201 const ACMatchClassifications& classifications) const; | 205 const ACMatchClassifications& classifications) const; |
202 #endif | 206 #endif |
203 }; | 207 }; |
204 | 208 |
205 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 209 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
206 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 210 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
207 | 211 |
208 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 212 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |