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

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

Issue 184663002: Omnibox: Make URLs of Bookmarks Searchable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/case_conversion.h" 17 #include "base/i18n/case_conversion.h"
18 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "chrome/browser/autocomplete/autocomplete_provider.h" 22 #include "chrome/browser/autocomplete/autocomplete_provider.h"
23 #include "chrome/browser/autocomplete/url_prefix.h" 23 #include "chrome/browser/autocomplete/url_prefix.h"
24 #include "chrome/browser/bookmarks/bookmark_service.h" 24 #include "chrome/browser/bookmarks/bookmark_service.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 "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
30 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
32 #include "net/base/net_util.h" 33 #include "net/base/net_util.h"
33 34
34 #if defined(USE_SYSTEM_PROTOBUF) 35 #if defined(USE_SYSTEM_PROTOBUF)
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 749
749 return true; 750 return true;
750 } 751 }
751 752
752 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row, 753 void URLIndexPrivateData::AddRowWordsToIndex(const URLRow& row,
753 RowWordStarts* word_starts, 754 RowWordStarts* word_starts,
754 const std::string& languages) { 755 const std::string& languages) {
755 HistoryID history_id = static_cast<HistoryID>(row.id()); 756 HistoryID history_id = static_cast<HistoryID>(row.id());
756 // Split URL into individual, unique words then add in the title words. 757 // Split URL into individual, unique words then add in the title words.
757 const GURL& gurl(row.url()); 758 const GURL& gurl(row.url());
758 const base::string16& url = CleanUpUrlForMatching(gurl, languages); 759 const base::string16& url =
760 bookmark_utils::CleanUpUrlForMatching(gurl, languages);
759 String16Set url_words = String16SetFromString16(url, 761 String16Set url_words = String16SetFromString16(url,
760 word_starts ? &word_starts->url_word_starts_ : NULL); 762 word_starts ? &word_starts->url_word_starts_ : NULL);
761 const base::string16& title = CleanUpTitleForMatching(row.title()); 763 const base::string16& title =
764 bookmark_utils::CleanUpTitleForMatching(row.title());
762 String16Set title_words = String16SetFromString16(title, 765 String16Set title_words = String16SetFromString16(title,
763 word_starts ? &word_starts->title_word_starts_ : NULL); 766 word_starts ? &word_starts->title_word_starts_ : NULL);
764 String16Set words; 767 String16Set words;
765 std::set_union(url_words.begin(), url_words.end(), 768 std::set_union(url_words.begin(), url_words.end(),
766 title_words.begin(), title_words.end(), 769 title_words.begin(), title_words.end(),
767 std::insert_iterator<String16Set>(words, words.begin())); 770 std::insert_iterator<String16Set>(words, words.begin()));
768 for (String16Set::iterator word_iter = words.begin(); 771 for (String16Set::iterator word_iter = words.begin();
769 word_iter != words.end(); ++word_iter) 772 word_iter != words.end(); ++word_iter)
770 AddWordToIndex(*word_iter, history_id); 773 AddWordToIndex(*word_iter, history_id);
771 774
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 word_starts.title_word_starts_.push_back(*jiter); 1232 word_starts.title_word_starts_.push_back(*jiter);
1230 word_starts_map_[history_id] = word_starts; 1233 word_starts_map_[history_id] = word_starts;
1231 } 1234 }
1232 } else { 1235 } else {
1233 // Since the cache did not contain any word starts we must rebuild then from 1236 // Since the cache did not contain any word starts we must rebuild then from
1234 // the URL and page titles. 1237 // the URL and page titles.
1235 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin(); 1238 for (HistoryInfoMap::const_iterator iter = history_info_map_.begin();
1236 iter != history_info_map_.end(); ++iter) { 1239 iter != history_info_map_.end(); ++iter) {
1237 RowWordStarts word_starts; 1240 RowWordStarts word_starts;
1238 const URLRow& row(iter->second.url_row); 1241 const URLRow& row(iter->second.url_row);
1239 const base::string16& url = CleanUpUrlForMatching(row.url(), languages); 1242 const base::string16& url =
1243 bookmark_utils::CleanUpUrlForMatching(row.url(), languages);
1240 String16VectorFromString16(url, false, &word_starts.url_word_starts_); 1244 String16VectorFromString16(url, false, &word_starts.url_word_starts_);
1241 const base::string16& title = CleanUpTitleForMatching(row.title()); 1245 const base::string16& title =
1246 bookmark_utils::CleanUpTitleForMatching(row.title());
1242 String16VectorFromString16(title, false, &word_starts.title_word_starts_); 1247 String16VectorFromString16(title, false, &word_starts.title_word_starts_);
1243 word_starts_map_[iter->first] = word_starts; 1248 word_starts_map_[iter->first] = word_starts;
1244 } 1249 }
1245 } 1250 }
1246 return true; 1251 return true;
1247 } 1252 }
1248 1253
1249 // static 1254 // static
1250 bool URLIndexPrivateData::URLSchemeIsWhitelisted( 1255 bool URLIndexPrivateData::URLSchemeIsWhitelisted(
1251 const GURL& gurl, 1256 const GURL& gurl,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 // recently visited (within the last 12/24 hours) as highly important. Get 1336 // recently visited (within the last 12/24 hours) as highly important. Get
1332 // input from mpearson. 1337 // input from mpearson.
1333 if (r1.typed_count() != r2.typed_count()) 1338 if (r1.typed_count() != r2.typed_count())
1334 return (r1.typed_count() > r2.typed_count()); 1339 return (r1.typed_count() > r2.typed_count());
1335 if (r1.visit_count() != r2.visit_count()) 1340 if (r1.visit_count() != r2.visit_count())
1336 return (r1.visit_count() > r2.visit_count()); 1341 return (r1.visit_count() > r2.visit_count());
1337 return (r1.last_visit() > r2.last_visit()); 1342 return (r1.last_visit() > r2.last_visit());
1338 } 1343 }
1339 1344
1340 } // namespace history 1345 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698