[Android WebAPK] Do not hide splash screen when network error dialog is up

This CL changes the splash screen hiding logic to not hide the splash screen
while the network error dialog is up.

BUG=920729

Change-Id: Ifa4659b2e97c70b5d4dde83ba52b3bd41a80ea29
Reviewed-on: https://chromium-review.googlesource.com/c/1405985
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622103}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappOfflineDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappOfflineDialog.java
index a6b7325..99e6d9a5 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappOfflineDialog.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappOfflineDialog.java
@@ -19,6 +19,11 @@
 public class WebappOfflineDialog {
     private Dialog mDialog;
 
+    /** Returns whether the dialog is showing. */
+    public boolean isShowing() {
+        return mDialog != null && mDialog.isShowing();
+    }
+
     /**
      * Shows the dialog that notifies users that the WebAPK or TWA is offline.
      * @param activity Activity that will be used for {@link Dialog#show()}.
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappSplashScreenController.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappSplashScreenController.java
index a1940f4..0c78563 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappSplashScreenController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappSplashScreenController.java
@@ -49,9 +49,6 @@
     private ViewGroup mSplashScreen;
     private WebappUma mWebappUma;
 
-    /** The error code of the navigation. */
-    private int mErrorCode;
-
     private WebappOfflineDialog mOfflineDialog;
 
     /** Indicates whether reloading is allowed. */
@@ -167,8 +164,7 @@
             int httpStatusCode) {
         if (!mIsForWebApk || !isInMainFrame) return;
 
-        mErrorCode = errorCode;
-        switch (mErrorCode) {
+        switch (errorCode) {
             case ERROR_OK:
                 if (mOfflineDialog != null) {
                     mOfflineDialog.cancel();
@@ -186,9 +182,11 @@
     }
 
     protected boolean canHideSplashScreen() {
-        if (!mIsForWebApk) return true;
-        return mErrorCode != NetError.ERR_INTERNET_DISCONNECTED
-                && mErrorCode != NetError.ERR_NETWORK_CHANGED;
+        if (mOfflineDialog == null) return true;
+
+        // {@link mOfflineDialog} is not nulled out when the user closes the network error dialog
+        // via the <Back> key.
+        return !mOfflineDialog.isShowing();
     }
 
     private void onNetworkChanged(Tab tab) {