| Index: chrome/android/java/src/org/chromium/chrome/browser/externalauth/UserRecoverableErrorHandler.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/externalauth/UserRecoverableErrorHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/externalauth/UserRecoverableErrorHandler.java
|
| index 55e5a68376ce06d753fa4f97f6690e7474bb5498..19d3b1e82c63e4454b25e11069d48f8a7697d70e 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/externalauth/UserRecoverableErrorHandler.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/externalauth/UserRecoverableErrorHandler.java
|
| @@ -138,6 +138,11 @@ public abstract class UserRecoverableErrorHandler {
|
| private final boolean mCancelable;
|
|
|
| /**
|
| + * Last error code from Google Play Services.
|
| + */
|
| + private int mErrorCode;
|
| +
|
| + /**
|
| * Create a new Modal Dialog handler for the specified activity and error code. The
|
| * specified activity may be used to launch the dialog via
|
| * {@link Activity#startActivityForResult(android.content.Intent, int)} and also to receive
|
| @@ -159,8 +164,16 @@ public abstract class UserRecoverableErrorHandler {
|
| */
|
| @Override
|
| protected final void handle(final Context context, final int errorCode) {
|
| - mDialog = GoogleApiAvailability.getInstance().getErrorDialog(
|
| - mActivity, errorCode, NO_RESPONSE_REQUIRED);
|
| + // Assume old dialogs generated by the same error handler are obsolete when an error
|
| + // with a different error code is encountered.
|
| + if (mErrorCode != errorCode) {
|
| + cancelDialog();
|
| + }
|
| + if (mDialog == null) {
|
| + mDialog = GoogleApiAvailability.getInstance().getErrorDialog(
|
| + mActivity, errorCode, NO_RESPONSE_REQUIRED);
|
| + mErrorCode = errorCode;
|
| + }
|
| // This can happen if |errorCode| is ConnectionResult.SERVICE_INVALID.
|
| if (mDialog != null) {
|
| mDialog.setCancelable(mCancelable);
|
| @@ -175,6 +188,7 @@ public abstract class UserRecoverableErrorHandler {
|
| public void cancelDialog() {
|
| if (mDialog != null) {
|
| mDialog.cancel();
|
| + mDialog = null;
|
| }
|
| }
|
| }
|
|
|