OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Similar to ClassifyMatchInString(), but for cases where the range to mark | 127 // Similar to ClassifyMatchInString(), but for cases where the range to mark |
128 // as matching is already known (avoids calling find()). This can be helpful | 128 // as matching is already known (avoids calling find()). This can be helpful |
129 // when find() would be misleading (e.g. you want to mark the second match in | 129 // when find() would be misleading (e.g. you want to mark the second match in |
130 // a string instead of the first). | 130 // a string instead of the first). |
131 static void ClassifyLocationInString(size_t match_location, | 131 static void ClassifyLocationInString(size_t match_location, |
132 size_t match_length, | 132 size_t match_length, |
133 size_t overall_length, | 133 size_t overall_length, |
134 int style, | 134 int style, |
135 ACMatchClassifications* classifications); | 135 ACMatchClassifications* classifications); |
136 | 136 |
| 137 // Converts classifications to and from a serialized string representation |
| 138 // (using comma-separated integers to sequentially list positions and styles). |
| 139 static std::string ClassificationsToString( |
| 140 const ACMatchClassifications& classifications); |
| 141 static ACMatchClassifications ClassificationsFromString( |
| 142 const std::string& serialized_classifications); |
| 143 |
| 144 // Adds a classification to the end of |classifications| iff its style is |
| 145 // different from the last existing classification. |offset| must be larger |
| 146 // than the offset of the last classification in |classifications|. |
| 147 static void AddLastClassificationIfNecessary( |
| 148 ACMatchClassifications* classifications, |
| 149 size_t offset, |
| 150 int style); |
| 151 |
137 // Removes invalid characters from |text|. Should be called on strings coming | 152 // Removes invalid characters from |text|. Should be called on strings coming |
138 // from external sources (such as extensions) before assigning to |contents| | 153 // from external sources (such as extensions) before assigning to |contents| |
139 // or |description|. | 154 // or |description|. |
140 static string16 SanitizeString(const string16& text); | 155 static string16 SanitizeString(const string16& text); |
141 | 156 |
142 // Copies the destination_url with "www." stripped off to | 157 // Copies the destination_url with "www." stripped off to |
143 // |stripped_destination_url|. This method is invoked internally by the | 158 // |stripped_destination_url|. This method is invoked internally by the |
144 // AutocompleteController and does not normally need to be invoked. | 159 // AutocompleteController and does not normally need to be invoked. |
145 void ComputeStrippedDestinationURL(); | 160 void ComputeStrippedDestinationURL(); |
146 | 161 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 void ValidateClassifications( | 272 void ValidateClassifications( |
258 const string16& text, | 273 const string16& text, |
259 const ACMatchClassifications& classifications) const; | 274 const ACMatchClassifications& classifications) const; |
260 #endif | 275 #endif |
261 }; | 276 }; |
262 | 277 |
263 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 278 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
264 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 279 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
265 | 280 |
266 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 281 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |