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 "components/url_formatter/url_formatter.h" | 15 #include "net/base/net_util.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 = | 375 base::string16 utf = net::IDNToUnicode(gurl.host(), std::string()); |
376 url_formatter::IDNToUnicode(gurl.host(), std::string()); | |
377 if (ascii != utf) | 376 if (ascii != utf) |
378 query_parser_.ExtractQueryWords(utf, &query_words); | 377 query_parser_.ExtractQueryWords(utf, &query_words); |
379 } | 378 } |
380 base::string16 title = base::i18n::ToLower(statement.ColumnString16(2)); | 379 base::string16 title = base::i18n::ToLower(statement.ColumnString16(2)); |
381 query_parser_.ExtractQueryWords(title, &query_words); | 380 query_parser_.ExtractQueryWords(title, &query_words); |
382 | 381 |
383 if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) { | 382 if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) { |
384 URLResult info; | 383 URLResult info; |
385 FillURLRow(statement, &info); | 384 FillURLRow(statement, &info); |
386 if (info.url().is_valid()) | 385 if (info.url().is_valid()) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 bool RowQualifiesAsSignificant(const URLRow& row, | 626 bool RowQualifiesAsSignificant(const URLRow& row, |
628 const base::Time& threshold) { | 627 const base::Time& threshold) { |
629 const base::Time& real_threshold = | 628 const base::Time& real_threshold = |
630 threshold.is_null() ? AutocompleteAgeThreshold() : threshold; | 629 threshold.is_null() ? AutocompleteAgeThreshold() : threshold; |
631 return (row.typed_count() >= kLowQualityMatchTypedLimit) || | 630 return (row.typed_count() >= kLowQualityMatchTypedLimit) || |
632 (row.visit_count() >= kLowQualityMatchVisitLimit) || | 631 (row.visit_count() >= kLowQualityMatchVisitLimit) || |
633 (row.last_visit() >= real_threshold); | 632 (row.last_visit() >= real_threshold); |
634 } | 633 } |
635 | 634 |
636 } // namespace history | 635 } // namespace history |
OLD | NEW |