| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "components/autofill/core/browser/autofill_driver.h" | 6 #include "components/autofill/core/browser/autofill_driver.h" |
| 7 #include "components/autofill/core/browser/password_autofill_manager.h" | 7 #include "components/autofill/core/browser/password_autofill_manager.h" |
| 8 #include "ui/events/keycodes/keyboard_codes.h" | 8 #include "ui/events/keycodes/keyboard_codes.h" |
| 9 | 9 |
| 10 namespace autofill { | 10 namespace autofill { |
| 11 | 11 |
| 12 //////////////////////////////////////////////////////////////////////////////// | 12 //////////////////////////////////////////////////////////////////////////////// |
| 13 // PasswordAutofillManager, public: | 13 // PasswordAutofillManager, public: |
| 14 | 14 |
| 15 PasswordAutofillManager::PasswordAutofillManager( | 15 PasswordAutofillManager::PasswordAutofillManager( |
| 16 AutofillDriver* autofill_driver) : autofill_driver_(autofill_driver) { | 16 AutofillDriver* autofill_driver) : autofill_driver_(autofill_driver) { |
| 17 DCHECK(autofill_driver); | 17 DCHECK(autofill_driver); |
| 18 } | 18 } |
| 19 | 19 |
| 20 PasswordAutofillManager::~PasswordAutofillManager() { | 20 PasswordAutofillManager::~PasswordAutofillManager() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool PasswordAutofillManager::DidAcceptAutofillSuggestion( | 23 bool PasswordAutofillManager::DidSelectSuggestion( |
| 24 const FormFieldData& field, | 24 const FormFieldData& field, |
| 25 const base::string16& username) { | 25 const base::string16& username) { |
| 26 PasswordFormFillData password; | 26 PasswordFormFillData password; |
| 27 if (!FindLoginInfo(field, &password)) | 27 if (!FindLoginInfo(field, &password)) |
| 28 return false; | 28 return false; |
| 29 | 29 |
| 30 if (WillFillUserNameAndPassword(username, password)) { | 30 if (WillFillUserNameAndPassword(username, password)) { |
| 31 autofill_driver_->RendererShouldAcceptPasswordAutofillSuggestion(username); | 31 autofill_driver_->RendererShouldPreviewPassword(username); |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 return false; |
| 36 } |
| 37 |
| 38 bool PasswordAutofillManager::DidAcceptSuggestion( |
| 39 const FormFieldData& field, |
| 40 const base::string16& username) { |
| 41 PasswordFormFillData password; |
| 42 if (!FindLoginInfo(field, &password)) |
| 43 return false; |
| 44 |
| 45 if (WillFillUserNameAndPassword(username, password)) { |
| 46 autofill_driver_->RendererShouldFillPassword(username); |
| 47 return true; |
| 48 } |
| 49 |
| 35 return false; | 50 return false; |
| 36 } | 51 } |
| 37 | 52 |
| 38 void PasswordAutofillManager::AddPasswordFormMapping( | 53 void PasswordAutofillManager::AddPasswordFormMapping( |
| 39 const FormFieldData& username_element, | 54 const FormFieldData& username_element, |
| 40 const PasswordFormFillData& password) { | 55 const PasswordFormFillData& password) { |
| 41 login_to_password_info_[username_element] = password; | 56 login_to_password_info_[username_element] = password; |
| 42 } | 57 } |
| 43 | 58 |
| 44 void PasswordAutofillManager::Reset() { | 59 void PasswordAutofillManager::Reset() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 PasswordFormFillData* found_password) { | 96 PasswordFormFillData* found_password) { |
| 82 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(field); | 97 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(field); |
| 83 if (iter == login_to_password_info_.end()) | 98 if (iter == login_to_password_info_.end()) |
| 84 return false; | 99 return false; |
| 85 | 100 |
| 86 *found_password = iter->second; | 101 *found_password = iter->second; |
| 87 return true; | 102 return true; |
| 88 } | 103 } |
| 89 | 104 |
| 90 } // namespace autofill | 105 } // namespace autofill |
| OLD | NEW |