| OLD | NEW |
| (Empty) |
| 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 WEBKIT_FORMS_PASSWORD_FORM_H__ | |
| 6 #define WEBKIT_FORMS_PASSWORD_FORM_H__ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/time.h" | |
| 12 #include "googleurl/src/gurl.h" | |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPasswordFormData.h
" | |
| 14 #include "webkit/forms/webkit_forms_export.h" | |
| 15 | |
| 16 namespace webkit { | |
| 17 namespace forms { | |
| 18 | |
| 19 // The PasswordForm struct encapsulates information about a login form, | |
| 20 // which can be an HTML form or a dialog with username/password text fields. | |
| 21 // | |
| 22 // The Web Data database stores saved username/passwords and associated form | |
| 23 // metdata using a PasswordForm struct, typically one that was created from | |
| 24 // a parsed HTMLFormElement or LoginDialog, but the saved entries could have | |
| 25 // also been created by imported data from another browser. | |
| 26 // | |
| 27 // The PasswordManager implements a fuzzy-matching algorithm to compare saved | |
| 28 // PasswordForm entries against PasswordForms that were created from a parsed | |
| 29 // HTML or dialog form. As one might expect, the more data contained in one | |
| 30 // of the saved PasswordForms, the better the job the PasswordManager can do | |
| 31 // in matching it against the actual form it was saved on, and autofill | |
| 32 // accurately. But it is not always possible, especially when importing from | |
| 33 // other browsers with different data models, to copy over all the information | |
| 34 // about a particular "saved password entry" to our PasswordForm | |
| 35 // representation. | |
| 36 // | |
| 37 // The field descriptions in the struct specification below are intended to | |
| 38 // describe which fields are not strictly required when adding a saved password | |
| 39 // entry to the database and how they can affect the matching process. | |
| 40 | |
| 41 struct WEBKIT_FORMS_EXPORT PasswordForm { | |
| 42 // Enum to differentiate between HTML form based authentication, and dialogs | |
| 43 // using basic or digest schemes. Default is SCHEME_HTML. Only PasswordForms | |
| 44 // of the same Scheme will be matched/autofilled against each other. | |
| 45 enum Scheme { | |
| 46 SCHEME_HTML, | |
| 47 SCHEME_BASIC, | |
| 48 SCHEME_DIGEST, | |
| 49 SCHEME_OTHER | |
| 50 } scheme; | |
| 51 | |
| 52 // The "Realm" for the sign-on (scheme, host, port for SCHEME_HTML, and | |
| 53 // contains the HTTP realm for dialog-based forms). | |
| 54 // The signon_realm is effectively the primary key used for retrieving | |
| 55 // data from the database, so it must not be empty. | |
| 56 std::string signon_realm; | |
| 57 | |
| 58 // The URL (minus query parameters) containing the form. This is the primary | |
| 59 // data used by the PasswordManager to decide (in longest matching prefix | |
| 60 // fashion) whether or not a given PasswordForm result from the database is a | |
| 61 // good fit for a particular form on a page, so it must not be empty. | |
| 62 GURL origin; | |
| 63 | |
| 64 // The action target of the form. This is the primary data used by the | |
| 65 // PasswordManager for form autofill; that is, the action of the saved | |
| 66 // credentials must match the action of the form on the page to be autofilled. | |
| 67 // If this is empty / not available, it will result in a "restricted" | |
| 68 // IE-like autofill policy, where we wait for the user to type in his | |
| 69 // username before autofilling the password. In these cases, after successful | |
| 70 // login the action URL will automatically be assigned by the | |
| 71 // PasswordManager. | |
| 72 // | |
| 73 // When parsing an HTML form, this must always be set. | |
| 74 GURL action; | |
| 75 | |
| 76 // The name of the submit button used. Optional; only used in scoring | |
| 77 // of PasswordForm results from the database to make matches as tight as | |
| 78 // possible. | |
| 79 // | |
| 80 // When parsing an HTML form, this must always be set. | |
| 81 string16 submit_element; | |
| 82 | |
| 83 // The name of the username input element. Optional (improves scoring). | |
| 84 // | |
| 85 // When parsing an HTML form, this must always be set. | |
| 86 string16 username_element; | |
| 87 | |
| 88 // The username. Optional. | |
| 89 // | |
| 90 // When parsing an HTML form, this is typically empty unless the site | |
| 91 // has implemented some form of autofill. | |
| 92 string16 username_value; | |
| 93 | |
| 94 // The name of the password input element, Optional (improves scoring). | |
| 95 // | |
| 96 // When parsing an HTML form, this must always be set. | |
| 97 string16 password_element; | |
| 98 | |
| 99 // The password. Required. | |
| 100 // | |
| 101 // When parsing an HTML form, this is typically empty. | |
| 102 string16 password_value; | |
| 103 | |
| 104 // If the form was a change password form, the name of the | |
| 105 // 'old password' input element. Optional. | |
| 106 string16 old_password_element; | |
| 107 | |
| 108 // The old password. Optional. | |
| 109 string16 old_password_value; | |
| 110 | |
| 111 // Whether or not this login was saved under an HTTPS session with a valid | |
| 112 // SSL cert. We will never match or autofill a PasswordForm where | |
| 113 // ssl_valid == true with a PasswordForm where ssl_valid == false. This means | |
| 114 // passwords saved under HTTPS will never get autofilled onto an HTTP page. | |
| 115 // When importing, this should be set to true if the page URL is HTTPS, thus | |
| 116 // giving it "the benefit of the doubt" that the SSL cert was valid when it | |
| 117 // was saved. Default to false. | |
| 118 bool ssl_valid; | |
| 119 | |
| 120 // True if this PasswordForm represents the last username/password login the | |
| 121 // user selected to log in to the site. If there is only one saved entry for | |
| 122 // the site, this will always be true, but when there are multiple entries | |
| 123 // the PasswordManager ensures that only one of them has a preferred bit set | |
| 124 // to true. Default to false. | |
| 125 // | |
| 126 // When parsing an HTML form, this is not used. | |
| 127 bool preferred; | |
| 128 | |
| 129 // When the login was saved (by chrome). | |
| 130 // | |
| 131 // When parsing an HTML form, this is not used. | |
| 132 base::Time date_created; | |
| 133 | |
| 134 // Tracks if the user opted to never remember passwords for this form. Default | |
| 135 // to false. | |
| 136 // | |
| 137 // When parsing an HTML form, this is not used. | |
| 138 bool blacklisted_by_user; | |
| 139 | |
| 140 // Enum to differentiate between manually filled forms and forms with auto | |
| 141 // generated passwords. | |
| 142 enum Type { | |
| 143 TYPE_MANUAL, | |
| 144 TYPE_GENERATED, | |
| 145 }; | |
| 146 | |
| 147 // The form type. Not used yet. Please see http://crbug.com/152422 | |
| 148 Type type; | |
| 149 | |
| 150 PasswordForm(); | |
| 151 PasswordForm(const WebKit::WebPasswordFormData& web_password_form); | |
| 152 ~PasswordForm(); | |
| 153 }; | |
| 154 | |
| 155 // Map username to PasswordForm* for convenience. See password_form_manager.h. | |
| 156 typedef std::map<string16, PasswordForm*> PasswordFormMap; | |
| 157 | |
| 158 } // namespace forms | |
| 159 } // namespace webkit | |
| 160 | |
| 161 #endif // WEBKIT_FORMS_PASSWORD_FORM_H__ | |
| OLD | NEW |