diff options
author | aruslan@chromium.org <aruslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-24 20:34:51 +0000 |
---|---|---|
committer | aruslan@chromium.org <aruslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-24 20:34:51 +0000 |
commit | bd319ec6053de1f01d35da9d1a062413278d180a (patch) | |
tree | 8ce78cc205d315384b958dee5f1262f279c7b14f /chrome/android | |
parent | e6d8e990c4b26bcbfa47c405fbc06ce7f4010c48 (diff) | |
download | chromium_src-bd319ec6053de1f01d35da9d1a062413278d180a.zip chromium_src-bd319ec6053de1f01d35da9d1a062413278d180a.tar.gz chromium_src-bd319ec6053de1f01d35da9d1a062413278d180a.tar.bz2 |
[rAc Android] Do not dismiss the dialog automatically.
Fot the steady state: on Submit/Cancel we receive a Hide() call from the controller anyway, so there is no need to rely on any "automatic" behavior.
For the editing state: we should never dismiss the dialog.
Note that the Back button is ignored with this CL (it has quite surprising behavior in the editing mode anyway), see http://crbug.com/234477.
BUG=233809
NOTRY=True
Review URL: https://chromiumcodereview.appspot.com/14159021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/android')
-rw-r--r-- | chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java | 39 | ||||
-rw-r--r-- | chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java | 22 |
2 files changed, 54 insertions, 7 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java index 4219934..8e68c80 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialog.java @@ -52,7 +52,6 @@ public class AutofillDialog extends AlertDialog new AutofillDialogMenuItem[AutofillDialogConstants.NUM_SECTIONS][]; private final AutofillDialogMenuItem[][] mDefaultMenuItems = new AutofillDialogMenuItem[AutofillDialogConstants.NUM_SECTIONS][]; - private boolean mWillDismiss = false; /** * An interface to handle the interaction with an AutofillDialog object. @@ -126,6 +125,11 @@ public class AutofillDialog extends AlertDialog public void dialogCancel(); /** + * Informs AutofillDialog controller that the user closed the dialog. + */ + public void dialogDismissed(); + + /** * Get the list associated with this field as a string array. * @param field The field for which the list should be returned. * @return A string array that contains the list @@ -268,7 +272,9 @@ public class AutofillDialog extends AlertDialog @Override public void dismiss() { - if (mWillDismiss) super.dismiss(); + // Any calls coming from the Android View system are ignored. + // If the dialog should be dismissed, internalDismiss() should be used. + // TODO(yusufo): http://crbug.com/234477 Consider not using AlertDialog. } @Override @@ -278,6 +284,14 @@ public class AutofillDialog extends AlertDialog } /** + * Dismisses the dialog. + **/ + private void internalDismiss() { + mDelegate.dialogDismissed(); + super.dismiss(); + } + + /** * Get the list associated with this field as a string array. * @param field The field for which the list should be returned. * @return A string array that contains the list @@ -288,10 +302,17 @@ public class AutofillDialog extends AlertDialog @Override public void onClick(DialogInterface dialog, int which) { + // Note that the dialog will NOT be dismissed automatically. if (!mContentView.isInEditingMode()) { - mWillDismiss = true; - if (which == AlertDialog.BUTTON_POSITIVE) mDelegate.dialogSubmit(); - else mDelegate.dialogCancel(); + if (which == AlertDialog.BUTTON_POSITIVE) { + // The controller will dismiss the dialog if the validation succeeds. + // Otherwise, the dialog should be in the operational state to show + // errors, challenges and notifications. + mDelegate.dialogSubmit(); + } else { + // The dialog will be dismissed with a call to dismissAutofillDialog(). + mDelegate.dialogCancel(); + } return; } @@ -305,7 +326,6 @@ public class AutofillDialog extends AlertDialog mDelegate.editingCancel(section); } changeLayoutTo(AutofillDialogContentView.LAYOUT_STEADY); - mWillDismiss = false; } @Override @@ -640,6 +660,13 @@ public class AutofillDialog extends AlertDialog } /** + * Dismisses the Autofill dialog as if cancel was pressed. + */ + public void dismissAutofillDialog() { + internalDismiss(); + } + + /** * Validates EditText fields in the editing mode when they get unfocused. */ @Override 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 9bac69c..721e13e 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 @@ -18,9 +18,9 @@ import org.chromium.ui.WindowAndroid; public class AutofillDialogGlue implements AutofillDialogDelegate, AutofillDialogAccountHelper.SignInContinuation { @SuppressWarnings("unused") - private final int mNativeDialogPopup; private final AutofillDialog mAutofillDialog; private final AutofillDialogAccountHelper mAccountHelper; + private int mNativeDialogPopup; // could be 0 after onDestroy(). public AutofillDialogGlue(int nativeAutofillDialogViewAndroid, WindowAndroid windowAndroid) { mNativeDialogPopup = nativeAutofillDialogViewAndroid; @@ -36,6 +36,14 @@ public class AutofillDialogGlue implements AutofillDialogDelegate, return new AutofillDialogGlue(nativeAutofillDialogViewAndroid, windowAndroid); } + @CalledByNative + private void onDestroy() { + if (mNativeDialogPopup == 0) return; + + mNativeDialogPopup = 0; + mAutofillDialog.dismissAutofillDialog(); + } + /** * @see AutofillDialog#updateNotificationArea(AutofillDialogNotification[]) */ @@ -185,15 +193,26 @@ public class AutofillDialogGlue implements AutofillDialogDelegate, @Override public void dialogSubmit() { + assert mNativeDialogPopup != 0; + if (mNativeDialogPopup == 0) return; + nativeDialogSubmit(mNativeDialogPopup); } @Override public void dialogCancel() { + assert mNativeDialogPopup != 0; + if (mNativeDialogPopup == 0) return; + nativeDialogCancel(mNativeDialogPopup); } @Override + public void dialogDismissed() { + if (mNativeDialogPopup != 0) nativeDialogDismissed(mNativeDialogPopup); + } + + @Override public Bitmap getIconForField(int fieldType, String input) { return nativeGetIconForField(mNativeDialogPopup, fieldType, input); } @@ -316,6 +335,7 @@ public class AutofillDialogGlue implements AutofillDialogDelegate, private native void nativeValidateSection(int nativeAutofillDialogViewAndroid, int section); private native void nativeDialogSubmit(int nativeAutofillDialogViewAndroid); private native void nativeDialogCancel(int nativeAutofillDialogViewAndroid); + private native void nativeDialogDismissed(int nativeAutofillDialogViewAndroid); private native String nativeGetLabelForSection(int nativeAutofillDialogViewAndroid, int section); private native String[] nativeGetListForField(int nativeAutofillDialogViewAndroid, int field); |