Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: components/autofill/core/browser/password_autofill_manager.cc

Issue 184103016: Autofill: Refactoring to support fetching password after a username is selected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..54590d5235bb44b8397413188b30886b69cc4629 100644
--- a/components/autofill/core/browser/password_autofill_manager.cc
+++ b/components/autofill/core/browser/password_autofill_manager.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/logging.h"
+#include "base/strings/utf_string_conversions.h"
Garrett Casto 2014/03/05 07:36:09 Unused?
Patrick Dubroy 2014/03/05 16:31:50 Done.
#include "components/autofill/core/browser/autofill_driver.h"
#include "components/autofill/core/browser/password_autofill_manager.h"
#include "ui/events/keycodes/keyboard_codes.h"
@@ -12,9 +13,9 @@ namespace autofill {
////////////////////////////////////////////////////////////////////////////////
// PasswordAutofillManager, public:
-PasswordAutofillManager::PasswordAutofillManager(
- AutofillDriver* autofill_driver) : autofill_driver_(autofill_driver) {
- DCHECK(autofill_driver);
+PasswordAutofillManager::PasswordAutofillManager(PasswordManagerDriver* driver)
+ : driver_(driver) {
+ DCHECK(driver);
}
PasswordAutofillManager::~PasswordAutofillManager() {
@@ -23,15 +24,15 @@ PasswordAutofillManager::~PasswordAutofillManager() {
bool PasswordAutofillManager::DidAcceptAutofillSuggestion(
const FormFieldData& field,
const base::string16& username) {
- PasswordFormFillData password;
- if (!FindLoginInfo(field, &password))
+ PasswordFormFillData fill_data;
+ if (!FindLoginInfo(field, &fill_data))
return false;
- if (WillFillUserNameAndPassword(username, password)) {
- autofill_driver_->RendererShouldAcceptPasswordAutofillSuggestion(username);
+ base::string16 password;
+ if (GetPasswordForUsername(username, fill_data, &password)) {
+ driver_->RendererShouldAcceptPasswordAutofillSuggestion(username, password);
return true;
}
-
return false;
}
@@ -48,19 +49,24 @@ 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) {
Garrett Casto 2014/03/05 07:36:09 "base::string16* password"
Patrick Dubroy 2014/03/05 16:31:50 Done.
// 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 +74,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;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698