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 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, | 363 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, |
364 "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls WHERE hidden = 0")); | 364 "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls WHERE hidden = 0")); |
365 | 365 |
366 while (statement.Step()) { | 366 while (statement.Step()) { |
367 query_parser::QueryWordVector query_words; | 367 query_parser::QueryWordVector query_words; |
368 base::string16 url = base::i18n::ToLower(statement.ColumnString16(1)); | 368 base::string16 url = base::i18n::ToLower(statement.ColumnString16(1)); |
369 query_parser_.ExtractQueryWords(url, &query_words); | 369 query_parser_.ExtractQueryWords(url, &query_words); |
370 GURL gurl(url); | 370 GURL gurl(url); |
371 if (gurl.is_valid()) { | 371 if (gurl.is_valid()) { |
372 // Decode punycode to match IDN. | 372 // Decode punycode to match IDN. |
373 // |query_words| won't be shown to user - therefore we can use empty | |
374 // |languages| to reduce dependency (no need to call PrefService). | |
375 base::string16 ascii = base::ASCIIToUTF16(gurl.host()); | 373 base::string16 ascii = base::ASCIIToUTF16(gurl.host()); |
376 base::string16 utf = | 374 base::string16 utf = url_formatter::IDNToUnicode(gurl.host()); |
377 url_formatter::IDNToUnicode(gurl.host(), std::string()); | |
378 if (ascii != utf) | 375 if (ascii != utf) |
379 query_parser_.ExtractQueryWords(utf, &query_words); | 376 query_parser_.ExtractQueryWords(utf, &query_words); |
380 } | 377 } |
381 base::string16 title = base::i18n::ToLower(statement.ColumnString16(2)); | 378 base::string16 title = base::i18n::ToLower(statement.ColumnString16(2)); |
382 query_parser_.ExtractQueryWords(title, &query_words); | 379 query_parser_.ExtractQueryWords(title, &query_words); |
383 | 380 |
384 if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) { | 381 if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) { |
385 URLResult info; | 382 URLResult info; |
386 FillURLRow(statement, &info); | 383 FillURLRow(statement, &info); |
387 if (info.url().is_valid()) | 384 if (info.url().is_valid()) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 bool RowQualifiesAsSignificant(const URLRow& row, | 625 bool RowQualifiesAsSignificant(const URLRow& row, |
629 const base::Time& threshold) { | 626 const base::Time& threshold) { |
630 const base::Time& real_threshold = | 627 const base::Time& real_threshold = |
631 threshold.is_null() ? AutocompleteAgeThreshold() : threshold; | 628 threshold.is_null() ? AutocompleteAgeThreshold() : threshold; |
632 return (row.typed_count() >= kLowQualityMatchTypedLimit) || | 629 return (row.typed_count() >= kLowQualityMatchTypedLimit) || |
633 (row.visit_count() >= kLowQualityMatchVisitLimit) || | 630 (row.visit_count() >= kLowQualityMatchVisitLimit) || |
634 (row.last_visit() >= real_threshold); | 631 (row.last_visit() >= real_threshold); |
635 } | 632 } |
636 | 633 |
637 } // namespace history | 634 } // namespace history |
OLD | NEW |