From 60bf5452d1f207048d6aee161a1374bd5e3cca86 Mon Sep 17 00:00:00 2001 From: "aruslan@chromium.org" Date: Fri, 26 Apr 2013 20:30:30 +0000 Subject: [PATCH] [rAc Android dialog] Fix for a too early DestroyFromNative. We were disconnecting the Java side from the C/C++ too early. BUG=235493 NOTRY=True Review URL: https://chromiumcodereview.appspot.com/14021006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196821 0039d316-1c4b-4281-b951-d872f2087c98 --- .../chrome/browser/autofill/AutofillDialogGlue.java | 17 +++++++++++++++++ .../ui/android/autofill/autofill_dialog_view_android.cc | 16 ++++++---------- .../ui/android/autofill/autofill_dialog_view_android.h | 3 --- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java index 721e13ec093f..20d1a1709b8e 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java @@ -44,6 +44,11 @@ public class AutofillDialogGlue implements AutofillDialogDelegate, mAutofillDialog.dismissAutofillDialog(); } + @CalledByNative + private void dismissDialog() { + mAutofillDialog.dismissAutofillDialog(); + } + /** * @see AutofillDialog#updateNotificationArea(AutofillDialogNotification[]) */ @@ -234,16 +239,28 @@ public class AutofillDialogGlue implements AutofillDialogDelegate, @Override public String getDialogButtonText(int dialogButtonId) { + // TODO(aruslan): to be removed once http://crbug.com/235493 is cleared. + assert mNativeDialogPopup != 0; + if (mNativeDialogPopup == 0) return null; + return nativeGetDialogButtonText(mNativeDialogPopup, dialogButtonId); } @Override public boolean isDialogButtonEnabled(int dialogButtonId) { + // TODO(aruslan): to be removed once http://crbug.com/235493 is cleared. + assert mNativeDialogPopup != 0; + if (mNativeDialogPopup == 0) return true; + return nativeIsDialogButtonEnabled(mNativeDialogPopup, dialogButtonId); } @Override public String getSaveLocallyText() { + // TODO(aruslan): to be removed once http://crbug.com/235493 is cleared. + assert mNativeDialogPopup != 0; + if (mNativeDialogPopup == 0) return null; + return nativeGetSaveLocallyText(mNativeDialogPopup); } diff --git a/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc b/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc index d101eea5c227..c29a1d33959c 100644 --- a/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc +++ b/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc @@ -34,7 +34,8 @@ AutofillDialogViewAndroid::AutofillDialogViewAndroid( : controller_(controller) {} AutofillDialogViewAndroid::~AutofillDialogViewAndroid() { - DestroyFromNative(); + JNIEnv* env = base::android::AttachCurrentThread(); + Java_AutofillDialogGlue_onDestroy(env, java_object_.obj()); } void AutofillDialogViewAndroid::Show() { @@ -50,7 +51,10 @@ void AutofillDialogViewAndroid::Show() { } void AutofillDialogViewAndroid::Hide() { - DestroyFromNative(); + JNIEnv* env = base::android::AttachCurrentThread(); + // This will call DialogDismissed(), and that could cause |this| to be + // deleted by the |controller|. + Java_AutofillDialogGlue_dismissDialog(env, java_object_.obj()); } void AutofillDialogViewAndroid::UpdateNotificationArea() { @@ -503,12 +507,4 @@ void AutofillDialogViewAndroid::UpdateSaveLocallyCheckBox() { env, java_object_.obj(), controller_->ShouldOfferToSaveInChrome()); } -// Lets the Java side to clean up before the C++ side cleanup. -void AutofillDialogViewAndroid::DestroyFromNative() { - JNIEnv* env = base::android::AttachCurrentThread(); - // This will call DialogDismissed(), and that could cause |this| to be - // deleted by the |controller|. - Java_AutofillDialogGlue_onDestroy(env, java_object_.obj()); -} - } // namespace autofill diff --git a/chrome/browser/ui/android/autofill/autofill_dialog_view_android.h b/chrome/browser/ui/android/autofill/autofill_dialog_view_android.h index 9fd0dddd8b7a..6efee44922fb 100644 --- a/chrome/browser/ui/android/autofill/autofill_dialog_view_android.h +++ b/chrome/browser/ui/android/autofill/autofill_dialog_view_android.h @@ -98,9 +98,6 @@ class AutofillDialogViewAndroid : public AutofillDialogView { // locally. void UpdateSaveLocallyCheckBox(); - // Lets the Java side to clean up before the C++ side cleanup. - void DestroyFromNative(); - // The controller that drives this view. Weak pointer, always non-NULL. AutofillDialogController* const controller_; -- 2.11.4.GIT