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..87ea21e1d1ecac220c9b2d0a41aa5ff1b544d35e 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; |
/** |
+ * Error code from Google Play Services. |
Bernhard Bauer
2017/01/12 10:14:33
Nit: "Last error code [...]"?
estevenson
2017/01/12 19:52:33
Done.
|
+ */ |
+ 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; |
} |
} |
} |