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

Side by Side Diff: components/omnibox/browser/url_index_private_data.cc

Issue 1171333003: Move net::FormatUrl and friends outside of //net and into //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again now that CQ is fixed Created 5 years, 4 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
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 "components/omnibox/browser/url_index_private_data.h" 5 #include "components/omnibox/browser/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_split.h" 19 #include "base/strings/string_split.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 "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 "components/omnibox/browser/in_memory_url_index.h" 28 #include "components/omnibox/browser/in_memory_url_index.h"
29 #include "net/base/net_util.h" 29 #include "components/url_formatter/url_formatter.h"
30 30
31 #if defined(USE_SYSTEM_PROTOBUF) 31 #if defined(USE_SYSTEM_PROTOBUF)
32 #include <google/protobuf/repeated_field.h> 32 #include <google/protobuf/repeated_field.h>
33 #else 33 #else
34 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" 34 #include "third_party/protobuf/src/google/protobuf/repeated_field.h"
35 #endif 35 #endif
36 36
37 using google::protobuf::RepeatedField; 37 using google::protobuf::RepeatedField;
38 using google::protobuf::RepeatedPtrField; 38 using google::protobuf::RepeatedPtrField;
39 using in_memory_url_index::InMemoryURLIndexCacheItem; 39 using in_memory_url_index::InMemoryURLIndexCacheItem;
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 const std::set<std::string>& scheme_whitelist, 700 const std::set<std::string>& scheme_whitelist,
701 base::CancelableTaskTracker* tracker) { 701 base::CancelableTaskTracker* tracker) {
702 const GURL& gurl(row.url()); 702 const GURL& gurl(row.url());
703 703
704 // Index only URLs with a whitelisted scheme. 704 // Index only URLs with a whitelisted scheme.
705 if (!URLSchemeIsWhitelisted(gurl, scheme_whitelist)) 705 if (!URLSchemeIsWhitelisted(gurl, scheme_whitelist))
706 return false; 706 return false;
707 707
708 history::URLID row_id = row.id(); 708 history::URLID row_id = row.id();
709 // Strip out username and password before saving and indexing. 709 // Strip out username and password before saving and indexing.
710 base::string16 url(net::FormatUrl(gurl, languages, 710 base::string16 url(url_formatter::FormatUrl(
711 net::kFormatUrlOmitUsernamePassword, 711 gurl, languages, url_formatter::kFormatUrlOmitUsernamePassword,
712 net::UnescapeRule::NONE, 712 net::UnescapeRule::NONE, nullptr, nullptr, nullptr));
713 NULL, NULL, NULL));
714 713
715 HistoryID history_id = static_cast<HistoryID>(row_id); 714 HistoryID history_id = static_cast<HistoryID>(row_id);
716 DCHECK_LT(history_id, std::numeric_limits<HistoryID>::max()); 715 DCHECK_LT(history_id, std::numeric_limits<HistoryID>::max());
717 716
718 // Add the row for quick lookup in the history info store. 717 // Add the row for quick lookup in the history info store.
719 history::URLRow new_row(GURL(url), row_id); 718 history::URLRow new_row(GURL(url), row_id);
720 new_row.set_visit_count(row.visit_count()); 719 new_row.set_visit_count(row.visit_count());
721 new_row.set_typed_count(row.typed_count()); 720 new_row.set_typed_count(row.typed_count());
722 new_row.set_last_visit(row.last_visit()); 721 new_row.set_last_visit(row.last_visit());
723 new_row.set_title(row.title()); 722 new_row.set_title(row.title());
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 // First cut: typed count, visit count, recency. 1350 // First cut: typed count, visit count, recency.
1352 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks 1351 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks
1353 // recently visited (within the last 12/24 hours) as highly important. Get 1352 // recently visited (within the last 12/24 hours) as highly important. Get
1354 // input from mpearson. 1353 // input from mpearson.
1355 if (r1.typed_count() != r2.typed_count()) 1354 if (r1.typed_count() != r2.typed_count())
1356 return (r1.typed_count() > r2.typed_count()); 1355 return (r1.typed_count() > r2.typed_count());
1357 if (r1.visit_count() != r2.visit_count()) 1356 if (r1.visit_count() != r2.visit_count())
1358 return (r1.visit_count() > r2.visit_count()); 1357 return (r1.visit_count() > r2.visit_count());
1359 return (r1.last_visit() > r2.last_visit()); 1358 return (r1.last_visit() > r2.last_visit());
1360 } 1359 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/shortcuts_provider.cc ('k') | components/omnibox/browser/zero_suggest_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698