OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/history/core/browser/url_database.h" | 5 #include "components/history/core/browser/url_database.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/i18n/case_conversion.h" | 11 #include "base/i18n/case_conversion.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "components/history/core/browser/keyword_search_term.h" | 14 #include "components/history/core/browser/keyword_search_term.h" |
15 #include "net/base/net_util.h" | 15 #include "components/url_formatter/url_formatter.h" |
16 #include "sql/statement.h" | 16 #include "sql/statement.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace history { | 19 namespace history { |
20 | 20 |
21 const char URLDatabase::kURLRowFields[] = HISTORY_URL_ROW_FIELDS; | 21 const char URLDatabase::kURLRowFields[] = HISTORY_URL_ROW_FIELDS; |
22 const int URLDatabase::kNumURLRowFields = 9; | 22 const int URLDatabase::kNumURLRowFields = 9; |
23 | 23 |
24 URLDatabase::URLEnumeratorBase::URLEnumeratorBase() | 24 URLDatabase::URLEnumeratorBase::URLEnumeratorBase() |
25 : initialized_(false) { | 25 : initialized_(false) { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 while (statement.Step()) { | 365 while (statement.Step()) { |
366 query_parser::QueryWordVector query_words; | 366 query_parser::QueryWordVector query_words; |
367 base::string16 url = base::i18n::ToLower(statement.ColumnString16(1)); | 367 base::string16 url = base::i18n::ToLower(statement.ColumnString16(1)); |
368 query_parser_.ExtractQueryWords(url, &query_words); | 368 query_parser_.ExtractQueryWords(url, &query_words); |
369 GURL gurl(url); | 369 GURL gurl(url); |
370 if (gurl.is_valid()) { | 370 if (gurl.is_valid()) { |
371 // Decode punycode to match IDN. | 371 // Decode punycode to match IDN. |
372 // |query_words| won't be shown to user - therefore we can use empty | 372 // |query_words| won't be shown to user - therefore we can use empty |
373 // |languages| to reduce dependency (no need to call PrefService). | 373 // |languages| to reduce dependency (no need to call PrefService). |
374 base::string16 ascii = base::ASCIIToUTF16(gurl.host()); | 374 base::string16 ascii = base::ASCIIToUTF16(gurl.host()); |
375 base::string16 utf = net::IDNToUnicode(gurl.host(), std::string()); | 375 base::string16 utf = |
| 376 url_formatter::IDNToUnicode(gurl.host(), std::string()); |
376 if (ascii != utf) | 377 if (ascii != utf) |
377 query_parser_.ExtractQueryWords(utf, &query_words); | 378 query_parser_.ExtractQueryWords(utf, &query_words); |
378 } | 379 } |
379 base::string16 title = base::i18n::ToLower(statement.ColumnString16(2)); | 380 base::string16 title = base::i18n::ToLower(statement.ColumnString16(2)); |
380 query_parser_.ExtractQueryWords(title, &query_words); | 381 query_parser_.ExtractQueryWords(title, &query_words); |
381 | 382 |
382 if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) { | 383 if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) { |
383 URLResult info; | 384 URLResult info; |
384 FillURLRow(statement, &info); | 385 FillURLRow(statement, &info); |
385 if (info.url().is_valid()) | 386 if (info.url().is_valid()) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 bool RowQualifiesAsSignificant(const URLRow& row, | 627 bool RowQualifiesAsSignificant(const URLRow& row, |
627 const base::Time& threshold) { | 628 const base::Time& threshold) { |
628 const base::Time& real_threshold = | 629 const base::Time& real_threshold = |
629 threshold.is_null() ? AutocompleteAgeThreshold() : threshold; | 630 threshold.is_null() ? AutocompleteAgeThreshold() : threshold; |
630 return (row.typed_count() >= kLowQualityMatchTypedLimit) || | 631 return (row.typed_count() >= kLowQualityMatchTypedLimit) || |
631 (row.visit_count() >= kLowQualityMatchVisitLimit) || | 632 (row.visit_count() >= kLowQualityMatchVisitLimit) || |
632 (row.last_visit() >= real_threshold); | 633 (row.last_visit() >= real_threshold); |
633 } | 634 } |
634 | 635 |
635 } // namespace history | 636 } // namespace history |
OLD | NEW |