| Index: chrome/browser/history/in_memory_url_index_types.cc
|
| diff --git a/chrome/browser/history/in_memory_url_index_types.cc b/chrome/browser/history/in_memory_url_index_types.cc
|
| index f219047e2c75f260325702c126e745ba8f438565..992c822b3a7173e7c0fa2c0bc693f0a38ba1512a 100644
|
| --- a/chrome/browser/history/in_memory_url_index_types.cc
|
| +++ b/chrome/browser/history/in_memory_url_index_types.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/i18n/break_iterator.h"
|
| #include "base/i18n/case_conversion.h"
|
| #include "base/strings/string_util.h"
|
| +#include "base/strings/utf_offset_string_conversions.h"
|
| #include "net/base/escape.h"
|
| #include "net/base/net_util.h"
|
|
|
| @@ -40,19 +41,6 @@ std::string TruncateUrl(const std::string& url) {
|
| return url.substr(0, kCleanedUpUrlMaxLength);
|
| }
|
|
|
| -base::string16 CleanUpUrlForMatching(const GURL& gurl,
|
| - const std::string& languages) {
|
| - return base::i18n::ToLower(net::FormatUrl(
|
| - GURL(TruncateUrl(gurl.spec())), languages,
|
| - net::kFormatUrlOmitUsernamePassword,
|
| - net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS,
|
| - NULL, NULL, NULL));
|
| -}
|
| -
|
| -base::string16 CleanUpTitleForMatching(const base::string16& title) {
|
| - return base::i18n::ToLower(title.substr(0u, kCleanedUpTitleMaxLength));
|
| -}
|
| -
|
| TermMatches MatchTermInString(const base::string16& term,
|
| const base::string16& cleaned_string,
|
| int term_num) {
|
| @@ -92,21 +80,30 @@ TermMatches SortAndDeoverlapMatches(const TermMatches& matches) {
|
|
|
| std::vector<size_t> OffsetsFromTermMatches(const TermMatches& matches) {
|
| std::vector<size_t> offsets;
|
| - for (TermMatches::const_iterator i = matches.begin(); i != matches.end(); ++i)
|
| + for (TermMatches::const_iterator i = matches.begin(); i != matches.end();
|
| + ++i) {
|
| offsets.push_back(i->offset);
|
| + offsets.push_back(i->offset + i->length);
|
| + }
|
| return offsets;
|
| }
|
|
|
| TermMatches ReplaceOffsetsInTermMatches(const TermMatches& matches,
|
| const std::vector<size_t>& offsets) {
|
| - DCHECK_EQ(matches.size(), offsets.size());
|
| + DCHECK_EQ(2 * matches.size(), offsets.size());
|
| TermMatches new_matches;
|
| std::vector<size_t>::const_iterator offset_iter = offsets.begin();
|
| for (TermMatches::const_iterator term_iter = matches.begin();
|
| term_iter != matches.end(); ++term_iter, ++offset_iter) {
|
| - if (*offset_iter != base::string16::npos) {
|
| + const size_t starting_offset = *offset_iter;
|
| + ++offset_iter;
|
| + const size_t ending_offset = *offset_iter;
|
| + if ((starting_offset != base::string16::npos) &&
|
| + (ending_offset != base::string16::npos) &&
|
| + (starting_offset != ending_offset)) {
|
| TermMatch new_match(*term_iter);
|
| - new_match.offset = *offset_iter;
|
| + new_match.offset = starting_offset;
|
| + new_match.length = ending_offset - starting_offset;
|
| new_matches.push_back(new_match);
|
| }
|
| }
|
|
|