OLD | NEW |
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_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
23 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 23 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
24 #include "chrome/browser/autocomplete/url_prefix.h" | 24 #include "chrome/browser/autocomplete/url_prefix.h" |
| 25 #include "chrome/browser/bookmarks/bookmark_utils.h" |
25 #include "chrome/browser/history/history_database.h" | 26 #include "chrome/browser/history/history_database.h" |
26 #include "chrome/browser/history/history_db_task.h" | 27 #include "chrome/browser/history/history_db_task.h" |
27 #include "chrome/browser/history/history_service.h" | 28 #include "chrome/browser/history/history_service.h" |
28 #include "chrome/browser/history/in_memory_url_index.h" | 29 #include "chrome/browser/history/in_memory_url_index.h" |
29 #include "components/bookmarks/core/browser/bookmark_service.h" | 30 #include "components/bookmarks/core/browser/bookmark_service.h" |
30 #include "content/public/browser/notification_details.h" | 31 #include "content/public/browser/notification_details.h" |
31 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
32 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
33 #include "net/base/net_util.h" | 34 #include "net/base/net_util.h" |
34 | 35 |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 | 750 |
750 return true; | 751 return true; |
751 } | 752 } |
752 | 753 |
753 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row, | 754 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row, |
754 RowWordStarts* word_starts, | 755 RowWordStarts* word_starts, |
755 const std::string& languages) { | 756 const std::string& languages) { |
756 HistoryID history_id = static_cast<HistoryID>(row.id()); | 757 HistoryID history_id = static_cast<HistoryID>(row.id()); |
757 // Split URL into individual, unique words then add in the title words. | 758 // Split URL into individual, unique words then add in the title words. |
758 const GURL& gurl(row.url()); | 759 const GURL& gurl(row.url()); |
759 const base::string16& url = CleanUpUrlForMatching(gurl, languages); | 760 const base::string16& url = |
| 761 bookmark_utils::CleanUpUrlForMatching(gurl, languages); |
760 String16Set url_words = String16SetFromString16(url, | 762 String16Set url_words = String16SetFromString16(url, |
761 word_starts ? &word_starts->url_word_starts_ : NULL); | 763 word_starts ? &word_starts->url_word_starts_ : NULL); |
762 const base::string16& title = CleanUpTitleForMatching(row.title()); | 764 const base::string16& title = |
| 765 bookmark_utils::CleanUpTitleForMatching(row.title()); |
763 String16Set title_words = String16SetFromString16(title, | 766 String16Set title_words = String16SetFromString16(title, |
764 word_starts ? &word_starts->title_word_starts_ : NULL); | 767 word_starts ? &word_starts->title_word_starts_ : NULL); |
765 String16Set words; | 768 String16Set words; |
766 std::set_union(url_words.begin(), url_words.end(), | 769 std::set_union(url_words.begin(), url_words.end(), |
767 title_words.begin(), title_words.end(), | 770 title_words.begin(), title_words.end(), |
768 std::insert_iterator<String16Set>(words, words.begin())); | 771 std::insert_iterator<String16Set>(words, words.begin())); |
769 for (String16Set::iterator word_iter = words.begin(); | 772 for (String16Set::iterator word_iter = words.begin(); |
770 word_iter != words.end(); ++word_iter) | 773 word_iter != words.end(); ++word_iter) |
771 AddWordToIndex(*word_iter, history_id); | 774 AddWordToIndex(*word_iter, history_id); |
772 | 775 |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 word_starts.title_word_starts_.push_back(*jiter); | 1233 word_starts.title_word_starts_.push_back(*jiter); |
1231 word_starts_map_[history_id] = word_starts; | 1234 word_starts_map_[history_id] = word_starts; |
1232 } | 1235 } |
1233 } else { | 1236 } else { |
1234 // Since the cache did not contain any word starts we must rebuild then from | 1237 // Since the cache did not contain any word starts we must rebuild then from |
1235 // the URL and page titles. | 1238 // the URL and page titles. |
1236 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin(); | 1239 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin(); |
1237 iter != history_info_map_.end(); ++iter) { | 1240 iter != history_info_map_.end(); ++iter) { |
1238 RowWordStarts word_starts; | 1241 RowWordStarts word_starts; |
1239 const URLRow& row(iter->second.url_row); | 1242 const URLRow& row(iter->second.url_row); |
1240 const base::string16& url = CleanUpUrlForMatching(row.url(), languages); | 1243 const base::string16& url = |
| 1244 bookmark_utils::CleanUpUrlForMatching(row.url(), languages); |
1241 String16VectorFromString16(url, false, &word_starts.url_word_starts_); | 1245 String16VectorFromString16(url, false, &word_starts.url_word_starts_); |
1242 const base::string16& title = CleanUpTitleForMatching(row.title()); | 1246 const base::string16& title = |
| 1247 bookmark_utils::CleanUpTitleForMatching(row.title()); |
1243 String16VectorFromString16(title, false, &word_starts.title_word_starts_); | 1248 String16VectorFromString16(title, false, &word_starts.title_word_starts_); |
1244 word_starts_map_[iter->first] = word_starts; | 1249 word_starts_map_[iter->first] = word_starts; |
1245 } | 1250 } |
1246 } | 1251 } |
1247 return true; | 1252 return true; |
1248 } | 1253 } |
1249 | 1254 |
1250 // static | 1255 // static |
1251 bool URLIndexPrivateData::URLSchemeIsWhitelisted( | 1256 bool URLIndexPrivateData::URLSchemeIsWhitelisted( |
1252 const GURL& gurl, | 1257 const GURL& gurl, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 // recently visited (within the last 12/24 hours) as highly important. Get | 1354 // recently visited (within the last 12/24 hours) as highly important. Get |
1350 // input from mpearson. | 1355 // input from mpearson. |
1351 if (r1.typed_count() != r2.typed_count()) | 1356 if (r1.typed_count() != r2.typed_count()) |
1352 return (r1.typed_count() > r2.typed_count()); | 1357 return (r1.typed_count() > r2.typed_count()); |
1353 if (r1.visit_count() != r2.visit_count()) | 1358 if (r1.visit_count() != r2.visit_count()) |
1354 return (r1.visit_count() > r2.visit_count()); | 1359 return (r1.visit_count() > r2.visit_count()); |
1355 return (r1.last_visit() > r2.last_visit()); | 1360 return (r1.last_visit() > r2.last_visit()); |
1356 } | 1361 } |
1357 | 1362 |
1358 } // namespace history | 1363 } // namespace history |
OLD | NEW |