OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_ |
6 #define CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "app/sql/connection.h" | 11 #include "app/sql/connection.h" |
12 #include "app/sql/meta_table.h" | 12 #include "app/sql/meta_table.h" |
| 13 #include "base/file_path.h" |
13 #include "base/string16.h" | 14 #include "base/string16.h" |
14 #include "webkit/glue/password_form.h" | 15 #include "webkit/glue/password_form.h" |
15 | 16 |
16 class FilePath; | |
17 struct sqlite3; | 17 struct sqlite3; |
18 | 18 |
19 // Interface to the database storage of login information, intended as a helper | 19 // Interface to the database storage of login information, intended as a helper |
20 // for PasswordStore on platforms that need internal storage of some or all of | 20 // for PasswordStore on platforms that need internal storage of some or all of |
21 // the login information. | 21 // the login information. |
22 class LoginDatabase { | 22 class LoginDatabase { |
23 public: | 23 public: |
24 LoginDatabase(); | 24 LoginDatabase(); |
25 virtual ~LoginDatabase(); | 25 virtual ~LoginDatabase(); |
26 | 26 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 std::vector<webkit_glue::PasswordForm*>* forms) const; | 62 std::vector<webkit_glue::PasswordForm*>* forms) const; |
63 | 63 |
64 // Loads the complete list of autofillable password forms (i.e., not blacklist | 64 // Loads the complete list of autofillable password forms (i.e., not blacklist |
65 // entries) into |forms|. | 65 // entries) into |forms|. |
66 bool GetAutofillableLogins( | 66 bool GetAutofillableLogins( |
67 std::vector<webkit_glue::PasswordForm*>* forms) const; | 67 std::vector<webkit_glue::PasswordForm*>* forms) const; |
68 | 68 |
69 // Loads the complete list of blacklist forms into |forms|. | 69 // Loads the complete list of blacklist forms into |forms|. |
70 bool GetBlacklistLogins(std::vector<webkit_glue::PasswordForm*>* forms) const; | 70 bool GetBlacklistLogins(std::vector<webkit_glue::PasswordForm*>* forms) const; |
71 | 71 |
| 72 // Deletes the login database file on disk, and creates a new, empty database. |
| 73 // This can be used after migrating passwords to some other store, to ensure |
| 74 // that SQLite doesn't leave fragments of passwords in the database file. |
| 75 // Returns true on success; otherwise, whether the file was deleted and |
| 76 // whether further use of this login database will succeed is unspecified. |
| 77 bool DeleteAndRecreateDatabaseFile(); |
| 78 |
72 private: | 79 private: |
73 // Returns an encrypted version of plain_text. | 80 // Returns an encrypted version of plain_text. |
74 std::string EncryptedString(const string16& plain_text) const; | 81 std::string EncryptedString(const string16& plain_text) const; |
75 | 82 |
76 // Returns a decrypted version of cipher_text. | 83 // Returns a decrypted version of cipher_text. |
77 string16 DecryptedString(const std::string& cipher_text) const; | 84 string16 DecryptedString(const std::string& cipher_text) const; |
78 | 85 |
79 bool InitLoginsTable(); | 86 bool InitLoginsTable(); |
80 void MigrateOldVersionsAsNeeded(); | 87 void MigrateOldVersionsAsNeeded(); |
81 | 88 |
82 // Fills |form| from the values in the given statement (which is assumed to | 89 // Fills |form| from the values in the given statement (which is assumed to |
83 // be of the form used by the Get*Logins methods). | 90 // be of the form used by the Get*Logins methods). |
84 void InitPasswordFormFromStatement(webkit_glue::PasswordForm* form, | 91 void InitPasswordFormFromStatement(webkit_glue::PasswordForm* form, |
85 sql::Statement& s) const; | 92 sql::Statement& s) const; |
86 | 93 |
87 // Loads all logins whose blacklist setting matches |blacklisted| into | 94 // Loads all logins whose blacklist setting matches |blacklisted| into |
88 // |forms|. | 95 // |forms|. |
89 bool GetAllLoginsWithBlacklistSetting( | 96 bool GetAllLoginsWithBlacklistSetting( |
90 bool blacklisted, std::vector<webkit_glue::PasswordForm*>* forms) const; | 97 bool blacklisted, std::vector<webkit_glue::PasswordForm*>* forms) const; |
91 | 98 |
| 99 FilePath db_path_; |
92 mutable sql::Connection db_; | 100 mutable sql::Connection db_; |
93 sql::MetaTable meta_table_; | 101 sql::MetaTable meta_table_; |
94 | 102 |
95 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); | 103 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); |
96 }; | 104 }; |
97 | 105 |
98 | |
99 #endif // CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_ | 106 #endif // CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_ |
OLD | NEW |