OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ |
6 #define CHROME_BROWSER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ | 6 #define CHROME_BROWSER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ |
7 | 7 |
8 // This file was contains some repeated code from | 8 // This file was contains some repeated code from |
9 // chrome/renderer/autofill/password_autofill_manager because as we move to the | 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. | 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 | 11 // Once the move is completed the repeated code in the renderer half should be |
12 // removed. | 12 // removed. |
13 // http://crbug.com/51644 | 13 // http://crbug.com/51644 |
14 | 14 |
15 #include <map> | 15 #include <map> |
16 | 16 |
17 #include "webkit/forms/password_form_dom_manager.h" | 17 #include "chrome/common/password_form_fill_data.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 class WebContents; | 20 class WebContents; |
21 } // namespace content | 21 } // namespace content |
22 | 22 |
23 // This class is responsible for filling password forms. | 23 // This class is responsible for filling password forms. |
24 class PasswordAutofillManager { | 24 class PasswordAutofillManager { |
25 public: | 25 public: |
26 explicit PasswordAutofillManager(content::WebContents* web_contents); | 26 explicit PasswordAutofillManager(content::WebContents* web_contents); |
27 virtual ~PasswordAutofillManager(); | 27 virtual ~PasswordAutofillManager(); |
28 | 28 |
29 // Fills the password associated with user name |value|. Returns true if the | 29 // Fills the password associated with user name |value|. Returns true if the |
30 // username and password fields were filled, false otherwise. | 30 // username and password fields were filled, false otherwise. |
31 bool DidAcceptAutofillSuggestion(const webkit::forms::FormField& field, | 31 bool DidAcceptAutofillSuggestion(const FormFieldData& field, |
32 const string16& value); | 32 const string16& value); |
33 | 33 |
34 // Invoked when a password mapping is added. | 34 // Invoked when a password mapping is added. |
35 void AddPasswordFormMapping( | 35 void AddPasswordFormMapping( |
36 const webkit::forms::FormField& username_element, | 36 const FormFieldData& username_element, |
37 const webkit::forms::PasswordFormFillData& password); | 37 const PasswordFormFillData& password); |
38 | 38 |
39 // Invoked to clear any page specific cached values. | 39 // Invoked to clear any page specific cached values. |
40 void Reset(); | 40 void Reset(); |
41 | 41 |
42 private: | 42 private: |
43 // TODO(csharp): Modify the AutofillExternalDeletegate code so that it can | 43 // TODO(csharp): Modify the AutofillExternalDeletegate code so that it can |
44 // figure out if a entry is a password one without using this mapping. | 44 // figure out if a entry is a password one without using this mapping. |
45 // crbug.com/118601 | 45 // crbug.com/118601 |
46 typedef std::map<webkit::forms::FormField, | 46 typedef std::map<FormFieldData, |
47 webkit::forms::PasswordFormFillData> | 47 PasswordFormFillData> |
48 LoginToPasswordInfoMap; | 48 LoginToPasswordInfoMap; |
49 | 49 |
50 // Returns true if |current_username| matches a username for one of the | 50 // Returns true if |current_username| matches a username for one of the |
51 // login mappings in |password|. | 51 // login mappings in |password|. |
52 bool WillFillUserNameAndPassword( | 52 bool WillFillUserNameAndPassword( |
53 const string16& current_username, | 53 const string16& current_username, |
54 const webkit::forms::PasswordFormFillData& password); | 54 const PasswordFormFillData& password); |
55 | 55 |
56 // Finds login information for a |node| that was previously filled. | 56 // Finds login information for a |node| that was previously filled. |
57 bool FindLoginInfo(const webkit::forms::FormField& field, | 57 bool FindLoginInfo(const FormFieldData& field, |
58 webkit::forms::PasswordFormFillData* found_password); | 58 PasswordFormFillData* found_password); |
59 | 59 |
60 // The logins we have filled so far with their associated info. | 60 // The logins we have filled so far with their associated info. |
61 LoginToPasswordInfoMap login_to_password_info_; | 61 LoginToPasswordInfoMap login_to_password_info_; |
62 | 62 |
63 // We only need the RenderViewHost pointer in WebContents, but if we attempt | 63 // We only need the RenderViewHost pointer in WebContents, but if we attempt |
64 // to just store RenderViewHost on creation, it becomes invalid once we start | 64 // to just store RenderViewHost on creation, it becomes invalid once we start |
65 // using it. By having the WebContents we can always get a valid pointer. | 65 // using it. By having the WebContents we can always get a valid pointer. |
66 content::WebContents* web_contents_; // Weak reference. | 66 content::WebContents* web_contents_; // Weak reference. |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager); | 68 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager); |
69 }; | 69 }; |
70 | 70 |
71 #endif // CHROME_BROWSER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ | 71 #endif // CHROME_BROWSER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ |
OLD | NEW |