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/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::forms::PasswordForm; | 19 using content::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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 InitPasswordFormFromStatement(new_form, s); | 290 InitPasswordFormFromStatement(new_form, s); |
291 | 291 |
292 forms->push_back(new_form); | 292 forms->push_back(new_form); |
293 } | 293 } |
294 return s.Succeeded(); | 294 return s.Succeeded(); |
295 } | 295 } |
296 | 296 |
297 bool LoginDatabase::GetLoginsCreatedBetween( | 297 bool LoginDatabase::GetLoginsCreatedBetween( |
298 const base::Time begin, | 298 const base::Time begin, |
299 const base::Time end, | 299 const base::Time end, |
300 std::vector<webkit::forms::PasswordForm*>* forms) const { | 300 std::vector<content::PasswordForm*>* forms) const { |
301 DCHECK(forms); | 301 DCHECK(forms); |
302 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 302 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
303 "SELECT origin_url, action_url, " | 303 "SELECT origin_url, action_url, " |
304 "username_element, username_value, " | 304 "username_element, username_value, " |
305 "password_element, password_value, " | 305 "password_element, password_value, " |
306 "submit_element, signon_realm, ssl_valid, preferred, " | 306 "submit_element, signon_realm, ssl_valid, preferred, " |
307 "date_created, blacklisted_by_user, scheme FROM logins " | 307 "date_created, blacklisted_by_user, scheme FROM logins " |
308 "WHERE date_created >= ? AND date_created < ?" | 308 "WHERE date_created >= ? AND date_created < ?" |
309 "ORDER BY origin_url")); | 309 "ORDER BY origin_url")); |
310 s.BindInt64(0, begin.ToTimeT()); | 310 s.BindInt64(0, begin.ToTimeT()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 return s.Succeeded(); | 353 return s.Succeeded(); |
354 } | 354 } |
355 | 355 |
356 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { | 356 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { |
357 DCHECK(db_.is_open()); | 357 DCHECK(db_.is_open()); |
358 meta_table_.Reset(); | 358 meta_table_.Reset(); |
359 db_.Close(); | 359 db_.Close(); |
360 file_util::Delete(db_path_, false); | 360 file_util::Delete(db_path_, false); |
361 return Init(db_path_); | 361 return Init(db_path_); |
362 } | 362 } |
OLD | NEW |