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