OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ | |
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/gtest_prod_util.h" | |
11 #include "components/autofill/core/browser/autofill_manager_delegate.h" | |
12 #include "components/autofill/core/browser/autofill_popup_delegate.h" | |
13 #include "components/autofill/core/common/password_form_fill_data.h" | |
14 | |
15 class PasswordManagerClient; | |
16 | |
17 namespace gfx { | |
18 class RectF; | |
19 } | |
20 | |
21 // This class is responsible for filling password forms. | |
22 class PasswordAutofillManager : public autofill::AutofillPopupDelegate { | |
23 public: | |
24 PasswordAutofillManager( | |
25 PasswordManagerClient* password_manager_client, | |
26 autofill::AutofillManagerDelegate* autofill_manager_delegate); | |
27 virtual ~PasswordAutofillManager(); | |
28 | |
29 // AutofillPopupDelegate implementation. | |
30 virtual void OnPopupShown() OVERRIDE; | |
31 virtual void OnPopupHidden() OVERRIDE; | |
32 virtual bool ShouldRepostEvent(const ui::MouseEvent& event) OVERRIDE; | |
33 virtual void DidSelectSuggestion(int identifier) OVERRIDE; | |
34 virtual void DidAcceptSuggestion(const base::string16& value, | |
35 int identifier) OVERRIDE; | |
36 virtual void RemoveSuggestion(const base::string16& value, | |
37 int identifier) OVERRIDE; | |
38 virtual void ClearPreviewedForm() OVERRIDE; | |
39 | |
40 // Invoked when a password mapping is added. | |
41 void OnAddPasswordFormMapping( | |
42 const autofill::FormFieldData& field, | |
43 const autofill::PasswordFormFillData& fill_data); | |
44 | |
45 // Handles a request from the renderer to show a popup with the given | |
46 // |suggestions| from the password manager. | |
Ilya Sherman
2014/03/28 21:33:34
What about |bounds| and |realms|?
| |
47 void OnShowPasswordSuggestions( | |
48 const autofill::FormFieldData& field, | |
49 const gfx::RectF& bounds, | |
50 const std::vector<base::string16>& suggestions, | |
51 const std::vector<base::string16>& realms); | |
52 | |
53 // Invoked to clear any page specific cached values. | |
54 void Reset(); | |
55 | |
56 // A public version of AcceptAutofillSuggestion(), only for use in tests. | |
57 bool AcceptAutofillSuggestionForTest(const autofill::FormFieldData& field, | |
58 const base::string16& username) { | |
59 return AcceptAutofillSuggestion(field, username); | |
60 } | |
Ilya Sherman
2014/03/28 21:33:34
nit: Please don't inline this method body -- only
| |
61 | |
62 private: | |
63 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, | |
64 AcceptAutofillSuggestion); | |
65 | |
66 typedef std::map<autofill::FormFieldData, autofill::PasswordFormFillData> | |
67 LoginToPasswordInfoMap; | |
68 | |
69 // Attempts to fill the password associated with user name |username|, and | |
70 // returns true if it was successful. | |
71 bool AcceptAutofillSuggestion(const autofill::FormFieldData& field, | |
72 const base::string16& username); | |
73 | |
74 // If |current_username| matches a username for one of the login mappings in | |
75 // |fill_data|, returns true and assigns the password to |out_password|. | |
76 // Otherwise, returns false and leaves |out_password| untouched. | |
77 bool GetPasswordForUsername( | |
78 const base::string16& current_username, | |
79 const autofill::PasswordFormFillData& fill_data, | |
80 base::string16* out_password); | |
81 | |
82 // Finds login information for a |node| that was previously filled. | |
83 bool FindLoginInfo(const autofill::FormFieldData& field, | |
84 autofill::PasswordFormFillData* found_password); | |
85 | |
86 // The logins we have filled so far with their associated info. | |
87 LoginToPasswordInfoMap login_to_password_info_; | |
88 | |
89 // Provides embedder-level operations on passwords. Must outlive |this|. | |
90 PasswordManagerClient* const password_manager_client_; // weak | |
91 | |
92 autofill::AutofillManagerDelegate* const autofill_manager_delegate_; // weak | |
93 | |
94 // The form field on which the autofill popup is shown. | |
95 autofill::FormFieldData form_field_; | |
96 | |
97 base::WeakPtrFactory<PasswordAutofillManager> weak_ptr_factory_; | |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager); | |
100 }; | |
101 | |
102 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ | |
OLD | NEW |