OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.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/time.h" | 14 #include "base/time.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "sql/statement.h" | 16 #include "sql/statement.h" |
17 #include "sql/transaction.h" | 17 #include "sql/transaction.h" |
18 | 18 |
19 using webkit_glue::PasswordForm; | 19 using webkit::forms::PasswordForm; |
20 | 20 |
21 static const int kCurrentVersionNumber = 1; | 21 static const int kCurrentVersionNumber = 1; |
22 static const int kCompatibleVersionNumber = 1; | 22 static const int kCompatibleVersionNumber = 1; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // Convenience enum for interacting with SQL queries that use all the columns. | 26 // Convenience enum for interacting with SQL queries that use all the columns. |
27 enum LoginTableColumns { | 27 enum LoginTableColumns { |
28 COLUMN_ORIGIN_URL = 0, | 28 COLUMN_ORIGIN_URL = 0, |
29 COLUMN_ACTION_URL, | 29 COLUMN_ACTION_URL, |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 InitPasswordFormFromStatement(new_form, s); | 325 InitPasswordFormFromStatement(new_form, s); |
326 | 326 |
327 forms->push_back(new_form); | 327 forms->push_back(new_form); |
328 } | 328 } |
329 return s.Succeeded(); | 329 return s.Succeeded(); |
330 } | 330 } |
331 | 331 |
332 bool LoginDatabase::GetLoginsCreatedBetween( | 332 bool LoginDatabase::GetLoginsCreatedBetween( |
333 const base::Time begin, | 333 const base::Time begin, |
334 const base::Time end, | 334 const base::Time end, |
335 std::vector<webkit_glue::PasswordForm*>* forms) const { | 335 std::vector<webkit::forms::PasswordForm*>* forms) const { |
336 DCHECK(forms); | 336 DCHECK(forms); |
337 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 337 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
338 "SELECT origin_url, action_url, " | 338 "SELECT origin_url, action_url, " |
339 "username_element, username_value, " | 339 "username_element, username_value, " |
340 "password_element, password_value, " | 340 "password_element, password_value, " |
341 "submit_element, signon_realm, ssl_valid, preferred, " | 341 "submit_element, signon_realm, ssl_valid, preferred, " |
342 "date_created, blacklisted_by_user, scheme FROM logins " | 342 "date_created, blacklisted_by_user, scheme FROM logins " |
343 "WHERE date_created >= ? AND date_created < ?" | 343 "WHERE date_created >= ? AND date_created < ?" |
344 "ORDER BY origin_url")); | 344 "ORDER BY origin_url")); |
345 | 345 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 return s.Succeeded(); | 398 return s.Succeeded(); |
399 } | 399 } |
400 | 400 |
401 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { | 401 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { |
402 DCHECK(db_.is_open()); | 402 DCHECK(db_.is_open()); |
403 meta_table_.Reset(); | 403 meta_table_.Reset(); |
404 db_.Close(); | 404 db_.Close(); |
405 file_util::Delete(db_path_, false); | 405 file_util::Delete(db_path_, false); |
406 return Init(db_path_); | 406 return Init(db_path_); |
407 } | 407 } |
OLD | NEW |