Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: components/password_manager/core/browser/login_database.h

Issue 906973007: PasswordStore: Clean up expectations about rewriting vectors of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // delete in either direction. 60 // delete in either direction.
61 bool RemoveLoginsCreatedBetween(base::Time delete_begin, 61 bool RemoveLoginsCreatedBetween(base::Time delete_begin,
62 base::Time delete_end); 62 base::Time delete_end);
63 63
64 // Removes all logins synced from |delete_begin| onwards (inclusive) and 64 // Removes all logins synced from |delete_begin| onwards (inclusive) and
65 // before |delete_end|. You may use a null Time value to do an unbounded 65 // before |delete_end|. You may use a null Time value to do an unbounded
66 // delete in either direction. 66 // delete in either direction.
67 bool RemoveLoginsSyncedBetween(base::Time delete_begin, 67 bool RemoveLoginsSyncedBetween(base::Time delete_begin,
68 base::Time delete_end); 68 base::Time delete_end);
69 69
70 // Loads a list of matching password forms into the specified vector |forms|. 70 // All Get* methods below overwrite |forms| with the returned credentials. On
71 // The list will contain all possibly relevant entries to the observed |form|, 71 // success, those methods return true, on failure they return false and clear
72 // including blacklisted matches. 72 // |forms|.
73
74 // Get a list of credentials matching |form|, including blacklisted matches.
73 bool GetLogins(const autofill::PasswordForm& form, 75 bool GetLogins(const autofill::PasswordForm& form,
74 ScopedVector<autofill::PasswordForm>* forms) const; 76 ScopedVector<autofill::PasswordForm>* forms) const;
75 77
76 // Loads all logins created from |begin| onwards (inclusive) and before |end|. 78 // Get all logins created from |begin| onwards (inclusive) and before |end|.
77 // You may use a null Time value to do an unbounded search in either 79 // You may use a null Time value to do an unbounded search in either
78 // direction. 80 // direction.
79 bool GetLoginsCreatedBetween( 81 bool GetLoginsCreatedBetween(
80 base::Time begin, 82 base::Time begin,
81 base::Time end, 83 base::Time end,
82 ScopedVector<autofill::PasswordForm>* forms) const; 84 ScopedVector<autofill::PasswordForm>* forms) const;
83 85
84 // Loads all logins synced from |begin| onwards (inclusive) and before |end|. 86 // Get all logins synced from |begin| onwards (inclusive) and before |end|.
85 // You may use a null Time value to do an unbounded search in either 87 // You may use a null Time value to do an unbounded search in either
86 // direction. 88 // direction.
87 bool GetLoginsSyncedBetween( 89 bool GetLoginsSyncedBetween(
88 base::Time begin, 90 base::Time begin,
89 base::Time end, 91 base::Time end,
90 ScopedVector<autofill::PasswordForm>* forms) const; 92 ScopedVector<autofill::PasswordForm>* forms) const;
91 93
92 // Loads the complete list of autofillable password forms (i.e., not blacklist 94 // Get the complete list of not blacklisted credentials.
93 // entries) into |forms|.
94 bool GetAutofillableLogins(ScopedVector<autofill::PasswordForm>* forms) const; 95 bool GetAutofillableLogins(ScopedVector<autofill::PasswordForm>* forms) const;
95 96
96 // Loads the complete list of blacklist forms into |forms|. 97 // Get the complete list of blacklisted credentials.
97 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) const; 98 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) const;
98 99
99 // Deletes the login database file on disk, and creates a new, empty database. 100 // Deletes the login database file on disk, and creates a new, empty database.
100 // This can be used after migrating passwords to some other store, to ensure 101 // This can be used after migrating passwords to some other store, to ensure
101 // that SQLite doesn't leave fragments of passwords in the database file. 102 // that SQLite doesn't leave fragments of passwords in the database file.
102 // Returns true on success; otherwise, whether the file was deleted and 103 // Returns true on success; otherwise, whether the file was deleted and
103 // whether further use of this login database will succeed is unspecified. 104 // whether further use of this login database will succeed is unspecified.
104 bool DeleteAndRecreateDatabaseFile(); 105 bool DeleteAndRecreateDatabaseFile();
105 106
106 private: 107 private:
107 // Result values for encryption/decryption actions. 108 // Result values for encryption/decryption actions.
108 enum EncryptionResult { 109 enum EncryptionResult {
109 // Success. 110 // Success.
110 ENCRYPTION_RESULT_SUCCESS, 111 ENCRYPTION_RESULT_SUCCESS,
111 // Failure for a specific item (e.g., the encrypted value was manually 112 // Failure for a specific item (e.g., the encrypted value was manually
112 // moved from another machine, and can't be decrypted on this machine). 113 // moved from another machine, and can't be decrypted on this machine).
113 // This is presumed to be a permanent failure. 114 // This is presumed to be a permanent failure.
114 ENCRYPTION_RESULT_ITEM_FAILURE, 115 ENCRYPTION_RESULT_ITEM_FAILURE,
115 // A service-level failure (e.g., on a platform using a keyring, the keyring 116 // A service-level failure (e.g., on a platform using a keyring, the keyring
116 // is temporarily unavailable). 117 // is temporarily unavailable).
117 // This is presumed to be a temporary failure. 118 // This is presumed to be a temporary failure.
118 ENCRYPTION_RESULT_SERVICE_FAILURE, 119 ENCRYPTION_RESULT_SERVICE_FAILURE,
119 }; 120 };
120 121
121 // Encrypts plain_text, setting the value of cipher_text and returning true if 122 // Encrypts plain_text, setting the value of cipher_text and returning true if
122 // successful, or returning false and leaving cipher_text unchanged if 123 // successful, or returning false and leaving cipher_text unchanged if
123 // encryption fails (e.g., if the underlying OS encryption system is 124 // encryption fails (e.g., if the underlying OS encryption system is
124 // temporarily unavailable). 125 // temporarily unavailable).
125 EncryptionResult EncryptedString(const base::string16& plain_text, 126 static EncryptionResult EncryptedString(const base::string16& plain_text,
126 std::string* cipher_text) const; 127 std::string* cipher_text);
127 128
128 // Decrypts cipher_text, setting the value of plain_text and returning true if 129 // Decrypts cipher_text, setting the value of plain_text and returning true if
129 // successful, or returning false and leaving plain_text unchanged if 130 // successful, or returning false and leaving plain_text unchanged if
130 // decryption fails (e.g., if the underlying OS encryption system is 131 // decryption fails (e.g., if the underlying OS encryption system is
131 // temporarily unavailable). 132 // temporarily unavailable).
132 EncryptionResult DecryptedString(const std::string& cipher_text, 133 static EncryptionResult DecryptedString(const std::string& cipher_text,
133 base::string16* plain_text) const; 134 base::string16* plain_text);
134 135
135 bool InitLoginsTable(); 136 bool InitLoginsTable();
136 bool MigrateOldVersionsAsNeeded(); 137 bool MigrateOldVersionsAsNeeded();
137 138
138 // Fills |form| from the values in the given statement (which is assumed to 139 // Fills |form| from the values in the given statement (which is assumed to
139 // be of the form used by the Get*Logins methods). 140 // be of the form used by the Get*Logins methods).
140 // Returns the EncryptionResult from decrypting the password in |s|; if not 141 // Returns the EncryptionResult from decrypting the password in |s|; if not
141 // ENCRYPTION_RESULT_SUCCESS, |form| is not filled. 142 // ENCRYPTION_RESULT_SUCCESS, |form| is not filled.
142 EncryptionResult InitPasswordFormFromStatement(autofill::PasswordForm* form, 143 static EncryptionResult InitPasswordFormFromStatement(
143 sql::Statement& s) const; 144 autofill::PasswordForm* form,
145 sql::Statement& s);
144 146
145 // Loads all logins whose blacklist setting matches |blacklisted| into 147 // Gets all blacklisted or all non-blacklisted (depending on |blacklisted|)
146 // |forms|. 148 // credentials. On success returns true and overwrites |forms| with the
149 // result, otherwise returns false and clears |forms|.
147 bool GetAllLoginsWithBlacklistSetting( 150 bool GetAllLoginsWithBlacklistSetting(
148 bool blacklisted, 151 bool blacklisted,
149 ScopedVector<autofill::PasswordForm>* forms) const; 152 ScopedVector<autofill::PasswordForm>* forms) const;
150 153
154 // Overwrites |forms| with credentials retrieved from |statement|. If
155 // |psl_match| is not null, filters out all results but thos PSL-matching
156 // |*psl_match|. On success returns true, otherwise clears |forms| and returns
157 // false.
158 static bool StatementToForms(sql::Statement* statement,
159 const autofill::PasswordForm* psl_match,
160 ScopedVector<autofill::PasswordForm>* forms);
161
151 base::FilePath db_path_; 162 base::FilePath db_path_;
152 mutable sql::Connection db_; 163 mutable sql::Connection db_;
153 sql::MetaTable meta_table_; 164 sql::MetaTable meta_table_;
154 165
155 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); 166 DISALLOW_COPY_AND_ASSIGN(LoginDatabase);
156 }; 167 };
157 168
158 } // namespace password_manager 169 } // namespace password_manager
159 170
160 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ 171 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698