[Paint Preview] Fix startup bug with Start Surface enabled

When StartSurface experiment is enabled, it will either:
1. Be shown on startup if a certain condition is met, or
2. Not be shown on startup.

Currently, paint preview is not displayed on startup if StartSurface
is enabled, regardless of whether StartSurface will be actually shown or
not (1 or 2 above).

This CL will display paint preview on startup if StartSurface is enabled
AND it won't be shown on startup (scenario 2 above). This is done by
making sure that ReturnToChromeExperimentsUtil#getTotalTabCount works
correctly when it's called pre-native and PAINT_PREVIEW_SHOW_ON_STARTUP
experiment is enabled.

(cherry picked from commit a87b527fbf41fce57368ba7c1cc726942b3a0357)

Bug: 1134752
Change-Id: I4d51396d82bee837184db038198770905a7f972c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2472432
Commit-Queue: Mehran Mahmoudi <[email protected]>
Reviewed-by: Mehran Mahmoudi <[email protected]>
Reviewed-by: Wei-Yin Chen (陳威尹) <[email protected]>
Auto-Submit: Mehran Mahmoudi <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#817215}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485304
Cr-Commit-Position: refs/branch-heads/4280@{#528}
Cr-Branched-From: ea420fb963f9658c9969b6513c56b8f47efa1a2a-refs/heads/master@{#812852}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/paint_preview/PaintPreviewHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/paint_preview/PaintPreviewHelper.java
index b0d2985..e8b4dfb 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/paint_preview/PaintPreviewHelper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/paint_preview/PaintPreviewHelper.java
@@ -51,7 +51,7 @@
 
     /**
      * Sets whether a Paint Preview should attempt to be shown on restoration of a tab. If the
-     * feature is not enabled this is effectively a no-op. This is used to
+     * feature is not enabled this is effectively a no-op.
      */
     public static void setShouldShowOnRestore(boolean shouldShowOnRestore) {
         sShouldShowOnRestore = shouldShowOnRestore;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tasks/ReturnToChromeExperimentsUtil.java b/chrome/android/java/src/org/chromium/chrome/browser/tasks/ReturnToChromeExperimentsUtil.java
index c3a7447..74c0c602 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tasks/ReturnToChromeExperimentsUtil.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tasks/ReturnToChromeExperimentsUtil.java
@@ -285,7 +285,9 @@
      * @return the total tab count, and works before native initialization.
      */
     public static int getTotalTabCount(TabModelSelector tabModelSelector) {
-        if (CachedFeatureFlags.isEnabled(ChromeFeatureList.INSTANT_START)
+        if ((CachedFeatureFlags.isEnabled(ChromeFeatureList.INSTANT_START)
+                    || CachedFeatureFlags.isEnabled(
+                            ChromeFeatureList.PAINT_PREVIEW_SHOW_ON_STARTUP))
                 && !tabModelSelector.isTabStateInitialized()) {
             List<PseudoTab> allTabs;
             try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) {