From 61f6cee64ce4c4271e7a4652a908490f48e028fb Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Thu, 20 Dec 2012 03:35:51 +0000 Subject: AutofillDialogControllerImpl refinements 1) merge Hide() and DelegateDestroyed() 2) remove possible hide/show race condition BUG=none Review URL: https://chromiumcodereview.appspot.com/11570057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174098 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/autofill/autofill_external_delegate.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'chrome/browser/autofill') diff --git a/chrome/browser/autofill/autofill_external_delegate.cc b/chrome/browser/autofill/autofill_external_delegate.cc index 4afc3d6..c20ad81 100644 --- a/chrome/browser/autofill/autofill_external_delegate.cc +++ b/chrome/browser/autofill/autofill_external_delegate.cc @@ -65,7 +65,7 @@ AutofillExternalDelegate::AutofillExternalDelegate( AutofillExternalDelegate::~AutofillExternalDelegate() { if (controller_) - controller_->DelegateDestroyed(); + controller_->Hide(); } void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id) { @@ -172,11 +172,9 @@ void AutofillExternalDelegate::OnShowPasswordSuggestions( void AutofillExternalDelegate::EnsurePopupForElement( const gfx::Rect& element_bounds) { - if (controller_) - return; - // |controller_| owns itself. - controller_ = new AutofillPopupControllerImpl( + controller_ = AutofillPopupControllerImpl::GetOrCreate( + controller_, this, // web_contents() may be NULL during testing. web_contents() ? web_contents()->GetView()->GetContentNativeView() : NULL, @@ -281,6 +279,9 @@ void AutofillExternalDelegate::HideAutofillPopup() { if (controller_) { ClearPreviewedForm(); controller_->Hide(); + // Go ahead and invalidate |controller_|. After calling Hide(), it won't + // inform |this| of its destruction. + ControllerDestroyed(); } } -- cgit v1.1