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

Side by Side Diff: chrome/browser/history/url_database.cc

Issue 22862006: "domain" item added to HistoryEntry to allow showing IDN in chrome://history/ (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 3 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 "chrome/browser/history/url_database.h" 5 #include "chrome/browser/history/url_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/i18n/case_conversion.h" 12 #include "base/i18n/case_conversion.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "net/base/net_util.h"
15 #include "sql/statement.h" 16 #include "sql/statement.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 namespace history { 20 namespace history {
20 21
21 const char URLDatabase::kURLRowFields[] = HISTORY_URL_ROW_FIELDS; 22 const char URLDatabase::kURLRowFields[] = HISTORY_URL_ROW_FIELDS;
22 const int URLDatabase::kNumURLRowFields = 9; 23 const int URLDatabase::kNumURLRowFields = 9;
23 24
24 URLDatabase::URLEnumeratorBase::URLEnumeratorBase() 25 URLDatabase::URLEnumeratorBase::URLEnumeratorBase()
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 query_parser_.ParseQueryNodes(query, &query_nodes.get()); 365 query_parser_.ParseQueryNodes(query, &query_nodes.get());
365 366
366 results->clear(); 367 results->clear();
367 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, 368 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
368 "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls WHERE hidden = 0")); 369 "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls WHERE hidden = 0"));
369 370
370 while (statement.Step()) { 371 while (statement.Step()) {
371 std::vector<QueryWord> query_words; 372 std::vector<QueryWord> query_words;
372 string16 url = base::i18n::ToLower(statement.ColumnString16(1)); 373 string16 url = base::i18n::ToLower(statement.ColumnString16(1));
373 query_parser_.ExtractQueryWords(url, &query_words); 374 query_parser_.ExtractQueryWords(url, &query_words);
375 GURL gurl(url);
376 if (gurl.is_valid()) {
377 // Decode punycode to match IDN.
378 // |query_words| won't be shown to user - therefore we can use empty
379 // |languages| to reduce dependency (no need to call PrefService).
380 string16 ascii = base::ASCIIToUTF16(gurl.host());
381 string16 utf = net::IDNToUnicode(gurl.host(), std::string());
382 if (ascii != utf)
383 query_parser_.ExtractQueryWords(utf, &query_words);
384 }
374 string16 title = base::i18n::ToLower(statement.ColumnString16(2)); 385 string16 title = base::i18n::ToLower(statement.ColumnString16(2));
375 query_parser_.ExtractQueryWords(title, &query_words); 386 query_parser_.ExtractQueryWords(title, &query_words);
376 387
377 if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) { 388 if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) {
378 history::URLResult info; 389 history::URLResult info;
379 FillURLRow(statement, &info); 390 FillURLRow(statement, &info);
380 if (info.url().is_valid()) 391 if (info.url().is_valid())
381 results->push_back(info); 392 results->push_back(info);
382 } 393 }
383 } 394 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 return GetDB().Execute(sql.c_str()); 606 return GetDB().Execute(sql.c_str());
596 } 607 }
597 608
598 bool URLDatabase::CreateMainURLIndex() { 609 bool URLDatabase::CreateMainURLIndex() {
599 // Index over URLs so we can quickly look up based on URL. 610 // Index over URLs so we can quickly look up based on URL.
600 return GetDB().Execute( 611 return GetDB().Execute(
601 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); 612 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)");
602 } 613 }
603 614
604 } // namespace history 615 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_querying_unittest.cc ('k') | chrome/browser/resources/history/history.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698