blob: 5eccdb75539e3634410b836c9d4353ca17539b45 [file] [log] [blame]
[email protected]eac44992012-02-14 21:39:351// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]9ac40092010-10-27 23:05:262// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]371dab12012-06-01 03:23:555#include "chrome/browser/autocomplete/autocomplete_match.h"
6
[email protected]5281d422012-07-28 21:37:107#include "base/i18n/time_formatting.h"
[email protected]9ac40092010-10-27 23:05:268#include "base/logging.h"
[email protected]98570e12013-06-10 19:54:229#include "base/strings/string16.h"
[email protected]3ea1b182013-02-08 22:38:4110#include "base/strings/string_number_conversions.h"
[email protected]98570e12013-06-10 19:54:2211#include "base/strings/string_util.h"
12#include "base/strings/stringprintf.h"
[email protected]135cb802013-06-09 16:44:2013#include "base/strings/utf_string_conversions.h"
[email protected]5281d422012-07-28 21:37:1014#include "base/time.h"
[email protected]30f5bc92012-06-26 04:14:5515#include "chrome/browser/autocomplete/autocomplete_provider.h"
[email protected]033f3422012-03-13 21:24:1816#include "chrome/browser/search_engines/template_url.h"
[email protected]85b8d6f2012-05-08 20:53:4717#include "chrome/browser/search_engines/template_url_service.h"
18#include "chrome/browser/search_engines/template_url_service_factory.h"
[email protected]345e8fda2012-09-06 01:07:4719#include "content/public/common/url_constants.h"
[email protected]9ac40092010-10-27 23:05:2620#include "grit/theme_resources.h"
21
[email protected]3b81314d2012-09-11 02:48:4122namespace {
23
24bool IsTrivialClassification(const ACMatchClassifications& classifications) {
25 return classifications.empty() ||
26 ((classifications.size() == 1) &&
27 (classifications.back().style == ACMatchClassification::NONE));
28}
29
30} // namespace
31
[email protected]9ac40092010-10-27 23:05:2632// AutocompleteMatch ----------------------------------------------------------
33
[email protected]531e0342011-11-10 15:08:4134// static
35const char16 AutocompleteMatch::kInvalidChars[] = {
36 '\n', '\r', '\t',
37 0x2028, // Line separator
38 0x2029, // Paragraph separator
39 0
40};
41
[email protected]9ac40092010-10-27 23:05:2642AutocompleteMatch::AutocompleteMatch()
43 : provider(NULL),
44 relevance(0),
[email protected]cf6256f2012-06-12 23:36:0145 typed_count(-1),
[email protected]9ac40092010-10-27 23:05:2646 deletable(false),
[email protected]a2fedb1e2011-01-25 15:23:3647 inline_autocomplete_offset(string16::npos),
[email protected]2905f742011-10-13 03:51:5848 transition(content::PAGE_TRANSITION_GENERATED),
[email protected]9ac40092010-10-27 23:05:2649 is_history_what_you_typed_match(false),
[email protected]b7f64d742013-05-21 04:04:0450 type(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED),
[email protected]7abfb3462011-01-31 16:43:0651 starred(false),
52 from_previous(false) {
[email protected]9ac40092010-10-27 23:05:2653}
54
55AutocompleteMatch::AutocompleteMatch(AutocompleteProvider* provider,
56 int relevance,
57 bool deletable,
58 Type type)
59 : provider(provider),
60 relevance(relevance),
[email protected]cf6256f2012-06-12 23:36:0161 typed_count(-1),
[email protected]9ac40092010-10-27 23:05:2662 deletable(deletable),
[email protected]a2fedb1e2011-01-25 15:23:3663 inline_autocomplete_offset(string16::npos),
[email protected]2905f742011-10-13 03:51:5864 transition(content::PAGE_TRANSITION_TYPED),
[email protected]9ac40092010-10-27 23:05:2665 is_history_what_you_typed_match(false),
66 type(type),
[email protected]7abfb3462011-01-31 16:43:0667 starred(false),
68 from_previous(false) {
[email protected]9ac40092010-10-27 23:05:2669}
70
[email protected]3cb0f8d92012-02-29 05:43:3471AutocompleteMatch::AutocompleteMatch(const AutocompleteMatch& match)
72 : provider(match.provider),
73 relevance(match.relevance),
[email protected]cf6256f2012-06-12 23:36:0174 typed_count(match.typed_count),
[email protected]3cb0f8d92012-02-29 05:43:3475 deletable(match.deletable),
76 fill_into_edit(match.fill_into_edit),
77 inline_autocomplete_offset(match.inline_autocomplete_offset),
78 destination_url(match.destination_url),
79 stripped_destination_url(match.stripped_destination_url),
80 contents(match.contents),
81 contents_class(match.contents_class),
82 description(match.description),
83 description_class(match.description_class),
84 transition(match.transition),
85 is_history_what_you_typed_match(match.is_history_what_you_typed_match),
86 type(match.type),
[email protected]bca359b2012-06-24 07:53:0487 associated_keyword(match.associated_keyword.get() ?
88 new AutocompleteMatch(*match.associated_keyword) : NULL),
[email protected]3cb0f8d92012-02-29 05:43:3489 keyword(match.keyword),
[email protected]3cb0f8d92012-02-29 05:43:3490 starred(match.starred),
[email protected]bca359b2012-06-24 07:53:0491 from_previous(match.from_previous),
92 search_terms_args(match.search_terms_args.get() ?
93 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) :
[email protected]5281d422012-07-28 21:37:1094 NULL),
95 additional_info(match.additional_info) {
[email protected]3cb0f8d92012-02-29 05:43:3496}
97
[email protected]9ac40092010-10-27 23:05:2698AutocompleteMatch::~AutocompleteMatch() {
99}
100
[email protected]3cb0f8d92012-02-29 05:43:34101AutocompleteMatch& AutocompleteMatch::operator=(
102 const AutocompleteMatch& match) {
103 if (this == &match)
104 return *this;
105
106 provider = match.provider;
107 relevance = match.relevance;
[email protected]cf6256f2012-06-12 23:36:01108 typed_count = match.typed_count;
[email protected]3cb0f8d92012-02-29 05:43:34109 deletable = match.deletable;
110 fill_into_edit = match.fill_into_edit;
111 inline_autocomplete_offset = match.inline_autocomplete_offset;
112 destination_url = match.destination_url;
113 stripped_destination_url = match.stripped_destination_url;
114 contents = match.contents;
115 contents_class = match.contents_class;
116 description = match.description;
117 description_class = match.description_class;
118 transition = match.transition;
119 is_history_what_you_typed_match = match.is_history_what_you_typed_match;
120 type = match.type;
121 associated_keyword.reset(match.associated_keyword.get() ?
122 new AutocompleteMatch(*match.associated_keyword) : NULL);
123 keyword = match.keyword;
[email protected]3cb0f8d92012-02-29 05:43:34124 starred = match.starred;
125 from_previous = match.from_previous;
[email protected]bca359b2012-06-24 07:53:04126 search_terms_args.reset(match.search_terms_args.get() ?
127 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : NULL);
[email protected]5281d422012-07-28 21:37:10128 additional_info = match.additional_info;
[email protected]3cb0f8d92012-02-29 05:43:34129 return *this;
130}
131
[email protected]9ac40092010-10-27 23:05:26132// static
[email protected]9ac40092010-10-27 23:05:26133int AutocompleteMatch::TypeToIcon(Type type) {
[email protected]fc65f272011-06-28 22:21:30134 int icons[] = {
[email protected]9ac40092010-10-27 23:05:26135 IDR_OMNIBOX_HTTP,
136 IDR_OMNIBOX_HTTP,
[email protected]c37ad9e2012-06-12 04:57:13137 IDR_OMNIBOX_HTTP,
138 IDR_OMNIBOX_HTTP,
139 IDR_OMNIBOX_HTTP,
[email protected]9ac40092010-10-27 23:05:26140 IDR_OMNIBOX_HTTP,
141 IDR_OMNIBOX_SEARCH,
142 IDR_OMNIBOX_SEARCH,
143 IDR_OMNIBOX_SEARCH,
144 IDR_OMNIBOX_SEARCH,
[email protected]8f7405482011-04-13 11:08:52145 IDR_OMNIBOX_EXTENSION_APP,
[email protected]dbacefb2012-09-12 03:32:06146 // ContactProvider isn't used by the omnibox, so this icon is never
147 // displayed.
148 IDR_OMNIBOX_SEARCH,
[email protected]25320602012-10-18 22:05:56149 IDR_OMNIBOX_HTTP,
[email protected]9ac40092010-10-27 23:05:26150 };
[email protected]b7f64d742013-05-21 04:04:04151 COMPILE_ASSERT(arraysize(icons) == AutocompleteMatchType::NUM_TYPES,
[email protected]fc65f272011-06-28 22:21:30152 icons_array_must_match_type_enum);
[email protected]9ac40092010-10-27 23:05:26153 return icons[type];
154}
155
156// static
[email protected]dd2f9e32012-09-19 14:23:40157int AutocompleteMatch::TypeToLocationBarIcon(Type type) {
158 int id = TypeToIcon(type);
159 if (id == IDR_OMNIBOX_HTTP)
160 return IDR_LOCATION_BAR_HTTP;
161 return id;
162}
163
164// static
[email protected]9ac40092010-10-27 23:05:26165bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1,
166 const AutocompleteMatch& elem2) {
167 // For equal-relevance matches, we sort alphabetically, so that providers
168 // who return multiple elements at the same priority get a "stable" sort
169 // across multiple updates.
[email protected]033f3422012-03-13 21:24:18170 return (elem1.relevance == elem2.relevance) ?
171 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance);
[email protected]9ac40092010-10-27 23:05:26172}
173
174// static
175bool AutocompleteMatch::DestinationSortFunc(const AutocompleteMatch& elem1,
176 const AutocompleteMatch& elem2) {
177 // Sort identical destination_urls together. Place the most relevant matches
178 // first, so that when we call std::unique(), these are the ones that get
179 // preserved.
[email protected]00193bf2012-09-15 14:52:50180 if (DestinationsEqual(elem1, elem2) ||
181 (elem1.stripped_destination_url.is_empty() &&
182 elem2.stripped_destination_url.is_empty()))
183 return MoreRelevant(elem1, elem2);
184 return elem1.stripped_destination_url < elem2.stripped_destination_url;
[email protected]9ac40092010-10-27 23:05:26185}
186
187// static
188bool AutocompleteMatch::DestinationsEqual(const AutocompleteMatch& elem1,
189 const AutocompleteMatch& elem2) {
[email protected]00193bf2012-09-15 14:52:50190 if (elem1.stripped_destination_url.is_empty() &&
191 elem2.stripped_destination_url.is_empty())
192 return false;
[email protected]3cb0f8d92012-02-29 05:43:34193 return elem1.stripped_destination_url == elem2.stripped_destination_url;
[email protected]9ac40092010-10-27 23:05:26194}
195
196// static
197void AutocompleteMatch::ClassifyMatchInString(
[email protected]a2fedb1e2011-01-25 15:23:36198 const string16& find_text,
199 const string16& text,
[email protected]9ac40092010-10-27 23:05:26200 int style,
201 ACMatchClassifications* classification) {
202 ClassifyLocationInString(text.find(find_text), find_text.length(),
203 text.length(), style, classification);
204}
205
[email protected]24d692aa2011-05-25 23:07:58206// static
[email protected]9ac40092010-10-27 23:05:26207void AutocompleteMatch::ClassifyLocationInString(
208 size_t match_location,
209 size_t match_length,
210 size_t overall_length,
211 int style,
212 ACMatchClassifications* classification) {
213 classification->clear();
214
215 // Don't classify anything about an empty string
216 // (AutocompleteMatch::Validate() checks this).
217 if (overall_length == 0)
218 return;
219
220 // Mark pre-match portion of string (if any).
221 if (match_location != 0) {
222 classification->push_back(ACMatchClassification(0, style));
223 }
224
225 // Mark matching portion of string.
[email protected]a2fedb1e2011-01-25 15:23:36226 if (match_location == string16::npos) {
[email protected]9ac40092010-10-27 23:05:26227 // No match, above classification will suffice for whole string.
228 return;
229 }
230 // Classifying an empty match makes no sense and will lead to validation
231 // errors later.
[email protected]eac44992012-02-14 21:39:35232 DCHECK_GT(match_length, 0U);
[email protected]9ac40092010-10-27 23:05:26233 classification->push_back(ACMatchClassification(match_location,
234 (style | ACMatchClassification::MATCH) & ~ACMatchClassification::DIM));
235
236 // Mark post-match portion of string (if any).
237 const size_t after_match(match_location + match_length);
238 if (after_match < overall_length) {
239 classification->push_back(ACMatchClassification(after_match, style));
240 }
241}
242
[email protected]5595f40d2011-10-28 17:29:18243// static
[email protected]3b81314d2012-09-11 02:48:41244AutocompleteMatch::ACMatchClassifications
245 AutocompleteMatch::MergeClassifications(
246 const ACMatchClassifications& classifications1,
247 const ACMatchClassifications& classifications2) {
248 // We must return the empty vector only if both inputs are truly empty.
249 // The result of merging an empty vector with a single (0, NONE)
250 // classification is the latter one-entry vector.
251 if (IsTrivialClassification(classifications1))
252 return classifications2.empty() ? classifications1 : classifications2;
253 if (IsTrivialClassification(classifications2))
254 return classifications1;
255
256 ACMatchClassifications output;
257 for (ACMatchClassifications::const_iterator i = classifications1.begin(),
258 j = classifications2.begin(); i != classifications1.end();) {
259 AutocompleteMatch::AddLastClassificationIfNecessary(&output,
260 std::max(i->offset, j->offset), i->style | j->style);
261 const size_t next_i_offset = (i + 1) == classifications1.end() ?
262 static_cast<size_t>(-1) : (i + 1)->offset;
263 const size_t next_j_offset = (j + 1) == classifications2.end() ?
264 static_cast<size_t>(-1) : (j + 1)->offset;
265 if (next_i_offset >= next_j_offset)
266 ++j;
267 if (next_j_offset >= next_i_offset)
268 ++i;
269 }
270
271 return output;
272}
273
274// static
[email protected]9d2b5f3b2012-03-14 21:34:32275std::string AutocompleteMatch::ClassificationsToString(
276 const ACMatchClassifications& classifications) {
277 std::string serialized_classifications;
278 for (size_t i = 0; i < classifications.size(); ++i) {
279 if (i)
280 serialized_classifications += ',';
281 serialized_classifications += base::IntToString(classifications[i].offset) +
282 ',' + base::IntToString(classifications[i].style);
283 }
284 return serialized_classifications;
285}
286
287// static
288ACMatchClassifications AutocompleteMatch::ClassificationsFromString(
289 const std::string& serialized_classifications) {
290 ACMatchClassifications classifications;
291 std::vector<std::string> tokens;
292 Tokenize(serialized_classifications, ",", &tokens);
293 DCHECK(!(tokens.size() & 1)); // The number of tokens should be even.
294 for (size_t i = 0; i < tokens.size(); i += 2) {
295 int classification_offset = 0;
296 int classification_style = ACMatchClassification::NONE;
297 if (!base::StringToInt(tokens[i], &classification_offset) ||
298 !base::StringToInt(tokens[i + 1], &classification_style)) {
299 NOTREACHED();
300 return classifications;
301 }
302 classifications.push_back(ACMatchClassification(classification_offset,
303 classification_style));
304 }
305 return classifications;
306}
307
308// static
309void AutocompleteMatch::AddLastClassificationIfNecessary(
310 ACMatchClassifications* classifications,
311 size_t offset,
312 int style) {
313 DCHECK(classifications);
314 if (classifications->empty() || classifications->back().style != style) {
315 DCHECK(classifications->empty() ||
316 (offset > classifications->back().offset));
317 classifications->push_back(ACMatchClassification(offset, style));
318 }
319}
320
321// static
[email protected]5595f40d2011-10-28 17:29:18322string16 AutocompleteMatch::SanitizeString(const string16& text) {
323 // NOTE: This logic is mirrored by |sanitizeString()| in
[email protected]e87032e2013-03-11 00:17:14324 // omnibox_custom_bindings.js.
[email protected]5595f40d2011-10-28 17:29:18325 string16 result;
326 TrimWhitespace(text, TRIM_LEADING, &result);
[email protected]531e0342011-11-10 15:08:41327 RemoveChars(result, kInvalidChars, &result);
[email protected]5595f40d2011-10-28 17:29:18328 return result;
329}
330
[email protected]749e7ae02012-09-05 18:47:46331// static
332bool AutocompleteMatch::IsSearchType(Type type) {
[email protected]b7f64d742013-05-21 04:04:04333 return type == AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED ||
334 type == AutocompleteMatchType::SEARCH_HISTORY ||
335 type == AutocompleteMatchType::SEARCH_SUGGEST ||
336 type == AutocompleteMatchType::SEARCH_OTHER_ENGINE;
[email protected]749e7ae02012-09-05 18:47:46337}
338
[email protected]dbff446582012-10-30 00:20:26339void AutocompleteMatch::ComputeStrippedDestinationURL(Profile* profile) {
[email protected]345e8fda2012-09-06 01:07:47340 stripped_destination_url = destination_url;
341 if (!stripped_destination_url.is_valid())
342 return;
343
[email protected]dbff446582012-10-30 00:20:26344 // If the destination URL looks like it was generated from a TemplateURL,
345 // remove all substitutions other than the search terms. This allows us
346 // to eliminate cases like past search URLs from history that differ only
347 // by some obscure query param from each other or from the search/keyword
348 // provider matches.
349 TemplateURL* template_url = GetTemplateURL(profile, true);
350 if (template_url != NULL && template_url->SupportsReplacement()) {
351 string16 search_terms;
352 if (template_url->ExtractSearchTermsFromURL(stripped_destination_url,
353 &search_terms)) {
354 stripped_destination_url =
355 GURL(template_url->url_ref().ReplaceSearchTerms(
356 TemplateURLRef::SearchTermsArgs(search_terms)));
357 }
358 }
359
[email protected]345e8fda2012-09-06 01:07:47360 // |replacements| keeps all the substitions we're going to make to
361 // from {destination_url} to {stripped_destination_url}. |need_replacement|
362 // is a helper variable that helps us keep track of whether we need
363 // to apply the replacement.
364 bool needs_replacement = false;
365 GURL::Replacements replacements;
366
367 // Remove the www. prefix from the host.
[email protected]3cb0f8d92012-02-29 05:43:34368 static const char prefix[] = "www.";
369 static const size_t prefix_len = arraysize(prefix) - 1;
[email protected]dbff446582012-10-30 00:20:26370 std::string host = stripped_destination_url.host();
[email protected]345e8fda2012-09-06 01:07:47371 if (host.compare(0, prefix_len, prefix) == 0) {
[email protected]3cb0f8d92012-02-29 05:43:34372 host = host.substr(prefix_len);
[email protected]345e8fda2012-09-06 01:07:47373 replacements.SetHostStr(host);
374 needs_replacement = true;
[email protected]3cb0f8d92012-02-29 05:43:34375 }
[email protected]345e8fda2012-09-06 01:07:47376
377 // Replace https protocol with http protocol.
378 if (stripped_destination_url.SchemeIs(chrome::kHttpsScheme)) {
379 replacements.SetScheme(
380 chrome::kHttpScheme,
381 url_parse::Component(0, strlen(chrome::kHttpScheme)));
382 needs_replacement = true;
383 }
384
385 if (needs_replacement)
[email protected]dbff446582012-10-30 00:20:26386 stripped_destination_url = stripped_destination_url.ReplaceComponents(
387 replacements);
[email protected]3cb0f8d92012-02-29 05:43:34388}
389
[email protected]85b8d6f2012-05-08 20:53:47390void AutocompleteMatch::GetKeywordUIState(Profile* profile,
391 string16* keyword,
[email protected]033f3422012-03-13 21:24:18392 bool* is_keyword_hint) const {
393 *is_keyword_hint = associated_keyword.get() != NULL;
394 keyword->assign(*is_keyword_hint ? associated_keyword->keyword :
[email protected]85b8d6f2012-05-08 20:53:47395 GetSubstitutingExplicitlyInvokedKeyword(profile));
[email protected]033f3422012-03-13 21:24:18396}
397
[email protected]85b8d6f2012-05-08 20:53:47398string16 AutocompleteMatch::GetSubstitutingExplicitlyInvokedKeyword(
399 Profile* profile) const {
[email protected]9b74ab52012-03-30 16:08:07400 if (transition != content::PAGE_TRANSITION_KEYWORD)
401 return string16();
[email protected]dbff446582012-10-30 00:20:26402 const TemplateURL* t_url = GetTemplateURL(profile, false);
[email protected]9b74ab52012-03-30 16:08:07403 return (t_url && t_url->SupportsReplacement()) ? keyword : string16();
[email protected]033f3422012-03-13 21:24:18404}
405
[email protected]dbff446582012-10-30 00:20:26406TemplateURL* AutocompleteMatch::GetTemplateURL(
407 Profile* profile, bool allow_fallback_to_destination_host) const {
[email protected]85b8d6f2012-05-08 20:53:47408 DCHECK(profile);
[email protected]dbff446582012-10-30 00:20:26409 TemplateURLService* template_url_service =
410 TemplateURLServiceFactory::GetForProfile(profile);
411 if (template_url_service == NULL)
412 return NULL;
413 TemplateURL* template_url = keyword.empty() ? NULL :
414 template_url_service->GetTemplateURLForKeyword(keyword);
415 if (template_url == NULL && allow_fallback_to_destination_host) {
416 template_url = template_url_service->GetTemplateURLForHost(
417 destination_url.host());
418 }
419 return template_url;
[email protected]3cb0f8d92012-02-29 05:43:34420}
421
[email protected]5281d422012-07-28 21:37:10422void AutocompleteMatch::RecordAdditionalInfo(const std::string& property,
423 const std::string& value) {
424 DCHECK(property.size());
425 DCHECK(value.size());
426 additional_info[property] = value;
427}
428
429void AutocompleteMatch::RecordAdditionalInfo(const std::string& property,
430 int value) {
[email protected]7d3cbc92013-03-18 22:33:04431 RecordAdditionalInfo(property, base::StringPrintf("%d", value));
[email protected]5281d422012-07-28 21:37:10432}
433
434void AutocompleteMatch::RecordAdditionalInfo(const std::string& property,
435 const base::Time& value) {
436 RecordAdditionalInfo(property,
437 UTF16ToUTF8(base::TimeFormatShortDateAndTime(value)));
438}
439
[email protected]9ac40092010-10-27 23:05:26440#ifndef NDEBUG
441void AutocompleteMatch::Validate() const {
442 ValidateClassifications(contents, contents_class);
443 ValidateClassifications(description, description_class);
444}
445
446void AutocompleteMatch::ValidateClassifications(
[email protected]a2fedb1e2011-01-25 15:23:36447 const string16& text,
[email protected]9ac40092010-10-27 23:05:26448 const ACMatchClassifications& classifications) const {
449 if (text.empty()) {
[email protected]37b95732011-05-26 23:11:09450 DCHECK(classifications.empty());
[email protected]9ac40092010-10-27 23:05:26451 return;
452 }
453
454 // The classifications should always cover the whole string.
[email protected]eac44992012-02-14 21:39:35455 DCHECK(!classifications.empty()) << "No classification for \"" << text << '"';
456 DCHECK_EQ(0U, classifications[0].offset)
457 << "Classification misses beginning for \"" << text << '"';
[email protected]9ac40092010-10-27 23:05:26458 if (classifications.size() == 1)
459 return;
460
461 // The classifications should always be sorted.
462 size_t last_offset = classifications[0].offset;
463 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1);
464 i != classifications.end(); ++i) {
[email protected]35f1f4f02012-09-11 13:17:00465 const char* provider_name = provider ? provider->GetName() : "None";
[email protected]eac44992012-02-14 21:39:35466 DCHECK_GT(i->offset, last_offset)
[email protected]6d478b12012-06-06 12:19:34467 << " Classification for \"" << text << "\" with offset of " << i->offset
468 << " is unsorted in relation to last offset of " << last_offset
[email protected]35f1f4f02012-09-11 13:17:00469 << ". Provider: " << provider_name << ".";
[email protected]eac44992012-02-14 21:39:35470 DCHECK_LT(i->offset, text.length())
[email protected]6d478b12012-06-06 12:19:34471 << " Classification of [" << i->offset << "," << text.length()
472 << "] is out of bounds for \"" << text << "\". Provider: "
[email protected]35f1f4f02012-09-11 13:17:00473 << provider_name << ".";
[email protected]9ac40092010-10-27 23:05:26474 last_offset = i->offset;
475 }
476}
477#endif