Add thumbnail_aspect_ratio variation flags

This CL adopts the aspect ratio from Finch to thumbnail size. If the
JPEG has different aspect ratio, regenerate the JPEG file from the ETC1
file.

Integration with tab_grid_layout_android_new_tab_tile variation is also
added.

Everything introduced in this CL is gated by field trail under the
enable-tab-grid-layout flag. And most of the Java part is verified to be
behind the gating functions
FeatureUtilities.isTabThumbnailAspectRatioNotOne() and
FeatureUtilities.isAllowToRefetchTabThumbnail() by formal equivalence
checking tool here: http://crrev.com/c/1934235. Note: the tool does not
support native yet.

[email protected]

This is based on http://crrev.com/c/1990214/14.

Bug: 1041536
Change-Id: I5db65a72b7c56a4546491a13d43872b46ee6e55b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003825
Commit-Queue: Wei-Yin Chen (陳威尹) <[email protected]>
Reviewed-by: Wei-Yin Chen (陳威尹) <[email protected]>
Cr-Commit-Position: refs/heads/master@{#732324}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index d005c70c..fb2eedd 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -1206,17 +1206,49 @@
 };
 
 const FeatureEntry::FeatureParam kTabGridLayoutAndroid_NewTabVariation[] = {
-    {"tab_grid_layout_android_new_tab", "NewTabVariation"}};
+    {"tab_grid_layout_android_new_tab", "NewTabVariation"},
+    {"allow_to_refetch", "true"}};
 
 const FeatureEntry::FeatureParam kTabGridLayoutAndroid_NewTabTile[] = {
     {"tab_grid_layout_android_new_tab_tile", "NewTabTile"}};
 
+const FeatureEntry::FeatureParam
+    kTabGridLayoutAndroid_ThumbnailAspectRatio_2[] = {
+        {"thumbnail_aspect_ratio", "2.0"},
+        {"allow_to_refetch", "true"}};
+
+const FeatureEntry::FeatureParam
+    kTabGridLayoutAndroid_ThumbnailAspectRatio_three_quarter[] = {
+        {"thumbnail_aspect_ratio", "0.75"},
+        {"allow_to_refetch", "true"}};
+
+const FeatureEntry::FeatureParam
+    kTabGridLayoutAndroid_ThumbnailAspectRatio_half[] = {
+        {"thumbnail_aspect_ratio", "0.5"},
+        {"allow_to_refetch", "true"}};
+
+const FeatureEntry::FeatureParam kTabGridLayoutAndroid_DisableRefetch[] = {
+    {"allow_to_refetch", "false"}};
+
 const FeatureEntry::FeatureVariation kTabGridLayoutAndroidVariations[] = {
     {"New Tab Variation", kTabGridLayoutAndroid_NewTabVariation,
      base::size(kTabGridLayoutAndroid_NewTabVariation), nullptr},
     {"New Tab Tile", kTabGridLayoutAndroid_NewTabTile,
      base::size(kTabGridLayoutAndroid_NewTabTile), nullptr},
+    {"thumbnail aspect ratio - 2:1",
+     kTabGridLayoutAndroid_ThumbnailAspectRatio_2,
+     base::size(kTabGridLayoutAndroid_ThumbnailAspectRatio_2), nullptr},
+    {"thumbnail aspect ratio - 1:2",
+     kTabGridLayoutAndroid_ThumbnailAspectRatio_half,
+     base::size(kTabGridLayoutAndroid_ThumbnailAspectRatio_half), nullptr},
+    {"thumbnail aspect ratio - 3:4",
+     kTabGridLayoutAndroid_ThumbnailAspectRatio_three_quarter,
+     base::size(kTabGridLayoutAndroid_ThumbnailAspectRatio_three_quarter),
+     nullptr},
+    {"Disable refetch", kTabGridLayoutAndroid_DisableRefetch,
+     base::size(kTabGridLayoutAndroid_DisableRefetch), nullptr},
 };
+
 const FeatureEntry::FeatureParam kStartSurfaceAndroid_SingleSurface[] = {
     {"start_surface_variation", "single"}};