Home | History | Annotate | Download | only in web
      1 /*
      2  * Copyright (C) 2009 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef WebPasswordFormData_h
     32 #define WebPasswordFormData_h
     33 
     34 #include "../platform/WebString.h"
     35 #include "../platform/WebURL.h"
     36 #include "../platform/WebVector.h"
     37 #include "WebFormElement.h"
     38 
     39 namespace WebKit {
     40 
     41 struct WebPasswordFormData {
     42     // If the provided form is suitable for password completion, isValid() will
     43     // return true;
     44     WEBKIT_EXPORT WebPasswordFormData(const WebFormElement&);
     45 
     46     // If creation failed, return false.
     47     bool isValid() const { return action.isValid(); }
     48 
     49     // The action target of the form. This is the primary data used by the
     50     // PasswordManager for form autofill; that is, the action of the saved
     51     // credentials must match the action of the form on the page to be autofilled.
     52     // If this is empty / not available, it will result in a "restricted"
     53     // IE-like autofill policy, where we wait for the user to type in his
     54     // username before autofilling the password. In these cases, after successful
     55     // login the action URL will automatically be assigned by the
     56     // PasswordManager.
     57     //
     58     // When parsing an HTML form, this must always be set.
     59     WebURL action;
     60 
     61     // The "Realm" for the sign-on (scheme, host, port for SCHEME_HTML, and
     62     // contains the HTTP realm for dialog-based forms).
     63     // The signon_realm is effectively the primary key used for retrieving
     64     // data from the database, so it must not be empty.
     65     WebString signonRealm;
     66 
     67     // The URL (minus query parameters) containing the form. This is the primary
     68     // data used by the PasswordManager to decide (in longest matching prefix
     69     // fashion) whether or not a given PasswordForm result from the database is a
     70     // good fit for a particular form on a page, so it must not be empty.
     71     WebURL origin;
     72 
     73     // The name of the submit button used. Optional; only used in scoring
     74     // of PasswordForm results from the database to make matches as tight as
     75     // possible.
     76     //
     77     // When parsing an HTML form, this must always be set.
     78     WebString submitElement;
     79 
     80     // The name of the username input element. Optional (improves scoring).
     81     //
     82     // When parsing an HTML form, this must always be set.
     83     WebString userNameElement;
     84 
     85     // The username. Optional.
     86     //
     87     // When parsing an HTML form, this is typically empty unless the site
     88     // has implemented some form of autofill.
     89     WebString userNameValue;
     90 
     91     // If the form has more than one field which could possibly contain the
     92     // username, the extra are placed here. Used for autofill in cases where
     93     // our heuristics for determining the username are wrong. Optional.
     94     //
     95     // When parsing an HTML form, this is typically empty.
     96     WebVector<WebString> possibleUserNames;
     97 
     98     // The name of the password input element, Optional (improves scoring).
     99     //
    100     // When parsing an HTML form, this must always be set.
    101     WebString passwordElement;
    102 
    103     // The password. Required.
    104     //
    105     // When parsing an HTML form, this is typically empty.
    106     WebString passwordValue;
    107 
    108     // Value of shouldAutocomplete for the password element.
    109     bool passwordShouldAutocomplete;
    110 
    111     // If the form was a change password form, the name of the
    112     // 'old password' input element. Optional.
    113     WebString oldPasswordElement;
    114 
    115     // The old password. Optional.
    116     WebString oldPasswordValue;
    117 
    118     WebPasswordFormData()
    119         : passwordShouldAutocomplete(false)
    120     {
    121     }
    122 };
    123 
    124 } // namespace WebKit
    125 
    126 #endif
    127