Index: components/password_manager/core/browser/password_autofill_manager.cc |
diff --git a/components/password_manager/core/browser/password_autofill_manager.cc b/components/password_manager/core/browser/password_autofill_manager.cc |
index 8ace098c8aadbe134c461bc371c527b0fb98cc5e..36108a0598abf90c1a11af6745130076b55e33c7 100644 |
--- a/components/password_manager/core/browser/password_autofill_manager.cc |
+++ b/components/password_manager/core/browser/password_autofill_manager.cc |
@@ -40,6 +40,20 @@ bool PasswordAutofillManager::AcceptSuggestion( |
return false; |
} |
+bool PasswordAutofillManager::SelectSuggestion( |
+ const autofill::FormFieldData& field, |
+ const base::string16& username) { |
+ autofill::PasswordFormFillData fill_data; |
+ base::string16 password; |
+ if (FindLoginInfo(field, &fill_data) && |
+ GetPasswordForUsername(username, fill_data, &password)) { |
+ PasswordManagerDriver* driver = password_manager_client_->GetDriver(); |
+ driver->PreviewPasswordAutofillSuggestion(username, password); |
+ return true; |
+ } |
+ return false; |
+} |
+ |
void PasswordAutofillManager::OnAddPasswordFormMapping( |
const autofill::FormFieldData& field, |
const autofill::PasswordFormFillData& fill_data) { |
@@ -90,6 +104,12 @@ bool PasswordAutofillManager::AcceptSuggestionForTest( |
return AcceptSuggestion(field, username); |
} |
+bool PasswordAutofillManager::SelectSuggestionForTest( |
+ const autofill::FormFieldData& field, |
+ const base::string16& username) { |
+ return SelectSuggestion(field, username); |
+} |
+ |
void PasswordAutofillManager::OnPopupShown() { |
} |
@@ -98,9 +118,9 @@ void PasswordAutofillManager::OnPopupHidden() { |
void PasswordAutofillManager::DidSelectSuggestion(const base::string16& value, |
int identifier) { |
- // This is called to preview an autofill suggestion, but we don't currently |
- // do that for password forms (crbug.com/63421). If it is ever implemented, |
- // ClearPreviewedForm() must also be implemented(). |
+ ClearPreviewedForm(); |
+ if (!SelectSuggestion(form_field_, value)) |
+ NOTREACHED(); |
Ilya Sherman
2014/05/13 00:44:05
nit: Please write these two lines as
bool success
ziran.sun
2014/05/14 15:35:12
What about NOTREACHED() uses in other places of th
Ilya Sherman
2014/05/14 23:10:58
Yes, let's do that :)
ziran.sun
2014/05/15 12:36:37
Done.
|
} |
void PasswordAutofillManager::DidAcceptSuggestion(const base::string16& value, |
@@ -116,8 +136,8 @@ void PasswordAutofillManager::RemoveSuggestion(const base::string16& value, |
} |
void PasswordAutofillManager::ClearPreviewedForm() { |
- // There is currently no preview for password autofill (crbug.com/63421). |
- // This function needs an implemention if preview is ever implemented. |
+ PasswordManagerDriver* driver = password_manager_client_->GetDriver(); |
+ driver->ClearPasswordPreviewedForm(); |
} |
//////////////////////////////////////////////////////////////////////////////// |