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

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

Issue 283563002: Password Login Database: report correct changes from AddLogin(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unused variable Created 6 years, 7 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 | Annotate | Revision Log
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
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/pickle.h" 12 #include "base/pickle.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "components/password_manager/core/browser/password_store_change.h"
14 #include "components/password_manager/core/browser/psl_matching_helper.h" 15 #include "components/password_manager/core/browser/psl_matching_helper.h"
15 #include "sql/connection.h" 16 #include "sql/connection.h"
16 #include "sql/meta_table.h" 17 #include "sql/meta_table.h"
17 18
18 namespace autofill {
19 struct PasswordForm;
20 } // namespace autofill
21
22 namespace password_manager { 19 namespace password_manager {
23 20
24 // Interface to the database storage of login information, intended as a helper 21 // Interface to the database storage of login information, intended as a helper
25 // for PasswordStore on platforms that need internal storage of some or all of 22 // for PasswordStore on platforms that need internal storage of some or all of
26 // the login information. 23 // the login information.
27 class LoginDatabase { 24 class LoginDatabase {
28 public: 25 public:
29 LoginDatabase(); 26 LoginDatabase();
30 virtual ~LoginDatabase(); 27 virtual ~LoginDatabase();
31 28
32 // Initialize the database with an sqlite file at the given path. 29 // Initialize the database with an sqlite file at the given path.
33 // If false is returned, no other method should be called. 30 // If false is returned, no other method should be called.
34 bool Init(const base::FilePath& db_path); 31 bool Init(const base::FilePath& db_path);
35 32
36 // Reports usage metrics to UMA. 33 // Reports usage metrics to UMA.
37 void ReportMetrics(); 34 void ReportMetrics();
38 35
39 // Adds |form| to the list of remembered password forms. 36 // Adds |form| to the list of remembered password forms. Returns the list of
40 bool AddLogin(const autofill::PasswordForm& form); 37 // changes applied ({}, {ADD}, {REMOVE, ADD}). If it returns {REMOVE, ADD}
38 // then the REMOVE is associated with the form that was added. Thus only the
39 // primary key columns contain the values associated with the removed form.
40 PasswordStoreChangeList AddLogin(const autofill::PasswordForm& form);
41 41
42 // Updates remembered password form. Returns true on success and sets 42 // Updates remembered password form. Returns true on success and sets
43 // items_changed (if non-NULL) to the number of logins updated. 43 // items_changed (if non-NULL) to the number of logins updated.
44 bool UpdateLogin(const autofill::PasswordForm& form, int* items_changed); 44 bool UpdateLogin(const autofill::PasswordForm& form, int* items_changed);
45 45
46 // Removes |form| from the list of remembered password forms. 46 // Removes |form| from the list of remembered password forms.
47 bool RemoveLogin(const autofill::PasswordForm& form); 47 bool RemoveLogin(const autofill::PasswordForm& form);
48 48
49 // Removes all logins created from |delete_begin| onwards (inclusive) and 49 // Removes all logins created from |delete_begin| onwards (inclusive) and
50 // before |delete_end|. You may use a null Time value to do an unbounded 50 // before |delete_end|. You may use a null Time value to do an unbounded
(...skipping 25 matching lines...) Expand all
76 std::vector<autofill::PasswordForm*>* forms) const; 76 std::vector<autofill::PasswordForm*>* forms) const;
77 77
78 // Deletes the login database file on disk, and creates a new, empty database. 78 // Deletes the login database file on disk, and creates a new, empty database.
79 // This can be used after migrating passwords to some other store, to ensure 79 // This can be used after migrating passwords to some other store, to ensure
80 // that SQLite doesn't leave fragments of passwords in the database file. 80 // that SQLite doesn't leave fragments of passwords in the database file.
81 // Returns true on success; otherwise, whether the file was deleted and 81 // Returns true on success; otherwise, whether the file was deleted and
82 // whether further use of this login database will succeed is unspecified. 82 // whether further use of this login database will succeed is unspecified.
83 bool DeleteAndRecreateDatabaseFile(); 83 bool DeleteAndRecreateDatabaseFile();
84 84
85 private: 85 private:
86 friend class LoginDatabaseTest;
87
88 // Result values for encryption/decryption actions. 86 // Result values for encryption/decryption actions.
89 enum EncryptionResult { 87 enum EncryptionResult {
90 // Success. 88 // Success.
91 ENCRYPTION_RESULT_SUCCESS, 89 ENCRYPTION_RESULT_SUCCESS,
92 // Failure for a specific item (e.g., the encrypted value was manually 90 // Failure for a specific item (e.g., the encrypted value was manually
93 // moved from another machine, and can't be decrypted on this machine). 91 // moved from another machine, and can't be decrypted on this machine).
94 // This is presumed to be a permanent failure. 92 // This is presumed to be a permanent failure.
95 ENCRYPTION_RESULT_ITEM_FAILURE, 93 ENCRYPTION_RESULT_ITEM_FAILURE,
96 // A service-level failure (e.g., on a platform using a keyring, the keyring 94 // A service-level failure (e.g., on a platform using a keyring, the keyring
97 // is temporarily unavailable). 95 // is temporarily unavailable).
(...skipping 23 matching lines...) Expand all
121 // Returns the EncryptionResult from decrypting the password in |s|; if not 119 // Returns the EncryptionResult from decrypting the password in |s|; if not
122 // ENCRYPTION_RESULT_SUCCESS, |form| is not filled. 120 // ENCRYPTION_RESULT_SUCCESS, |form| is not filled.
123 EncryptionResult InitPasswordFormFromStatement(autofill::PasswordForm* form, 121 EncryptionResult InitPasswordFormFromStatement(autofill::PasswordForm* form,
124 sql::Statement& s) const; 122 sql::Statement& s) const;
125 123
126 // Loads all logins whose blacklist setting matches |blacklisted| into 124 // Loads all logins whose blacklist setting matches |blacklisted| into
127 // |forms|. 125 // |forms|.
128 bool GetAllLoginsWithBlacklistSetting( 126 bool GetAllLoginsWithBlacklistSetting(
129 bool blacklisted, std::vector<autofill::PasswordForm*>* forms) const; 127 bool blacklisted, std::vector<autofill::PasswordForm*>* forms) const;
130 128
131 // Serialization routines for vectors.
132 Pickle SerializeVector(const std::vector<base::string16>& vec) const;
133 std::vector<base::string16> DeserializeVector(const Pickle& pickle) const;
134
135 base::FilePath db_path_; 129 base::FilePath db_path_;
136 mutable sql::Connection db_; 130 mutable sql::Connection db_;
137 sql::MetaTable meta_table_; 131 sql::MetaTable meta_table_;
138 132
139 PSLMatchingHelper psl_helper_; 133 PSLMatchingHelper psl_helper_;
140 134
141 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); 135 DISALLOW_COPY_AND_ASSIGN(LoginDatabase);
142 }; 136 };
143 137
144 } // namespace password_manager 138 } // namespace password_manager
145 139
146 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ 140 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698