Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: chrome/browser/history/url_index_private_data.cc

Issue 255423002: Omnibox: Highlight Matches in URLs Properly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: spacing Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/history/url_index_private_data.h" 5 #include "chrome/browser/history/url_index_private_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <iterator> 9 #include <iterator>
10 #include <limits> 10 #include <limits>
11 #include <numeric> 11 #include <numeric>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/i18n/break_iterator.h" 17 #include "base/i18n/break_iterator.h"
18 #include "base/i18n/case_conversion.h" 18 #include "base/i18n/case_conversion.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/utf_offset_string_conversions.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "base/time/time.h" 23 #include "base/time/time.h"
23 #include "chrome/browser/autocomplete/autocomplete_provider.h" 24 #include "chrome/browser/autocomplete/autocomplete_provider.h"
24 #include "chrome/browser/autocomplete/url_prefix.h" 25 #include "chrome/browser/autocomplete/url_prefix.h"
25 #include "chrome/browser/bookmarks/bookmark_utils.h" 26 #include "chrome/browser/bookmarks/bookmark_utils.h"
26 #include "chrome/browser/history/history_database.h" 27 #include "chrome/browser/history/history_database.h"
27 #include "chrome/browser/history/history_db_task.h" 28 #include "chrome/browser/history/history_db_task.h"
28 #include "chrome/browser/history/history_service.h" 29 #include "chrome/browser/history/history_service.h"
29 #include "chrome/browser/history/in_memory_url_index.h" 30 #include "chrome/browser/history/in_memory_url_index.h"
30 #include "components/bookmarks/core/browser/bookmark_service.h" 31 #include "components/bookmarks/core/browser/bookmark_service.h"
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 751
751 return true; 752 return true;
752 } 753 }
753 754
754 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row, 755 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row,
755 RowWordStarts* word_starts, 756 RowWordStarts* word_starts,
756 const std::string& languages) { 757 const std::string& languages) {
757 HistoryID history_id = static_cast<HistoryID>(row.id()); 758 HistoryID history_id = static_cast<HistoryID>(row.id());
758 // Split URL into individual, unique words then add in the title words. 759 // Split URL into individual, unique words then add in the title words.
759 const GURL& gurl(row.url()); 760 const GURL& gurl(row.url());
761 base::OffsetAdjuster::Adjustments adjustments;
760 const base::string16& url = 762 const base::string16& url =
761 bookmark_utils::CleanUpUrlForMatching(gurl, languages); 763 bookmark_utils::CleanUpUrlForMatching(gurl, languages, &adjustments);
Peter Kasting 2014/04/23 23:18:01 Nit: And another 2 in this file
Mark P 2014/04/24 14:05:02 Done.
762 String16Set url_words = String16SetFromString16(url, 764 String16Set url_words = String16SetFromString16(url,
763 word_starts ? &word_starts->url_word_starts_ : NULL); 765 word_starts ? &word_starts->url_word_starts_ : NULL);
764 const base::string16& title = 766 const base::string16& title =
765 bookmark_utils::CleanUpTitleForMatching(row.title()); 767 bookmark_utils::CleanUpTitleForMatching(row.title());
766 String16Set title_words = String16SetFromString16(title, 768 String16Set title_words = String16SetFromString16(title,
767 word_starts ? &word_starts->title_word_starts_ : NULL); 769 word_starts ? &word_starts->title_word_starts_ : NULL);
768 String16Set words; 770 String16Set words;
769 std::set_union(url_words.begin(), url_words.end(), 771 std::set_union(url_words.begin(), url_words.end(),
770 title_words.begin(), title_words.end(), 772 title_words.begin(), title_words.end(),
771 std::insert_iterator<String16Set>(words, words.begin())); 773 std::insert_iterator<String16Set>(words, words.begin()));
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 word_starts.title_word_starts_.push_back(*jiter); 1235 word_starts.title_word_starts_.push_back(*jiter);
1234 word_starts_map_[history_id] = word_starts; 1236 word_starts_map_[history_id] = word_starts;
1235 } 1237 }
1236 } else { 1238 } else {
1237 // Since the cache did not contain any word starts we must rebuild then from 1239 // Since the cache did not contain any word starts we must rebuild then from
1238 // the URL and page titles. 1240 // the URL and page titles.
1239 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin(); 1241 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin();
1240 iter != history_info_map_.end(); ++iter) { 1242 iter != history_info_map_.end(); ++iter) {
1241 RowWordStarts word_starts; 1243 RowWordStarts word_starts;
1242 const URLRow& row(iter->second.url_row); 1244 const URLRow& row(iter->second.url_row);
1243 const base::string16& url = 1245 base::OffsetAdjuster::Adjustments adjustments;
1244 bookmark_utils::CleanUpUrlForMatching(row.url(), languages); 1246 const base::string16& url = bookmark_utils::CleanUpUrlForMatching(
1247 row.url(), languages, &adjustments);
1245 String16VectorFromString16(url, false, &word_starts.url_word_starts_); 1248 String16VectorFromString16(url, false, &word_starts.url_word_starts_);
1246 const base::string16& title = 1249 const base::string16& title =
1247 bookmark_utils::CleanUpTitleForMatching(row.title()); 1250 bookmark_utils::CleanUpTitleForMatching(row.title());
1248 String16VectorFromString16(title, false, &word_starts.title_word_starts_); 1251 String16VectorFromString16(title, false, &word_starts.title_word_starts_);
1249 word_starts_map_[iter->first] = word_starts; 1252 word_starts_map_[iter->first] = word_starts;
1250 } 1253 }
1251 } 1254 }
1252 return true; 1255 return true;
1253 } 1256 }
1254 1257
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 // recently visited (within the last 12/24 hours) as highly important. Get 1357 // recently visited (within the last 12/24 hours) as highly important. Get
1355 // input from mpearson. 1358 // input from mpearson.
1356 if (r1.typed_count() != r2.typed_count()) 1359 if (r1.typed_count() != r2.typed_count())
1357 return (r1.typed_count() > r2.typed_count()); 1360 return (r1.typed_count() > r2.typed_count());
1358 if (r1.visit_count() != r2.visit_count()) 1361 if (r1.visit_count() != r2.visit_count())
1359 return (r1.visit_count() > r2.visit_count()); 1362 return (r1.visit_count() > r2.visit_count());
1360 return (r1.last_visit() > r2.last_visit()); 1363 return (r1.last_visit() > r2.last_visit());
1361 } 1364 }
1362 1365
1363 } // namespace history 1366 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698