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

Side by Side Diff: chrome/browser/password_manager/login_database.h

Issue 8680040: Group forms-related files in webkit/glue in a forms/ subdirectory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + another build fix Created 9 years 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "sql/connection.h" 14 #include "sql/connection.h"
15 #include "sql/meta_table.h" 15 #include "sql/meta_table.h"
16 #include "webkit/glue/password_form.h" 16 #include "webkit/forms/password_form.h"
17 17
18 // Interface to the 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 class LoginDatabase { 21 class LoginDatabase {
22 public: 22 public:
23 LoginDatabase(); 23 LoginDatabase();
24 virtual ~LoginDatabase(); 24 virtual ~LoginDatabase();
25 25
26 // Initialize the database with an sqlite file at the given path. 26 // Initialize the database with an sqlite file at the given path.
27 // If false is returned, no other method should be called. 27 // If false is returned, no other method should be called.
28 bool Init(const FilePath& db_path); 28 bool Init(const FilePath& db_path);
29 29
30 // Reports usage metrics to UMA. 30 // Reports usage metrics to UMA.
31 void ReportMetrics(); 31 void ReportMetrics();
32 32
33 // Adds |form| to the list of remembered password forms. 33 // Adds |form| to the list of remembered password forms.
34 bool AddLogin(const webkit_glue::PasswordForm& form); 34 bool AddLogin(const webkit::forms::PasswordForm& form);
35 35
36 // Updates remembered password form. Returns true on success and sets 36 // Updates remembered password form. Returns true on success and sets
37 // items_changed (if non-NULL) to the number of logins updated. 37 // items_changed (if non-NULL) to the number of logins updated.
38 bool UpdateLogin(const webkit_glue::PasswordForm& form, int* items_changed); 38 bool UpdateLogin(const webkit::forms::PasswordForm& form, int* items_changed);
39 39
40 // Removes |form| from the list of remembered password forms. 40 // Removes |form| from the list of remembered password forms.
41 bool RemoveLogin(const webkit_glue::PasswordForm& form); 41 bool RemoveLogin(const webkit::forms::PasswordForm& form);
42 42
43 // Removes all logins created from |delete_begin| onwards (inclusive) and 43 // Removes all logins created from |delete_begin| onwards (inclusive) and
44 // before |delete_end|. You may use a null Time value to do an unbounded 44 // before |delete_end|. You may use a null Time value to do an unbounded
45 // delete in either direction. 45 // delete in either direction.
46 bool RemoveLoginsCreatedBetween(const base::Time delete_begin, 46 bool RemoveLoginsCreatedBetween(const base::Time delete_begin,
47 const base::Time delete_end); 47 const base::Time delete_end);
48 48
49 // Loads a list of matching password forms into the specified vector |forms|. 49 // Loads a list of matching password forms into the specified vector |forms|.
50 // The list will contain all possibly relevant entries to the observed |form|, 50 // The list will contain all possibly relevant entries to the observed |form|,
51 // including blacklisted matches. 51 // including blacklisted matches.
52 bool GetLogins(const webkit_glue::PasswordForm& form, 52 bool GetLogins(const webkit::forms::PasswordForm& form,
53 std::vector<webkit_glue::PasswordForm*>* forms) const; 53 std::vector<webkit::forms::PasswordForm*>* forms) const;
54 54
55 // Loads all logins created from |begin| onwards (inclusive) and before |end|. 55 // Loads all logins created from |begin| onwards (inclusive) and before |end|.
56 // You may use a null Time value to do an unbounded search in either 56 // You may use a null Time value to do an unbounded search in either
57 // direction. 57 // direction.
58 bool GetLoginsCreatedBetween( 58 bool GetLoginsCreatedBetween(
59 const base::Time begin, 59 const base::Time begin,
60 const base::Time end, 60 const base::Time end,
61 std::vector<webkit_glue::PasswordForm*>* forms) const; 61 std::vector<webkit::forms::PasswordForm*>* forms) const;
62 62
63 // Loads the complete list of autofillable password forms (i.e., not blacklist 63 // Loads the complete list of autofillable password forms (i.e., not blacklist
64 // entries) into |forms|. 64 // entries) into |forms|.
65 bool GetAutofillableLogins( 65 bool GetAutofillableLogins(
66 std::vector<webkit_glue::PasswordForm*>* forms) const; 66 std::vector<webkit::forms::PasswordForm*>* forms) const;
67 67
68 // Loads the complete list of blacklist forms into |forms|. 68 // Loads the complete list of blacklist forms into |forms|.
69 bool GetBlacklistLogins(std::vector<webkit_glue::PasswordForm*>* forms) const; 69 bool GetBlacklistLogins(
70 std::vector<webkit::forms::PasswordForm*>* forms) const;
70 71
71 // Deletes the login database file on disk, and creates a new, empty database. 72 // Deletes the login database file on disk, and creates a new, empty database.
72 // This can be used after migrating passwords to some other store, to ensure 73 // This can be used after migrating passwords to some other store, to ensure
73 // that SQLite doesn't leave fragments of passwords in the database file. 74 // that SQLite doesn't leave fragments of passwords in the database file.
74 // Returns true on success; otherwise, whether the file was deleted and 75 // Returns true on success; otherwise, whether the file was deleted and
75 // whether further use of this login database will succeed is unspecified. 76 // whether further use of this login database will succeed is unspecified.
76 bool DeleteAndRecreateDatabaseFile(); 77 bool DeleteAndRecreateDatabaseFile();
77 78
78 private: 79 private:
79 // Returns an encrypted version of plain_text. 80 // Returns an encrypted version of plain_text.
80 std::string EncryptedString(const string16& plain_text) const; 81 std::string EncryptedString(const string16& plain_text) const;
81 82
82 // Returns a decrypted version of cipher_text. 83 // Returns a decrypted version of cipher_text.
83 string16 DecryptedString(const std::string& cipher_text) const; 84 string16 DecryptedString(const std::string& cipher_text) const;
84 85
85 bool InitLoginsTable(); 86 bool InitLoginsTable();
86 void MigrateOldVersionsAsNeeded(); 87 void MigrateOldVersionsAsNeeded();
87 88
88 // 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
89 // be of the form used by the Get*Logins methods). 90 // be of the form used by the Get*Logins methods).
90 void InitPasswordFormFromStatement(webkit_glue::PasswordForm* form, 91 void InitPasswordFormFromStatement(webkit::forms::PasswordForm* form,
91 sql::Statement& s) const; 92 sql::Statement& s) const;
92 93
93 // Loads all logins whose blacklist setting matches |blacklisted| into 94 // Loads all logins whose blacklist setting matches |blacklisted| into
94 // |forms|. 95 // |forms|.
95 bool GetAllLoginsWithBlacklistSetting( 96 bool GetAllLoginsWithBlacklistSetting(
96 bool blacklisted, std::vector<webkit_glue::PasswordForm*>* forms) const; 97 bool blacklisted, std::vector<webkit::forms::PasswordForm*>* forms) const;
97 98
98 FilePath db_path_; 99 FilePath db_path_;
99 mutable sql::Connection db_; 100 mutable sql::Connection db_;
100 sql::MetaTable meta_table_; 101 sql::MetaTable meta_table_;
101 102
102 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); 103 DISALLOW_COPY_AND_ASSIGN(LoginDatabase);
103 }; 104 };
104 105
105 #endif // CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_ 106 #endif // CHROME_BROWSER_PASSWORD_MANAGER_LOGIN_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/importer/profile_writer.cc ('k') | chrome/browser/password_manager/login_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698