ToolbarTablet remembers to reshow update badge when leaving tab switcher

Have ToolbarTablet know if the badge was visible when it entered tab
switcher mode so that when the user leaves tab switcher mode the
badge can be restored.

Bug: 925363
Change-Id: I7a6fa06ce4bd4fc0eb914225f791fc38bed3f549
Reviewed-on: https://chromium-review.googlesource.com/c/1437711
Reviewed-by: David Trainor <dtrainor@chromium.org>
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#627410}(cherry picked from commit 38440e2dc6cdab89cf42872c6d64b96042d516fe)
Reviewed-on: https://chromium-review.googlesource.com/c/1452417
Reviewed-by: Pedro Amaral <amaralp@chromium.org>
Cr-Commit-Position: refs/branch-heads/3683@{#186}
Cr-Branched-From: e51029943e0a38dd794b73caaf6373d5496ae783-refs/heads/master@{#625896}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/MenuButton.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/MenuButton.java
index 8185485..4260176 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/MenuButton.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/MenuButton.java
@@ -98,7 +98,7 @@
         updateContentDescription(visible);
     }
 
-    public void updateImageResources() {
+    private void updateImageResources() {
         MenuButtonState buttonState = UpdateMenuItemHelper.getInstance().getUiState().buttonState;
         if (buttonState == null) return;
         @DrawableRes
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarTablet.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarTablet.java
index eef6f48..fbd6c746d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarTablet.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarTablet.java
@@ -79,6 +79,7 @@
 
     private NewTabPage mVisibleNtp;
 
+    private boolean mWasAppMenuUpdateBadgeShowing;
     /**
      * Constructs a ToolbarTablet object.
      * @param context The Context in which this View object is created.
@@ -468,12 +469,13 @@
             mForwardButton.setEnabled(false);
             mReloadButton.setEnabled(false);
             mLocationBar.getContainerView().setVisibility(View.INVISIBLE);
-            removeAppMenuUpdateBadge(false);
+            mWasAppMenuUpdateBadgeShowing = isShowingAppMenuUpdateBadge();
+            if (mWasAppMenuUpdateBadgeShowing) removeAppMenuUpdateBadge(false);
         } else {
             mIsInTabSwitcherMode = false;
             mLocationBar.getContainerView().setVisibility(View.VISIBLE);
 
-            showAppMenuUpdateBadge(false);
+            if (mWasAppMenuUpdateBadgeShowing) showAppMenuUpdateBadge(false);
         }
     }