| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 COMPONENTS_AUTOFILL_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ | |
| 6 #define COMPONENTS_AUTOFILL_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ | |
| 7 | |
| 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 | |
| 12 // removed. | |
| 13 // http://crbug.com/51644 | |
| 14 | |
| 15 #include <map> | |
| 16 | |
| 17 #include "components/autofill/core/common/password_form_fill_data.h" | |
| 18 | |
| 19 namespace content { | |
| 20 class WebContents; | |
| 21 } // namespace content | |
| 22 | |
| 23 namespace autofill { | |
| 24 | |
| 25 // This class is responsible for filling password forms. | |
| 26 class PasswordAutofillManager { | |
| 27 public: | |
| 28 explicit PasswordAutofillManager(content::WebContents* web_contents); | |
| 29 virtual ~PasswordAutofillManager(); | |
| 30 | |
| 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); | |
| 35 | |
| 36 // Invoked when a password mapping is added. | |
| 37 void AddPasswordFormMapping( | |
| 38 const FormFieldData& username_element, | |
| 39 const PasswordFormFillData& password); | |
| 40 | |
| 41 // Invoked to clear any page specific cached values. | |
| 42 void Reset(); | |
| 43 | |
| 44 private: | |
| 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. | |
| 47 // crbug.com/118601 | |
| 48 typedef std::map<FormFieldData, | |
| 49 PasswordFormFillData> | |
| 50 LoginToPasswordInfoMap; | |
| 51 | |
| 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); | |
| 57 | |
| 58 // Finds login information for a |node| that was previously filled. | |
| 59 bool FindLoginInfo(const FormFieldData& field, | |
| 60 PasswordFormFillData* found_password); | |
| 61 | |
| 62 // The logins we have filled so far with their associated info. | |
| 63 LoginToPasswordInfoMap login_to_password_info_; | |
| 64 | |
| 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. | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager); | |
| 71 }; | |
| 72 | |
| 73 } // namespace autofill | |
| 74 | |
| 75 #endif // COMPONENTS_AUTOFILL_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ | |
| OLD | NEW |