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/autocomplete/url_index_private_data.h" | 5 #include "chrome/browser/autocomplete/url_index_private_data.h" |
6 | 6 |
7 #include <functional> | 7 #include <functional> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <limits> | 9 #include <limits> |
10 #include <numeric> | 10 #include <numeric> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
16 #include "base/i18n/break_iterator.h" | 16 #include "base/i18n/break_iterator.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/in_memory_url_index.h" | 22 #include "chrome/browser/autocomplete/in_memory_url_index.h" |
23 #include "components/bookmarks/browser/bookmark_model.h" | 23 #include "components/bookmarks/browser/bookmark_model.h" |
24 #include "components/bookmarks/browser/bookmark_utils.h" | 24 #include "components/bookmarks/browser/bookmark_utils.h" |
25 #include "components/history/core/browser/history_database.h" | 25 #include "components/history/core/browser/history_database.h" |
26 #include "components/history/core/browser/history_db_task.h" | 26 #include "components/history/core/browser/history_db_task.h" |
27 #include "components/history/core/browser/history_service.h" | 27 #include "components/history/core/browser/history_service.h" |
28 #include "net/base/net_util.h" | 28 #include "components/url_formatter/url_formatter.h" |
29 | 29 |
30 #if defined(USE_SYSTEM_PROTOBUF) | 30 #if defined(USE_SYSTEM_PROTOBUF) |
31 #include <google/protobuf/repeated_field.h> | 31 #include <google/protobuf/repeated_field.h> |
32 #else | 32 #else |
33 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" | 33 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" |
34 #endif | 34 #endif |
35 | 35 |
36 using google::protobuf::RepeatedField; | 36 using google::protobuf::RepeatedField; |
37 using google::protobuf::RepeatedPtrField; | 37 using google::protobuf::RepeatedPtrField; |
38 using in_memory_url_index::InMemoryURLIndexCacheItem; | 38 using in_memory_url_index::InMemoryURLIndexCacheItem; |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 const std::set<std::string>& scheme_whitelist, | 695 const std::set<std::string>& scheme_whitelist, |
696 base::CancelableTaskTracker* tracker) { | 696 base::CancelableTaskTracker* tracker) { |
697 const GURL& gurl(row.url()); | 697 const GURL& gurl(row.url()); |
698 | 698 |
699 // Index only URLs with a whitelisted scheme. | 699 // Index only URLs with a whitelisted scheme. |
700 if (!URLSchemeIsWhitelisted(gurl, scheme_whitelist)) | 700 if (!URLSchemeIsWhitelisted(gurl, scheme_whitelist)) |
701 return false; | 701 return false; |
702 | 702 |
703 history::URLID row_id = row.id(); | 703 history::URLID row_id = row.id(); |
704 // Strip out username and password before saving and indexing. | 704 // Strip out username and password before saving and indexing. |
705 base::string16 url(net::FormatUrl(gurl, languages, | 705 base::string16 url(url_formatter::FormatUrl( |
706 net::kFormatUrlOmitUsernamePassword, | 706 gurl, languages, url_formatter::kFormatUrlOmitUsernamePassword, |
707 net::UnescapeRule::NONE, | 707 net::UnescapeRule::NONE, nullptr, nullptr, nullptr)); |
708 NULL, NULL, NULL)); | |
709 | 708 |
710 HistoryID history_id = static_cast<HistoryID>(row_id); | 709 HistoryID history_id = static_cast<HistoryID>(row_id); |
711 DCHECK_LT(history_id, std::numeric_limits<HistoryID>::max()); | 710 DCHECK_LT(history_id, std::numeric_limits<HistoryID>::max()); |
712 | 711 |
713 // Add the row for quick lookup in the history info store. | 712 // Add the row for quick lookup in the history info store. |
714 history::URLRow new_row(GURL(url), row_id); | 713 history::URLRow new_row(GURL(url), row_id); |
715 new_row.set_visit_count(row.visit_count()); | 714 new_row.set_visit_count(row.visit_count()); |
716 new_row.set_typed_count(row.typed_count()); | 715 new_row.set_typed_count(row.typed_count()); |
717 new_row.set_last_visit(row.last_visit()); | 716 new_row.set_last_visit(row.last_visit()); |
718 new_row.set_title(row.title()); | 717 new_row.set_title(row.title()); |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 // First cut: typed count, visit count, recency. | 1344 // First cut: typed count, visit count, recency. |
1346 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks | 1345 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks |
1347 // recently visited (within the last 12/24 hours) as highly important. Get | 1346 // recently visited (within the last 12/24 hours) as highly important. Get |
1348 // input from mpearson. | 1347 // input from mpearson. |
1349 if (r1.typed_count() != r2.typed_count()) | 1348 if (r1.typed_count() != r2.typed_count()) |
1350 return (r1.typed_count() > r2.typed_count()); | 1349 return (r1.typed_count() > r2.typed_count()); |
1351 if (r1.visit_count() != r2.visit_count()) | 1350 if (r1.visit_count() != r2.visit_count()) |
1352 return (r1.visit_count() > r2.visit_count()); | 1351 return (r1.visit_count() > r2.visit_count()); |
1353 return (r1.last_visit() > r2.last_visit()); | 1352 return (r1.last_visit() > r2.last_visit()); |
1354 } | 1353 } |
OLD | NEW |