| Index: chrome/browser/autocomplete/history_provider.cc
|
| diff --git a/chrome/browser/autocomplete/history_provider.cc b/chrome/browser/autocomplete/history_provider.cc
|
| index 64d7063acf981e3bc54ec038b1c9d6b2d009149f..efd6bb929e84b3be912d7f6c7ef1cb541c0cfdd2 100644
|
| --- a/chrome/browser/autocomplete/history_provider.cc
|
| +++ b/chrome/browser/autocomplete/history_provider.cc
|
| @@ -13,6 +13,7 @@
|
| #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
|
| #include "chrome/browser/history/history_service.h"
|
| #include "chrome/browser/history/history_service_factory.h"
|
| +#include "chrome/browser/history/in_memory_url_index_types.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/common/net/url_fixer_upper.h"
|
| #include "chrome/common/url_constants.h"
|
| @@ -157,3 +158,36 @@ bool HistoryProvider::PreventInlineAutocomplete(
|
| (!input.text().empty() &&
|
| IsWhitespace(input.text()[input.text().length() - 1]));
|
| }
|
| +
|
| +// static
|
| +ACMatchClassifications HistoryProvider::SpansFromTermMatch(
|
| + const history::TermMatches& matches,
|
| + size_t text_length,
|
| + bool is_url) {
|
| + ACMatchClassification::Style url_style =
|
| + is_url ? ACMatchClassification::URL : ACMatchClassification::NONE;
|
| + ACMatchClassifications spans;
|
| + if (matches.empty()) {
|
| + if (text_length)
|
| + spans.push_back(ACMatchClassification(0, url_style));
|
| + return spans;
|
| + }
|
| + if (matches[0].offset)
|
| + spans.push_back(ACMatchClassification(0, url_style));
|
| + size_t match_count = matches.size();
|
| + for (size_t i = 0; i < match_count;) {
|
| + size_t offset = matches[i].offset;
|
| + spans.push_back(ACMatchClassification(offset,
|
| + ACMatchClassification::MATCH | url_style));
|
| + // Skip all adjacent matches.
|
| + do {
|
| + offset += matches[i].length;
|
| + ++i;
|
| + } while ((i < match_count) && (offset == matches[i].offset));
|
| + if (offset < text_length)
|
| + spans.push_back(ACMatchClassification(offset, url_style));
|
| + }
|
| +
|
| + return spans;
|
| +}
|
| +
|
|
|