[Explore sites]: Add all the missing cases for getVariation.

Bug: 919454
Change-Id: Iabb79625a254bb619564eef676b6f74579007dcb
Reviewed-on: https://chromium-review.googlesource.com/c/1398308
Reviewed-by: Justin DeWitt <dewittj@chromium.org>
Reviewed-by: Theresa <twellington@chromium.org>
Commit-Queue: Cathy Li <chili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#620873}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBackgroundTask.java b/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBackgroundTask.java
index d1c1495..2a75f0f5 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBackgroundTask.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBackgroundTask.java
@@ -63,7 +63,7 @@
     protected void onStartTaskWithNative(
             Context context, TaskParameters taskParameters, TaskFinishedCallback callback) {
         assert taskParameters.getTaskId() == TaskIds.EXPLORE_SITES_REFRESH_JOB_ID;
-        if (ExploreSitesBridge.getVariation() != ExploreSitesVariation.ENABLED) {
+        if (ExploreSitesBridge.isEnabled(ExploreSitesBridge.getVariation())) {
             cancelTask();
             return;
         }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBridge.java
index bf3ff36..1843d1d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesBridge.java
@@ -83,6 +83,15 @@
         return nativeGetVariation();
     }
 
+    public static boolean isEnabled(@ExploreSitesVariation int variation) {
+        return variation == ExploreSitesVariation.ENABLED
+                || variation == ExploreSitesVariation.PERSONALIZED;
+    }
+
+    public static boolean isExperimental(@ExploreSitesVariation int variation) {
+        return variation == ExploreSitesVariation.EXPERIMENT;
+    }
+
     @CalledByNative
     static void scheduleDailyTask() {
         ExploreSitesBackgroundTask.schedule(false /* updateCurrent */);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java
index 76e4bff..b8d3f713 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageLayout.java
@@ -36,7 +36,6 @@
 import org.chromium.chrome.browser.explore_sites.ExperimentalExploreSitesSection;
 import org.chromium.chrome.browser.explore_sites.ExploreSitesBridge;
 import org.chromium.chrome.browser.explore_sites.ExploreSitesSection;
-import org.chromium.chrome.browser.explore_sites.ExploreSitesVariation;
 import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
 import org.chromium.chrome.browser.native_page.ContextMenuManager;
 import org.chromium.chrome.browser.ntp.NewTabPage.OnSearchBoxScrollListener;
@@ -191,9 +190,10 @@
         mSearchBoxView = findViewById(R.id.search_box);
         insertSiteSectionView();
 
-        if (ExploreSitesBridge.getVariation() == ExploreSitesVariation.ENABLED) {
+        int variation = ExploreSitesBridge.getVariation();
+        if (ExploreSitesBridge.isEnabled(variation)) {
             mExploreSectionView = ((ViewStub) findViewById(R.id.explore_sites_stub)).inflate();
-        } else if (ExploreSitesBridge.getVariation() == ExploreSitesVariation.EXPERIMENT) {
+        } else if (ExploreSitesBridge.isExperimental(variation)) {
             ViewStub exploreStub = findViewById(R.id.explore_sites_stub);
             exploreStub.setLayoutResource(R.layout.experimental_explore_sites_section);
             mExploreSectionView = exploreStub.inflate();
@@ -244,19 +244,12 @@
         mSiteSectionViewHolder.bindDataSource(mTileGroup, tileRenderer);
 
         int variation = ExploreSitesBridge.getVariation();
-        switch (variation) {
-            case ExploreSitesVariation.ENABLED: // fall-through
-            case ExploreSitesVariation.PERSONALIZED:
-                mExploreSection = new ExploreSitesSection(mExploreSectionView, profile,
-                        mManager.getNavigationDelegate(),
-                        SuggestionsConfig.getTileStyle(mUiConfig));
-                break;
-            case ExploreSitesVariation.EXPERIMENT:
-                mExploreSection = new ExperimentalExploreSitesSection(
-                        mExploreSectionView, profile, mManager.getNavigationDelegate());
-                break;
-            case ExploreSitesVariation.DISABLED: // fall-through
-            default: // do nothing.
+        if (ExploreSitesBridge.isEnabled(variation)) {
+            mExploreSection = new ExploreSitesSection(mExploreSectionView, profile,
+                    mManager.getNavigationDelegate(), SuggestionsConfig.getTileStyle(mUiConfig));
+        } else if (ExploreSitesBridge.isExperimental(variation)) {
+            mExploreSection = new ExperimentalExploreSitesSection(
+                    mExploreSectionView, profile, mManager.getNavigationDelegate());
         }
 
         mSearchProviderLogoView = findViewById(R.id.search_provider_logo);
@@ -476,7 +469,7 @@
         ViewGroup.LayoutParams layoutParams = mSiteSectionView.getLayoutParams();
         layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
         // If the explore sites section exists, then space it more closely.
-        if (ExploreSitesBridge.getVariation() == ExploreSitesVariation.ENABLED) {
+        if (ExploreSitesBridge.isEnabled(ExploreSitesBridge.getVariation())) {
             ((MarginLayoutParams) layoutParams).bottomMargin =
                     getResources().getDimensionPixelOffset(
                             R.dimen.tile_grid_layout_vertical_spacing);