1 // Copyright 2013 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.
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_
8 // This file was contains some repeated code from
9 // chrome/renderer/autofill/password_autofill_manager because as we move to the
10 // new Autofill UI we needs these functions in both the browser and renderer.
11 // Once the move is completed the repeated code in the renderer half should be
13 // http://crbug.com/51644
17 #include "components/autofill/core/common/password_form_fill_data.h"
21 } // namespace content
25 // This class is responsible for filling password forms.
26 class PasswordAutofillManager {
28 explicit PasswordAutofillManager(content::WebContents* web_contents);
29 virtual ~PasswordAutofillManager();
31 // Fills the password associated with user name |value|. Returns true if the
32 // username and password fields were filled, false otherwise.
33 bool DidAcceptAutofillSuggestion(const FormFieldData& field,
34 const base::string16& value);
36 // Invoked when a password mapping is added.
37 void AddPasswordFormMapping(
38 const FormFieldData& username_element,
39 const PasswordFormFillData& password);
41 // Invoked to clear any page specific cached values.
45 // TODO(csharp): Modify the AutofillExternalDeletegate code so that it can
46 // figure out if a entry is a password one without using this mapping.
48 typedef std::map<FormFieldData,
50 LoginToPasswordInfoMap;
52 // Returns true if |current_username| matches a username for one of the
53 // login mappings in |password|.
54 bool WillFillUserNameAndPassword(
55 const base::string16& current_username,
56 const PasswordFormFillData& password);
58 // Finds login information for a |node| that was previously filled.
59 bool FindLoginInfo(const FormFieldData& field,
60 PasswordFormFillData* found_password);
62 // The logins we have filled so far with their associated info.
63 LoginToPasswordInfoMap login_to_password_info_;
65 // We only need the RenderViewHost pointer in WebContents, but if we attempt
66 // to just store RenderViewHost on creation, it becomes invalid once we start
67 // using it. By having the WebContents we can always get a valid pointer.
68 content::WebContents* web_contents_; // Weak reference.
70 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager);
73 } // namespace autofill
75 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_