OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/string16.h" | 11 #include "base/string16.h" |
12 #include "chrome/browser/meta_table_helper.h" | 12 #include "chrome/browser/meta_table_helper.h" |
13 #include "webkit/glue/password_form.h" | 13 #include "webkit/glue/password_form.h" |
14 | 14 |
15 class FilePath; | 15 class FilePath; |
16 struct sqlite3; | 16 struct sqlite3; |
17 | 17 |
18 // Base class for database storage of login information, intended as a helper | 18 // Interface to the database storage of login information, intended as a helper |
19 // for PasswordStore on platforms that need internal storage of some or all of | 19 // for PasswordStore on platforms that need internal storage of some or all of |
20 // the login information. | 20 // the login information. |
21 // Subclasses need to provide EncryptedString and DecryptedString | |
22 // implementations, which will be used to encrypt the password in the database. | |
23 class LoginDatabase { | 21 class LoginDatabase { |
24 public: | 22 public: |
25 LoginDatabase(); | 23 LoginDatabase(); |
26 virtual ~LoginDatabase(); | 24 virtual ~LoginDatabase(); |
27 | 25 |
28 // Initialize the database with an sqlite file at the given path. | 26 // Initialize the database with an sqlite file at the given path. |
29 // If false is returned, no other method should be called. | 27 // If false is returned, no other method should be called. |
30 bool Init(const FilePath& db_path); | 28 bool Init(const FilePath& db_path); |
31 | 29 |
32 // Adds |form| to the list of remembered password forms. | 30 // Adds |form| to the list of remembered password forms. |
(...skipping 11 matching lines...) Expand all Loading... |
44 // delete in either direction. | 42 // delete in either direction. |
45 bool RemoveLoginsCreatedBetween(const base::Time delete_begin, | 43 bool RemoveLoginsCreatedBetween(const base::Time delete_begin, |
46 const base::Time delete_end); | 44 const base::Time delete_end); |
47 | 45 |
48 // Loads a list of matching password forms into the specified vector |forms|. | 46 // Loads a list of matching password forms into the specified vector |forms|. |
49 // The list will contain all possibly relevant entries to the observed |form|, | 47 // The list will contain all possibly relevant entries to the observed |form|, |
50 // including blacklisted matches. | 48 // including blacklisted matches. |
51 bool GetLogins(const webkit_glue::PasswordForm& form, | 49 bool GetLogins(const webkit_glue::PasswordForm& form, |
52 std::vector<webkit_glue::PasswordForm*>* forms) const; | 50 std::vector<webkit_glue::PasswordForm*>* forms) const; |
53 | 51 |
| 52 // Loads all logins created from |begin| onwards (inclusive) and before |end|. |
| 53 // You may use a null Time value to do an unbounded search in either |
| 54 // direction. |
| 55 bool GetLoginsCreatedBetween( |
| 56 const base::Time begin, |
| 57 const base::Time end, |
| 58 std::vector<webkit_glue::PasswordForm*>* forms) const; |
| 59 |
54 // Loads the complete list of autofillable password forms (i.e., not blacklist | 60 // Loads the complete list of autofillable password forms (i.e., not blacklist |
55 // entries) into |forms|. | 61 // entries) into |forms|. |
56 bool GetAutofillableLogins( | 62 bool GetAutofillableLogins( |
57 std::vector<webkit_glue::PasswordForm*>* forms) const; | 63 std::vector<webkit_glue::PasswordForm*>* forms) const; |
58 | 64 |
59 // Loads the complete list of blacklist forms into |forms|. | 65 // Loads the complete list of blacklist forms into |forms|. |
60 bool GetBlacklistLogins( | 66 bool GetBlacklistLogins( |
61 std::vector<webkit_glue::PasswordForm*>* forms) const; | 67 std::vector<webkit_glue::PasswordForm*>* forms) const; |
62 | 68 |
63 protected: | 69 private: |
64 // Returns an encrypted version of plain_text. | 70 // Returns an encrypted version of plain_text. |
65 virtual std::string EncryptedString(const string16& plain_text) const = 0; | 71 std::string EncryptedString(const string16& plain_text) const; |
66 | 72 |
67 // Returns a decrypted version of cipher_text. | 73 // Returns a decrypted version of cipher_text. |
68 virtual string16 DecryptedString(const std::string& cipher_text) | 74 string16 DecryptedString(const std::string& cipher_text) const; |
69 const = 0; | |
70 | 75 |
71 bool InitLoginsTable(); | 76 bool InitLoginsTable(); |
72 void MigrateOldVersionsAsNeeded(); | 77 void MigrateOldVersionsAsNeeded(); |
73 | 78 |
74 private: | |
75 // Fills |form| from the values in the given statement (which is assumed to | 79 // Fills |form| from the values in the given statement (which is assumed to |
76 // be of the form used by the Get*Logins methods). | 80 // be of the form used by the Get*Logins methods). |
77 void InitPasswordFormFromStatement(webkit_glue::PasswordForm* form, | 81 void InitPasswordFormFromStatement(webkit_glue::PasswordForm* form, |
78 SQLStatement* s) const; | 82 SQLStatement* s) const; |
79 | 83 |
80 // Loads all logins whose blacklist setting matches |blacklisted| into | 84 // Loads all logins whose blacklist setting matches |blacklisted| into |
81 // |forms|. | 85 // |forms|. |
82 bool GetAllLoginsWithBlacklistSetting( | 86 bool GetAllLoginsWithBlacklistSetting( |
83 bool blacklisted, std::vector<webkit_glue::PasswordForm*>* forms) const; | 87 bool blacklisted, std::vector<webkit_glue::PasswordForm*>* forms) const; |
84 | 88 |
85 sqlite3* db_; | 89 sqlite3* db_; |
86 MetaTableHelper meta_table_; | 90 MetaTableHelper meta_table_; |
87 | 91 |
88 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); | 92 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); |
89 }; | 93 }; |
90 | 94 |
91 | 95 |
92 #endif // CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_ | 96 #endif // CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_ |
OLD | NEW |