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