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