| OLD | NEW |
| 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_WEBDATA_LOGINS_TABLE_H_ | 5 #ifndef CHROME_BROWSER_WEBDATA_LOGINS_TABLE_H_ |
| 6 #define CHROME_BROWSER_WEBDATA_LOGINS_TABLE_H_ | 6 #define CHROME_BROWSER_WEBDATA_LOGINS_TABLE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/browser/webdata/web_database_table.h" | 12 #include "chrome/browser/webdata/web_database_table.h" |
| 13 | 13 |
| 14 namespace base { | |
| 15 class Time; | |
| 16 } | |
| 17 | |
| 18 namespace webkit { | |
| 19 namespace forms { | |
| 20 struct PasswordForm; | |
| 21 } | |
| 22 } | |
| 23 | |
| 24 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 25 struct IE7PasswordInfo; | 15 struct IE7PasswordInfo; |
| 26 #endif | 16 #endif |
| 27 | 17 |
| 28 // This class manages the logins table within the SQLite database passed to the | 18 // This class manages the logins table within the SQLite database passed to the |
| 29 // constructor. It expects the following schemas: | 19 // constructor. We no longer store passwords here except for imported IE |
| 30 // | 20 // passwords, so this class is now mostly responsible for deleting the table if |
| 31 // Note: The database stores time in seconds, UTC. | 21 // it is found to exist. (The data was migrated out long ago.) |
| 32 // | |
| 33 // logins | |
| 34 // origin_url | |
| 35 // action_url | |
| 36 // username_element | |
| 37 // username_value | |
| 38 // password_element | |
| 39 // password_value | |
| 40 // submit_element | |
| 41 // signon_realm The authority (scheme, host, port). | |
| 42 // ssl_valid SSL status of page containing the form at first | |
| 43 // impression. | |
| 44 // preferred MRU bit. | |
| 45 // date_created This column was added after logins support. "Legacy" | |
| 46 // entries have a value of 0. | |
| 47 // blacklisted_by_user Tracks whether or not the user opted to 'never | |
| 48 // remember' | |
| 49 // passwords for this site. | |
| 50 // | |
| 51 class LoginsTable : public WebDatabaseTable { | 22 class LoginsTable : public WebDatabaseTable { |
| 52 public: | 23 public: |
| 53 LoginsTable(sql::Connection* db, sql::MetaTable* meta_table) | 24 LoginsTable(sql::Connection* db, sql::MetaTable* meta_table) |
| 54 : WebDatabaseTable(db, meta_table) {} | 25 : WebDatabaseTable(db, meta_table) {} |
| 55 virtual ~LoginsTable() {} | 26 virtual ~LoginsTable() {} |
| 56 virtual bool Init() OVERRIDE; | 27 virtual bool Init() OVERRIDE; |
| 57 virtual bool IsSyncable() OVERRIDE; | 28 virtual bool IsSyncable() OVERRIDE; |
| 58 | 29 |
| 59 // Adds |form| to the list of remembered password forms. | |
| 60 bool AddLogin(const webkit::forms::PasswordForm& form); | |
| 61 | |
| 62 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
| 63 // Adds |info| to the list of imported passwords from ie7/ie8. | 31 // Adds |info| to the list of imported passwords from ie7/ie8. |
| 64 bool AddIE7Login(const IE7PasswordInfo& info); | 32 bool AddIE7Login(const IE7PasswordInfo& info); |
| 65 | 33 |
| 66 // Removes |info| from the list of imported passwords from ie7/ie8. | 34 // Removes |info| from the list of imported passwords from ie7/ie8. |
| 67 bool RemoveIE7Login(const IE7PasswordInfo& info); | 35 bool RemoveIE7Login(const IE7PasswordInfo& info); |
| 68 | 36 |
| 69 // Return the ie7/ie8 login matching |info|. | 37 // Return the ie7/ie8 login matching |info|. |
| 70 bool GetIE7Login(const IE7PasswordInfo& info, IE7PasswordInfo* result); | 38 bool GetIE7Login(const IE7PasswordInfo& info, IE7PasswordInfo* result); |
| 71 #endif | 39 #endif |
| 72 | 40 |
| 73 // Updates remembered password form. | |
| 74 bool UpdateLogin(const webkit::forms::PasswordForm& form); | |
| 75 | |
| 76 // Removes |form| from the list of remembered password forms. | |
| 77 bool RemoveLogin(const webkit::forms::PasswordForm& form); | |
| 78 | |
| 79 // Removes all logins created from |delete_begin| onwards (inclusive) and | |
| 80 // before |delete_end|. You may use a null Time value to do an unbounded | |
| 81 // delete in either direction. | |
| 82 bool RemoveLoginsCreatedBetween(base::Time delete_begin, | |
| 83 base::Time delete_end); | |
| 84 | |
| 85 // Loads a list of matching password forms into the specified vector |forms|. | |
| 86 // The list will contain all possibly relevant entries to the observed |form|, | |
| 87 // including blacklisted matches. | |
| 88 bool GetLogins(const webkit::forms::PasswordForm& form, | |
| 89 std::vector<webkit::forms::PasswordForm*>* forms); | |
| 90 | |
| 91 // Loads the complete list of password forms into the specified vector |forms| | |
| 92 // if include_blacklisted is true, otherwise only loads those which are | |
| 93 // actually autofill-able; i.e haven't been blacklisted by the user selecting | |
| 94 // the 'Never for this site' button. | |
| 95 bool GetAllLogins(std::vector<webkit::forms::PasswordForm*>* forms, | |
| 96 bool include_blacklisted); | |
| 97 | |
| 98 private: | 41 private: |
| 99 DISALLOW_COPY_AND_ASSIGN(LoginsTable); | 42 DISALLOW_COPY_AND_ASSIGN(LoginsTable); |
| 100 }; | 43 }; |
| 101 | 44 |
| 102 #endif // CHROME_BROWSER_WEBDATA_LOGINS_TABLE_H_ | 45 #endif // CHROME_BROWSER_WEBDATA_LOGINS_TABLE_H_ |
| OLD | NEW |