| Index: chrome/browser/autofill/autofill_external_delegate.cc
|
| diff --git a/chrome/browser/autofill/autofill_external_delegate.cc b/chrome/browser/autofill/autofill_external_delegate.cc
|
| index 4105709df4993045f92069ceaa3933924acb55fc..e9de257822c12a81c0cd591960ce260ec56e0499 100644
|
| --- a/chrome/browser/autofill/autofill_external_delegate.cc
|
| +++ b/chrome/browser/autofill/autofill_external_delegate.cc
|
| @@ -24,6 +24,8 @@ AutofillExternalDelegate::AutofillExternalDelegate(
|
| AutofillManager* autofill_manager)
|
| : tab_contents_wrapper_(tab_contents_wrapper),
|
| autofill_manager_(autofill_manager),
|
| + password_autofill_manager_(
|
| + tab_contents_wrapper->web_contents()->GetRenderViewHost()),
|
| autofill_query_id_(0),
|
| display_warning_if_disabled_(false),
|
| has_shown_autofill_popup_for_current_edit_(false),
|
| @@ -33,9 +35,12 @@ AutofillExternalDelegate::AutofillExternalDelegate(
|
|
|
| void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id,
|
| int list_index) {
|
| + if (unique_id == kPasswordEntryIds)
|
| + return;
|
| +
|
| if (list_index == suggestions_options_index_ ||
|
| list_index == suggestions_clear_index_ ||
|
| - unique_id == -1)
|
| + unique_id == kWarningIds)
|
| return;
|
|
|
| FillAutofillFormData(unique_id, true);
|
| @@ -81,7 +86,7 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
|
| v.assign(1, l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED));
|
| l.assign(1, string16());
|
| i.assign(1, string16());
|
| - ids.assign(1, -1);
|
| + ids.assign(1, kWarningIds);
|
| } else if (ids[0] < 0 && ids.size() > 1) {
|
| // If we received a warning instead of suggestions from autofill but regular
|
| // suggestions from autocomplete, don't show the autofill warning.
|
| @@ -136,6 +141,19 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
|
| has_shown_autofill_popup_for_current_edit_ |= has_autofill_item;
|
| }
|
|
|
| +void AutofillExternalDelegate::ShowPasswordSuggestions(
|
| + const std::vector<string16>& suggestions) {
|
| + if (suggestions.empty()) {
|
| + HideAutofillPopup();
|
| + return;
|
| + }
|
| +
|
| + std::vector<string16> labels(suggestions.size());
|
| + std::vector<string16> icons(suggestions.size());
|
| + std::vector<int> ids(suggestions.size(), kPasswordEntryIds);
|
| + ApplyAutofillSuggestions(suggestions, labels, icons, ids, -1);
|
| +}
|
| +
|
| void AutofillExternalDelegate::DidEndTextFieldEditing() {
|
| has_shown_autofill_popup_for_current_edit_ = false;
|
| }
|
| @@ -145,13 +163,9 @@ void AutofillExternalDelegate::DidAcceptAutofillSuggestions(
|
| int unique_id,
|
| unsigned index) {
|
| // If the selected element is a warning we don't want to do anything.
|
| - if (unique_id < 0)
|
| + if (unique_id == kWarningIds)
|
| return;
|
|
|
| - // TODO(csharp): Add the password autofill manager.
|
| - // if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value))
|
| - // return;
|
| -
|
| if (suggestions_options_index_ != -1 &&
|
| index == static_cast<unsigned>(suggestions_options_index_)) {
|
| // User selected 'Autofill Options'.
|
| @@ -162,8 +176,8 @@ void AutofillExternalDelegate::DidAcceptAutofillSuggestions(
|
| RenderViewHost* host =
|
| tab_contents_wrapper_->web_contents()->GetRenderViewHost();
|
| host->Send(new AutofillMsg_ClearForm(host->GetRoutingID()));
|
| - } else if (!unique_id) {
|
| - // User selected an Autocomplete entry, so we fill directly.
|
| + } else if (!unique_id || unique_id == kPasswordEntryIds) {
|
| + // User selected an Autocomplete or Password entry, so we fill directly.
|
| RenderViewHost* host =
|
| tab_contents_wrapper_->web_contents()->GetRenderViewHost();
|
| host->Send(new AutofillMsg_SetNodeText(
|
| @@ -177,6 +191,10 @@ void AutofillExternalDelegate::DidAcceptAutofillSuggestions(
|
| }
|
|
|
| void AutofillExternalDelegate::ClearPreviewedForm() {
|
| + if (password_autofill_manager_.DidClearAutofillSelection(
|
| + autofill_query_field_))
|
| + return;
|
| +
|
| RenderViewHost* host =
|
| tab_contents_wrapper_->web_contents()->GetRenderViewHost();
|
| host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID()));
|
| @@ -189,6 +207,18 @@ void AutofillExternalDelegate::HideAutofillPopup() {
|
| HideAutofillPopupInternal();
|
| }
|
|
|
| +void AutofillExternalDelegate::Reset() {
|
| + HideAutofillPopup();
|
| +
|
| + password_autofill_manager_.Reset();
|
| +}
|
| +
|
| +void AutofillExternalDelegate::AddPasswordFormMapping(
|
| + const webkit::forms::FormField& form,
|
| + const webkit::forms::PasswordFormFillData& fill_data) {
|
| + password_autofill_manager_.AddPasswordFormMapping(form, fill_data);
|
| +}
|
| +
|
| void AutofillExternalDelegate::FillAutofillFormData(int unique_id,
|
| bool is_preview) {
|
| RenderViewHost* host =
|
|
|