OLD | NEW |
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 "net/base/net_util.h" |
| 16 #include "net/base/url_constants.h" |
16 #include "sql/statement.h" | 17 #include "sql/statement.h" |
17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 namespace history { | 21 namespace history { |
21 | 22 |
22 const char URLDatabase::kURLRowFields[] = HISTORY_URL_ROW_FIELDS; | 23 const char URLDatabase::kURLRowFields[] = HISTORY_URL_ROW_FIELDS; |
23 const int URLDatabase::kNumURLRowFields = 9; | 24 const int URLDatabase::kNumURLRowFields = 9; |
24 | 25 |
25 URLDatabase::URLEnumeratorBase::URLEnumeratorBase() | 26 URLDatabase::URLEnumeratorBase::URLEnumeratorBase() |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 while (statement.Step()) { | 306 while (statement.Step()) { |
306 history::URLRow info; | 307 history::URLRow info; |
307 FillURLRow(statement, &info); | 308 FillURLRow(statement, &info); |
308 if (info.url().is_valid()) | 309 if (info.url().is_valid()) |
309 results->push_back(info); | 310 results->push_back(info); |
310 } | 311 } |
311 return !results->empty(); | 312 return !results->empty(); |
312 } | 313 } |
313 | 314 |
314 bool URLDatabase::IsTypedHost(const std::string& host) { | 315 bool URLDatabase::IsTypedHost(const std::string& host) { |
315 const char* schemes[] = { | 316 const char* schemes[] = {net::kHttpScheme, net::kHttpsScheme, |
316 content::kHttpScheme, | 317 content::kFtpScheme}; |
317 content::kHttpsScheme, | |
318 content::kFtpScheme | |
319 }; | |
320 URLRows dummy; | 318 URLRows dummy; |
321 for (size_t i = 0; i < arraysize(schemes); ++i) { | 319 for (size_t i = 0; i < arraysize(schemes); ++i) { |
322 std::string scheme_and_host(schemes[i]); | 320 std::string scheme_and_host(schemes[i]); |
323 scheme_and_host += content::kStandardSchemeSeparator + host; | 321 scheme_and_host += content::kStandardSchemeSeparator + host; |
324 if (AutocompleteForPrefix(scheme_and_host + '/', 1, true, &dummy) || | 322 if (AutocompleteForPrefix(scheme_and_host + '/', 1, true, &dummy) || |
325 AutocompleteForPrefix(scheme_and_host + ':', 1, true, &dummy)) | 323 AutocompleteForPrefix(scheme_and_host + ':', 1, true, &dummy)) |
326 return true; | 324 return true; |
327 } | 325 } |
328 return false; | 326 return false; |
329 } | 327 } |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 return GetDB().Execute(sql.c_str()); | 614 return GetDB().Execute(sql.c_str()); |
617 } | 615 } |
618 | 616 |
619 bool URLDatabase::CreateMainURLIndex() { | 617 bool URLDatabase::CreateMainURLIndex() { |
620 // Index over URLs so we can quickly look up based on URL. | 618 // Index over URLs so we can quickly look up based on URL. |
621 return GetDB().Execute( | 619 return GetDB().Execute( |
622 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); | 620 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); |
623 } | 621 } |
624 | 622 |
625 } // namespace history | 623 } // namespace history |
OLD | NEW |