| Index: components/autofill/core/browser/password_autofill_manager.cc
|
| diff --git a/components/autofill/core/browser/password_autofill_manager.cc b/components/autofill/core/browser/password_autofill_manager.cc
|
| index 730c10e49d5d1b2282440dcf3dd406593cd3977b..cebdda6c4e3c4ae6c68f8edbc751c92ad618973e 100644
|
| --- a/components/autofill/core/browser/password_autofill_manager.cc
|
| +++ b/components/autofill/core/browser/password_autofill_manager.cc
|
| @@ -4,35 +4,36 @@
|
|
|
| #include "base/logging.h"
|
| #include "components/autofill/core/browser/autofill_driver.h"
|
| -#include "components/autofill/core/browser/password_autofill_manager.h"
|
| +#include "components/password_manager/core/browser/password_autofill_manager.h"
|
| #include "ui/events/keycodes/keyboard_codes.h"
|
|
|
| -namespace autofill {
|
| -
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // PasswordAutofillManager, public:
|
|
|
| PasswordAutofillManager::PasswordAutofillManager(
|
| - AutofillDriver* autofill_driver) : autofill_driver_(autofill_driver) {
|
| + PasswordManagerClient* password_manager_client,
|
| + AutofillDriver* autofill_driver)
|
| + : password_manager_client_(password_manager_client),
|
| + autofill_driver_(autofill_driver) {
|
| + DCHECK(password_manager_client);
|
| DCHECK(autofill_driver);
|
| }
|
|
|
| PasswordAutofillManager::~PasswordAutofillManager() {
|
| }
|
|
|
| -bool PasswordAutofillManager::DidAcceptAutofillSuggestion(
|
| +void PasswordAutofillManager::DidAcceptAutofillSuggestion(
|
| const FormFieldData& field,
|
| const base::string16& username) {
|
| - PasswordFormFillData password;
|
| - if (!FindLoginInfo(field, &password))
|
| - return false;
|
| -
|
| - if (WillFillUserNameAndPassword(username, password)) {
|
| - autofill_driver_->RendererShouldAcceptPasswordAutofillSuggestion(username);
|
| - return true;
|
| + PasswordFormFillData fill_data;
|
| + base::string16 password;
|
| + if (FindLoginInfo(field, &fill_data) &&
|
| + GetPasswordForUsername(username, fill_data, &password)) {
|
| + autofill_driver_->RendererShouldAcceptPasswordAutofillSuggestion(
|
| + username, password);
|
| + return;
|
| }
|
| -
|
| - return false;
|
| + NOTREACHED();
|
| }
|
|
|
| void PasswordAutofillManager::AddPasswordFormMapping(
|
| @@ -48,19 +49,28 @@ void PasswordAutofillManager::Reset() {
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // PasswordAutofillManager, private:
|
|
|
| -bool PasswordAutofillManager::WillFillUserNameAndPassword(
|
| +bool PasswordAutofillManager::GetPasswordForUsername(
|
| const base::string16& current_username,
|
| - const PasswordFormFillData& fill_data) {
|
| + const PasswordFormFillData& fill_data,
|
| + base::string16* password) {
|
| + // TODO(dubroy): When password access requires some kind of authentication
|
| + // (e.g. Keychain access on Mac OS), use |password_manager_client_| here to
|
| + // fetch the actual password. See crbug.com/178358 for more context.
|
| +
|
| // Look for any suitable matches to current field text.
|
| - if (fill_data.basic_data.fields[0].value == current_username)
|
| + if (fill_data.basic_data.fields[0].value == current_username) {
|
| + *password = fill_data.basic_data.fields[1].value;
|
| return true;
|
| + }
|
|
|
| // Scan additional logins for a match.
|
| for (PasswordFormFillData::LoginCollection::const_iterator iter =
|
| fill_data.additional_logins.begin();
|
| iter != fill_data.additional_logins.end(); ++iter) {
|
| - if (iter->first == current_username)
|
| - return true;
|
| + if (iter->first == current_username) {
|
| + *password = iter->second.password;
|
| + return true;
|
| + }
|
| }
|
|
|
| for (PasswordFormFillData::UsernamesCollection::const_iterator usernames_iter
|
| @@ -68,8 +78,10 @@ bool PasswordAutofillManager::WillFillUserNameAndPassword(
|
| usernames_iter != fill_data.other_possible_usernames.end();
|
| ++usernames_iter) {
|
| for (size_t i = 0; i < usernames_iter->second.size(); ++i) {
|
| - if (usernames_iter->second[i] == current_username)
|
| + if (usernames_iter->second[i] == current_username) {
|
| + *password = usernames_iter->first.password;
|
| return true;
|
| + }
|
| }
|
| }
|
|
|
| @@ -86,5 +98,3 @@ bool PasswordAutofillManager::FindLoginInfo(
|
| *found_password = iter->second;
|
| return true;
|
| }
|
| -
|
| -} // namespace autofill
|
|
|