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/password_manager/login_database.h" | 5 #include "chrome/browser/password_manager/login_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/pickle.h" | 14 #include "base/pickle.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
19 #include "sql/connection.h" | 19 #include "sql/connection.h" |
20 #include "sql/statement.h" | 20 #include "sql/statement.h" |
21 #include "sql/transaction.h" | 21 #include "sql/transaction.h" |
22 | 22 |
23 using content::PasswordForm; | 23 using autofill::PasswordForm; |
24 | 24 |
25 static const int kCurrentVersionNumber = 3; | 25 static const int kCurrentVersionNumber = 3; |
26 static const int kCompatibleVersionNumber = 1; | 26 static const int kCompatibleVersionNumber = 1; |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Convenience enum for interacting with SQL queries that use all the columns. | 30 // Convenience enum for interacting with SQL queries that use all the columns. |
31 enum LoginTableColumns { | 31 enum LoginTableColumns { |
32 COLUMN_ORIGIN_URL = 0, | 32 COLUMN_ORIGIN_URL = 0, |
33 COLUMN_ACTION_URL, | 33 COLUMN_ACTION_URL, |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 } | 498 } |
499 } | 499 } |
500 forms->push_back(new_form.release()); | 500 forms->push_back(new_form.release()); |
501 } | 501 } |
502 return s.Succeeded(); | 502 return s.Succeeded(); |
503 } | 503 } |
504 | 504 |
505 bool LoginDatabase::GetLoginsCreatedBetween( | 505 bool LoginDatabase::GetLoginsCreatedBetween( |
506 const base::Time begin, | 506 const base::Time begin, |
507 const base::Time end, | 507 const base::Time end, |
508 std::vector<content::PasswordForm*>* forms) const { | 508 std::vector<autofill::PasswordForm*>* forms) const { |
509 DCHECK(forms); | 509 DCHECK(forms); |
510 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 510 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
511 "SELECT origin_url, action_url, " | 511 "SELECT origin_url, action_url, " |
512 "username_element, username_value, " | 512 "username_element, username_value, " |
513 "password_element, password_value, submit_element, " | 513 "password_element, password_value, submit_element, " |
514 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 514 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
515 "scheme, password_type, possible_usernames, times_used " | 515 "scheme, password_type, possible_usernames, times_used " |
516 "FROM logins WHERE date_created >= ? AND date_created < ?" | 516 "FROM logins WHERE date_created >= ? AND date_created < ?" |
517 "ORDER BY origin_url")); | 517 "ORDER BY origin_url")); |
518 s.BindInt64(0, begin.ToTimeT()); | 518 s.BindInt64(0, begin.ToTimeT()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 std::vector<string16> LoginDatabase::DeserializeVector(const Pickle& p) const { | 580 std::vector<string16> LoginDatabase::DeserializeVector(const Pickle& p) const { |
581 std::vector<string16> ret; | 581 std::vector<string16> ret; |
582 string16 str; | 582 string16 str; |
583 | 583 |
584 PickleIterator iterator(p); | 584 PickleIterator iterator(p); |
585 while (iterator.ReadString16(&str)) { | 585 while (iterator.ReadString16(&str)) { |
586 ret.push_back(str); | 586 ret.push_back(str); |
587 } | 587 } |
588 return ret; | 588 return ret; |
589 } | 589 } |
OLD | NEW |