Commit 7fadbd3b authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[NTP Tiles] Feature to decrease the limit for showing real icons to 32px

This is an experimental feature to show also lower-resolution favicons
in NTP tiles. This implementation serves for decision-making.

Bug: 752130
Change-Id: I4d09ede341fb63c49845f6aac8b5b547b4473db1
Reviewed-on: https://chromium-review.googlesource.com/600236
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarMichael van Ouwerkerk <mvanouwerkerk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491989}
parent 1d3f2f6a
...@@ -199,6 +199,8 @@ public abstract class ChromeFeatureList { ...@@ -199,6 +199,8 @@ public abstract class ChromeFeatureList {
public static final String NTP_OFFLINE_PAGES_FEATURE_NAME = "NTPOfflinePages"; public static final String NTP_OFFLINE_PAGES_FEATURE_NAME = "NTPOfflinePages";
public static final String NTP_SHOW_GOOGLE_G_IN_OMNIBOX = "NTPShowGoogleGInOmnibox"; public static final String NTP_SHOW_GOOGLE_G_IN_OMNIBOX = "NTPShowGoogleGInOmnibox";
public static final String NTP_SNIPPETS_INCREASED_VISIBILITY = "NTPSnippetsIncreasedVisibility"; public static final String NTP_SNIPPETS_INCREASED_VISIBILITY = "NTPSnippetsIncreasedVisibility";
public static final String NTP_TILES_LOWER_RESOLUTION_FAVICONS =
"NTPTilesLowerResolutionFavicons";
public static final String OMNIBOX_SPARE_RENDERER = "OmniboxSpareRenderer"; public static final String OMNIBOX_SPARE_RENDERER = "OmniboxSpareRenderer";
public static final String PAY_WITH_GOOGLE_V1 = "PayWithGoogleV1"; public static final String PAY_WITH_GOOGLE_V1 = "PayWithGoogleV1";
public static final String READER_MODE_IN_CCT = "ReaderModeInCCT"; public static final String READER_MODE_IN_CCT = "ReaderModeInCCT";
......
...@@ -20,6 +20,7 @@ import org.chromium.base.ApiCompatibilityUtils; ...@@ -20,6 +20,7 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.favicon.LargeIconBridge; import org.chromium.chrome.browser.favicon.LargeIconBridge;
import org.chromium.chrome.browser.widget.RoundedIconGenerator; import org.chromium.chrome.browser.widget.RoundedIconGenerator;
...@@ -37,6 +38,7 @@ public class TileRenderer { ...@@ -37,6 +38,7 @@ public class TileRenderer {
private static final int ICON_CORNER_RADIUS_DP = 4; private static final int ICON_CORNER_RADIUS_DP = 4;
private static final int ICON_TEXT_SIZE_DP = 20; private static final int ICON_TEXT_SIZE_DP = 20;
private static final int ICON_MIN_SIZE_PX = 48; private static final int ICON_MIN_SIZE_PX = 48;
private static final int ICON_DECREASED_MIN_SIZE_PX = 32;
private final Context mContext; private final Context mContext;
private final ImageFetcher mImageFetcher; private final ImageFetcher mImageFetcher;
...@@ -56,11 +58,13 @@ public class TileRenderer { ...@@ -56,11 +58,13 @@ public class TileRenderer {
Resources resources = mContext.getResources(); Resources resources = mContext.getResources();
mDesiredIconSize = resources.getDimensionPixelSize(R.dimen.tile_view_icon_size); mDesiredIconSize = resources.getDimensionPixelSize(R.dimen.tile_view_icon_size);
// On ldpi devices, mDesiredIconSize could be even smaller than ICON_MIN_SIZE_PX.
mMinIconSize = Math.min(mDesiredIconSize, ICON_MIN_SIZE_PX);
int desiredIconSizeDp = int desiredIconSizeDp =
Math.round(mDesiredIconSize / resources.getDisplayMetrics().density); Math.round(mDesiredIconSize / resources.getDisplayMetrics().density);
// On ldpi devices, mDesiredIconSize could be even smaller than the global limit.
mMinIconSize = Math.min(mDesiredIconSize,
useDecreasedMinSize() ? ICON_DECREASED_MIN_SIZE_PX : ICON_MIN_SIZE_PX);
int cornerRadiusDp; int cornerRadiusDp;
if (tileStyle == TileView.Style.MODERN) { if (tileStyle == TileView.Style.MODERN) {
cornerRadiusDp = desiredIconSizeDp / 2; cornerRadiusDp = desiredIconSizeDp / 2;
...@@ -74,6 +78,10 @@ public class TileRenderer { ...@@ -74,6 +78,10 @@ public class TileRenderer {
cornerRadiusDp, iconColor, ICON_TEXT_SIZE_DP); cornerRadiusDp, iconColor, ICON_TEXT_SIZE_DP);
} }
private static boolean useDecreasedMinSize() {
return ChromeFeatureList.isEnabled(ChromeFeatureList.NTP_TILES_LOWER_RESOLUTION_FAVICONS);
}
/** /**
* Renders tile views in the given {@link ViewGroup}, reusing existing tile views where * Renders tile views in the given {@link ViewGroup}, reusing existing tile views where
* possible because view inflation and icon loading are slow. * possible because view inflation and icon loading are slow.
......
...@@ -60,7 +60,8 @@ import java.util.List; ...@@ -60,7 +60,8 @@ import java.util.List;
@RunWith(LocalRobolectricTestRunner.class) @RunWith(LocalRobolectricTestRunner.class)
@Config(manifest = Config.NONE) @Config(manifest = Config.NONE)
@Features({@Features.Register(ChromeFeatureList.NTP_OFFLINE_PAGES_FEATURE_NAME), @Features({@Features.Register(ChromeFeatureList.NTP_OFFLINE_PAGES_FEATURE_NAME),
@Features.Register(ChromeFeatureList.SUGGESTIONS_HOME_MODERN_LAYOUT)}) @Features.Register(ChromeFeatureList.SUGGESTIONS_HOME_MODERN_LAYOUT),
@Features.Register(ChromeFeatureList.NTP_TILES_LOWER_RESOLUTION_FAVICONS)})
public class TileGroupUnitTest { public class TileGroupUnitTest {
private static final int MAX_COLUMNS_TO_FETCH = 4; private static final int MAX_COLUMNS_TO_FETCH = 4;
private static final int MAX_ROWS_TO_FETCH = 1; private static final int MAX_ROWS_TO_FETCH = 1;
......
...@@ -2465,6 +2465,10 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -2465,6 +2465,10 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kEnableNtpMostLikelyFaviconsFromServerDescription, flag_descriptions::kEnableNtpMostLikelyFaviconsFromServerDescription,
kOsAndroid, kOsAndroid,
FEATURE_VALUE_TYPE(ntp_tiles::kNtpMostLikelyFaviconsFromServerFeature)}, FEATURE_VALUE_TYPE(ntp_tiles::kNtpMostLikelyFaviconsFromServerFeature)},
{"enable-ntp-tiles-lower-resolution-favicons",
flag_descriptions::kNtpTilesLowerResolutionFaviconsName,
flag_descriptions::kNtpTilesLowerResolutionFaviconsDescription, kOsAndroid,
FEATURE_VALUE_TYPE(ntp_tiles::kLowerResolutionFaviconsFeature)},
{"enable-content-suggestions-large-thumbnail", {"enable-content-suggestions-large-thumbnail",
flag_descriptions::kEnableContentSuggestionsLargeThumbnailName, flag_descriptions::kEnableContentSuggestionsLargeThumbnailName,
flag_descriptions::kEnableContentSuggestionsLargeThumbnailDescription, flag_descriptions::kEnableContentSuggestionsLargeThumbnailDescription,
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "components/autofill/core/browser/autofill_experiments.h" #include "components/autofill/core/browser/autofill_experiments.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h"
#include "components/ntp_snippets/features.h" #include "components/ntp_snippets/features.h"
#include "components/ntp_tiles/constants.h"
#include "components/offline_pages/core/offline_page_feature.h" #include "components/offline_pages/core/offline_page_feature.h"
#include "components/password_manager/core/common/password_manager_features.h" #include "components/password_manager/core/common/password_manager_features.h"
#include "components/payments/core/features.h" #include "components/payments/core/features.h"
...@@ -107,6 +108,7 @@ const base::Feature* kFeaturesExposedToJava[] = { ...@@ -107,6 +108,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&ntp_snippets::kForeignSessionsSuggestionsFeature, &ntp_snippets::kForeignSessionsSuggestionsFeature,
&ntp_snippets::kNotificationsFeature, &ntp_snippets::kNotificationsFeature,
&ntp_snippets::kPublisherFaviconsFromNewServerFeature, &ntp_snippets::kPublisherFaviconsFromNewServerFeature,
&ntp_tiles::kLowerResolutionFaviconsFeature,
&offline_pages::kBackgroundLoaderForDownloadsFeature, &offline_pages::kBackgroundLoaderForDownloadsFeature,
&offline_pages::kOfflinePagesCTFeature, // See crbug.com/620421. &offline_pages::kOfflinePagesCTFeature, // See crbug.com/620421.
&offline_pages::kOfflinePagesSharingFeature, &offline_pages::kOfflinePagesSharingFeature,
......
...@@ -1597,6 +1597,13 @@ const char kEnableNtpMostLikelyFaviconsFromServerDescription[] = ...@@ -1597,6 +1597,13 @@ const char kEnableNtpMostLikelyFaviconsFromServerDescription[] =
"If enabled, missing favicons for NTP tiles get downloaded from Google. " "If enabled, missing favicons for NTP tiles get downloaded from Google. "
"This only applies to tiles that originate from synced history."; "This only applies to tiles that originate from synced history.";
const char kNtpTilesLowerResolutionFaviconsName[] =
"Show also lower resolution favicons in NTP tiles.";
const char kNtpTilesLowerResolutionFaviconsDescription[] =
"If enabled, the size limit for a favicon to get displayed in an NTP tile "
"decreases. Tiles where the largest available favicon is below this limit "
"get displayed as colored tiles.";
const char kEnableNtpOfflinePageDownloadSuggestionsName[] = const char kEnableNtpOfflinePageDownloadSuggestionsName[] =
"Show offline page downloads on the New Tab page"; "Show offline page downloads on the New Tab page";
const char kEnableNtpOfflinePageDownloadSuggestionsDescription[] = const char kEnableNtpOfflinePageDownloadSuggestionsDescription[] =
......
...@@ -977,6 +977,9 @@ extern const char kEnableNtpForeignSessionsSuggestionsDescription[]; ...@@ -977,6 +977,9 @@ extern const char kEnableNtpForeignSessionsSuggestionsDescription[];
extern const char kEnableNtpMostLikelyFaviconsFromServerName[]; extern const char kEnableNtpMostLikelyFaviconsFromServerName[];
extern const char kEnableNtpMostLikelyFaviconsFromServerDescription[]; extern const char kEnableNtpMostLikelyFaviconsFromServerDescription[];
extern const char kNtpTilesLowerResolutionFaviconsName[];
extern const char kNtpTilesLowerResolutionFaviconsDescription[];
extern const char kEnableNtpOfflinePageDownloadSuggestionsName[]; extern const char kEnableNtpOfflinePageDownloadSuggestionsName[];
extern const char kEnableNtpOfflinePageDownloadSuggestionsDescription[]; extern const char kEnableNtpOfflinePageDownloadSuggestionsDescription[];
......
...@@ -18,6 +18,9 @@ extern const base::Feature kPopularSitesBakedInContentFeature{ ...@@ -18,6 +18,9 @@ extern const base::Feature kPopularSitesBakedInContentFeature{
extern const base::Feature kNtpMostLikelyFaviconsFromServerFeature{ extern const base::Feature kNtpMostLikelyFaviconsFromServerFeature{
"NTPMostLikelyFaviconsFromServer", base::FEATURE_DISABLED_BY_DEFAULT}; "NTPMostLikelyFaviconsFromServer", base::FEATURE_DISABLED_BY_DEFAULT};
extern const base::Feature kLowerResolutionFaviconsFeature{
"NTPTilesLowerResolutionFavicons", base::FEATURE_DISABLED_BY_DEFAULT};
bool AreNtpMostLikelyFaviconsFromServerEnabled() { bool AreNtpMostLikelyFaviconsFromServerEnabled() {
// Check if the experimental flag is forced on or off. // Check if the experimental flag is forced on or off.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
......
...@@ -23,6 +23,10 @@ extern const base::Feature kPopularSitesBakedInContentFeature; ...@@ -23,6 +23,10 @@ extern const base::Feature kPopularSitesBakedInContentFeature;
// Likely tiles on the New Tab Page. // Likely tiles on the New Tab Page.
extern const base::Feature kNtpMostLikelyFaviconsFromServerFeature; extern const base::Feature kNtpMostLikelyFaviconsFromServerFeature;
// Feature to allow displaying lower resolution favicons for Tiles on the New
// Tab Page.
extern const base::Feature kLowerResolutionFaviconsFeature;
// Use this to find out whether the kNtpMostLikelyFaviconsFromServerFeature is // Use this to find out whether the kNtpMostLikelyFaviconsFromServerFeature is
// enabled. This helper function abstracts iOS special way to override the // enabled. This helper function abstracts iOS special way to override the
// feature (via command-line params). // feature (via command-line params).
......
...@@ -22636,6 +22636,7 @@ uploading your change for review. These are checked by presubmit scripts. ...@@ -22636,6 +22636,7 @@ uploading your change for review. These are checked by presubmit scripts.
<int value="-2063014275" label="enable-web-bluetooth"/> <int value="-2063014275" label="enable-web-bluetooth"/>
<int value="-2062872298" label="market-url-for-testing"/> <int value="-2062872298" label="market-url-for-testing"/>
<int value="-2062373123" label="WebPaymentsModifiers:enabled"/> <int value="-2062373123" label="WebPaymentsModifiers:enabled"/>
<int value="-2059771509" label="NTPTilesLowerResolutionFavicons:disabled"/>
<int value="-2058656447" label="ContextualSearchUrlActions:enabled"/> <int value="-2058656447" label="ContextualSearchUrlActions:enabled"/>
<int value="-2053860791" label="XGEOVisibleNetworks:enabled"/> <int value="-2053860791" label="XGEOVisibleNetworks:enabled"/>
<int value="-2048732429" label="enable-alternative-services"/> <int value="-2048732429" label="enable-alternative-services"/>
...@@ -23799,6 +23800,7 @@ from previous Chrome versions. ...@@ -23799,6 +23800,7 @@ from previous Chrome versions.
<int value="1705724232" label="use-android-midi-api"/> <int value="1705724232" label="use-android-midi-api"/>
<int value="1713230497" label="ColorCorrectRendering:disabled"/> <int value="1713230497" label="ColorCorrectRendering:disabled"/>
<int value="1716104463" label="enable-fullscreen-app-list"/> <int value="1716104463" label="enable-fullscreen-app-list"/>
<int value="1717987538" label="NTPTilesLowerResolutionFavicons:enabled"/>
<int value="1723601083" label="enable-app-window-controls"/> <int value="1723601083" label="enable-app-window-controls"/>
<int value="1724800383" label="AsmJsToWebAssembly:disabled"/> <int value="1724800383" label="AsmJsToWebAssembly:disabled"/>
<int value="1730094138" label="enable-md-storage-manager"/> <int value="1730094138" label="enable-md-storage-manager"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment