| 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 08ce18a0f74af0e02c0a673f28de4724c40345c5..12a94970ccbeba0f9758144de9700844c74e6df4 100644
|
| --- a/chrome/browser/autofill/autofill_external_delegate.cc
|
| +++ b/chrome/browser/autofill/autofill_external_delegate.cc
|
| @@ -3,6 +3,7 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/utf_string_conversions.h"
|
| +#include "chrome/browser/autocomplete_history_manager.h"
|
| #include "chrome/browser/autofill/autofill_external_delegate.h"
|
| #include "chrome/browser/autofill/autofill_manager.h"
|
| #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
|
| @@ -30,19 +31,16 @@ AutofillExternalDelegate::AutofillExternalDelegate(
|
| tab_contents_wrapper ? tab_contents_wrapper->web_contents() : NULL),
|
| autofill_query_id_(0),
|
| display_warning_if_disabled_(false),
|
| - has_shown_autofill_popup_for_current_edit_(false),
|
| - suggestions_clear_index_(-1),
|
| - suggestions_options_index_(-1) {
|
| + has_shown_autofill_popup_for_current_edit_(false) {
|
| }
|
|
|
| -void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id,
|
| - int list_index) {
|
| +void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id) {
|
| if (password_autofill_manager_.DidSelectAutofillSuggestion(
|
| autofill_query_field_))
|
| return;
|
|
|
| - if (list_index == suggestions_options_index_ ||
|
| - list_index == suggestions_clear_index_ ||
|
| + if (unique_id == WebAutofillClient::MenuItemIDAutofillOptions ||
|
| + unique_id == WebAutofillClient::MenuItemIDClearForm ||
|
| unique_id == WebAutofillClient::MenuItemIDWarningMessage)
|
| return;
|
|
|
| @@ -81,7 +79,6 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
|
| std::vector<string16> l(labels);
|
| std::vector<string16> i(icons);
|
| std::vector<int> ids(unique_ids);
|
| - int separator_index = -1;
|
|
|
| DCHECK_GT(ids.size(), 0U);
|
| if (!autofill_query_field_.should_autocomplete) {
|
| @@ -113,16 +110,15 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
|
| }
|
| }
|
|
|
| + int separator_index = ids.size();
|
| +
|
| // The form has been auto-filled, so give the user the chance to clear the
|
| // form. Append the 'Clear form' menu item.
|
| - if (has_autofill_item &&
|
| - autofill_query_field_.is_autofilled) {
|
| + if (has_autofill_item && autofill_query_field_.is_autofilled) {
|
| v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM));
|
| l.push_back(string16());
|
| i.push_back(string16());
|
| - ids.push_back(0);
|
| - suggestions_clear_index_ = v.size() - 1;
|
| - separator_index = v.size() - 1;
|
| + ids.push_back(WebAutofillClient::MenuItemIDClearForm);
|
| }
|
|
|
| if (has_autofill_item) {
|
| @@ -130,9 +126,7 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
|
| v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS_POPUP));
|
| l.push_back(string16());
|
| i.push_back(string16());
|
| - ids.push_back(0);
|
| - suggestions_options_index_ = v.size() - 1;
|
| - separator_index = values.size();
|
| + ids.push_back(WebAutofillClient::MenuItemIDAutofillOptions);
|
| }
|
|
|
| // Send to display.
|
| @@ -163,6 +157,19 @@ void AutofillExternalDelegate::OnShowPasswordSuggestions(
|
| ApplyAutofillSuggestions(suggestions, empty, empty, password_ids, -1);
|
| }
|
|
|
| +void AutofillExternalDelegate::RemoveAutocompleteEntry(const string16& value) {
|
| + if (tab_contents_wrapper_) {
|
| + tab_contents_wrapper_->autocomplete_history_manager()->
|
| + OnRemoveAutocompleteEntry(autofill_query_field_.name, value);
|
| + }
|
| +}
|
| +
|
| +void AutofillExternalDelegate::RemoveAutofillProfileOrCreditCard(
|
| + int unique_id) {
|
| + autofill_manager_->RemoveAutofillProfileOrCreditCard(unique_id);
|
| +}
|
| +
|
| +
|
| void AutofillExternalDelegate::DidEndTextFieldEditing() {
|
| has_shown_autofill_popup_for_current_edit_ = false;
|
| }
|
| @@ -175,12 +182,10 @@ bool AutofillExternalDelegate::DidAcceptAutofillSuggestions(
|
| if (unique_id == WebAutofillClient::MenuItemIDWarningMessage)
|
| return false;
|
|
|
| - if (suggestions_options_index_ != -1 &&
|
| - index == static_cast<unsigned>(suggestions_options_index_)) {
|
| + if (unique_id == WebAutofillClient::MenuItemIDAutofillOptions) {
|
| // User selected 'Autofill Options'.
|
| autofill_manager_->OnShowAutofillDialog();
|
| - } else if (suggestions_clear_index_ != -1 &&
|
| - index == static_cast<unsigned>(suggestions_clear_index_)) {
|
| + } else if (unique_id == WebAutofillClient::MenuItemIDClearForm) {
|
| // User selected 'Clear form'.
|
| RenderViewHost* host =
|
| tab_contents_wrapper_->web_contents()->GetRenderViewHost();
|
| @@ -189,7 +194,7 @@ bool AutofillExternalDelegate::DidAcceptAutofillSuggestions(
|
| autofill_query_field_, value)) {
|
| // DidAcceptAutofillSuggestion has already handled the work to fill in
|
| // the page as required.
|
| - } else if (!unique_id) {
|
| + } else if (unique_id == WebAutofillClient::MenuItemIDAutocompleteEntry) {
|
| // User selected an Autocomplete, so we fill directly.
|
| RenderViewHost* host =
|
| tab_contents_wrapper_->web_contents()->GetRenderViewHost();
|
| @@ -216,9 +221,6 @@ void AutofillExternalDelegate::ClearPreviewedForm() {
|
| }
|
|
|
| void AutofillExternalDelegate::HideAutofillPopup() {
|
| - suggestions_clear_index_ = -1;
|
| - suggestions_options_index_ = -1;
|
| -
|
| HideAutofillPopupInternal();
|
| }
|
|
|
|
|