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 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "chrome/browser/autocomplete/autocomplete_match.h" | 7 #include "chrome/browser/autocomplete/autocomplete_match.h" |
8 #include "grit/theme_resources.h" | 8 #include "grit/theme_resources.h" |
9 | 9 |
10 // AutocompleteMatch ---------------------------------------------------------- | 10 // AutocompleteMatch ---------------------------------------------------------- |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Mark post-match portion of string (if any). | 161 // Mark post-match portion of string (if any). |
162 const size_t after_match(match_location + match_length); | 162 const size_t after_match(match_location + match_length); |
163 if (after_match < overall_length) { | 163 if (after_match < overall_length) { |
164 classification->push_back(ACMatchClassification(after_match, style)); | 164 classification->push_back(ACMatchClassification(after_match, style)); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 // static | 168 // static |
169 string16 AutocompleteMatch::SanitizeString(const string16& text) { | 169 string16 AutocompleteMatch::SanitizeString(const string16& text) { |
170 // NOTE: This logic is mirrored by |sanitizeString()| in | 170 // NOTE: This logic is mirrored by |sanitizeString()| in |
171 // extension_process_bindings.js. | 171 // schema_generated_bindings.js. |
172 string16 result; | 172 string16 result; |
173 TrimWhitespace(text, TRIM_LEADING, &result); | 173 TrimWhitespace(text, TRIM_LEADING, &result); |
174 RemoveChars(result, kInvalidChars, &result); | 174 RemoveChars(result, kInvalidChars, &result); |
175 return result; | 175 return result; |
176 } | 176 } |
177 | 177 |
178 #ifndef NDEBUG | 178 #ifndef NDEBUG |
179 void AutocompleteMatch::Validate() const { | 179 void AutocompleteMatch::Validate() const { |
180 ValidateClassifications(contents, contents_class); | 180 ValidateClassifications(contents, contents_class); |
181 ValidateClassifications(description, description_class); | 181 ValidateClassifications(description, description_class); |
(...skipping 16 matching lines...) Expand all Loading... |
198 // The classifications should always be sorted. | 198 // The classifications should always be sorted. |
199 size_t last_offset = classifications[0].offset; | 199 size_t last_offset = classifications[0].offset; |
200 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); | 200 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); |
201 i != classifications.end(); ++i) { | 201 i != classifications.end(); ++i) { |
202 DCHECK(i->offset > last_offset) << "Classification unsorted"; | 202 DCHECK(i->offset > last_offset) << "Classification unsorted"; |
203 DCHECK(i->offset < text.length()) << "Classification out of bounds"; | 203 DCHECK(i->offset < text.length()) << "Classification out of bounds"; |
204 last_offset = i->offset; | 204 last_offset = i->offset; |
205 } | 205 } |
206 } | 206 } |
207 #endif | 207 #endif |
OLD | NEW |