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 void OnShowPasswordSuggestions( | |
Ilya Sherman
2014/03/18 00:14:27
nit: Docs, please.
Patrick Dubroy
2014/03/28 15:44:22
Done.
Patrick Dubroy
2014/03/28 15:44:22
Done.
| |
46 const autofill::FormFieldData& field, | |
47 const gfx::RectF& bounds, | |
48 const std::vector<base::string16>& suggestions, | |
49 const std::vector<base::string16>& realms); | |
50 | |
51 // Invoked to clear any page specific cached values. | |
52 void Reset(); | |
53 | |
54 private: | |
55 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, | |
56 AcceptAutofillSuggestion); | |
Ilya Sherman
2014/03/18 00:14:27
Please avoid friending tests. Use protected metho
Patrick Dubroy
2014/03/28 15:44:22
How about adding a public ...ForTest() method? I t
Ilya Sherman
2014/03/28 21:33:34
I personally prefer protected methods, but a publi
| |
57 | |
58 typedef std::map<autofill::FormFieldData, autofill::PasswordFormFillData> | |
59 LoginToPasswordInfoMap; | |
60 | |
61 // Attempts to fill the password associated with user name |username|, and | |
62 // returns true if it was successful. | |
63 bool AcceptAutofillSuggestion(const autofill::FormFieldData& field, | |
64 const base::string16& username); | |
65 | |
66 // If |current_username| matches a username for one of the login mappings in | |
67 // |fill_data|, returns true and assigns the password to |out_password|. | |
68 // Otherwise, returns false and leaves |out_password| untouched. | |
69 bool GetPasswordForUsername( | |
70 const base::string16& current_username, | |
71 const autofill::PasswordFormFillData& fill_data, | |
72 base::string16* out_password); | |
73 | |
74 // Finds login information for a |node| that was previously filled. | |
75 bool FindLoginInfo(const autofill::FormFieldData& field, | |
76 autofill::PasswordFormFillData* found_password); | |
77 | |
78 // The logins we have filled so far with their associated info. | |
79 LoginToPasswordInfoMap login_to_password_info_; | |
80 | |
81 // Provides embedder-level operations on passwords. Must outlive |this|. | |
82 PasswordManagerClient* const password_manager_client_; // weak | |
83 | |
84 autofill::AutofillManagerDelegate* const autofill_manager_delegate_; // weak | |
85 | |
86 autofill::FormFieldData form_field_; | |
Ilya Sherman
2014/03/18 00:14:27
nit: Docs.
Patrick Dubroy
2014/03/28 15:44:22
Done.
| |
87 | |
88 base::WeakPtrFactory<PasswordAutofillManager> weak_ptr_factory_; | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager); | |
91 }; | |
92 | |
93 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ | |
OLD | NEW |