Chromium Code Reviews| 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 507f08e075bf2e927dd1669c7745e6a8ab62da33..d8cc8eb3633aa718b777cd68d8bf6e48975ea8df 100644 |
| --- a/chrome/browser/autofill/autofill_external_delegate.cc |
| +++ b/chrome/browser/autofill/autofill_external_delegate.cc |
| @@ -64,10 +64,7 @@ AutofillExternalDelegate::AutofillExternalDelegate( |
| &(web_contents->GetController()))); |
| } |
| -AutofillExternalDelegate::~AutofillExternalDelegate() { |
| - if (controller_) |
| - controller_->Hide(); |
| -} |
| +AutofillExternalDelegate::~AutofillExternalDelegate() {} |
| void AutofillExternalDelegate::OnQuery(int query_id, |
| const FormData& form, |
| @@ -78,8 +75,7 @@ void AutofillExternalDelegate::OnQuery(int query_id, |
| autofill_query_field_ = field; |
| display_warning_if_disabled_ = display_warning_if_disabled; |
| autofill_query_id_ = query_id; |
| - |
| - EnsurePopupForElement(element_bounds); |
| + autofill_popup_bounding_ = element_bounds; |
| } |
| void AutofillExternalDelegate::OnSuggestionsReturned( |
| @@ -88,7 +84,7 @@ void AutofillExternalDelegate::OnSuggestionsReturned( |
| const std::vector<string16>& autofill_labels, |
| const std::vector<string16>& autofill_icons, |
| const std::vector<int>& autofill_unique_ids) { |
| - if (query_id != autofill_query_id_ || !controller_) |
| + if (query_id != autofill_query_id_) |
| return; |
| std::vector<string16> values(autofill_values); |
| @@ -134,8 +130,10 @@ void AutofillExternalDelegate::OnSuggestionsReturned( |
| } |
| // Send to display. |
| - if (autofill_query_field_.is_focusable) |
| - ApplyAutofillSuggestions(values, labels, icons, ids); |
| + if (autofill_query_field_.is_focusable) { |
| + autofill_manager_->delegate()->ShowAutofillPopup( |
| + autofill_popup_bounding_, values, labels, icons, ids, this); |
| + } |
| } |
| void AutofillExternalDelegate::OnShowPasswordSuggestions( |
| @@ -143,7 +141,7 @@ void AutofillExternalDelegate::OnShowPasswordSuggestions( |
| const FormFieldData& field, |
| const gfx::RectF& element_bounds) { |
| autofill_query_field_ = field; |
| - EnsurePopupForElement(element_bounds); |
| + autofill_popup_bounding_ = element_bounds; |
| if (suggestions.empty()) { |
| HideAutofillPopup(); |
| @@ -153,34 +151,8 @@ void AutofillExternalDelegate::OnShowPasswordSuggestions( |
| std::vector<string16> empty(suggestions.size()); |
| std::vector<int> password_ids(suggestions.size(), |
| WebAutofillClient::MenuItemIDPasswordEntry); |
| - ApplyAutofillSuggestions(suggestions, empty, empty, password_ids); |
| -} |
| - |
| -void AutofillExternalDelegate::EnsurePopupForElement( |
| - const gfx::RectF& element_bounds) { |
| - // Convert element_bounds to be in screen space. |
| - gfx::Rect client_area; |
| - web_contents_->GetContainerBounds(&client_area); |
| - gfx::RectF element_bounds_in_screen_space = |
| - element_bounds + client_area.OffsetFromOrigin(); |
| - |
| - // |controller_| owns itself. |
| - controller_ = AutofillPopupControllerImpl::GetOrCreate( |
| - controller_, |
| - this, |
| - web_contents()->GetView()->GetContentNativeView(), |
| - element_bounds_in_screen_space); |
| -} |
| - |
| -void AutofillExternalDelegate::ApplyAutofillSuggestions( |
| - const std::vector<string16>& autofill_values, |
| - const std::vector<string16>& autofill_labels, |
| - const std::vector<string16>& autofill_icons, |
| - const std::vector<int>& autofill_unique_ids) { |
| - controller_->Show(autofill_values, |
| - autofill_labels, |
| - autofill_icons, |
| - autofill_unique_ids); |
| + autofill_manager_->delegate()->ShowAutofillPopup( |
| + autofill_popup_bounding_, suggestions, empty, empty, password_ids, this); |
| } |
| void AutofillExternalDelegate::SetCurrentDataListValues( |
| @@ -273,8 +245,7 @@ void AutofillExternalDelegate::ClearPreviewedForm() { |
| } |
| void AutofillExternalDelegate::HideAutofillPopup() { |
|
Ilya Sherman
2013/02/26 02:12:15
Optional nit: Perhaps remove this method entirely,
kaiwang
2013/02/26 22:18:40
Done.
|
| - if (controller_) |
| - controller_->Hide(); |
| + autofill_manager_->delegate()->HideAutofillPopup(); |
| } |
| void AutofillExternalDelegate::Reset() { |