Chromium Code Reviews| Index: chrome/browser/autocomplete/autocomplete_match.cc |
| =================================================================== |
| --- chrome/browser/autocomplete/autocomplete_match.cc (revision 107110) |
| +++ chrome/browser/autocomplete/autocomplete_match.cc (working copy) |
| @@ -3,6 +3,7 @@ |
| // found in the LICENSE file. |
| #include "base/logging.h" |
| +#include "base/string_util.h" |
| #include "chrome/browser/autocomplete/autocomplete_match.h" |
| #include "grit/theme_resources.h" |
| @@ -156,6 +157,17 @@ |
| } |
| } |
| +// static |
| +string16 AutocompleteMatch::SanitizeString(const string16& text) { |
| + // NOTE: This logic is mirrored by |sanitizeString()| in |
| + // extension_process_bindings.js. |
| + const char16 kRemoveChars[] = { '\n', '\r', '\t', 0x2028, 0x2029, 0 }; |
|
Scott Hess - ex-Googler
2011/10/26 21:08:00
Document the crazy code points so I don't have to
Alexei Svitkine (slow)
2011/10/27 13:30:53
Done.
|
| + string16 result; |
| + TrimWhitespace(text, TRIM_LEADING, &result); |
| + RemoveChars(result, kRemoveChars, &result); |
|
Scott Hess - ex-Googler
2011/10/26 21:08:00
The potential for aliasing kinda frightens me, but
Alexei Svitkine (slow)
2011/10/27 13:30:53
Yeah, this is actually documented as safe to do fo
Scott Hess - ex-Googler
2011/10/27 18:28:37
Oh, cool, I embarrassingly went direct to the impl
|
| + return result; |
| +} |
| + |
| #ifndef NDEBUG |
| void AutocompleteMatch::Validate() const { |
| ValidateClassifications(contents, contents_class); |