Home | History | Annotate | Download | only in glue
      1 // Copyright (c) 2006-2008 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_DOM_MANAGER_H_
      6 #define WEBKIT_GLUE_PASSWORD_FORM_DOM_MANAGER_H_
      7 
      8 #include "webkit/glue/form_data.h"
      9 #include "webkit/glue/password_form.h"
     10 
     11 namespace WebKit {
     12 class WebForm;
     13 }
     14 
     15 class GURL;
     16 
     17 namespace webkit_glue {
     18 
     19 // Structure used for autofilling password forms.
     20 // basic_data identifies the HTML form on the page and preferred username/
     21 //            password for login, while
     22 // additional_logins is a list of other matching user/pass pairs for the form.
     23 // wait_for_username tells us whether we need to wait for the user to enter
     24 // a valid username before we autofill the password. By default, this is off
     25 // unless the PasswordManager determined there is an additional risk
     26 // associated with this form. This can happen, for example, if action URI's
     27 // of the observed form and our saved representation don't match up.
     28 struct PasswordFormFillData {
     29   typedef std::map<string16, string16> LoginCollection;
     30 
     31   FormData basic_data;
     32   LoginCollection additional_logins;
     33   bool wait_for_username;
     34   PasswordFormFillData();
     35   ~PasswordFormFillData();
     36 };
     37 
     38 class PasswordFormDomManager {
     39  public:
     40   // Create a PasswordForm from DOM form. Webkit doesn't allow storing
     41   // custom metadata to DOM nodes, so we have to do this every time an event
     42   // happens with a given form and compare against previously Create'd forms
     43   // to identify..which sucks.
     44   static PasswordForm* CreatePasswordForm(const WebKit::WebFormElement& form);
     45 
     46   // Create a FillData structure in preparation for autofilling a form,
     47   // from basic_data identifying which form to fill, and a collection of
     48   // matching stored logins to use as username/password values.
     49   // preferred_match should equal (address) one of matches.
     50   // wait_for_username_before_autofill is true if we should not autofill
     51   // anything until the user typed in a valid username and blurred the field.
     52   static void InitFillData(const PasswordForm& form_on_page,
     53                            const PasswordFormMap& matches,
     54                            const PasswordForm* const preferred_match,
     55                            bool wait_for_username_before_autofill,
     56                            PasswordFormFillData* result);
     57  private:
     58   DISALLOW_IMPLICIT_CONSTRUCTORS(PasswordFormDomManager);
     59 };
     60 
     61 }  // namespace webkit_glue
     62 
     63 #endif  // WEBKIT_GLUE_PASSWORD_FORM_DOM_MANAGER_H__
     64